![]() |
API参考
|
Algorithm related interfaces to be registered 更多...

类 | |
| struct | HITLS_CRYPT_EcdhMethod |
| ECDH Callback function to be registered 更多... | |
| struct | HITLS_CRYPT_DhMethod |
| DH Callback function to be registered 更多... | |
| struct | HITLS_CRYPT_KdfMethod |
| KDF function 更多... | |
类型定义 | |
| typedef int32_t(* | CRYPT_RandBytesCallback) (uint8_t *buf, uint32_t len) |
| Obtain the random number. | |
| typedef HITLS_CRYPT_Key *(* | CRYPT_GenerateEcdhKeyPairCallback) (HITLS_Ctx *ctx, const HITLS_ECParameters *curveParams) |
| ECDH: Generate a key pair based on elliptic curve parameters. | |
| typedef void(* | CRYPT_FreeEcdhKeyCallback) (HITLS_CRYPT_Key *key) |
| Release the key. | |
| typedef int32_t(* | CRYPT_GetEcdhEncodedPubKeyCallback) (HITLS_CRYPT_Key *key, uint8_t *pubKeyBuf, uint32_t bufLen, uint32_t *pubKeyLen) |
| ECDH: Extract the public key data. | |
| typedef int32_t(* | CRYPT_CalcEcdhSharedSecretCallback) (HITLS_CRYPT_Key *key, uint8_t *peerPubkey, uint32_t pubKeyLen, uint8_t *sharedSecret, uint32_t *sharedSecretLen) |
| ECDH: Calculate the shared key based on the local key and peer public key. Ref RFC 8446 section 7.4.1, this callback should retain the leading zeros. | |
| typedef int32_t(* | CRYPT_KemEncapsulateCallback) (HITLS_KemEncapsulateParams *params) |
| KEM: Encapsulate a shared secret using peer's public key. | |
| typedef int32_t(* | CRYPT_KemDecapsulateCallback) (HITLS_CRYPT_Key *key, const uint8_t *ciphertext, uint32_t ciphertextLen, uint8_t *sharedSecret, uint32_t *sharedSecretLen) |
| KEM: Decapsulate the ciphertext to recover shared secret. | |
| typedef int32_t(* | CRYPT_Sm2CalcEcdhSharedSecretCallback) (HITLS_Sm2GenShareKeyParameters *sm2Params, uint8_t *sharedSecret, uint32_t *sharedSecretLen) |
| SM2 calculates the shared key based on the local key and peer public key. | |
| typedef HITLS_CRYPT_Key *(* | CRYPT_GenerateDhKeyBySecbitsCallback) (int32_t secbits) |
| Generate a key pair based on secbits. | |
| typedef HITLS_CRYPT_Key *(* | CRYPT_GenerateDhKeyByParamsCallback) (uint8_t *p, uint16_t plen, uint8_t *g, uint16_t glen) |
| DH: Generate a key pair based on the dh parameter. | |
| typedef HITLS_CRYPT_Key *(* | CRYPT_DupDhKeyCallback) (HITLS_CRYPT_Key *key) |
| Deep copy key | |
| typedef void(* | CRYPT_FreeDhKeyCallback) (HITLS_CRYPT_Key *key) |
| Release the key. | |
| typedef int32_t(* | CRYPT_DHGetParametersCallback) (HITLS_CRYPT_Key *key, uint8_t *p, uint16_t *plen, uint8_t *g, uint16_t *glen) |
| DH: Obtain p g plen glen by using the key handle. | |
| typedef int32_t(* | CRYPT_GetDhEncodedPubKeyCallback) (HITLS_CRYPT_Key *key, uint8_t *pubKeyBuf, uint32_t bufLen, uint32_t *pubKeyLen) |
| DH: Extract the Dh public key data. | |
| typedef int32_t(* | CRYPT_CalcDhSharedSecretCallback) (HITLS_CRYPT_Key *key, uint8_t *peerPubkey, uint32_t pubKeyLen, uint8_t *sharedSecret, uint32_t *sharedSecretLen) |
| DH: Calculate the shared key based on the local key and peer public key. Ref RFC 5246 section 5.1.2, this callback should remove the pre-zeros. | |
| typedef uint32_t(* | CRYPT_HmacSizeCallback) (HITLS_HashAlgo hashAlgo) |
| Obtain the HMAC length based on the hash algorithm. | |
| typedef HITLS_HMAC_Ctx *(* | CRYPT_HmacInitCallback) (HITLS_HashAlgo hashAlgo, const uint8_t *key, uint32_t len) |
| Initialize the HMAC context. | |
| typedef int32_t(* | CRYPT_HmacReInitCallback) (HITLS_HMAC_Ctx *ctx) |
| reinit the HMAC context. | |
| typedef void(* | CRYPT_HmacFreeCallback) (HITLS_HMAC_Ctx *ctx) |
| Release the HMAC context. | |
| typedef int32_t(* | CRYPT_HmacUpdateCallback) (HITLS_HMAC_Ctx *ctx, const uint8_t *data, uint32_t len) |
| Add the HMAC input data. | |
| typedef int32_t(* | CRYPT_HmacFinalCallback) (HITLS_HMAC_Ctx *ctx, uint8_t *out, uint32_t *len) |
| Output the HMAC result. | |
| typedef int32_t(* | CRYPT_HmacCallback) (HITLS_HashAlgo hashAlgo, const uint8_t *key, uint32_t keyLen, const uint8_t *in, uint32_t inLen, uint8_t *out, uint32_t *outLen) |
| Function for calculating the HMAC for a single time | |
| typedef uint32_t(* | CRYPT_DigestSizeCallback) (HITLS_HashAlgo hashAlgo) |
| Obtain the hash length. | |
| typedef HITLS_HASH_Ctx *(* | CRYPT_DigestInitCallback) (HITLS_HashAlgo hashAlgo) |
| Initialize the hash context. | |
| typedef HITLS_HASH_Ctx *(* | CRYPT_DigestCopyCallback) (HITLS_HASH_Ctx *ctx) |
| Copy the hash context. | |
| typedef void(* | CRYPT_DigestFreeCallback) (HITLS_HASH_Ctx *ctx) |
| Release the hash context. | |
| typedef int32_t(* | CRYPT_DigestUpdateCallback) (HITLS_HASH_Ctx *ctx, const uint8_t *data, uint32_t len) |
| Hash Add input data. | |
| typedef int32_t(* | CRYPT_DigestFinalCallback) (HITLS_HASH_Ctx *ctx, uint8_t *out, uint32_t *len) |
| Output the hash result. | |
| typedef int32_t(* | CRYPT_DigestCallback) (HITLS_HashAlgo hashAlgo, const uint8_t *in, uint32_t inLen, uint8_t *out, uint32_t *outLen) |
| Hash function | |
| typedef int32_t(* | CRYPT_EncryptCallback) (const HITLS_CipherParameters *cipher, const uint8_t *in, uint32_t inLen, uint8_t *out, uint32_t *outLen) |
| TLS encryption | |
| typedef int32_t(* | CRYPT_DecryptCallback) (const HITLS_CipherParameters *cipher, const uint8_t *in, uint32_t inLen, uint8_t *out, uint32_t *outLen) |
| TLS decryption | |
| typedef void(* | CRYPT_CipherFreeCallback) (HITLS_Cipher_Ctx *ctx) |
| Release the cipher ctx. | |
| typedef int32_t(* | CRYPT_HkdfExtractCallback) (const HITLS_CRYPT_HkdfExtractInput *input, uint8_t *prk, uint32_t *prkLen) |
| HKDF-Extract | |
| typedef int32_t(* | CRYPT_HkdfExpandCallback) (const HITLS_CRYPT_HkdfExpandInput *input, uint8_t *outputKeyMaterial, uint32_t outputKeyMaterialLen) |
| HKDF-Expand | |
函数 | |
| int32_t | HITLS_CRYPT_RegisterBaseMethod (HITLS_CRYPT_BaseMethod *userCryptCallBack) |
| Register the basic callback function. | |
| int32_t | HITLS_CRYPT_RegisterEcdhMethod (HITLS_CRYPT_EcdhMethod *userCryptCallBack) |
| Register the ECDH callback function. | |
| int32_t | HITLS_CRYPT_RegisterDhMethod (const HITLS_CRYPT_DhMethod *userCryptCallBack) |
| Register the callback function of the DH. | |
| int32_t | HITLS_CRYPT_RegisterHkdfMethod (HITLS_CRYPT_KdfMethod *userCryptCallBack) |
| Register the callback function of the HKDF. | |
Algorithm related interfaces to be registered
hitls maintenance and debugging
| typedef int32_t(* CRYPT_CalcDhSharedSecretCallback) (HITLS_CRYPT_Key *key, uint8_t *peerPubkey, uint32_t pubKeyLen, uint8_t *sharedSecret, uint32_t *sharedSecretLen) |
DH: Calculate the shared key based on the local key and peer public key. Ref RFC 5246 section 5.1.2, this callback should remove the pre-zeros.
| key | [IN] Key handle |
| peerPubkey | [IN] Public key data |
| pubKeyLen | [IN] Public key data length |
| sharedSecret | [OUT] Shared key |
| sharedSecretLen | [IN/OUT] IN: Maximum length of the key padding OUT: Key length |
| typedef int32_t(* CRYPT_CalcEcdhSharedSecretCallback) (HITLS_CRYPT_Key *key, uint8_t *peerPubkey, uint32_t pubKeyLen, uint8_t *sharedSecret, uint32_t *sharedSecretLen) |
ECDH: Calculate the shared key based on the local key and peer public key. Ref RFC 8446 section 7.4.1, this callback should retain the leading zeros.
| key | [IN] Key handle |
| peerPubkey | [IN] Public key data |
| pubKeyLen | [IN] Public key data length |
| sharedSecret | [OUT] Shared key |
| sharedSecretLen | [IN/OUT] IN: Maximum length of the key padding OUT: Key length |
| typedef void(* CRYPT_CipherFreeCallback) (HITLS_Cipher_Ctx *ctx) |
Release the cipher ctx.
| ctx | [IN] cipher ctx handle |
| typedef int32_t(* CRYPT_DecryptCallback) (const HITLS_CipherParameters *cipher, const uint8_t *in, uint32_t inLen, uint8_t *out, uint32_t *outLen) |
TLS decryption
Provides decryption capabilities for records, including the AEAD and CBC algorithms. Decrypt the input factor (key parameter) and ciphertext according to the record protocol to obtain the plaintext.
| cipher | [IN] Key parameters |
| in | [IN] Ciphertext data |
| inLen | [IN] Ciphertext data length |
| out | [OUT] Plaintext data |
| outLen | [IN/OUT] IN: maximum buffer length OUT: plaintext data length |
| typedef int32_t(* CRYPT_DHGetParametersCallback) (HITLS_CRYPT_Key *key, uint8_t *p, uint16_t *plen, uint8_t *g, uint16_t *glen) |
DH: Obtain p g plen glen by using the key handle.
| key | [IN] Key handle |
| p | [OUT] p Parameter |
| plen | [IN/OUT] IN: Maximum length of data padding OUT: p Parameter length |
| g | [OUT] g Parameter |
| glen | [IN/OUT] IN: Maximum length of data padding OUT: g Parameter length |
| typedef int32_t(* CRYPT_DigestCallback) (HITLS_HashAlgo hashAlgo, const uint8_t *in, uint32_t inLen, uint8_t *out, uint32_t *outLen) |
Hash function
| hashAlgo | [IN] Hash algorithm |
| in | [IN] Input data |
| inLen | [IN] Input data length |
| out | [OUT] Output data |
| outLen | [IN/OUT] IN: Maximum buffer length OUT: Output data length |
| typedef HITLS_HASH_Ctx *(* CRYPT_DigestCopyCallback) (HITLS_HASH_Ctx *ctx) |
Copy the hash context.
| ctx | [IN] Hash Context |
| typedef int32_t(* CRYPT_DigestFinalCallback) (HITLS_HASH_Ctx *ctx, uint8_t *out, uint32_t *len) |
Output the hash result.
| ctx | [IN] Hash context |
| out | [IN] Output data. |
| len | [IN/OUT] IN: Maximum buffer length OUT: Output data length |
| typedef void(* CRYPT_DigestFreeCallback) (HITLS_HASH_Ctx *ctx) |
Release the hash context.
| ctx | [IN] Hash Context |
| typedef HITLS_HASH_Ctx *(* CRYPT_DigestInitCallback) (HITLS_HashAlgo hashAlgo) |
Initialize the hash context.
| hashAlgo | [IN] Hash algorithm |
| typedef uint32_t(* CRYPT_DigestSizeCallback) (HITLS_HashAlgo hashAlgo) |
Obtain the hash length.
| hashAlgo | [IN] Hash algorithm. |
| typedef int32_t(* CRYPT_DigestUpdateCallback) (HITLS_HASH_Ctx *ctx, const uint8_t *data, uint32_t len) |
Hash Add input data.
| ctx | [IN] Hash context |
| data | [IN] Input data |
| len | [IN] Input data length |
| typedef HITLS_CRYPT_Key *(* CRYPT_DupDhKeyCallback) (HITLS_CRYPT_Key *key) |
| typedef int32_t(* CRYPT_EncryptCallback) (const HITLS_CipherParameters *cipher, const uint8_t *in, uint32_t inLen, uint8_t *out, uint32_t *outLen) |
TLS encryption
Provides the encryption capability for records, including the AEAD and CBC algorithms. Encrypts the input factor (key parameter) and plaintext based on the record protocol to obtain the ciphertext.
The protocol allows the sending of app packets with payload length 0. Therefore, the length of the plaintext input may be 0. Therefore, the plaintext with the length of 0 must be encrypted.
| cipher | [IN] Key parameters |
| in | [IN] Plaintext data |
| inLen | [IN] Plaintext data length |
| out | [OUT] Ciphertext data |
| outLen | [IN/OUT] IN: maximum buffer length OUT: ciphertext data length |
| typedef void(* CRYPT_FreeDhKeyCallback) (HITLS_CRYPT_Key *key) |
Release the key.
| key | [IN] Key handle |
| typedef void(* CRYPT_FreeEcdhKeyCallback) (HITLS_CRYPT_Key *key) |
Release the key.
| key | [IN] Key handle |
| typedef HITLS_CRYPT_Key *(* CRYPT_GenerateDhKeyByParamsCallback) (uint8_t *p, uint16_t plen, uint8_t *g, uint16_t glen) |
DH: Generate a key pair based on the dh parameter.
| p | [IN] p Parameter |
| plen | [IN] p Parameter length |
| g | [IN] g Parameter |
| glen | [IN] g Parameter length |
| typedef HITLS_CRYPT_Key *(* CRYPT_GenerateDhKeyBySecbitsCallback) (int32_t secbits) |
Generate a key pair based on secbits.
| secbits | [IN] Key security level |
| typedef HITLS_CRYPT_Key *(* CRYPT_GenerateEcdhKeyPairCallback) (HITLS_Ctx *ctx, const HITLS_ECParameters *curveParams) |
ECDH: Generate a key pair based on elliptic curve parameters.
| ctx | [IN] TLS object |
| curveParams | [IN] Elliptic curve parameter |
| typedef int32_t(* CRYPT_GetDhEncodedPubKeyCallback) (HITLS_CRYPT_Key *key, uint8_t *pubKeyBuf, uint32_t bufLen, uint32_t *pubKeyLen) |
DH: Extract the Dh public key data.
| key | [IN] Key handle |
| pubKeyBuf | [OUT] Public key data |
| bufLen | [IN] Buffer length |
| pubKeyLen | [OUT] Public key data length |
| typedef int32_t(* CRYPT_GetEcdhEncodedPubKeyCallback) (HITLS_CRYPT_Key *key, uint8_t *pubKeyBuf, uint32_t bufLen, uint32_t *pubKeyLen) |
ECDH: Extract the public key data.
| key | [IN] Key handle |
| pubKeyBuf | [OUT] Public key data |
| bufLen | [IN] Buffer length |
| pubKeyLen | [OUT] Public key data length |
| typedef int32_t(* CRYPT_HkdfExpandCallback) (const HITLS_CRYPT_HkdfExpandInput *input, uint8_t *outputKeyMaterial, uint32_t outputKeyMaterialLen) |
HKDF-Expand
| input | [IN] Enter the key material. |
| outputKeyMaterial | [OUT] Output key |
| outputKeyMaterialLen | [IN] Output key length |
| typedef int32_t(* CRYPT_HkdfExtractCallback) (const HITLS_CRYPT_HkdfExtractInput *input, uint8_t *prk, uint32_t *prkLen) |
HKDF-Extract
| input | [IN] Enter the key material. |
| prk | [OUT] Output key |
| prkLen | [IN/OUT] IN: Maximum buffer length OUT: Output key length |
| typedef int32_t(* CRYPT_HmacCallback) (HITLS_HashAlgo hashAlgo, const uint8_t *key, uint32_t keyLen, const uint8_t *in, uint32_t inLen, uint8_t *out, uint32_t *outLen) |
Function for calculating the HMAC for a single time
| hashAlgo | [IN] Hash algorithm |
| key | [IN] Key |
| keyLen | [IN] Key length |
| in | [IN] Input data. |
| inLen | [IN] Input data length |
| out | [OUT] Output the HMAC data result. |
| outLen | [IN/OUT] IN: Maximum buffer length OUT: Output data length |
| typedef int32_t(* CRYPT_HmacFinalCallback) (HITLS_HMAC_Ctx *ctx, uint8_t *out, uint32_t *len) |
Output the HMAC result.
| ctx | [IN] HMAC context |
| out | [OUT] Output data |
| len | [IN/OUT] IN: Maximum buffer length OUT: Output data length |
| typedef void(* CRYPT_HmacFreeCallback) (HITLS_HMAC_Ctx *ctx) |
Release the HMAC context.
| ctx | [IN] HMAC context |
| typedef HITLS_HMAC_Ctx *(* CRYPT_HmacInitCallback) (HITLS_HashAlgo hashAlgo, const uint8_t *key, uint32_t len) |
Initialize the HMAC context.
| hashAlgo | [IN] Hash algorithm |
| key | [IN] Key |
| len | [IN] Key length |
| typedef int32_t(* CRYPT_HmacReInitCallback) (HITLS_HMAC_Ctx *ctx) |
reinit the HMAC context.
| ctx | [IN] HMAC context |
| typedef uint32_t(* CRYPT_HmacSizeCallback) (HITLS_HashAlgo hashAlgo) |
Obtain the HMAC length based on the hash algorithm.
| hashAlgo | [IN] Hash algorithm |
| typedef int32_t(* CRYPT_HmacUpdateCallback) (HITLS_HMAC_Ctx *ctx, const uint8_t *data, uint32_t len) |
Add the HMAC input data.
| ctx | [IN] HMAC context |
| data | [IN] Input data |
| len | [IN] Data length |
| typedef int32_t(* CRYPT_KemDecapsulateCallback) (HITLS_CRYPT_Key *key, const uint8_t *ciphertext, uint32_t ciphertextLen, uint8_t *sharedSecret, uint32_t *sharedSecretLen) |
KEM: Decapsulate the ciphertext to recover shared secret.
| key | [IN] Key handle |
| ciphertext | [IN] Ciphertext buffer |
| ciphertextLen | [IN] Ciphertext length |
| sharedSecret | [OUT] Shared secret buffer |
| sharedSecretLen | [IN/OUT] IN: Maximum length of the shared secret buffer OUT: Actual shared secret length |
| 0 | indicates success. Other values indicate failure. |
| typedef int32_t(* CRYPT_KemEncapsulateCallback) (HITLS_KemEncapsulateParams *params) |
KEM: Encapsulate a shared secret using peer's public key.
| params | [IN/OUT] Parameters for KEM encapsulation |
| 0 | indicates success. Other values indicate failure. |
| typedef int32_t(* CRYPT_RandBytesCallback) (uint8_t *buf, uint32_t len) |
Obtain the random number.
| buf | [OUT] Random number |
| len | [IN] Random number length |
| typedef int32_t(* CRYPT_Sm2CalcEcdhSharedSecretCallback) (HITLS_Sm2GenShareKeyParameters *sm2Params, uint8_t *sharedSecret, uint32_t *sharedSecretLen) |
SM2 calculates the shared key based on the local key and peer public key.
| sm2Params | [IN] Shared key calculation parameters |
| sharedSecret | [OUT] Shared key |
| sharedSecretLen | [IN/OUT] IN: Maximum length of the key padding OUT: Key length |
| int32_t HITLS_CRYPT_RegisterBaseMethod | ( | HITLS_CRYPT_BaseMethod * | userCryptCallBack | ) |
Register the basic callback function.
| userCryptCallBack | [IN] Callback function to be registered |
| HITLS_SUCCESS,if | successful. |
| HITLS_NULL_INPUT,the | input parameter is NULL.. |
| int32_t HITLS_CRYPT_RegisterDhMethod | ( | const HITLS_CRYPT_DhMethod * | userCryptCallBack | ) |
Register the callback function of the DH.
| userCryptCallBack | [IN] Callback function to be registered |
| HITLS_SUCCESS,if | successful. |
| HITLS_NULL_INPUT,the | input parameter is NULL.. |
| int32_t HITLS_CRYPT_RegisterEcdhMethod | ( | HITLS_CRYPT_EcdhMethod * | userCryptCallBack | ) |
Register the ECDH callback function.
| userCryptCallBack | [IN] Callback function to be registered |
| HITLS_SUCCESS,if | successful. |
| HITLS_NULL_INPUT,the | input parameter is NULL.. |
| int32_t HITLS_CRYPT_RegisterHkdfMethod | ( | HITLS_CRYPT_KdfMethod * | userCryptCallBack | ) |
Register the callback function of the HKDF.
| userCryptCallBack | [IN] Callback function to be registered |
| HITLS_SUCCESS,if | successful. |
| HITLS_NULL_INPUT,the | input parameter is NULL.. |