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

hpke of crypto module 更多...

Crypt_eal_hpke 的协作图:

函数

int32_t CRYPT_EAL_HpkeGenerateKeyPair (CRYPT_EAL_LibCtx *libCtx, const char *attrName, CRYPT_HPKE_CipherSuite cipherSuite, uint8_t *ikm, uint32_t ikmLen, CRYPT_EAL_PkeyCtx **pkey)
 Generate a key pair for HPKE using the specified cipher suite and input key material
CRYPT_EAL_HpkeCtx * CRYPT_EAL_HpkeNewCtx (CRYPT_EAL_LibCtx *libCtx, const char *attrName, CRYPT_HPKE_Role role, CRYPT_HPKE_Mode mode, CRYPT_HPKE_CipherSuite cipherSuite)
 Create a new HPKE context
int32_t CRYPT_EAL_HpkeGetEncapKeyLen (CRYPT_HPKE_CipherSuite cipherSuite, uint32_t *encapKeyLen)
 Get the length of the encapsulated key for the specified cipher suite
int32_t CRYPT_EAL_HpkeSetupSender (CRYPT_EAL_HpkeCtx *ctx, CRYPT_EAL_PkeyCtx *pkey, uint8_t *info, uint32_t infoLen, uint8_t *pkR, uint32_t pkRLen, uint8_t *encapKey, uint32_t *encapKeyLen)
 Setup HPKE base mode for sender
int32_t CRYPT_EAL_HpkeSeal (CRYPT_EAL_HpkeCtx *ctx, uint8_t *aad, uint32_t aadLen, const uint8_t *plainText, uint32_t plainTextLen, uint8_t *cipherText, uint32_t *cipherTextLen)
 Seal (encrypt) data using HPKE context
int32_t CRYPT_EAL_HpkeSetupRecipient (CRYPT_EAL_HpkeCtx *ctx, CRYPT_EAL_PkeyCtx *pkey, uint8_t *info, uint32_t infoLen, uint8_t *encapKey, uint32_t encapKeyLen)
 Setup HPKE for the recipient
int32_t CRYPT_EAL_HpkeOpen (CRYPT_EAL_HpkeCtx *ctx, uint8_t *aad, uint32_t aadLen, const uint8_t *cipherText, uint32_t cipherTextLen, uint8_t *plainText, uint32_t *plainTextLen)
 Open an HPKE-encrypted message
int32_t CRYPT_EAL_HpkeExportSecret (CRYPT_EAL_HpkeCtx *ctx, uint8_t *info, uint32_t infoLen, uint8_t *key, uint32_t keyLen)
 Export a secret from the HPKE context
int32_t CRYPT_EAL_HpkeSetSeq (CRYPT_EAL_HpkeCtx *ctx, uint64_t seq)
 Set the sequence number for the HPKE context
int32_t CRYPT_EAL_HpkeGetSeq (CRYPT_EAL_HpkeCtx *ctx, uint64_t *seq)
 Retrieve the sequence number from the HPKE context
int32_t CRYPT_EAL_HpkeGetSharedSecret (CRYPT_EAL_HpkeCtx *ctx, uint8_t *buff, uint32_t *buffLen)
 Retrieve the shared secret from the HPKE context
int32_t CRYPT_EAL_HpkeSetSharedSecret (CRYPT_EAL_HpkeCtx *ctx, uint8_t *info, uint32_t infoLen, uint8_t *buff, uint32_t buffLen)
 Set the shared secret in the HPKE context
void CRYPT_EAL_HpkeFreeCtx (CRYPT_EAL_HpkeCtx *ctx)
 Free HPKE context and associated resources
int32_t CRYPT_EAL_HpkeSetPsk (CRYPT_EAL_HpkeCtx *ctx, uint8_t *psk, uint32_t pskLen, uint8_t *pskId, uint32_t pskIdLen)
 Setup psk and pskId for mode_psk and mode_auth_psk
int32_t CRYPT_EAL_HpkeSetAuthPriKey (CRYPT_EAL_HpkeCtx *ctx, CRYPT_EAL_PkeyCtx *pkey)
 Set the authentication private key in the HPKE context
int32_t CRYPT_EAL_HpkeSetAuthPubKey (CRYPT_EAL_HpkeCtx *ctx, uint8_t *pub, uint32_t pubLen)
 Set the authentication public key in the HPKE context

详细描述

hpke of crypto module

函数说明

◆ CRYPT_EAL_HpkeExportSecret()

int32_t CRYPT_EAL_HpkeExportSecret ( CRYPT_EAL_HpkeCtx * ctx,
uint8_t * info,
uint32_t infoLen,
uint8_t * key,
uint32_t keyLen )

Export a secret from the HPKE context

参数
ctx[IN] HPKE context
info[IN] Additional information for the export
infoLen[IN] Length of the additional information
key[OUT] Buffer to store the exported secret
keyLen[IN] Length of the buffer for the exported secret
返回值
CRYPT_SUCCESSif successful Other error codes see crypt_errno.h

◆ CRYPT_EAL_HpkeFreeCtx()

void CRYPT_EAL_HpkeFreeCtx ( CRYPT_EAL_HpkeCtx * ctx)

Free HPKE context and associated resources

参数
ctx[IN] HPKE context to free

◆ CRYPT_EAL_HpkeGenerateKeyPair()

int32_t CRYPT_EAL_HpkeGenerateKeyPair ( CRYPT_EAL_LibCtx * libCtx,
const char * attrName,
CRYPT_HPKE_CipherSuite cipherSuite,
uint8_t * ikm,
uint32_t ikmLen,
CRYPT_EAL_PkeyCtx ** pkey )

Generate a key pair for HPKE using the specified cipher suite and input key material

This function generates a key pair for HPKE using the provided cipher suite and input key material. The generated key pair is returned in a CRYPT_EAL_PkeyCtx structure.

参数
libCtx[IN] The library context
attrName[IN] Specify expected attribute values
cipherSuite[IN] The HPKE cipher suite to be used for key generation
ikm[IN] The input key material for key generation
ikmLen[IN] The length of the input key material
pkey[OUT] A pointer to a pointer to the generated CRYPT_EAL_PkeyCtx structure
返回值
CRYPT_SUCCESSif the key pair is generated successfully Other error codes defined in crypt_errno.h if an error occurs

◆ CRYPT_EAL_HpkeGetEncapKeyLen()

int32_t CRYPT_EAL_HpkeGetEncapKeyLen ( CRYPT_HPKE_CipherSuite cipherSuite,
uint32_t * encapKeyLen )

Get the length of the encapsulated key for the specified cipher suite

参数
cipherSuite[IN] HPKE cipher suite
encapKeyLen[OUT] Length of the encapsulated key
返回值
CRYPT_SUCCESSif successful Other error codes defined in crypt_errno.h if an error occurs

◆ CRYPT_EAL_HpkeGetSeq()

int32_t CRYPT_EAL_HpkeGetSeq ( CRYPT_EAL_HpkeCtx * ctx,
uint64_t * seq )

Retrieve the sequence number from the HPKE context

参数
ctx[IN] HPKE context
seq[OUT] Buffer to store the retrieved sequence number
返回值
CRYPT_SUCCESSif successful Other error codes see crypt_errno.h

◆ CRYPT_EAL_HpkeGetSharedSecret()

int32_t CRYPT_EAL_HpkeGetSharedSecret ( CRYPT_EAL_HpkeCtx * ctx,
uint8_t * buff,
uint32_t * buffLen )

Retrieve the shared secret from the HPKE context

参数
ctx[IN] HPKE context
buff[OUT] Buffer to store the shared secret
buffLen[IN/OUT] On input, the length of the buffer; on output, the length of the shared secret
返回值
CRYPT_SUCCESSif successful Other error codes see crypt_errno.h

◆ CRYPT_EAL_HpkeNewCtx()

CRYPT_EAL_HpkeCtx * CRYPT_EAL_HpkeNewCtx ( CRYPT_EAL_LibCtx * libCtx,
const char * attrName,
CRYPT_HPKE_Role role,
CRYPT_HPKE_Mode mode,
CRYPT_HPKE_CipherSuite cipherSuite )

Create a new HPKE context

参数
libCtx[IN] Library context
attrName[IN] Specify expected attribute values
role[IN] HPKE role (sender or recipient)
mode[IN] HPKE mode
cipherSuite[IN] HPKE cipher suite containing KEM, KDF and AEAD algorithms
返回值
CRYPT_EAL_HpkeCtxpointer if successful, NULL if failed

◆ CRYPT_EAL_HpkeOpen()

int32_t CRYPT_EAL_HpkeOpen ( CRYPT_EAL_HpkeCtx * ctx,
uint8_t * aad,
uint32_t aadLen,
const uint8_t * cipherText,
uint32_t cipherTextLen,
uint8_t * plainText,
uint32_t * plainTextLen )

Open an HPKE-encrypted message

参数
ctx[IN] HPKE context for decryption
aad[IN] Additional authenticated data
aadLen[IN] Length of the additional authenticated data
cipherText[IN] The encrypted message to be decrypted
cipherTextLen[IN] Length of the encrypted message
plainText[OUT] Buffer to store the decrypted message
plainTextLen[IN/OUT] On input, the length of the buffer; on output, the length of the decrypted message
返回值
CRYPT_SUCCESSif successful Other error codes see crypt_errno.h

◆ CRYPT_EAL_HpkeSeal()

int32_t CRYPT_EAL_HpkeSeal ( CRYPT_EAL_HpkeCtx * ctx,
uint8_t * aad,
uint32_t aadLen,
const uint8_t * plainText,
uint32_t plainTextLen,
uint8_t * cipherText,
uint32_t * cipherTextLen )

Seal (encrypt) data using HPKE context

参数
ctx[IN] HPKE context
aad[IN] Additional authenticated data
aadLen[IN] Length of additional authenticated data
plainText[IN] Plaintext to encrypt
plainTextLen[IN] Length of plaintext
cipherText[OUT] Ciphertext output buffer, if set to NULL, only return the ciphertext length
cipherTextLen[IN/OUT] On input, the length of the buffer; on output, the length of the ciphertext
返回值
CRYPT_SUCCESSif successful Other error codes see crypt_errno.h

◆ CRYPT_EAL_HpkeSetAuthPriKey()

int32_t CRYPT_EAL_HpkeSetAuthPriKey ( CRYPT_EAL_HpkeCtx * ctx,
CRYPT_EAL_PkeyCtx * pkey )

Set the authentication private key in the HPKE context

参数
ctx[IN] HPKE context
pkey[IN] Private key context for authentication
返回值
CRYPT_SUCCESSif successful Other error codes see crypt_errno.h

◆ CRYPT_EAL_HpkeSetAuthPubKey()

int32_t CRYPT_EAL_HpkeSetAuthPubKey ( CRYPT_EAL_HpkeCtx * ctx,
uint8_t * pub,
uint32_t pubLen )

Set the authentication public key in the HPKE context

参数
ctx[IN] HPKE context
pub[IN] Public key buffer
pubLen[IN] Length of the public key buffer
返回值
CRYPT_SUCCESSif successful Other error codes see crypt_errno.h

◆ CRYPT_EAL_HpkeSetPsk()

int32_t CRYPT_EAL_HpkeSetPsk ( CRYPT_EAL_HpkeCtx * ctx,
uint8_t * psk,
uint32_t pskLen,
uint8_t * pskId,
uint32_t pskIdLen )

Setup psk and pskId for mode_psk and mode_auth_psk

参数
ctx[IN] HPKE context
psk[IN] Pre-shared key (PSK) used for the key exchange
pskLen[IN] Length of the pre-shared key (PSK) in bytes
pskId[IN] Identifier for the pre-shared key (PSK)
pskIdLen[IN] Length of the PSK identifier in bytes
返回值
CRYPT_SUCCESSif the setup is successful Other error codes defined in crypt_errno.h if an error occurs

◆ CRYPT_EAL_HpkeSetSeq()

int32_t CRYPT_EAL_HpkeSetSeq ( CRYPT_EAL_HpkeCtx * ctx,
uint64_t seq )

Set the sequence number for the HPKE context

参数
ctx[IN] HPKE context
seq[IN] Sequence number to be set
返回值
CRYPT_SUCCESSif successful Other error codes see crypt_errno.h

◆ CRYPT_EAL_HpkeSetSharedSecret()

int32_t CRYPT_EAL_HpkeSetSharedSecret ( CRYPT_EAL_HpkeCtx * ctx,
uint8_t * info,
uint32_t infoLen,
uint8_t * buff,
uint32_t buffLen )

Set the shared secret in the HPKE context

This function set the shared secret and generate the hpke key info.

参数
ctx[IN] HPKE context
info[IN] Additional information for the shared secret
infoLen[IN] Length of the additional information
buff[IN] Buffer containing the shared secret
buffLen[IN] Length of the shared secret
返回值
CRYPT_SUCCESSif successful Other error codes see crypt_errno.h

◆ CRYPT_EAL_HpkeSetupRecipient()

int32_t CRYPT_EAL_HpkeSetupRecipient ( CRYPT_EAL_HpkeCtx * ctx,
CRYPT_EAL_PkeyCtx * pkey,
uint8_t * info,
uint32_t infoLen,
uint8_t * encapKey,
uint32_t encapKeyLen )

Setup HPKE for the recipient

This function sets up the HPKE context for the recipient only in the base mode and psk mode. It takes the recipient's private key, additional information, and the encapsulated key to generate the shared secret.

参数
ctx[IN] HPKE context for the recipient
pkey[IN] Private key context for the recipient
info[IN] Additional information for the key setup
infoLen[IN] Length of the additional information
encapKey[IN] Encapsulated key input buffer
encapKeyLen[IN] Length of the encapsulated key
返回值
CRYPT_SUCCESSif the setup is successful Other error codes defined in crypt_errno.h if an error occurs

◆ CRYPT_EAL_HpkeSetupSender()

int32_t CRYPT_EAL_HpkeSetupSender ( CRYPT_EAL_HpkeCtx * ctx,
CRYPT_EAL_PkeyCtx * pkey,
uint8_t * info,
uint32_t infoLen,
uint8_t * pkR,
uint32_t pkRLen,
uint8_t * encapKey,
uint32_t * encapKeyLen )

Setup HPKE base mode for sender

This function only sets up the HPKE context for the sender in the base mode and psk mode. It takes the sender's private key, the recipient's public key, and additional information to generate an encapsulated key.

参数
ctx[IN] HPKE context for the sender
pkey[IN] Private key context for the sender, if set to NULL, will generate a keypair randomly
info[IN] Additional information for the key setup
infoLen[IN] Length of the additional information
pkR[IN] Recipient's public key. For ec key, the format is 04 || X || Y, for X25519 key, the format is X.
pkRLen[IN] Length of the recipient's public key
encapKey[OUT] Buffer to store the encapsulated key
encapKeyLen[IN/OUT] On input, the length of the buffer; on output, the length of the encapsulated key
返回值
CRYPT_SUCCESSif the setup is successful Other error codes defined in crypt_errno.h if an error occurs