Lifecycle management of cryptographic keys in the HSM.
See HSM technical documentation.
Data Structures | |
| struct | DN_EXPORT_BYOK_AZURE |
Definitions and Macros | |
| #define | D_IMPORT_ALG_PRIV_KEY_RSA (0xFFFFFFE1) /* Imports an RSA private key. */ |
| #define | D_IMPORT_ALG_PRIV_KEY_ECC (0xFFFFFFE0) /* Imports an ECC private key (Elliptic Curves with the exception of ECX). */ |
| #define | D_IMPORT_ALG_PRIV_KEY_P8 (0xFFFFFFDF) /* Imports a key in P8 format */ |
| #define | D_IMPORT_ALG_PRIV_KEY_ECX (0xFFFFDE) /* Import an ECX private key */ |
| #define | D_IMPORT_ALG_PRIV_KEY_DSA (0xFFFFFFDD) /* Import a DSA private key */ |
| #define | D_IMPORT_ALG_PRIV_KEY_DH (0xFFFFDC) /* Import a DH private key */ |
| #define | D_IMPORT_ALG_PRIV_KEY_ML_DSA (0xFFFFDA) /* Import a ML-DSA private key */ |
| #define | D_IMPORT_ALG_PRIV_KEY_ML_KEM (0xFFFFFFD9) /* Import an ML-KEM private key */ |
| #define | D_IMPORT_ALG_PRIV_KEY_SLH_DSA (0xFFFFFFD8) /* Import a private key SLH-DSA */ |
| #define | DN_FORM_DER (1) |
| #define | DN_BYOK_TYPE_AZURE (1) |
| #define | DN_BYOK_TYPE_AWS (2) |
Functions | |
| int AAP_API | DGenerateKey (HSESSIONCTX hSession, char *szKeyId, int nAlgId, DWORD dwFlags, HKEYCTX *phKey) |
| int AAP_API | DGenerateKeyMaterial (HSESSIONCTX hSession, int nAlgId, BYTE *pbData, DWORD *pdwDataLen, DWORD dwReserved) |
| int AAP_API | DGetUserKey (HSESSIONCTX hSession, char *szKeyId, DWORD dwFlags, HKEYCTX *phKey) |
| int AAP_API | DImportKey (HSESSIONCTX hSession, char *szKeyId, HKEYCTX hKEKey, DWORD dwBlobType, int nAlgId, DWORD dwFlags, BYTE *pbData, DWORD dwDataLen, HKEYCTX *phKey) |
| int AAP_API | DExportKey (HKEYCTX hKey, HKEYCTX hKEKey, DWORD dwBlobType, DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen) |
| int AAP_API | DPKCS8ImportKey (HSESSIONCTX hSession, char *szKeyId, char *szSecret, DWORD dwKeyAlg, DWORD dwAttrib, BYTE *pbKeyEnvelope, DWORD dwKeyEnvelopeLen) |
| int AAP_API | DPKCS8ExportKey (HSESSIONCTX hSession, char *szKeyId, char *szSecret, BYTE **ppbKeyEnvelope, DWORD *pdwKeyEnvelopeLen) |
| int AAP_API | DSetKeyParam (HKEYCTX hKey, DWORD dwParam, BYTE *pbData, DWORD dwDataLen, DWORD dwFlags) |
| int AAP_API | DGetKeyParam (HKEYCTX hKey, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags) |
| int AAP_API | DDeriveKey (HHASHCTX hHash, char *szKeyId, int nAlgId, DWORD dwFlags, HKEYCTX *phKey) |
| int AAP_API | DDuplicateKey (HKEYCTX hKey, DWORD dwFlags, HKEYCTX *phKey) |
| int AAP_API | DHashSessionKey (HKEYCTX hKey, HHASHCTX hHash, DWORD dwFlags) |
| int AAP_API | DDestroyKey (HKEYCTX *phKey, DWORD dwFlags) |
| int AAP_API | DGeneratePKCS10CSR (HSESSIONCTX hSession, char *szPrivateKeyName, BYTE bVersion, char *szDN, DWORD dwOutType, DWORD *pdwCSRLen, BYTE **ppbCSR, DWORD dwParam) |
| int AAP_API | DAssociatePKCS11Key (HSESSIONCTX hSession, char *szPriKey, char *szPubKey, char *szCert, void *pvReserved, DWORD dwReserved) |
| int AAP_API | DExportPKCS12 (const HSESSIONCTX hSession, const char *szPkcs12Pwd, const char *szKeyId, const char *szCertId, const char *szReserved, BYTE **ppbPkcs12, DWORD *pdwPkcs12Len, DWORD dwFlags) |
| int AAP_API | DImportPKCS12Buffer (const HSESSIONCTX hSession, BYTE *pbPkcs12, DWORD dwPkcs12Len, const char *szPkcs12Pwd, const char *szKeyId, DWORD dwKeyAttr, const char *szCertId, const char *szPubKeyId, DWORD dwFlags) |
| int AAP_API | DImportPKCS12 (const HSESSIONCTX hSession, const char *szPkcs12File, const char *szPkcs12Pwd, const char *szKeyId, const DWORD dwKeyAttr, const char *szCertId) |
| int AAP_API | DRSAPublicKey2Info (BYTE *pbKey, DWORD dwKeyLen, DWORD dwInForm, void *pvPubKeyInfo, DWORD dwReserved) |
| int AAP_API | DRSAPrivateKey2Info (const BYTE *pbRsa, DWORD dwRsaLen, DWORD dwInForm, DN_RSA_PRIVATE_KEY_INFO *stRsaInfo, DWORD dwReserved) |
| int AAP_API | DByokExport (HSESSIONCTX hSession, const char *cszKeyId, const char *cszKekId, DWORD dwType, const void *pvData, BYTE **ppbOutData, DWORD *pdwOutDataLen, DWORD dwReserved) |
| #define D_IMPORT_ALG_PRIV_KEY_RSA (0xFFFFFFE1) /* Importa uma chave privada RSA. */ |
#include <dinamo.h>
| #define D_IMPORT_ALG_PRIV_KEY_ECC (0xFFFFFFE0) /* Importa uma chave privada ECC(Curvas Elípticas com exceção de ECX). */ |
#include <dinamo.h>
| #define D_IMPORT_ALG_PRIV_KEY_P8 (0xFFFFFFDF) /* Importa uma chave no formato P8 */ |
#include <dinamo.h>
| #define D_IMPORT_ALG_PRIV_KEY_ECX (0xFFFFFFDE) /* Importa uma chave privada ECX */ |
#include <dinamo.h>
| #define D_IMPORT_ALG_PRIV_KEY_DSA (0xFFFFFFDD) /* Importa uma chave privada DSA */ |
#include <dinamo.h>
| #define D_IMPORT_ALG_PRIV_KEY_DH (0xFFFFFFDC) /* Importa uma chave privada DH */ |
#include <dinamo.h>
| #define D_IMPORT_ALG_PRIV_KEY_ML_DSA (0xFFFFFFDA) /* Importa uma chave privada ML-DSA */ |
#include <dinamo.h>
| #define D_IMPORT_ALG_PRIV_KEY_ML_KEM (0xFFFFFFD9) /* Importa uma chave privada ML-KEM */ |
#include <dinamo.h>
| #define D_IMPORT_ALG_PRIV_KEY_SLH_DSA (0xFFFFFFD8) /* Importa uma chave privada SLH-DSA */ |
#include <dinamo.h>
| #define DN_FORM_DER (1) |
#include <dinamo.h>
DER format.
| #define DN_BYOK_TYPE_AZURE (1) |
#include <dinamo.h>
Exports BYOK key to Azure.
| #define DN_BYOK_TYPE_AWS (2) |
#include <dinamo.h>
Export BYOK key to AWS.
| int AAP_API DGenerateKey | ( | HSESSIONCTX | hSession, |
| char * | szKeyId, | ||
| int | nAlgId, | ||
| DWORD | dwFlags, | ||
| HKEYCTX * | phKey ) |
#include <dinamo.h>
Creates and stores a cryptographic key associated with an algorithm according to the specified parameters, within the HSM.
| [in] | hSession | Context acquired through the DOpenSession() function. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [in] | szKeyId | The key identifier within the HSM. This identifier must not contain spaces or special characters. It is case-sensitive. An object identifier in the HSM can have a maximum length of MAX_OBJ_ID characters (including the null terminator). When creating keys in another user's partition (permission is required), the name must be fully qualified with an FQN (Full Qualified Name: partition_id/obj_id). The maximum length for an FQN is MAX_OBJ_ID_FQN_LEN (including the null terminator). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [in] | nAlgId | Defines the algorithm associated with the cryptographic key to be generated. Symmetric Keys
RSA Asymmetric Keys
ECC Asymmetric Keys
ECX Asymmetric Keys
PQC Asymmetric Keys
HMAC Keys
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [in] | dwFlags | Additional key parameters.
In addition to the values in the previous table, a key usage profile definition can be added. It is possible to define the key usage profile (Attribute Usage-profile), using only one of the values below. If none of the values below are specified, the key profile is set to be free for any use. Defining the usage profile is mandatory when the HSM is in RM3.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [in] | phKey | Pointer to the generated key context. After use, it must be released with the DDestroyKey() function. NULL can be passed to prevent returning the key context. |
| Parameter | Value |
|---|---|
| Initialization Vector | It will be a vector with all bytes equal to zero and with the same block size as the key algorithm's operation. |
| Symmetric Encryption Operation Mode | The CBC (Cipher Block Chaining) mode will be used. |
| Padding | The format defined in the PKCS#5 standard will be used as padding. |
| Value | Block size |
|---|---|
| ALG_DES | 8 bytes |
| ALG_3DES_112 | 8 bytes |
| ALG_3DES_168 | 8 bytes |
| ALG_AES_128 | 16 bytes |
| ALG_AES_192 | 16 bytes |
| ALG_AES_256 | 16 bytes |
| ALG_ARC5 | 8 bytes |
| Type | Value |
|---|---|
| Deterministic | ML-DSA enabled; SLH-DSA disabled. |
| Pre-hash | Disabled. Only used when a specific hash is defined. |
| Context | Disabled. Only used when a specific context is defined. |
| int AAP_API DGenerateKeyMaterial | ( | HSESSIONCTX | hSession, |
| int | nAlgId, | ||
| BYTE * | pbData, | ||
| DWORD * | pdwDataLen, | ||
| DWORD | dwReserved ) |
#include <dinamo.h>
Generates a cryptographic key and returns its material. This operation generates a key using the HSM and returns the key's content without persisting it in the HSM.
| [in] | hSession | Context acquired through the DOpenSession() function. |
| [in] | nAlgId | Defines the algorithm for the cryptographic key to be generated. This operation only supports symmetric key algorithms. See the list of algorithms in DGenerateKey(). |
| [in] | pbData | Buffer that will contain the generated key. Can be passed as NULL to receive the expected size of pbData in pdwDataLen. |
| [in,out] | pdwDataLen | Pointer containing the size of the pbData buffer. This variable will contain the exact size of the data copied into pbData. If pbData is NULL or the specified size is insufficient to complete the operation, pdwDataLen will contain the expected size of pbData. |
| [in] | dwReserved | Reserved for future use. |
| int AAP_API DGetUserKey | ( | HSESSIONCTX | hSession, |
| char * | szKeyId, | ||
| DWORD | dwFlags, | ||
| HKEYCTX * | phKey ) |
#include <dinamo.h>
Retrieves the context of a key, provided the current user has access, stored within the HSM. This function does not create a new key.
| [in] | hSession | Context acquired through the DOpenSession() function. | ||||||
| [in] | szKeyId | Identifier of the key within the HSM. This identifier must not contain spaces or special characters. Uppercase and lowercase characters are case-sensitive. See szKeyId in DGenerateKey() for details on maximum identifier sizes. | ||||||
| [in] | dwFlags | Pass zero. Otherwise, the following table is accepted.
| ||||||
| [out] | phKey | Pointer to the context of the generated key. After use, it must be released with the DDestroyKey() function. |
| int AAP_API DImportKey | ( | HSESSIONCTX | hSession, |
| char * | szKeyId, | ||
| HKEYCTX | hKEKey, | ||
| DWORD | dwBlobType, | ||
| int | nAlgId, | ||
| DWORD | dwFlags, | ||
| BYTE * | pbData, | ||
| DWORD | dwDataLen, | ||
| HKEYCTX * | phKey ) |
#include <dinamo.h>
Imports a cryptographic key into the HSM. Keys can be permanent or temporary. Keys exported using the DExportKey() function can be imported without format alteration.
| [in] | hSession | Context acquired through the DOpenSession() function. | ||||||||||||||||||||||||||||||||||
| [in] | szKeyId | Identifier of the key within the HSM. This identifier must not contain spaces or special characters. Uppercase and lowercase characters are case-sensitive. See szKeyId in DGenerateKey() for details on maximum identifier sizes. | ||||||||||||||||||||||||||||||||||
| [in] | hKEKey | Key context with which the key blob to be imported is encrypted - KEK (key encryption key) | ||||||||||||||||||||||||||||||||||
| [in] | dwBlobType | Format of the key buffer in the parameter pbData.
| ||||||||||||||||||||||||||||||||||
| [in] | nAlgId | Indicates the algorithm associated with the cryptographic key to be generated. See the list of algorithms in DGenerateKey(). Use D_IMPORT_ALG_PRIV_KEY_RSA when the imported private key is RSA and encrypted by a KEK; the specific algorithm will be automatically detected by the HSM after opening the encrypted BLOB. | ||||||||||||||||||||||||||||||||||
| [in] | dwFlags | Additional key parameters. See options in the DGenerateKey() function. | ||||||||||||||||||||||||||||||||||
| [in] | pbData | Buffer containing the key to be imported. | ||||||||||||||||||||||||||||||||||
| [in] | dwDataLen | Size of the data block containing the key to be imported. | ||||||||||||||||||||||||||||||||||
| [out] | phKey | Pointer to the context of the generated key. After use, it must be released with the DDestroyKey function. |
Format of the SIMPLE_BLOB:
EB = 00 || BT || PS || 00 || D
DER structures for PRIVATEKEY_BLOB:
DER structure of PUBLICKEY_BLOB:
DER structure of PUBLICKEY_BLOB_X509:
| int AAP_API DExportKey | ( | HKEYCTX | hKey, |
| HKEYCTX | hKEKey, | ||
| DWORD | dwBlobType, | ||
| DWORD | dwFlags, | ||
| BYTE * | pbData, | ||
| DWORD * | pdwDataLen ) |
#include <dinamo.h>
Exports a key stored in the HSM so that it can be transported. The key can then be imported back into Dinamo with the DImportKey() function.
| [in] | hKey | Context of the key to be exported. |
| [in] | hKEKey | Context of the key with which the key block will be encrypted - KEK (key encryption key). |
| [in] | dwBlobType | Key buffer format in the pbData parameter. See parameter dwBlobType in DImportKey() for list of types. |
| [in] | dwFlags | Reserved for future use (must be 0). |
| [in] | pbData | Buffer containing the key data according to the dwBlobType parameter. This parameter can be NULL to specify the required amount of memory. |
| [in,out] | pdwDataLen | Pointer to the buffer size, in bytes, specified in pbData. When the function returns, this parameter will contain the size of the data stored in pbData. |
| int AAP_API DPKCS8ImportKey | ( | HSESSIONCTX | hSession, |
| char * | szKeyId, | ||
| char * | szSecret, | ||
| DWORD | dwKeyAlg, | ||
| DWORD | dwAttrib, | ||
| BYTE * | pbKeyEnvelope, | ||
| DWORD | dwKeyEnvelopeLen ) |
#include <dinamo.h>
Imports an RSA private asymmetric key, enveloped according to the PKCS#8 standard, into the HSM. The RSA private key can be imported in plaintext or protected by a digital envelope. For details on the standards, refer to the Public-Key Cryptography Standards (PKCS) documents from RSA Labs. In restricted operating modes (RM1 and RM2), RSA keys can only be imported via the PKCS#8 standard using a digital envelope. This involves deriving an AES 256 key from a password of at least 1 character and at most 16 characters, with the derivation performed according to the PKCS#5 version 2.0 standard.
The envelope used may originate from any system compliant with the described standards.
| [in] | hSession | Context acquired through the DOpenSession() function. | ||||||||||||||||||||||||||||||
| [in] | szKeyId | Identifier for the RSA key that will be created on the basis of the HSM. See szKeyId in DGenerateKey() for details on maximum identifier sizes. | ||||||||||||||||||||||||||||||
| [in] | szSecret | Password used to derive the AES 256 key. NULL can be passed to indicate no password (plaintext import), or a password of up to ND_MAX_P8_PWD_LEN characters plus a null terminator. | ||||||||||||||||||||||||||||||
| [in] | dwKeyAlg | Indicates the algorithm associated with the cryptographic key to be generated.
| ||||||||||||||||||||||||||||||
| [in] | dwAttrib | Additional key parameters.
| ||||||||||||||||||||||||||||||
| [in] | pbKeyEnvelope | Buffer containing the input PKCS#8 envelope. | ||||||||||||||||||||||||||||||
| [in] | dwKeyEnvelopeLen | Size in bytes of the input PKCS#8 envelope. |
| int AAP_API DPKCS8ExportKey | ( | HSESSIONCTX | hSession, |
| char * | szKeyId, | ||
| char * | szSecret, | ||
| BYTE ** | ppbKeyEnvelope, | ||
| DWORD * | pdwKeyEnvelopeLen ) |
#include <dinamo.h>
Exports an RSA private asymmetric key stored in the HSM, enveloped according to the PKCS#8 standard. The RSA private key can be exported in plaintext or protected by a digital envelope. For details on the standards, refer to the Public-Key Cryptography Standards (PKCS) documents from RSA Labs. In restricted operating modes (RM1 and RM2), exportable RSA keys can only be exported via the PKCS#8 standard using a digital envelope. This involves deriving an AES 256 key from a password with a length between ND_MIN_P8_PWD_LEN and ND_MAX_P8_PWD_LEN characters, with the derivation performed according to the PKCS#5 version 2.0 standard. The output envelope can be imported into any system compliant with the described standards.
| [in] | hSession | Context acquired through the DOpenSession() function. |
| [in] | szKeyId | Identifier of the RSA key to be exported. See szKeyId in DGenerateKey() for details on maximum identifier sizes. |
| [in] | szSecret | Password with a length between ND_MIN_P8_PWD_LEN and ND_MAX_P8_PWD_LEN characters plus a null terminator, used to derive the AES 256 key. NULL can be passed to export in plaintext, without a password. |
| [out] | ppbKeyEnvelope | A pointer to a pointer that will hold the output PKCS#8 envelope. Memory allocation is handled internally by the library. The calling application is responsible for freeing the allocated memory. The DFree() function must be used to release this buffer. |
| [out] | pdwKeyEnvelopeLen | A pointer to a DWORD that will contain the size, in bytes, of the output PKCS#8 envelope. |
| int AAP_API DSetKeyParam | ( | HKEYCTX | hKey, |
| DWORD | dwParam, | ||
| BYTE * | pbData, | ||
| DWORD | dwDataLen, | ||
| DWORD | dwFlags ) |
#include <dinamo.h>
Modifies parameters of key contexts, which generally influence their manipulation.
| [in] | hKey | Context of the key to be exported. | ||||||||||||||||||||||
| [in] | dwParam | Defines the operation to be executed and, consequently, the structure or data passed in the parameter pbData.
| ||||||||||||||||||||||
| [in] | pbData | Pointer to the data or structures specified in dwParam. | ||||||||||||||||||||||
| [in] | dwDataLen | Size of the data or structure specified in dwParam. | ||||||||||||||||||||||
| [in] | dwFlags | REMOVE_ATTRIBUTE can be used to revoke a user's privilege over a key. This flag should only be used in conjunction with DKP_OWNER or DKP_USER. |
| int AAP_API DGetKeyParam | ( | HKEYCTX | hKey, |
| DWORD | dwParam, | ||
| BYTE * | pbData, | ||
| DWORD * | pdwDataLen, | ||
| DWORD | dwFlags ) |
#include <dinamo.h>
Retrieves parameters from key contexts.
| [in] | hKey | Key context to be exported | ||||||||||||||||
| [in] | dwParam | Defines the operation to be executed and, consequently, the structure or data passed in the parameter pbData. All values described in DSetKeyParam() and more:
| ||||||||||||||||
| [in] | pbData | Pointer to the data or structures specified in dwParam | ||||||||||||||||
| [in] | pdwDataLen | Size of data or structure specified in dwParam | ||||||||||||||||
| [in] | dwFlags | Reserved for future use (must be 0). |
| int AAP_API DDeriveKey | ( | HHASHCTX | hHash, |
| char * | szKeyId, | ||
| int | nAlgId, | ||
| DWORD | dwFlags, | ||
| HKEYCTX * | phKey ) |
#include <dinamo.h>
Derives a key from the provided hash. If the hash is not yet complete, it will be finalized and its value used as a symmetric key.
| [in] | hHash | Hash context created with DCreateHash. |
| [in] | szKeyId | Identifier of the key within the HSM. This identifier must not contain spaces or special characters. Uppercase and lowercase characters are case-sensitive. See szKeyId in DGenerateKey() for details on maximum identifier sizes. |
| [in] | nAlgId | Indicates the algorithm associated with the cryptographic key to be generated. See the list of algorithms in DGenerateKey(). |
| [in] | dwFlags | Additional key parameters. See the list of additional key parameters in DGenerateKey(). |
| [in] | phKey | Pointer to the context of the generated key. After use, it must be released with the DDestroyKey() function. |
#include <dinamo.h>
Duplicates a key context, including its internal state.
| [in] | hKey | Key context. |
| [in] | dwFlags | Reserved for future use (must be 0). |
| [out] | phKey | Pointer to the context of the generated key. After use, it must be released with the DDestroyKey() function. |
#include <dinamo.h>
Uses the value of a symmetric key as input data for a hash operation. The hash context must be clean to be used with this function; that is, it cannot have been used with the DHashData() function.
| [in] | hKey | Key context. |
| [in] | hHash | Hash context created with DCreateHash(). |
| [in] | dwFlags | Reserved for future use (must be 0). |
#include <dinamo.h>
Releases a key context after use. Once released, this context can no longer be used by any function and becomes invalid.
| [in] | phKey | Pointer to a key context that will be released. | ||||
| [in] | dwFlags | Operation modifiers.
|
| int AAP_API DGeneratePKCS10CSR | ( | HSESSIONCTX | hSession, |
| char * | szPrivateKeyName, | ||
| BYTE | bVersion, | ||
| char * | szDN, | ||
| DWORD | dwOutType, | ||
| DWORD * | pdwCSRLen, | ||
| BYTE ** | ppbCSR, | ||
| DWORD | dwParam ) |
#include <dinamo.h>
Generates a CSR (Certificate Signing Request). This is a specialized function of the HSM's PKCS#10 CSR generation API.
| [in] | hSession | Context acquired through the DOpenSession() function. | ||||||||||||||||||||||
| [in] | szPrivateKeyName | Private key identifier. | ||||||||||||||||||||||
| [in] | bVersion | PKCS#10 CSR version. The following table is supported.
| ||||||||||||||||||||||
| [in] | szDN | DN (Distinguished Name), for CSR generation, with a maximum length of CORE_P10_CSR_DN_MAX_LEN. DN fields must be separated by '/'. | ||||||||||||||||||||||
| [in] | dwOutType | CSR output type. The following table is supported.
| ||||||||||||||||||||||
| [out] | pdwCSRLen | Pointer to the size of the buffer allocated in ppbCSR. | ||||||||||||||||||||||
| [out] | ppbCSR | Pointer to a pointer that will receive the CSR. The size of the allocated buffer will be available via pdwCSRLen. Memory allocation is handled internally. The calling application is responsible for freeing the allocated memory using the DFree() API. | ||||||||||||||||||||||
| [in] | dwParam | Additional parameters. The following table is supported.
|
| int AAP_API DAssociatePKCS11Key | ( | HSESSIONCTX | hSession, |
| char * | szPriKey, | ||
| char * | szPubKey, | ||
| char * | szCert, | ||
| void * | pvReserved, | ||
| DWORD | dwReserved ) |
#include <dinamo.h>
Associates a private key with a certificate and optionally a public key, following the PKCS#11 Base v2.40 specifications, section 4.6.3, and as used by Firefox.
| [in] | hSession | Context acquired through the DOpenSession() function. . |
| [in] | szPriKey | Name of the private key to be associated. |
| [in] | szPubKey | Name of the public key to be associated. NULL can be passed to avoid generating the associated public key. It must be related to the private key. |
| [in] | szCert | Name of the certificate to be exported. It must be related to the private key. |
| [in] | pvReserved | Reserved for future use. Must be NULL. |
| [in] | dwReserved | Reserved for future use. Must be 0. |
| Attribute | Value |
|---|---|
| CKA_ID | SHA1 of the public key module. Defined for Private key, public key, and certificate. |
| CKA_LABEL | Certificate ID. Defined for private key and certificate. |
| CKA_SUBJECT | Subject retrieved from the certificate. Defined for private key and certificate. |
For EC keys, CKA_ID will be the SHA1 hash of the CKA_PUBLIC_KEY_INFO value.
| int AAP_API DExportPKCS12 | ( | const HSESSIONCTX | hSession, |
| const char * | szPkcs12Pwd, | ||
| const char * | szKeyId, | ||
| const char * | szCertId, | ||
| const char * | szReserved, | ||
| BYTE ** | ppbPkcs12, | ||
| DWORD * | pdwPkcs12Len, | ||
| DWORD | dwFlags ) |
#include <dinamo.h>
Exports an RSA private key and certificate in PKCS#12 format.
| [in] | hSession | Context acquired through the DOpenSession() function. . | ||||
| [in] | szPkcs12Pwd | Password for the PKCS#12 file. Pass NULL to generate a PKCS#12 without a password. | ||||
| [in] | szKeyId | Name of the private key to be exported. See szKeyId in DGenerateKey() for details on maximum identifier sizes. | ||||
| [in] | szCertId | Name of the certificate to be exported. It must be related to the private key. | ||||
| [in] | szReserved | Reserved for future use. Must be NULL. | ||||
| [out] | ppbPkcs12 | Pointer to a pointer that will contain the generated PKCS#12. This data area will be internally allocated and must be freed using DFree(). | ||||
| [out] | pdwPkcs12Len | Pointer to the size of the data written in ppbPkcs12. | ||||
| [in] | dwFlags | Pass 0 or one of the options from the table below.
|
| int AAP_API DImportPKCS12Buffer | ( | const HSESSIONCTX | hSession, |
| BYTE * | pbPkcs12, | ||
| DWORD | dwPkcs12Len, | ||
| const char * | szPkcs12Pwd, | ||
| const char * | szKeyId, | ||
| DWORD | dwKeyAttr, | ||
| const char * | szCertId, | ||
| const char * | szPubKeyId, | ||
| DWORD | dwFlags ) |
#include <dinamo.h>
Imports a private/public key and a certificate from a buffer in PKCS#12 format.
| [in] | hSession | Context acquired through the DOpenSession() function. . |
| [in] | pbPkcs12 | PKCS#12 to be imported. |
| [in] | dwPkcs12Len | Size of the buffer containing PKCS#12 in pbPkcs12. |
| [in] | szPkcs12Pwd | PKCS#12 password. Pass NULL if there is no password. |
| [in] | szKeyId | Name of the private key to be imported. See szKeyId in DGenerateKey() for details on maximum identifier sizes. |
| [in] | dwKeyAttr | Attributes of the private key that will be imported See dwFlags in DGenerateKey() for details on the key attributes. |
| [in] | szCertId | Name of the certificate to be imported. It must be related to the private key. |
| [in] | szPubKeyId | Name of the public key that can be imported. Can be NULL if the public key is not to be imported. |
| [in] | dwFlags | Reserved for future use. Must be 0. |
| int AAP_API DImportPKCS12 | ( | const HSESSIONCTX | hSession, |
| const char * | szPkcs12File, | ||
| const char * | szPkcs12Pwd, | ||
| const char * | szKeyId, | ||
| const DWORD | dwKeyAttr, | ||
| const char * | szCertId ) |
#include <dinamo.h>
Imports a private/public key and a certificate from a PKCS#12 formatted file.
| [in] | hSession | Context acquired through the DOpenSession() function. . |
| [in] | szPkcs12File | Name of the PKCS#12 file to be imported. |
| [in] | szPkcs12Pwd | PKCS#12 password. Pass NULL if there is no password. |
| [in] | szKeyId | Name of the private key to be imported. See szKeyId in DGenerateKey() for details on maximum identifier sizes. |
| [in] | dwKeyAttr | Attributes of the private key that will be imported See dwFlags in DGenerateKey() for details on the key attributes. |
| [in] | szCertId | Name of the certificate to be imported. It must be related to the private key. |
| int AAP_API DRSAPublicKey2Info | ( | BYTE * | pbKey, |
| DWORD | dwKeyLen, | ||
| DWORD | dwInForm, | ||
| void * | pvPubKeyInfo, | ||
| DWORD | dwReserved ) |
#include <dinamo.h>
Decodes the information of an RSA public key. It accepts public keys in PKCS#1 RSAPublicKey or X.509 SubjectPublicKeyInfo format.
| [in] | pbKey | Public key. | ||||
| [in] | dwKeyLen | Size of the pbKey buffer. | ||||
| [in] | dwInForm | Key input format in pbKey. The table below is accepted.
| ||||
| [out] | pvPubKeyInfo | Pointer to a DN_RSA_PUB_KEY_INFO structure. | ||||
| [in] | dwReserved | Reserved for future use (must be 0). |
| int AAP_API DRSAPrivateKey2Info | ( | const BYTE * | pbRsa, |
| DWORD | dwRsaLen, | ||
| DWORD | dwInForm, | ||
| DN_RSA_PRIVATE_KEY_INFO * | stRsaInfo, | ||
| DWORD | dwReserved ) |
#include <dinamo.h>
Decodes the information of an RSA private key. It accepts private keys in PKCS#1 RSAPrivateKey or unencrypted PKCS#8 PrivateKeyInfo format.
| [in] | pbRsa | Private key. | ||||
| [in] | dwRsaLen | Size of the pbRsa buffer. | ||||
| [in] | dwInForm | Key input format in pbRsa. The table below is accepted.
| ||||
| [out] | stRsaInfo | Pointer to a DN_RSA_PRIVATE_KEY_INFO structure. | ||||
| [in] | dwReserved | Reserved for future use (must be 0). |
| int AAP_API DByokExport | ( | HSESSIONCTX | hSession, |
| const char * | cszKeyId, | ||
| const char * | cszKekId, | ||
| DWORD | dwType, | ||
| const void * | pvData, | ||
| BYTE ** | ppbOutData, | ||
| DWORD * | pdwOutDataLen, | ||
| DWORD | dwReserved ) |
#include <dinamo.h>
Exports a key in BYOK (Bring Your Own Key) format to a cloud provider.
| [in] | hSession | Session context. | ||||||
| [in] | cszKeyId | Identifier of the key to be exported. See szKeyId in DGenerateKey() for details on maximum identifier sizes. | ||||||
| [in] | cszKekId | Identifier of the KEK key that will be used to encrypt the key to be exported. | ||||||
| [in] | dwType | Export type. The table below is supported.
| ||||||
| [in] | pvData | Pointer to a specific data structure for each type of export. See dwType for details. | ||||||
| [out] | ppbOutData | Pointer to a pointer that will contain the output data. This data area will be internally allocated and must be freed using DFree(). | ||||||
| [out] | pdwOutDataLen | Pointer to the size of the data written to ppbOutData. | ||||||
| [in] | dwReserved | Reserved for future use (must be 0). |