### Include CAdESCOM GUIDs File in C Source: https://cpdn.cryptopro.ru/content/cades/cades-com-usage.html For C programming, include the `cadescom_i.c` file once in your application to use CAdESCOM GUIDs. Duplicate inclusion will cause a linker error. ```c #include ``` -------------------------------- ### CryptoPro PKI Developer's Guide - TSP SDK Source: https://cpdn.cryptopro.ru/content/cades/cadesui.html Documentation for the CryptoPro TSP SDK, including its usage, installation package creation, and reference to low-level interfaces and client application interfaces. ```APIDOC ## CryptoPro TSP SDK Documentation ### Description This section details the CryptoPro Time Stamp Protocol (TSP) Software Development Kit (SDK), covering its integration and usage for developers. ### Key Areas * **Usage**: Information on how to utilize the TSP SDK. * **Installation Package Creation**: Procedures for creating installation packages. * **Low-level Interface**: Details on classes like `CAccuracy`, `CMSRequest`, `CMSStamp`, `CRequest`, `CResponse`, `CToken`. * **Client Application Interface (C++)**: Information on C++ classes `CRequest`, `CStamp` and functions `FreeMSStamp`, `GetMSStamp`. * **Client Application Interface (COM)**: Details on COM interfaces, including `ITSPRequest` with methods like `Import`, `Export`, `Send`, `Display` and properties like `TSAAddress`. ``` -------------------------------- ### Get Interface GUID with __uuidof() in C++ Source: https://cpdn.cryptopro.ru/content/cades/cades-com-usage.html Use the `__uuidof()` operator in C++ to obtain the GUID for CAdESCOM interfaces or classes, for example, when creating an instance. ```cpp CoCreateInstance(&__uuidof(CadesSignedData), ...); ``` -------------------------------- ### C_Initialize Source: https://cpdn.cryptopro.ru/content/PKCS1150r4/html/group___pro_p_k_c_s11_general_1gad9e50402e107e29566799a2611d37d3f.html Initializes the Cryptoki library. This function must be called before any other Cryptoki function, except for C_GetFunctionList. Each application using the library must call this function, and each successful call must be matched by a call to C_Finalize. ```APIDOC ## C_Initialize ### Description Initializes the Cryptoki library. This function must be the first function called by an application, excluding the call to C_GetFunctionList(). If multiple applications work with the Cryptoki library simultaneously, each must call C_Initialize(). Each successful call to C_Initialize() must be completed by a call to C_Finalize(). ### Method CPRO_PUBLIC_API CK_RV C_Initialize( CK_VOID_PTR _pInitArgs ); ### Parameters #### Arguments - **_pInitArgs** (CK_VOID_PTR) - Reserved for future use. Note: In this implementation, _pInitArgs cannot be used to pass function parameters. ### Return Values Upon successful completion, the function returns CKR_OK; otherwise, an error code is returned. #### Return Codes - **CKR_CRYPTOKI_ALREADY_INITIALIZED**: The Cryptoki library has already been initialized. - **CKR_FUNCTION_FAILED**: The function cannot be executed, but this error code does not contain detailed information about the cause of the failure. It is possible that a subsequent call to the function will be successful. - **CKR_FUNCTION_NOT_SUPPORTED**: Function not supported. ### Notes Detailed description of the function can be found in the RSA (PKCS#11 v 2.30) documentation. ### Implementation Specifics - The _pInitArgs parameter is reserved for future use and cannot be used to pass parameters in this implementation. ### Requirements - **AIX:** 5/6/7 or higher. - **FreeBSD:** 7/8/9 or higher. - **Linux:** LSB 3.1 (RHEL 4, SuSE 10) or higher. - **Solaris:** 10/11 or higher. - **Mac OSX:** 10.7/8 or higher. - **iOS:** 6/7 or higher. - **Windows:** Windows 2000 SP4 or older with Internet Explorer 6.0 or older. ``` -------------------------------- ### GostAlgorithmSuite Constructors Source: https://cpdn.cryptopro.ru/content/PKCS1150r4/html/group___pro_p_k_c_s11.html Provides constructors for the GostAlgorithmSuite class. ```APIDOC ## GostAlgorithmSuite Constructors ### Description Constructors for the GostAlgorithmSuite class. ### Constructors - GostAlgorithmSuite() - GostAlgorithmSuite(Boolean) ``` -------------------------------- ### C_VerifyInit Source: https://cpdn.cryptopro.ru/content/PKCS1150r4/html/group___pro_p_k_c_s11_verify.html Initializes a signature verification operation where the signature is appended to the data. ```APIDOC ## C_VerifyInit ### Description Initializes a signature verification operation where the signature is appended to the data. ### Function Signature ```c CK_RV C_VerifyInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hKey) ``` ### Parameters #### Input Parameters - **hSession** (CK_SESSION_HANDLE) - Handle of the session to initialize. - **pMechanism** (CK_MECHANISM_PTR) - Pointer to a structure that specifies the general mechanism type and its parameters. - **hKey** (CK_OBJECT_HANDLE) - Handle of the verification key. ### Return Value - **CK_RV** - Indicates success or failure of the operation. ``` -------------------------------- ### ICPX509Enrollment Source: https://cpdn.cryptopro.ru/content/cades/cadescom_interface.html Provides methods for creating and installing certificate requests. Extends the IX509Enrollment interface. ```APIDOC ## ICPX509Enrollment ### Description Provides methods for creating and installing certificate requests. Extends the IX509Enrollment interface. ### Interface ICPX509Enrollment ``` -------------------------------- ### C_VerifyInit Source: https://cpdn.cryptopro.ru/content/PKCS1150r4/html/group___pro_p_k_c_s11_verify_1gac4ae2407b1537b61f913599fcf05f471.html Initializes a signature verification operation. The CKA_VERIFY attribute of the verification key must be CK_TRUE. ```APIDOC ## C_VerifyInit ### Description Initializes a signature verification operation where the signature is appended to the data. The **CKA_VERIFY** attribute of the verification key must be CK_TRUE. ### Function Signature ``` **CPRO_PUBLIC_API CK_RV** **C_VerifyInit(** **CK_SESSION_HANDLE** _hSession_, **CK_MECHANISM_PTR** _pMechanism_, **CK_OBJECT_HANDLE** _hKey_ **); ``` ### Parameters #### Arguments - **_hSession_** (CK_SESSION_HANDLE) - The session handle. - **_pMechanism_** (CK_MECHANISM_PTR) - A pointer to the verification mechanism. - **_hKey_** (CK_OBJECT_HANDLE) - The handle of the verification key. ### Return Values Upon successful completion, the function returns CKR_OK, otherwise it returns an error code. #### Return Codes - **CKR_OK**: Successful completion. - **CKR_CRYPTOKI_NOT_INITIALIZED**: The cryptographic interface library has not been initialized. - **CKR_OPERATION_ACTIVE**: An active operation already exists that prevents Cryptoki from activating this operation. - **CKR_ARGUMENTS_BAD**: Some of the arguments passed to the function are inappropriate. - **CKR_SESSION_HANDLE_INVALID**: The session handle was invalid. - **CKR_KEY_HANDLE_INVALID**: The specified key handle is invalid. - **CKR_KEY_FUNCTION_NOT_PERMITTED**: An attempt was made to perform a cryptographic operation with a key that does not have the necessary attributes set for this operation. - **CKR_KEY_TYPE_INCONSISTENT**: The type of the specified key is inconsistent with the mechanism passed to the function. - **CKR_MECHANISM_INVALID**: An invalid mechanism was passed to the cryptographic operation. - **CKR_MECHANISM_PARAM_INVALID**: The cryptographic operation was passed a mechanism with invalid parameters. - **CKR_FUNCTION_FAILED**: The function could not be executed, but this error code does not contain detailed information about the cause of the failure. ### Notes - For a detailed description of the function, see the RSA (PKCS#11 v 2.30) documents. - **Implementation Specifics:** The function is implemented in accordance with the requirements of the PKCS#11 standard. ``` -------------------------------- ### Token Initialization Functions Source: https://cpdn.cryptopro.ru/content/PKCS1150r4/html/group___pro_p_k_c_s11_func.html Functions for initializing a token and managing PINs. ```APIDOC ## C_InitToken ### Description Initializes a token with a new PIN and label. ### Method Not Applicable (Function Call) ### Endpoint Not Applicable ### Parameters None explicitly defined in this context. ### Response None explicitly defined in this context. ## C_InitPIN ### Description Initializes the PIN for a token. ### Method Not Applicable (Function Call) ### Endpoint Not Applicable ### Parameters None explicitly defined in this context. ### Response None explicitly defined in this context. ## C_SetPIN ### Description Sets a new PIN for a token. ### Method Not Applicable (Function Call) ### Endpoint Not Applicable ### Parameters None explicitly defined in this context. ### Response None explicitly defined in this context. ``` -------------------------------- ### C_GetObjectSize Function Signature Source: https://cpdn.cryptopro.ru/content/PKCS1150r4/html/group___pro_p_k_c_s11_object_1ga5ed2259aad5ae158234c7d8d5ce43901.html This is the function signature for C_GetObjectSize, which is used to get the size of a PKCS#11 object. ```c #define CPRO_PUBLIC_API CK_RV C_GetObjectSize( CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject, CK_ULONG_PTR pulSize ); ``` -------------------------------- ### Display Detached Signature with Page Handling Source: https://cpdn.cryptopro.ru/content/cades/cadesuisamplepages.html This C++ snippet demonstrates how to display a detached enhanced electronic digital signature using CadesViewSignatureDetached. It retrieves property pages for the signature and displays them in a property sheet. Ensure necessary setup and imports for C++ and CryptoPro SDK are in place. ```cpp const BYTE *pDataArray[1]; pDataArray[0] = &original[0]; DWORD cDataArray[1]; cDataArray[0] = (DWORD)original.size(); CADES_VIEW_SIGNATURE_PARA viewPara = { sizeof(viewPara) }; viewPara.dwMsgAndCertEncodingType = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING; LPPROPSHEETPAGEW *pPropSheetPages = NULL; DWORD cPropSheetPages = 0; if (!CadesViewSignatureDetached(0, &viewPara, &detachedMsg[0], (DWORD)detachedMsg.size(), 1, pDataArray, cDataArray, &pPropSheetPages, &cPropSheetPages)) { CadesFreeSignaturePropPages(pPropSheetPages, cPropSheetPages); std::cout << "CadesViewSignatureDetached() failed." << std::endl; return; } std::vector pages(cPropSheetPages); for (DWORD i=0; i