How aws-samples/aws-cloudhsm-pkcs11-examples works
Project type and purpose
• This is an open-source collection of C/C++ command-line example tools demonstrating how to use the AWS CloudHSM PKCS#11 API.
• Each subdirectory under src/ (e.g. encrypt/, sign/, digest/, wrapping/) contains a standalone example binary illustrating one or more PKCS#11 operations.
File structure
• Top‐level build and configuration files:
• CMakeLists.txt orchestrates the overall build
• scripts/build.sh automates build invocation
• CI and contribution metadata in .travis.yml, CONTRIBUTING.md, etc.
• Vendor interface:
• include/pkcs11/v2.40/*.h are the official Cryptoki headers that define the CK_* API
• Shared code:
• src/common/ supplies command-line parsing (gopt), PKCS#11 module loading, session management, error handling
• Example modules:
• Each feature directory under src/ (e.g. generate/, encrypt/, derive/, wrapping/) has its own CMakeLists.txt and implements a minimal main() that links against common + PKCS#11
• Non-FIPS examples and tests are grouped under src/non_fips_examples/
• Output binaries under build/src/...
README for additional insights
• Confirms dependencies (GCC/Clang, CMake, OpenSSL dev libs, Visual Studio on Windows)
• Build steps always produce many small executables that each load the CloudHSM PKCS#11 shared library at runtime
• Run-time input: user PIN, path to PKCS#11 vendor library, optional CloudHSM-specific flags