API参考
载入中...
搜索中...
未找到
Hitls_crypt_reg

Algorithm related interfaces to be registered 更多...

Hitls_crypt_reg 的协作图:

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

类型定义说明

◆ CRYPT_CalcDhSharedSecretCallback

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
返回
0 indicates success. Other values indicate failure.

◆ CRYPT_CalcEcdhSharedSecretCallback

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
返回
0 indicates success. Other values indicate failure.

◆ CRYPT_CipherFreeCallback

typedef void(* CRYPT_CipherFreeCallback) (HITLS_Cipher_Ctx *ctx)

Release the cipher ctx.

参数
ctx[IN] cipher ctx handle

◆ CRYPT_DecryptCallback

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
返回
0 indicates success. Other values indicate failure.

◆ CRYPT_DHGetParametersCallback

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.

注意
If the p and g parameters are null pointers, only the lengths of p and g are obtained.
参数
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
返回
0 indicates success. Other values indicate failure.

◆ CRYPT_DigestCallback

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
返回
0 indicates success. Other values indicate failure.

◆ CRYPT_DigestCopyCallback

typedef HITLS_HASH_Ctx *(* CRYPT_DigestCopyCallback) (HITLS_HASH_Ctx *ctx)

Copy the hash context.

参数
ctx[IN] Hash Context
返回
Hash context, memory is released using CRYPT_DigestFreeCallback.

◆ CRYPT_DigestFinalCallback

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
返回
0 indicates success. Other values indicate failure.

◆ CRYPT_DigestFreeCallback

typedef void(* CRYPT_DigestFreeCallback) (HITLS_HASH_Ctx *ctx)

Release the hash context.

参数
ctx[IN] Hash Context

◆ CRYPT_DigestInitCallback

typedef HITLS_HASH_Ctx *(* CRYPT_DigestInitCallback) (HITLS_HashAlgo hashAlgo)

Initialize the hash context.

参数
hashAlgo[IN] Hash algorithm
返回
Hash context, memory is released using CRYPT_DigestFreeCallback.

◆ CRYPT_DigestSizeCallback

typedef uint32_t(* CRYPT_DigestSizeCallback) (HITLS_HashAlgo hashAlgo)

Obtain the hash length.

参数
hashAlgo[IN] Hash algorithm.
返回
Hash length

◆ CRYPT_DigestUpdateCallback

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
返回
0 indicates success. Other values indicate failure.

◆ CRYPT_DupDhKeyCallback

typedef HITLS_CRYPT_Key *(* CRYPT_DupDhKeyCallback) (HITLS_CRYPT_Key *key)

Deep copy key

参数
key[IN] Key handle
返回
Key handle, memory is released using CRYPT_FreeDhKeyCallback.

◆ CRYPT_EncryptCallback

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
返回
0 indicates success. Other values indicate failure.

◆ CRYPT_FreeDhKeyCallback

typedef void(* CRYPT_FreeDhKeyCallback) (HITLS_CRYPT_Key *key)

Release the key.

参数
key[IN] Key handle

◆ CRYPT_FreeEcdhKeyCallback

typedef void(* CRYPT_FreeEcdhKeyCallback) (HITLS_CRYPT_Key *key)

Release the key.

参数
key[IN] Key handle

◆ CRYPT_GenerateDhKeyByParamsCallback

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
返回
Key handle, memory is released using CRYPT_FreeDhKeyCallback.

◆ CRYPT_GenerateDhKeyBySecbitsCallback

typedef HITLS_CRYPT_Key *(* CRYPT_GenerateDhKeyBySecbitsCallback) (int32_t secbits)

Generate a key pair based on secbits.

参数
secbits[IN] Key security level
返回
Key handle, memory is released using CRYPT_FreeDhKeyCallback.

◆ CRYPT_GenerateEcdhKeyPairCallback

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
返回
Key handle, memory is released using CRYPT_FreeEcdhKeyCallback.

◆ CRYPT_GetDhEncodedPubKeyCallback

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
返回
0 indicates success. Other values indicate failure.

◆ CRYPT_GetEcdhEncodedPubKeyCallback

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
返回
0 indicates success. Other values indicate failure.

◆ CRYPT_HkdfExpandCallback

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
返回
0 indicates success. Other values indicate failure.

◆ CRYPT_HkdfExtractCallback

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
返回
0 indicates success. Other values indicate failure.

◆ CRYPT_HmacCallback

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
返回
0 indicates success. Other values indicate failure.

◆ CRYPT_HmacFinalCallback

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
返回
0 indicates success. Other values indicate failure.

◆ CRYPT_HmacFreeCallback

typedef void(* CRYPT_HmacFreeCallback) (HITLS_HMAC_Ctx *ctx)

Release the HMAC context.

参数
ctx[IN] HMAC context

◆ CRYPT_HmacInitCallback

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
返回
HMAC context, memory is released using CRYPT_HmacFreeCallback.

◆ CRYPT_HmacReInitCallback

typedef int32_t(* CRYPT_HmacReInitCallback) (HITLS_HMAC_Ctx *ctx)

reinit the HMAC context.

参数
ctx[IN] HMAC context
返回
HMAC context

◆ CRYPT_HmacSizeCallback

typedef uint32_t(* CRYPT_HmacSizeCallback) (HITLS_HashAlgo hashAlgo)

Obtain the HMAC length based on the hash algorithm.

参数
hashAlgo[IN] Hash algorithm
返回
HMAC length

◆ CRYPT_HmacUpdateCallback

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
返回
0 indicates success. Other values indicate failure.

◆ CRYPT_KemDecapsulateCallback

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
返回值
0indicates success. Other values indicate failure.

◆ CRYPT_KemEncapsulateCallback

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
返回值
0indicates success. Other values indicate failure.

◆ CRYPT_RandBytesCallback

typedef int32_t(* CRYPT_RandBytesCallback) (uint8_t *buf, uint32_t len)

Obtain the random number.

参数
buf[OUT] Random number
len[IN] Random number length
返回
0 indicates success. Other values indicate failure.

◆ CRYPT_Sm2CalcEcdhSharedSecretCallback

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
返回
0 indicates success. Other values indicate failure.

函数说明

◆ HITLS_CRYPT_RegisterBaseMethod()

int32_t HITLS_CRYPT_RegisterBaseMethod ( HITLS_CRYPT_BaseMethod * userCryptCallBack)

Register the basic callback function.

参数
userCryptCallBack[IN] Callback function to be registered
返回值
HITLS_SUCCESS,ifsuccessful.
HITLS_NULL_INPUT,theinput parameter is NULL..

◆ HITLS_CRYPT_RegisterDhMethod()

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,ifsuccessful.
HITLS_NULL_INPUT,theinput parameter is NULL..

◆ HITLS_CRYPT_RegisterEcdhMethod()

int32_t HITLS_CRYPT_RegisterEcdhMethod ( HITLS_CRYPT_EcdhMethod * userCryptCallBack)

Register the ECDH callback function.

参数
userCryptCallBack[IN] Callback function to be registered
返回值
HITLS_SUCCESS,ifsuccessful.
HITLS_NULL_INPUT,theinput parameter is NULL..

◆ HITLS_CRYPT_RegisterHkdfMethod()

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,ifsuccessful.
HITLS_NULL_INPUT,theinput parameter is NULL..