Hello, 
(I'm new user of ns3 and crypto) 
I have link errors with Crypto++. These errors indicate that the compiler 
cannot find certain functions or classes defined in Crypto++. This can 
happen if Crypto++ is not correctly linked to my project. However, I tried 
to modify my project's CMakeLists.txt file as follows: 
set(target_prefix scratch_)

function(create_scratch source_files)
  # Return early if no sources in the subdirectory
  list(LENGTH source_files number_sources)
  if(number_sources EQUAL 0)
    return()
  endif()

  # If the scratch has more than a source file, we need to find the source 
with
  # the main function
  set(scratch_src)
  foreach(source_file ${source_files})
    file(READ ${source_file} source_file_contents)
    string(REGEX MATCHALL "main[(| (]" main_position 
"${source_file_contents}")
    if(CMAKE_MATCH_0)
      set(scratch_src ${source_file})
    endif()
  endforeach()

  if(NOT scratch_src)
    return()
  endif()

  # Get parent directory name
  get_filename_component(scratch_dirname ${scratch_src} DIRECTORY)
  string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}" "" scratch_dirname
                 "${scratch_dirname}"
  )
  string(REPLACE "/" "_" scratch_dirname "${scratch_dirname}")

  # Get source name
  get_filename_component(scratch_name ${scratch_src} NAME_WE)

  set(target_prefix scratch_)
  if(scratch_dirname)
    # Join the names together if dirname is not the scratch folder
    set(target_prefix scratch${scratch_dirname}_)
  endif()

  # Get source absolute path and transform into relative path
  get_filename_component(scratch_src ${scratch_src} ABSOLUTE)
  get_filename_component(scratch_absolute_directory ${scratch_src} 
DIRECTORY)
  string(REPLACE "${PROJECT_SOURCE_DIR}" "${CMAKE_OUTPUT_DIRECTORY}"
                 scratch_directory ${scratch_absolute_directory}
  )
  add_executable(${target_prefix}${scratch_name} "${source_files}")
  if(${NS3_STATIC})
    target_link_libraries(
      ${target_prefix}${scratch_name} ${LIB_AS_NEEDED_PRE_STATIC}
      ${lib-ns3-static}
    )
  else()
    target_link_libraries(
      ${target_prefix}${scratch_name} "${ns3-libs}" "${ns3-contrib-libs}"
      "${ns3-external-libs}"
    )
  endif()
  set_runtime_outputdirectory(
    ${scratch_name} ${scratch_directory}/ ${target_prefix}
  )
endfunction()

# Scan *.cc files in ns-3-dev/scratch and build a target for each
file(GLOB single_source_file_scratches CONFIGURE_DEPENDS 
${CMAKE_CURRENT_SOURCE_DIR}/*.cc)
foreach(scratch_src ${single_source_file_scratches})
  create_scratch(${scratch_src})
endforeach()

# Scan *.cc files in ns-3-dev/scratch subdirectories and build a target for 
each
# subdirectory
file(
  GLOB_RECURSE scratch_subdirectories
  CONFIGURE_DEPENDS
  LIST_DIRECTORIES true
  ${CMAKE_CURRENT_SOURCE_DIR}/**
)
# Filter out files
foreach(entry ${scratch_subdirectories})
  if(NOT (IS_DIRECTORY ${entry}))
    list(REMOVE_ITEM scratch_subdirectories ${entry})
  endif()
endforeach()

foreach(subdir ${scratch_subdirectories})
  if(EXISTS ${subdir}/CMakeLists.txt)
    # If the subdirectory contains a CMakeLists.txt file
    # we let the CMake file manage the source files
    #
    # Use this if you want to link to external libraries
    # without creating a module
    add_subdirectory(${subdir})
  else()
    # Otherwise we pick all the files in the subdirectory
    # and create a scratch for them automatically
    file(GLOB scratch_sources CONFIGURE_DEPENDS ${subdir}/*.cc)
    create_scratch("${scratch_sources}")
  endif()
endforeach()
find_external_library(DEPENDENCY_NAME cryptopp
                      HEADER_NAME aes.h
                      LIBRARY_NAME cryptopp
                      SEARCH_PATHS /usr/include/cryptopp)


if(${CRYPTOPP_FOUND}) # Notice that the contents of DEPENDENCY_NAME became 
a prefix for the _FOUND variable
    find_package(cryptopp REQUIRED)
    include_directories(${CRYPTOPP_INCLUDE_DIRS})
    link_libraries(${CRYPTOPP_LIBRARIES})
endif()
add_executable(${target_prefix}${scratch_name} "fanetex.cc")
target_link_libraries(${target_prefix}${scratch_name} PRIVATE cryptopp)

can you help me to solve this problem ? Thank you [image: Capture d’écran 
2024-04-17 114345.png]

Le mardi 16 avril 2024 à 21:53:22 UTC-5, Frank Sapone a écrit :

> I grabbed it but it's not relevant.  I need to have a certificate with RSA 
> PSS that can be read by CryptoPP with the X509Cert lib.  Is it possible to 
> do this?
>
> On Tuesday, April 16, 2024 at 3:19:47 PM UTC-4 Jeffrey Walton wrote:
>
>> On Tue, Apr 16, 2024 at 1:44 PM One Sini <[email protected]> wrote:
>>
>>> I wasn't entirely satisfied with the security, so I've adjusted the 
>>> code. I'm not sure if that helps you, depending on what you're doing with 
>>> it.
>>>
>>> This code uses RSA with OAEP (Optimal Asymmetric Encryption Padding) to 
>>> avoid security issues like padding oracle attacks. It generates RSA keys 
>>> with a length of 2048 bits, encrypts the message with OAEP padding, and 
>>> then decrypts it.
>>>
>>> Best Regards Satoshi 
>>>
>>
>> I deleted the message from the group. The *.pdf and *.pages smells of 
>> malware.
>>
>> If you want to provide code, please inline it or provide it as a text 
>> attachment.
>>
>> Jeff
>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/cryptopp-users/58ab5611-410b-4cfe-9059-65eb6ad384fan%40googlegroups.com.

Reply via email to