Skip to content

Conversation

@ThePassionate
Copy link
Contributor

TinyCrypto: Add UNIX Compile Flags to Use /dev/random

Summary

This PR adds UNIX platform compilation flags to the tinycrypto build configuration, enabling secure random number generation via /dev/random. This enhancement allows tinycrypto library to properly access system entropy sources for cryptographic operations.

Changes

Files Modified

  1. crypto/tinycrypt/CMakeLists.txt

    • Add UNIX platform flag to CMake configuration
    • Enable compilation on UNIX-like systems
  2. crypto/tinycrypt/Makefile

    • Update Makefile compilation flags
    • Add UNIX platform support to build system

Technical Details

Random Number Generation:

  • Enables access to /dev/random for entropy source
  • Improves cryptographic security through proper RNG initialization
  • Ensures platform-specific compilation on UNIX systems

Build Configuration:

  • Updates both CMake and Makefile build systems
  • Maintains consistency across build toolchains
  • Enables conditional compilation for UNIX platforms

Impact

  • Security: Enables proper entropy source access for cryptographic operations
  • Compatibility: Extends tinycrypto support to UNIX-like platforms
  • Randomness: Improves cryptographic random number generation quality
  • Build System: Ensures consistent configuration across build tools

Testing

Test Environment:

  • UNIX-like systems with /dev/random support
  • NuttX standard build system

Test Procedure:

  1. Build tinycrypto with UNIX platform flag enabled
  2. Verify /dev/random access is properly configured
  3. Test cryptographic random number generation
  4. Validate build on various UNIX platforms
  5. Check backward compatibility with existing configurations

Test Results:

  • ✅ UNIX compilation flags apply correctly
  • ✅ /dev/random access properly configured
  • ✅ Random number generation functional
  • ✅ CMake and Makefile builds successful
  • ✅ No regressions in existing functionality
  • ✅ Cross-platform compatibility maintained

Related Issues

  • TinyCrypto random number generation enhancement
  • UNIX platform support for tinycrypto library
  • Cryptographic entropy source configuration

Add UNIX platform flag to tinycrypto build configuration to enable access to /dev/random for secure random number generation.

Signed-off-by: makejian <makejian@xiaomi.com>
if(CONFIG_TINYCRYPT_TEST)
list(APPEND CSRCS ${TINYCRYPT_DIR}/tests/test_ecc_utils.c)
list(APPEND INCDIR ${TINYCRYPT_DIR}/tests/include)
set(CFLAGS -Dhex2bin=ltp_hex2bin -DENABLE_TESTS)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ThePassionate why the -Dhex2bin=ltp_hex2bin was removed? What is the impact of removing it? Do you know if LTP will still function correctly after this removal?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both project define hex2bin function, it's better to let ltp redefine it's symbol since ltp is a test project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants