### Output Directories Setup Source: https://github.com/freertos/corepkcs11/blob/main/test/CMakeLists.txt Configures the output directories for runtime, archive, and library artifacts. ```cmake set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) ``` -------------------------------- ### Project and Version Setup Source: https://github.com/freertos/corepkcs11/blob/main/test/CMakeLists.txt Initializes the CMake build system, sets the minimum required version, and defines the project name, version, and languages. ```cmake cmake_minimum_required(VERSION 3.13.0) project( "corePKCS11 tests" VERSION 3.6.1 LANGUAGES C) ``` -------------------------------- ### Global Path Variable Setup Source: https://github.com/freertos/corepkcs11/blob/main/test/CMakeLists.txt Sets a global internal variable for the root directory of the corePKCS11 repository. ```cmake get_filename_component(__MODULE_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE) set(MODULE_ROOT_DIR ${__MODULE_ROOT_DIR} CACHE INTERNAL "corePKCS11 repository root.") ``` -------------------------------- ### Search for MISRA Rule Violations Source: https://github.com/freertos/corepkcs11/blob/main/MISRA.md Use grep to find specific MISRA rule violation references within the source code. This example searches for 'MISRA Ref 10.5.1'. ```bash grep 'MISRA Ref 10.5.1' . -rI ``` -------------------------------- ### C_VerifyInit Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Initializes a verification operation. ```APIDOC ## C_VerifyInit ### Description Initializes a verification operation. ### Method C_VerifyInit ### Endpoint N/A (Library Function) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### C_SignInit Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Initializes a signing operation. ```APIDOC ## C_SignInit ### Description Initializes a signing operation. ### Method C_SignInit ### Endpoint N/A (Library Function) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### C_Initialize Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Initializes the Cryptoki module. This function must be called before any other Cryptoki function. ```APIDOC ## C_Initialize ### Description Initializes the Cryptoki module. This function must be called before any other Cryptoki function. ### Method C_Initialize ### Endpoint N/A (Library Function) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Declare C_VerifyInit for mbedTLS Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declaration for the C_VerifyInit function used with mbedTLS. ```c CK_RV C_VerifyInit( CK_SESSION_HANDLE sessionHandle, CK_BYTE_PTR pParameter, CK_ULONG ulParameterLen ); ``` -------------------------------- ### Generate Doxygen Documentation Source: https://github.com/freertos/corepkcs11/blob/main/README.md Run this command from the root of the repository to generate Doxygen pages. Doxygen version 1.9.6 was used for the existing references. ```shell doxygen docs/doxygen/config.doxyfile ``` -------------------------------- ### C_DigestInit Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Initializes a message digest operation. ```APIDOC ## C_DigestInit ### Description Initializes a message digest operation. ### Method C_DigestInit ### Endpoint N/A (Library Function) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### xInitializePkcs11Token Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Initializes a specific PKCS #11 token. This typically involves setting up the token for use. ```APIDOC ## xInitializePkcs11Token ### Description Initializes a specific PKCS #11 token. This typically involves setting up the token for use. ### Method Not applicable (function call) ### Endpoint Not applicable (function call) ### Parameters None explicitly documented in this snippet. ### Request Example ```c xInitializePkcs11Token(); ``` ### Response None explicitly documented in this snippet. ``` -------------------------------- ### xInitializePKCS11 Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Initializes the PKCS #11 module. This function must be called before any other PKCS #11 functions. ```APIDOC ## xInitializePKCS11 ### Description Initializes the PKCS #11 module. This function must be called before any other PKCS #11 functions. ### Method Not applicable (function call) ### Endpoint Not applicable (function call) ### Parameters None explicitly documented in this snippet. ### Request Example ```c xInitializePKCS11(); ``` ### Response None explicitly documented in this snippet. ``` -------------------------------- ### Declare PKCS11_PAL_Initialize Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declaration for the PKCS11_PAL_Initialize function. ```c extern CK_RV PKCS11_PAL_Initialize( void ); ``` -------------------------------- ### Run Coverity Static Analysis Source: https://github.com/freertos/corepkcs11/blob/main/tools/coverity/README.md Performs static analysis using Coverity on the specified output directory. It uses a MISRA configuration file and targets files within the 'source' directory. ```bash cov-analyze --dir . --coding-standard-config ../../tools/coverity/misra.config --tu-pattern "file('.*/source/.*')" ``` -------------------------------- ### Configure Compiler for Coverity Source: https://github.com/freertos/corepkcs11/blob/main/tools/coverity/README.md Configures Coverity to use the GCC compiler. Use --force to overwrite existing configurations. ```bash cov-configure --force --compiler cc --comptype gcc ``` -------------------------------- ### xGetSlotList Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Retrieves a list of available PKCS #11 slots. Slots represent the cryptographic hardware devices. ```APIDOC ## xGetSlotList ### Description Retrieves a list of available PKCS #11 slots. Slots represent the cryptographic hardware devices. ### Method Not applicable (function call) ### Endpoint Not applicable (function call) ### Parameters None explicitly documented in this snippet. ### Request Example ```c xGetSlotList(); ``` ### Response None explicitly documented in this snippet. ``` -------------------------------- ### C_Login Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Logs a user into a token. ```APIDOC ## C_Login ### Description Logs a user into a token. ### Method C_Login ### Endpoint N/A (Library Function) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Consolidated Coverity Analysis Commands Source: https://github.com/freertos/corepkcs11/blob/main/tools/coverity/README.md A consolidated script containing all necessary commands to configure, build, analyze, and format results for Coverity static analysis. ```bash cov-configure --force --compiler cc --comptype gcc; cmake -B build -S test -DCOV_ANALYSIS=1; cd build/; cov-build --emit-complementary-info --dir cov-out make coverity_analysis; cd cov-out/ cov-analyze --dir . --coding-standard-config ../../tools/coverity/misra.config; cov-format-errors --dir . --file "source" --exclude-files '(/build/|/test/|/dependency/|/portable/)' --html-output html-out; cov-format-errors --dir . --file "source" --exclude-files '(/build/|/test/|/dependency/|/portable/)' --json-output-v2 defects.json; echo -e "\n-------------------------Non-Suppresed Deviations, if any, Listed Below-------------------------\n"; jq '.issues[] | .events[] | .eventTag ' defects.json | sort | uniq -c | sort -nr; echo -e "\n-------------------------Non-Suppresed Deviations, if any, Listed Above-------------------------\n"; cd ../../; ``` -------------------------------- ### Create Build Files with CMake for Coverity Source: https://github.com/freertos/corepkcs11/blob/main/tools/coverity/README.md Generates build files using CMake, enabling Coverity analysis with the -DCOV_ANALYSIS=1 flag. The build is configured to use the 'test' directory as the source. ```bash cmake -B build -S test -DCOV_ANALYSIS=1 ``` -------------------------------- ### Build Static Analysis Target with Coverity Source: https://github.com/freertos/corepkcs11/blob/main/tools/coverity/README.md Builds the static analysis target using 'make coverity_analysis' within the build directory. This command emits complementary information and directs output to 'cov-out'. ```bash cov-build --emit-complementary-info --dir cov-out make coverity_analysis ``` -------------------------------- ### C_OpenSession Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Opens a session between the application and a token. ```APIDOC ## C_OpenSession ### Description Opens a session between the application and a token. ### Method C_OpenSession ### Endpoint N/A (Library Function) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### C_CreateObject Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Creates a new object on the token. ```APIDOC ## C_CreateObject ### Description Creates a new object on the token. ### Method C_CreateObject ### Endpoint N/A (Library Function) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### xInitializePkcs11Session Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Opens a session with a PKCS #11 token. Sessions are required to perform cryptographic operations. ```APIDOC ## xInitializePkcs11Session ### Description Opens a session with a PKCS #11 token. Sessions are required to perform cryptographic operations. ### Method Not applicable (function call) ### Endpoint Not applicable (function call) ### Parameters None explicitly documented in this snippet. ### Request Example ```c xInitializePkcs11Session(); ``` ### Response None explicitly documented in this snippet. ``` -------------------------------- ### C_InitToken Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Initializes a token. This function is used to initialize a token with a new PIN and label. ```APIDOC ## C_InitToken ### Description Initializes a token. This function is used to initialize a token with a new PIN and label. ### Method C_InitToken ### Endpoint N/A (Library Function) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### C_GetSlotList Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Obtains a list of available slots. ```APIDOC ## C_GetSlotList ### Description Obtains a list of available slots. ### Method C_GetSlotList ### Endpoint N/A (Library Function) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Declare C_SignInit for mbedTLS Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declaration for the C_SignInit function used with mbedTLS. ```c CK_RV C_SignInit( CK_SESSION_HANDLE sessionHandle, CK_BYTE_PTR pParameter, CK_ULONG ulParameterLen ); ``` -------------------------------- ### Build Options Configuration Source: https://github.com/freertos/corepkcs11/blob/main/test/CMakeLists.txt Defines boolean options to control the build, such as enabling system tests, unit tests, and code coverage analysis. ```cmake option(SYSTEM_TESTS "Set this to ON to build system tests" ON) option(UNITTEST "Set this to ON to build unit tests" ON) option(COV_ANALYSIS "Set this to ON to build coverity_analysis target" ON) ``` -------------------------------- ### Declare xInitializePkcs11Token Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declaration for the xInitializePkcs11Token function. ```c extern CK_RV xInitializePkcs11Token( CK_SLOT_ID xSlotID, CK_UTF8CHAR_PTR pxPin, CK_ULONG ulPinLen ); ``` -------------------------------- ### Declare xInitializePkcs11Session Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declaration for the xInitializePkcs11Session function. ```c extern CK_RV xInitializePkcs11Session( CK_SESSION_HANDLE * pxSessionHandle ); ``` -------------------------------- ### C_FindObjectsInit Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Initializes a search for objects with specified attributes. ```APIDOC ## C_FindObjectsInit ### Description Initializes a search for objects with specified attributes. ### Method C_FindObjectsInit ### Endpoint N/A (Library Function) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Declare xInitializePKCS11 Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declaration for the xInitializePKCS11 function. ```c extern CK_RV xInitializePKCS11( void ); ``` -------------------------------- ### Add Coverity Analysis Library Target (mbedTLS 3.x) Source: https://github.com/freertos/corepkcs11/blob/main/test/coverity_analysis/CMakeLists.txt Defines a static library target for Coverity analysis using mbedTLS 3.x. It includes PKCS sources and links against mbedcrypto and pkcs11_api. ```cmake add_library(coverity_analysis_mbedtls_3 STATIC) target_sources(coverity_analysis_mbedtls_3 PRIVATE ${PKCS_SOURCES}) target_link_libraries(coverity_analysis_mbedtls_3 MbedTLS3::mbedcrypto pkcs11_api) # Build corePKCS11 library with gnuC90 standard due to mbedtls target_compile_options(coverity_analysis_mbedtls_3 PUBLIC -std=gnu90) # corePKCS11 public include path. target_include_directories( coverity_analysis_mbedtls_3 PUBLIC ${PKCS_INCLUDE_PUBLIC_DIRS} PUBLIC ${MBEDTLS_3_INSTALL}/include PUBLIC ${MODULE_ROOT_DIR}/source/dependency/3rdparty/mbedtls_utils PUBLIC ${MODULE_ROOT_DIR}/test/include ) ``` -------------------------------- ### Declare C_DigestInit for mbedTLS Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declaration for the C_DigestInit function used with mbedTLS. ```c CK_RV C_DigestInit( CK_SESSION_HANDLE sessionHandle, CK_BYTE_PTR pParameter, CK_ULONG ulParameterLen ); ``` -------------------------------- ### Add Coverity Analysis Library Target (mbedTLS 2.x) Source: https://github.com/freertos/corepkcs11/blob/main/test/coverity_analysis/CMakeLists.txt Defines a static library target for Coverity analysis using mbedTLS 2.x. It includes PKCS sources and links against mbedcrypto and pkcs11_api. ```cmake add_library(coverity_analysis STATIC) target_sources(coverity_analysis PRIVATE ${PKCS_SOURCES}) target_link_libraries(coverity_analysis MbedTLS2::mbedcrypto pkcs11_api) # Build corePKCS11 library with gnuC90 standard due to mbedtls target_compile_options(coverity_analysis PUBLIC -std=gnu90) # corePKCS11 public include path. target_include_directories( coverity_analysis PUBLIC ${PKCS_INCLUDE_PUBLIC_DIRS} PUBLIC ${MBEDTLS_2_INSTALL}/include PUBLIC ${MODULE_ROOT_DIR}/source/dependency/3rdparty/mbedtls_utils PUBLIC ${MODULE_ROOT_DIR}/test/include ) ``` -------------------------------- ### Declare xGetSlotList Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declaration for the xGetSlotList function. ```c extern CK_RV xGetSlotList( CK_SLOT_ID * pxSlotList, CK_ULONG * pulCount ); ``` -------------------------------- ### PKCS #11 Mbed TLS C_Initialize Function Declaration Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declares the C_Initialize function for the PKCS #11 Mbed TLS implementation. This function initializes the PKCS #11 module. ```c CK_RV C_Initialize( void * pInitArgs ); ``` -------------------------------- ### C_GetFunctionList Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Obtains a list of functions implemented by the Cryptoki module. ```APIDOC ## C_GetFunctionList ### Description Obtains a list of functions implemented by the Cryptoki module. ### Method C_GetFunctionList ### Endpoint N/A (Library Function) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### PKCS #11 Configuration Macros Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Defines configuration macros for the corePKCS11 library, including memory allocation, PIN settings, and object/session limits. ```c #define PKCS11_MALLOC( size ) pvPortMalloc( size ) ``` ```c #define PKCS11_FREE( ptr ) vPortFree( ptr ) ``` ```c #define PKCS11_DEFAULT_USER_PIN "1234" ``` ```c #define MAX_LABEL_LENGTH ( 32 ) ``` ```c #define MAX_NUM_OBJECTS ( 10 ) ``` ```c #define MAX_SESSIONS ( 5 ) ``` ```c #define PKCS11_PAL_DESTROY_SUPPORTED ( 1 ) ``` ```c #define PKCS11_OTA_SUPPORTED ( 1 ) ``` ```c #define PKCS11_JITP_CODEVERIFY_ROOT_CERT_SUPPORTED ( 1 ) ``` ```c #define PKCS11_LABEL_DEVICE_PRIVATE_KEY_FOR_TLS "device_private_key" ``` ```c #define PKCS11_LABEL_DEVICE_PUBLIC_KEY_FOR_TLS "device_public_key" ``` ```c #define PKCS11_LABEL_DEVICE_CERTIFICATE_FOR_TLS "device_cert" ``` ```c #define PKCS11_LABEL_ROOT_CERTIFICATE "root_cert" ``` ```c #define PKCS11_LABEL_HMAC_KEY "hmac_key" ``` ```c #define PKCS11_LABEL_CMAC_KEY "cmac_key" ``` ```c #define PKCS11_LABEL_CODE_VERIFICATION_KEY "code_verify_key" ``` ```c #define PKCS11_LABEL_JITP_CERTIFICATE "jitp_cert" ``` -------------------------------- ### Declare xFindObjectWithLabelAndClass Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declaration for the xFindObjectWithLabelAndClass function. ```c extern CK_RV xFindObjectWithLabelAndClass( CK_SESSION_HANDLE xSessionHandle, CK_UTF8CHAR_PTR pcLabel, CK_ULONG ulLabelLen, CK_OBJECT_CLASS xClass, CK_OBJECT_HANDLE * pxObjectHandle ); ``` -------------------------------- ### Declare C_OpenSession for mbedTLS Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declaration for the C_OpenSession function used with mbedTLS. ```c CK_RV C_OpenSession( CK_SESSION_HANDLE * sessionHandle, CK_FLAGS flags ); ``` -------------------------------- ### C_Verify Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Verifies a signature. ```APIDOC ## C_Verify ### Description Verifies a signature. ### Method C_Verify ### Endpoint N/A (Library Function) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### C_Finalize Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Deinitializes the Cryptoki module. This function must be called before the application exits. ```APIDOC ## C_Finalize ### Description Deinitializes the Cryptoki module. This function must be called before the application exits. ### Method C_Finalize ### Endpoint N/A (Library Function) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Declare C_GenerateKeyPair for mbedTLS Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declaration for the C_GenerateKeyPair function used with mbedTLS. ```c CK_RV C_GenerateKeyPair( CK_SESSION_HANDLE sessionHandle, CK_KEY_TYPE keyType, CK_ATTRIBUTE_PTR pPublicKeyTemplate, CK_ULONG ulPublicKeyAttributeCount, CK_ATTRIBUTE_PTR pPrivateKeyTemplate, CK_ULONG ulPrivateKeyAttributeCount, CK_OBJECT_HANDLE * phPublicKey, CK_OBJECT_HANDLE * phPrivateKey ); ``` -------------------------------- ### Declare PKCS11_PAL_FindObject Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declaration for the PKCS11_PAL_FindObject function. ```c extern CK_RV PKCS11_PAL_FindObject( CK_SESSION_HANDLE xSessionHandle, CK_OBJECT_HANDLE * pxObjectHandle ); ``` -------------------------------- ### Declare C_CreateObject for mbedTLS Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declaration for the C_CreateObject function used with mbedTLS. ```c CK_RV C_CreateObject( CK_SESSION_HANDLE sessionHandle, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount, CK_OBJECT_HANDLE * pNewObject ); ``` -------------------------------- ### Declare C_Login for mbedTLS Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declaration for the C_Login function used with mbedTLS. ```c CK_RV C_Login( CK_SESSION_HANDLE sessionHandle, CK_USER_TYPE userType, CK_UTF8CHAR_PTR pPin, CK_ULONG ulPinLen ); ``` -------------------------------- ### C_GenerateKeyPair Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Generates a new key pair. ```APIDOC ## C_GenerateKeyPair ### Description Generates a new key pair. ### Method C_GenerateKeyPair ### Endpoint N/A (Library Function) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Declare PKCS11_PAL_DestroyObject Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declaration for the PKCS11_PAL_DestroyObject function. ```c extern CK_RV PKCS11_PAL_DestroyObject( CK_SESSION_HANDLE xSessionHandle, CK_OBJECT_HANDLE xObjectHandle ); ``` -------------------------------- ### Declare PKCS11_PAL_SaveObject Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declaration for the PKCS11_PAL_SaveObject function. ```c extern CK_RV PKCS11_PAL_SaveObject( CK_SESSION_HANDLE xSessionHandle, CK_OBJECT_HANDLE xObjectHandle ); ``` -------------------------------- ### Include External CMake Modules Source: https://github.com/freertos/corepkcs11/blob/main/test/CMakeLists.txt Includes necessary CMake modules for mbedTLS and testing frameworks like Unity and CMock. ```cmake include(${MODULE_ROOT_DIR}/tools/mbedtls.cmake}) if(UNITTEST OR SYSTEM_TESTS) include(${MODULE_ROOT_DIR}/tools/unity.cmake) include(${MODULE_ROOT_DIR}/tools/cmock.cmake) endif() ``` -------------------------------- ### xFindObjectWithLabelAndClass Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Finds a PKCS #11 object based on its label and class. This is useful for locating specific keys or certificates. ```APIDOC ## xFindObjectWithLabelAndClass ### Description Finds a PKCS #11 object based on its label and class. This is useful for locating specific keys or certificates. ### Method Not applicable (function call) ### Endpoint Not applicable (function call) ### Parameters None explicitly documented in this snippet. ### Request Example ```c xFindObjectWithLabelAndClass(); ``` ### Response None explicitly documented in this snippet. ``` -------------------------------- ### Convert PKCS #11 Signature to PKI/mbedTLS Signature Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Converts a signature from PKCS #11 format to PKI/mbedTLS format. Ensure the input signature is valid. ```c #define declare_pkcs11_utils_pkimbedtlssignaturetopkcs11signature( void *pvMbedTLSSignature, size_t *pxMbedTLSSignatureLength, const void *pvPKCS11Signature, size_t uxPKCS11SignatureLength ) ``` -------------------------------- ### Format Coverity Errors to HTML Source: https://github.com/freertos/corepkcs11/blob/main/tools/coverity/README.md Formats Coverity analysis errors into an HTML report. It filters out files from build, test, dependency, and portable directories and outputs to 'html-out'. ```bash cov-format-errors --dir . --file "source" --exclude-files '(/build/|/test/|/dependency/|/portable/)' --html-output html-out ``` -------------------------------- ### C_GetTokenInfo Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Obtains information about a specific token. ```APIDOC ## C_GetTokenInfo ### Description Obtains information about a specific token. ### Method C_GetTokenInfo ### Endpoint N/A (Library Function) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Declare C_Verify for mbedTLS Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declaration for the C_Verify function used with mbedTLS. ```c CK_RV C_Verify( CK_SESSION_HANDLE sessionHandle, CK_BYTE_PTR pData, CK_ULONG ulDataLen, CK_BYTE_PTR pSignature, CK_ULONG ulSignatureLen ); ``` -------------------------------- ### PKI_pkcs11SignatureTombedTLSSignature Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Converts a signature from PKCS #11 format to mbedTLS format. ```APIDOC ## PKI_pkcs11SignatureTombedTLSSignature ### Description Converts a signature from PKCS #11 format to mbedTLS format. This is useful when an API expects an mbedTLS formatted signature but the signature was generated using PKCS #11. ### Method [Assumed to be a function call within an SDK or library] ### Endpoint N/A (Library function) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A (Library function) ### Response #### Success Response [Details of the converted signature in mbedTLS format] #### Response Example N/A ``` -------------------------------- ### C_FindObjectsFinal Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Finishes a search for objects. ```APIDOC ## C_FindObjectsFinal ### Description Finishes a search for objects. ### Method C_FindObjectsFinal ### Endpoint N/A (Library Function) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### PKCS #11 Mbed TLS C_GetSlotList Function Declaration Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declares the C_GetSlotList function for the PKCS #11 Mbed TLS implementation. This function retrieves a list of available slots. ```c CK_RV C_GetSlotList( CK_BBOOL tokenPresent, CK_SLOT_ID_PTR pSlotList, CK_ULONG_PTR pulCount ); ``` -------------------------------- ### Convert PKI/mbedTLS Signature to PKCS #11 Signature Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Converts a signature from PKI/mbedTLS format to PKCS #11 format. Ensure the input signature is valid. ```c #define declare_pkcs11_utils_pkipkcs11signaturetombedtlssignature( void *pvPKCS11Signature, size_t *pulPKCS11SignatureLength, const void *pvMbedTLSSignature, size_t uxMbedTLSSignatureLength ) ``` -------------------------------- ### Add Test Subdirectories Source: https://github.com/freertos/corepkcs11/blob/main/test/CMakeLists.txt Adds subdirectories to the build based on the enabled test options (UNITTEST, SYSTEM_TESTS, COV_ANALYSIS). ```cmake if(UNITTEST) add_subdirectory(pkcs11_mbedtls_utest) add_subdirectory(pkcs11_utils_utest) add_subdirectory(wrapper_utest) endif() if(SYSTEM_TESTS) add_subdirectory(mbedtls_integration) endif() if(COV_ANALYSIS) add_subdirectory(coverity_analysis) endif() ``` -------------------------------- ### Declare C_FindObjects for mbedTLS Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declaration for the C_FindObjects function used with mbedTLS. ```c CK_RV C_FindObjects( CK_SESSION_HANDLE sessionHandle, CK_OBJECT_HANDLE_PTR phObject, CK_ULONG ulMaxObjectCount, CK_ULONG_PTR pulObjectCount ); ``` -------------------------------- ### In-Source Build Check Source: https://github.com/freertos/corepkcs11/blob/main/test/CMakeLists.txt Prevents in-source builds by checking if the source directory is the same as the binary directory. If they are the same, it prints a fatal error message. ```cmake if(${PROJECT_SOURCE_DIR} STREQUAL ${PROJECT_BINARY_DIR}) message( FATAL_ERROR "In-source build is not allowed. Please build in a separate directory, such as ${PROJECT_SOURCE_DIR}/build." ) endif() ``` -------------------------------- ### Format Coverity Errors to JSON and Query Deviations Source: https://github.com/freertos/corepkcs11/blob/main/tools/coverity/README.md Formats Coverity analysis errors into JSON format (defects.json) and then uses 'jq' to extract and count unique non-suppressed deviations (event tags). ```bash cov-format-errors --dir . --file "source" --exclude-files '(/build/|/test/|/dependency/|/portable/)' --json-output-v2 defects.json; echo -e "\n-------------------------Non-Suppresed Deviations, if any, Listed Below-------------------------\n"; jq '.issues[] | .events[] | .eventTag ' defects.json | sort | uniq -c | sort -nr; echo -e "\n-------------------------Non-Suppresed Deviations, if any, Listed Above-------------------------\n" ``` -------------------------------- ### Enable Testing with CTest Source: https://github.com/freertos/corepkcs11/blob/main/test/CMakeLists.txt Enables the CTest testing utility, which is required before defining test targets. ```cmake enable_testing() ``` -------------------------------- ### C_FindObjects Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Finds objects with specified attributes. ```APIDOC ## C_FindObjects ### Description Finds objects with specified attributes. ### Method C_FindObjects ### Endpoint N/A (Library Function) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### PKCS #11 Mbed TLS C_InitToken Function Declaration Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declares the C_InitToken function for the PKCS #11 Mbed TLS implementation. This function initializes a token with a new PIN and label. ```c CK_RV C_InitToken( CK_SLOT_ID slotID, CK_UTF8CHAR_PTR pPin, CK_ULONG ulPinLen, CK_UTF8CHAR_PTR pLabel ); ``` -------------------------------- ### C_GenerateRandom Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Generates cryptographically strong pseudo-random data. ```APIDOC ## C_GenerateRandom ### Description Generates cryptographically strong pseudo-random data. ### Method C_GenerateRandom ### Endpoint N/A (Library Function) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### PKI_mbedTLSSignatureToPkcs11Signature Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Converts a signature from mbedTLS format to PKCS #11 format. ```APIDOC ## PKI_mbedTLSSignatureToPkcs11Signature ### Description Converts a signature from mbedTLS format to PKCS #11 format. This is useful when an API expects a PKCS #11 formatted signature but the signature was generated using mbedTLS. ### Method [Assumed to be a function call within an SDK or library] ### Endpoint N/A (Library function) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A (Library function) ### Response #### Success Response [Details of the converted signature in PKCS #11 format] #### Response Example N/A ``` -------------------------------- ### C_GetMechanismInfo Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Obtains information about a specific mechanism. ```APIDOC ## C_GetMechanismInfo ### Description Obtains information about a specific mechanism. ### Method C_GetMechanismInfo ### Endpoint N/A (Library Function) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### CMock Resource Path Definition Source: https://github.com/freertos/corepkcs11/blob/main/test/CMakeLists.txt Sets the cache variable for the CMock library source directory. ```cmake set( CMOCK_DIR ${MODULE_ROOT_DIR}/test/unit-test/CMock CACHE INTERNAL "CMock library source directory." ) ``` -------------------------------- ### PKCS #11 Mbed TLS C_GetFunctionList Function Declaration Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declares the C_GetFunctionList function for the PKCS #11 Mbed TLS implementation. This function retrieves a linked list of all supported functions. ```c CK_RV C_GetFunctionList( CK_FUNCTION_LIST_PTR_PTR ppFunctionList ); ``` -------------------------------- ### Declare vAppendSHA256AlgorithmIdentifierSequence Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declaration for the vAppendSHA256AlgorithmIdentifierSequence function. ```c extern void vAppendSHA256AlgorithmIdentifierSequence( CK_ATTRIBUTE_PTR pxTemplate, CK_ULONG ulAttributeCount ); ``` -------------------------------- ### Declare C_FindObjectsFinal for mbedTLS Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declaration for the C_FindObjectsFinal function used with mbedTLS. ```c CK_RV C_FindObjectsFinal( CK_SESSION_HANDLE sessionHandle ); ``` -------------------------------- ### Declare C_DestroyObject for mbedTLS Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declaration for the C_DestroyObject function used with mbedTLS. ```c CK_RV C_DestroyObject( CK_SESSION_HANDLE sessionHandle, CK_OBJECT_HANDLE hObject ); ``` -------------------------------- ### PKCS #11 Mbed TLS C_GetTokenInfo Function Declaration Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declares the C_GetTokenInfo function for the PKCS #11 Mbed TLS implementation. This function retrieves information about a specific token. ```c CK_RV C_GetTokenInfo( CK_SLOT_ID slotID, CK_TOKEN_INFO_PTR pInfo ); ``` -------------------------------- ### Declare C_GenerateRandom for mbedTLS Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declaration for the C_GenerateRandom function used with mbedTLS. ```c CK_RV C_GenerateRandom( CK_SESSION_HANDLE sessionHandle, CK_BYTE_PTR pRandomData, CK_ULONG ulRandomDataLen ); ``` -------------------------------- ### Declare C_CloseSession for mbedTLS Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declaration for the C_CloseSession function used with mbedTLS. ```c CK_RV C_CloseSession( CK_SESSION_HANDLE sessionHandle ); ``` -------------------------------- ### Custom Coverage Analysis Target Source: https://github.com/freertos/corepkcs11/blob/main/test/CMakeLists.txt Defines a custom target named 'coverage' that runs a script to perform coverage analysis on tests. It lists dependencies including test targets and external tools. ```cmake add_custom_target( coverage COMMAND ${CMAKE_COMMAND} -P ${MODULE_ROOT_DIR}/tools/cmock/coverage.cmake DEPENDS cmock unity $<$:core_pkcs11_mbedtls_utest> $<$:pkcs11_wrapper_utest> $<$:pkcs11_utils_utest> $<$:integration_mbedtls_2> $<$:integration_mbedtls_3> WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) ``` -------------------------------- ### Declare C_FindObjectsInit for mbedTLS Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declaration for the C_FindObjectsInit function used with mbedTLS. ```c CK_RV C_FindObjectsInit( CK_SESSION_HANDLE sessionHandle, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount ); ``` -------------------------------- ### C_CloseSession Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Closes a session between the application and a token. ```APIDOC ## C_CloseSession ### Description Closes a session between the application and a token. ### Method C_CloseSession ### Endpoint N/A (Library Function) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### C_DigestFinal Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Completes a message digest operation. ```APIDOC ## C_DigestFinal ### Description Completes a message digest operation. ### Method C_DigestFinal ### Endpoint N/A (Library Function) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### C_DestroyObject Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Destroys an object on the token. ```APIDOC ## C_DestroyObject ### Description Destroys an object on the token. ### Method C_DestroyObject ### Endpoint N/A (Library Function) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Declare C_DigestUpdate for mbedTLS Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declaration for the C_DigestUpdate function used with mbedTLS. ```c CK_RV C_DigestUpdate( CK_SESSION_HANDLE sessionHandle, CK_BYTE_PTR pPart, CK_ULONG ulPartLen ); ``` -------------------------------- ### Declare C_DigestFinal for mbedTLS Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declaration for the C_DigestFinal function used with mbedTLS. ```c CK_RV C_DigestFinal( CK_SESSION_HANDLE sessionHandle, CK_BYTE_PTR pDigest, CK_ULONG_PTR pulDigestLen ); ``` -------------------------------- ### PKCS #11 Mbed TLS C_GetMechanismInfo Function Declaration Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declares the C_GetMechanismInfo function for the PKCS #11 Mbed TLS implementation. This function retrieves information about a specific mechanism. ```c CK_RV C_GetMechanismInfo( CK_SLOT_ID slotID, CK_MECHANISM_TYPE type, CK_MECHANISM_INFO_PTR pInfo ); ``` -------------------------------- ### Declare C_GetAttributeValue for mbedTLS Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declaration for the C_GetAttributeValue function used with mbedTLS. ```c CK_RV C_GetAttributeValue( CK_SESSION_HANDLE sessionHandle, CK_OBJECT_HANDLE hObject, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount ); ``` -------------------------------- ### PKCS #11 Mbed TLS C_Finalize Function Declaration Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Declares the C_Finalize function for the PKCS #11 Mbed TLS implementation. This function deinitializes the PKCS #11 module. ```c CK_RV C_Finalize( void * pReserved ); ``` -------------------------------- ### vAppendSHA256AlgorithmIdentifierSequence Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Appends a SHA256 algorithm identifier sequence. This is likely used in constructing specific cryptographic structures. ```APIDOC ## vAppendSHA256AlgorithmIdentifierSequence ### Description Appends a SHA256 algorithm identifier sequence. This is likely used in constructing specific cryptographic structures. ### Method Not applicable (function call) ### Endpoint Not applicable (function call) ### Parameters None explicitly documented in this snippet. ### Request Example ```c vAppendSHA256AlgorithmIdentifierSequence(); ``` ### Response None explicitly documented in this snippet. ``` -------------------------------- ### C_DigestUpdate Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Updates a message digest operation with data. ```APIDOC ## C_DigestUpdate ### Description Updates a message digest operation with data. ### Method C_DigestUpdate ### Endpoint N/A (Library Function) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### C_GetAttributeValue Source: https://github.com/freertos/corepkcs11/blob/main/docs/doxygen/pages.dox Obtains the value of attributes of an object. ```APIDOC ## C_GetAttributeValue ### Description Obtains the value of attributes of an object. ### Method C_GetAttributeValue ### Endpoint N/A (Library Function) ### Parameters N/A ### Request Example N/A ### Response N/A ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.