22#ifndef HITLS_CRYPT_REG_H
23#define HITLS_CRYPT_REG_H
26#include "hitls_type.h"
27#include "hitls_crypt_type.h"
104 uint8_t *sharedSecret, uint32_t *sharedSecretLen);
128 uint8_t *sharedSecret, uint32_t *sharedSecretLen);
141 uint8_t *sharedSecret, uint32_t *sharedSecretLen);
151typedef HITLS_CRYPT_Key *(*CRYPT_GenerateDhKeyBySecbitsCallback)(int32_t secbits);
164typedef HITLS_CRYPT_Key *(*CRYPT_GenerateDhKeyByParamsCallback)(uint8_t *p, uint16_t plen, uint8_t *g, uint16_t glen);
173typedef HITLS_CRYPT_Key *(*CRYPT_DupDhKeyCallback)(HITLS_CRYPT_Key *key);
198 uint8_t *g, uint16_t *glen);
212 uint32_t *pubKeyLen);
228 uint8_t *sharedSecret, uint32_t *sharedSecretLen);
250typedef HITLS_HMAC_Ctx *(*CRYPT_HmacInitCallback)(HITLS_HashAlgo hashAlgo,
const uint8_t *key, uint32_t len);
309 const uint8_t *in, uint32_t inLen, uint8_t *out, uint32_t *outLen);
329typedef HITLS_HASH_Ctx *(*CRYPT_DigestInitCallback)(HITLS_HashAlgo hashAlgo);
339typedef HITLS_HASH_Ctx *(*CRYPT_DigestCopyCallback)(HITLS_HASH_Ctx *ctx);
386 uint8_t *out, uint32_t *outLen);
407 uint8_t *out, uint32_t *outLen);
424 uint8_t *out, uint32_t *outLen);
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....
定义 hitls_crypt_reg.h:103
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
定义 hitls_crypt_reg.h:308
int32_t HITLS_CRYPT_RegisterDhMethod(const HITLS_CRYPT_DhMethod *userCryptCallBack)
Register the callback function of the DH.
定义 crypt.c:183
HITLS_CRYPT_Key *(* CRYPT_GenerateDhKeyBySecbitsCallback)(int32_t secbits)
Generate a key pair based on secbits.
定义 hitls_crypt_reg.h:151
void(* CRYPT_HmacFreeCallback)(HITLS_HMAC_Ctx *ctx)
Release the HMAC context.
定义 hitls_crypt_reg.h:268
HITLS_HMAC_Ctx *(* CRYPT_HmacInitCallback)(HITLS_HashAlgo hashAlgo, const uint8_t *key, uint32_t len)
Initialize the HMAC context.
定义 hitls_crypt_reg.h:250
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.
定义 hitls_crypt_reg.h:197
void(* CRYPT_FreeDhKeyCallback)(HITLS_CRYPT_Key *key)
Release the key.
定义 hitls_crypt_reg.h:181
void(* CRYPT_CipherFreeCallback)(HITLS_Cipher_Ctx *ctx)
Release the cipher ctx.
定义 hitls_crypt_reg.h:432
int32_t(* CRYPT_HmacFinalCallback)(HITLS_HMAC_Ctx *ctx, uint8_t *out, uint32_t *len)
Output the HMAC result.
定义 hitls_crypt_reg.h:292
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.
定义 hitls_crypt_reg.h:127
void(* CRYPT_DigestFreeCallback)(HITLS_HASH_Ctx *ctx)
Release the hash context.
定义 hitls_crypt_reg.h:347
int32_t HITLS_CRYPT_RegisterHkdfMethod(HITLS_CRYPT_KdfMethod *userCryptCallBack)
Register the callback function of the HKDF.
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....
定义 hitls_crypt_reg.h:227
int32_t(* CRYPT_GetEcdhEncodedPubKeyCallback)(HITLS_CRYPT_Key *key, uint8_t *pubKeyBuf, uint32_t bufLen, uint32_t *pubKeyLen)
ECDH: Extract the public key data.
定义 hitls_crypt_reg.h:87
int32_t(* CRYPT_HmacUpdateCallback)(HITLS_HMAC_Ctx *ctx, const uint8_t *data, uint32_t len)
Add the HMAC input data.
定义 hitls_crypt_reg.h:280
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.
定义 hitls_crypt_reg.h:164
void(* CRYPT_FreeEcdhKeyCallback)(HITLS_CRYPT_Key *key)
Release the key.
定义 hitls_crypt_reg.h:74
int32_t(* CRYPT_DigestCallback)(HITLS_HashAlgo hashAlgo, const uint8_t *in, uint32_t inLen, uint8_t *out, uint32_t *outLen)
Hash function
定义 hitls_crypt_reg.h:385
int32_t(* CRYPT_GetDhEncodedPubKeyCallback)(HITLS_CRYPT_Key *key, uint8_t *pubKeyBuf, uint32_t bufLen, uint32_t *pubKeyLen)
DH: Extract the Dh public key data.
定义 hitls_crypt_reg.h:211
int32_t(* CRYPT_HmacReInitCallback)(HITLS_HMAC_Ctx *ctx)
reinit the HMAC context.
定义 hitls_crypt_reg.h:260
int32_t(* CRYPT_HkdfExpandCallback)(const HITLS_CRYPT_HkdfExpandInput *input, uint8_t *outputKeyMaterial, uint32_t outputKeyMaterialLen)
HKDF-Expand
定义 hitls_crypt_reg.h:455
HITLS_CRYPT_Key *(* CRYPT_DupDhKeyCallback)(HITLS_CRYPT_Key *key)
Deep copy key
定义 hitls_crypt_reg.h:173
int32_t HITLS_CRYPT_RegisterBaseMethod(HITLS_CRYPT_BaseMethod *userCryptCallBack)
Register the basic callback function.
定义 crypt.c:97
int32_t(* CRYPT_DigestFinalCallback)(HITLS_HASH_Ctx *ctx, uint8_t *out, uint32_t *len)
Output the hash result.
定义 hitls_crypt_reg.h:371
uint32_t(* CRYPT_DigestSizeCallback)(HITLS_HashAlgo hashAlgo)
Obtain the hash length.
定义 hitls_crypt_reg.h:319
int32_t(* CRYPT_RandBytesCallback)(uint8_t *buf, uint32_t len)
Obtain the random number.
定义 hitls_crypt_reg.h:55
int32_t(* CRYPT_HkdfExtractCallback)(const HITLS_CRYPT_HkdfExtractInput *input, uint8_t *prk, uint32_t *prkLen)
HKDF-Extract
定义 hitls_crypt_reg.h:443
int32_t(* CRYPT_DigestUpdateCallback)(HITLS_HASH_Ctx *ctx, const uint8_t *data, uint32_t len)
Hash Add input data.
定义 hitls_crypt_reg.h:359
HITLS_HASH_Ctx *(* CRYPT_DigestCopyCallback)(HITLS_HASH_Ctx *ctx)
Copy the hash context.
定义 hitls_crypt_reg.h:339
int32_t(* CRYPT_DecryptCallback)(const HITLS_CipherParameters *cipher, const uint8_t *in, uint32_t inLen, uint8_t *out, uint32_t *outLen)
TLS decryption
定义 hitls_crypt_reg.h:423
int32_t(* CRYPT_EncryptCallback)(const HITLS_CipherParameters *cipher, const uint8_t *in, uint32_t inLen, uint8_t *out, uint32_t *outLen)
TLS encryption
定义 hitls_crypt_reg.h:406
HITLS_HASH_Ctx *(* CRYPT_DigestInitCallback)(HITLS_HashAlgo hashAlgo)
Initialize the hash context.
定义 hitls_crypt_reg.h:329
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.
定义 hitls_crypt_reg.h:140
uint32_t(* CRYPT_HmacSizeCallback)(HITLS_HashAlgo hashAlgo)
Obtain the HMAC length based on the hash algorithm.
定义 hitls_crypt_reg.h:238
HITLS_CRYPT_Key *(* CRYPT_GenerateEcdhKeyPairCallback)(HITLS_Ctx *ctx, const HITLS_ECParameters *curveParams)
ECDH: Generate a key pair based on elliptic curve parameters.
定义 hitls_crypt_reg.h:66
int32_t(* CRYPT_KemEncapsulateCallback)(HITLS_KemEncapsulateParams *params)
KEM: Encapsulate a shared secret using peer's public key.
定义 hitls_crypt_reg.h:114
int32_t HITLS_CRYPT_RegisterEcdhMethod(HITLS_CRYPT_EcdhMethod *userCryptCallBack)
Register the ECDH callback function.
定义 crypt.c:163
struct TlsCtx HITLS_Ctx
HITLS context
定义 hitls_type.h:35
Callback function that must be registered
定义 hitls_crypt_reg.h:462
CRYPT_HmacFreeCallback hmacFree
定义 hitls_crypt_reg.h:468
CRYPT_DigestCallback digest
定义 hitls_crypt_reg.h:478
CRYPT_DigestInitCallback digestInit
定义 hitls_crypt_reg.h:473
CRYPT_DigestFreeCallback digestFree
定义 hitls_crypt_reg.h:475
CRYPT_CipherFreeCallback cipherFree
定义 hitls_crypt_reg.h:483
CRYPT_HmacSizeCallback hmacSize
定义 hitls_crypt_reg.h:464
CRYPT_DigestCopyCallback digestCopy
定义 hitls_crypt_reg.h:474
CRYPT_HmacUpdateCallback hmacUpdate
定义 hitls_crypt_reg.h:469
CRYPT_DigestUpdateCallback digestUpdate
定义 hitls_crypt_reg.h:476
CRYPT_HmacFinalCallback hmacFinal
定义 hitls_crypt_reg.h:470
CRYPT_RandBytesCallback randBytes
定义 hitls_crypt_reg.h:463
CRYPT_HmacCallback hmac
定义 hitls_crypt_reg.h:471
CRYPT_EncryptCallback encrypt
定义 hitls_crypt_reg.h:479
CRYPT_HmacReInitCallback hmacReinit
定义 hitls_crypt_reg.h:467
CRYPT_DecryptCallback decrypt
定义 hitls_crypt_reg.h:481
CRYPT_DigestSizeCallback digestSize
定义 hitls_crypt_reg.h:472
CRYPT_HmacInitCallback hmacInit
定义 hitls_crypt_reg.h:466
CRYPT_DigestFinalCallback digestFinal
定义 hitls_crypt_reg.h:477
DH Callback function to be registered
定义 hitls_crypt_reg.h:506
CRYPT_DHGetParametersCallback getDhParameters
定义 hitls_crypt_reg.h:512
CRYPT_GenerateDhKeyBySecbitsCallback generateDhKeyBySecbits
定义 hitls_crypt_reg.h:507
CRYPT_CalcDhSharedSecretCallback calcDhSharedSecret
定义 hitls_crypt_reg.h:515
CRYPT_DupDhKeyCallback dupDhKey
定义 hitls_crypt_reg.h:510
CRYPT_FreeDhKeyCallback freeDhKey
定义 hitls_crypt_reg.h:511
CRYPT_GetDhEncodedPubKeyCallback getDhPubKey
定义 hitls_crypt_reg.h:514
CRYPT_GenerateDhKeyByParamsCallback generateDhKeyByParams
定义 hitls_crypt_reg.h:508
ECDH Callback function to be registered
定义 hitls_crypt_reg.h:490
CRYPT_GenerateEcdhKeyPairCallback generateEcdhKeyPair
定义 hitls_crypt_reg.h:491
CRYPT_KemDecapsulateCallback kemDecapsulate
定义 hitls_crypt_reg.h:499
CRYPT_GetEcdhEncodedPubKeyCallback getEcdhPubKey
定义 hitls_crypt_reg.h:494
CRYPT_FreeEcdhKeyCallback freeEcdhKey
定义 hitls_crypt_reg.h:493
CRYPT_CalcEcdhSharedSecretCallback calcEcdhSharedSecret
定义 hitls_crypt_reg.h:495
CRYPT_KemEncapsulateCallback kemEncapsulate
定义 hitls_crypt_reg.h:498
KDF function
定义 hitls_crypt_reg.h:523
Key parameters
定义 hitls_crypt_type.h:235
Elliptic curve parameter
定义 hitls_crypt_type.h:222
Input parameters for KEM encapsulation
定义 hitls_crypt_reg.h:36
uint32_t * ciphertextLen
定义 hitls_crypt_reg.h:41
HITLS_NamedGroup groupId
定义 hitls_crypt_reg.h:37
uint8_t * ciphertext
定义 hitls_crypt_reg.h:40
uint32_t pubKeyLen
定义 hitls_crypt_reg.h:39
uint32_t * sharedSecretLen
定义 hitls_crypt_reg.h:43
uint8_t * peerPubkey
定义 hitls_crypt_reg.h:38
uint8_t * sharedSecret
定义 hitls_crypt_reg.h:42
sm2 ecdhe negotiation key parameters
定义 hitls_crypt_type.h:254