* This file is part of the openHiTLS project.
*
* openHiTLS is licensed under the Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
*
* http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
* @defgroup crypt_types
* @ingroup crypt
* @brief types of crypto
*/
#ifndef CRYPT_TYPES_H
#define CRYPT_TYPES_H
#include <stdint.h>
#include <stddef.h>
#include "crypt_algid.h"
#ifdef __cplusplus
extern "C" {
#endif
* @ingroup crypt_types
*
* Data structure
*/
typedef struct {
uint8_t *data;
uint32_t len;
} CRYPT_Data;
* @ingroup crypt_types
*
* Constant data structure
*/
typedef struct {
const uint8_t *data;
uint32_t len;
} CRYPT_ConstData;
* @ingroup crypt_types
*
* Data range
*/
typedef struct {
uint32_t min;
uint32_t max;
} CRYPT_Range;
* @ingroup crypt_types
*
* @brief Pkcsv15 padding mode, when RSA is used for signature.
*/
typedef struct {
CRYPT_MD_AlgId mdId;
} CRYPT_RSA_PkcsV15Para;
* @ingroup crypt_types
*
* RSA salt length type, when rsa pss mode is used for signature and verify
*/
typedef enum {
CRYPT_RSA_SALTLEN_TYPE_HASHLEN = -1,
CRYPT_RSA_SALTLEN_TYPE_MAXLEN = -2,
CRYPT_RSA_SALTLEN_TYPE_AUTOLEN = -3
} CRYPT_RSA_SaltLenType;
* @ingroup crypt_types
*
* PSS padding mode, when RSA is used for signature.
*/
typedef struct {
int32_t saltLen;
CRYPT_MD_AlgId mdId;
CRYPT_MD_AlgId mgfId;
} CRYPT_RSA_PssPara;
typedef struct {
CRYPT_MD_AlgId mdId;
CRYPT_MD_AlgId mgfId;
} CRYPT_RSA_OaepPara;
typedef enum {
CRYPT_RSA_BLINDING = 0x00000001,
CRYPT_RSA_BSSA = 0x00000002,
CRYPT_RSA_MAXFLAG
} CRYPT_RSA_Flag;
typedef enum {
CRYPT_DH_NO_PADZERO = 0x00000001,
shared key. It takes effect only after local settings are made. */
CRYPT_DH_MAXFLAG
} CRYPT_DH_Flag;
* @ingroup crypt_types
*
* ECC flag bits for encode behaviors
*/
typedef enum {
CRYPT_ECC_CACHE_PUBKEY = 0x00000001,
CRYPT_ECC_PRIKEY_NO_PUBKEY = 0x00000002,
CRYPT_ECC_MAXFLAG
} CRYPT_ECC_Flag;
* @ingroup crypt_types
*
* RSA private key parameter structure
*/
typedef struct {
uint8_t *d;
uint8_t *n;
uint8_t *p;
uint8_t *q;
uint8_t *dP;
uint8_t *dQ;
uint8_t *qInv;
uint8_t *e;
uint32_t dLen;
uint32_t nLen;
uint32_t pLen;
uint32_t qLen;
uint32_t dPLen;
uint32_t dQLen;
uint32_t qInvLen;
uint32_t eLen;
} CRYPT_RsaPrv;
* @ingroup crypt_types
*
* Elliptic curve parameter information
*/
typedef struct {
uint8_t *p;
uint8_t *a;
uint8_t *b;
uint8_t *n;
uint8_t *h;
uint8_t *x;
uint8_t *y;
uint32_t pLen;
uint32_t aLen;
uint32_t bLen;
uint32_t nLen;
uint32_t hLen;
uint32_t xLen;
uint32_t yLen;
} CRYPT_EccPara;
* @ingroup crypt_types
*
* Paillier private key parameter structure
*/
typedef struct {
uint8_t *n;
uint8_t *lambda;
uint8_t *mu;
uint8_t *n2;
uint32_t nLen;
uint32_t lambdaLen;
uint32_t muLen;
uint32_t n2Len;
} CRYPT_PaillierPrv;
typedef struct {
void *para;
void *(*init)(void *para);
int32_t (*read)(void *ctx, uint32_t timeout, uint8_t *buf, uint32_t bufLen);
void (*deinit)(void *ctx);
} CRYPT_EAL_NsMethod;
typedef struct {
uint32_t rctCutoff;
uint32_t aptCutoff;
* see nist.sp.800-90b section 4.4.2
* The window size W is selected based on the alphabet size, and shall be assigned to 1024
* if the noise source is binary (that is, the noise source produces only two distinct values) and 512 if
* the noise source is not binary (that is, the noise source produces more than two distinct values).
*/
uint32_t aptWinSize;
} CRYPT_EAL_NsTestPara;
typedef struct {
const char *name;
bool autoTest;
uint32_t minEntropy;
CRYPT_EAL_NsMethod nsMeth;
CRYPT_EAL_NsTestPara nsPara;
} CRYPT_EAL_NsPara;
* @ingroup crypt_types
* @brief Entropy source callback for obtaining entropy data.
*
* @param ctx [IN] the entropy source handle.
* @param buf [OUT] buffer.
* @param bufLen [IN] the length of buffer.
* @return 0, success
* Other error codes
*/
typedef uint32_t (*CRYPT_EAL_EntropyGet)(void *ctx, uint8_t *buf, uint32_t bufLen);
typedef struct {
bool isPhysical;
uint32_t minEntropy;
void *entropyCtx;
CRYPT_EAL_EntropyGet entropyGet;
} CRYPT_EAL_EsPara;
* @ingroup crypt_types
*
* ElGamal private key parameter structure
*/
typedef struct {
uint8_t *p;
uint8_t *g;
uint8_t *x;
uint32_t pLen;
uint32_t gLen;
uint32_t xLen;
} CRYPT_ElGamalPrv;
* @ingroup crypt_types
*
* DSA private key parameter structure
*/
typedef CRYPT_Data CRYPT_DsaPrv;
* @ingroup crypt_types
*
* ECC private key parameter structure.
*/
typedef CRYPT_Data CRYPT_EccPrv;
* @ingroup crypt_types
*
* ECDSA private key parameter structure.
*/
typedef CRYPT_Data CRYPT_EcdsaPrv;
* @ingroup crypt_types
*
* SM2 private key parameter structure
*/
typedef CRYPT_Data CRYPT_Sm2Prv;
* @ingroup crypt_types
*
* DH private key parameter structure
*/
typedef CRYPT_Data CRYPT_DhPrv;
* @ingroup crypt_types
*
* ECDH private key parameter structure
*/
typedef CRYPT_Data CRYPT_EcdhPrv;
* @ingroup crypt_types
*
* ed25519/x25519 private key parameter structure
*/
typedef CRYPT_Data CRYPT_Curve25519Prv;
* @ingroup crypt_types
*
* kem decaps key parameter structure
*/
typedef CRYPT_Data CRYPT_KemDecapsKey;
* @ingroup crypt_types
*
* MLDSA private key parameter structure
*/
typedef CRYPT_Data CRYPT_MlDsaPrv;
* @ingroup crypt_types
*
* Composite private key parameter structure
*/
typedef CRYPT_Data CRYPT_CompositePrv;
* @ingroup crypt_types
*
* RSA public key parameter structure
*/
typedef struct {
uint8_t *e;
uint8_t *n;
uint32_t eLen;
uint32_t nLen;
} CRYPT_RsaPub;
* @ingroup crypt_types
*
* Paillier public key parameter structure
*/
typedef struct {
uint8_t *n;
uint8_t *g;
uint8_t *n2;
uint32_t nLen;
uint32_t gLen;
uint32_t n2Len;
} CRYPT_PaillierPub;
* @brief SLH-DSA public key structure
*/
typedef struct {
uint8_t *seed;
uint8_t *root;
uint32_t len;
} CRYPT_SlhDsaPub;
* @brief SLH-DSA private key structure
*/
typedef struct {
uint8_t *seed;
uint8_t *prf;
CRYPT_SlhDsaPub pub;
} CRYPT_SlhDsaPrv;
* @brief XMSS public key structure
*/
typedef CRYPT_SlhDsaPub CRYPT_XmssPub;
* @brief XMSS private key structure
*/
typedef struct {
uint8_t *seed;
uint8_t *prf;
uint64_t index;
CRYPT_XmssPub pub;
} CRYPT_XmssPrv;
* @ingroup crypt_types
*
* ElGamal public key parameter structure
*/
typedef struct {
uint8_t *p;
uint8_t *g;
uint8_t *y;
uint8_t *q;
uint32_t pLen;
uint32_t gLen;
uint32_t yLen;
uint32_t qLen;
} CRYPT_ElGamalPub;
* @ingroup crypt_types
*
* DSA public key parameter structure
*/
typedef CRYPT_Data CRYPT_DsaPub;
* @ingroup crypt_types
*
* ECC public key parameter structure
*/
typedef CRYPT_Data CRYPT_EccPub;
* @ingroup crypt_types
*
* ECDSA public key parameter structure.
*/
typedef CRYPT_Data CRYPT_EcdsaPub;
* @ingroup crypt_types
*
* SM2 public key parameter structure
*/
typedef CRYPT_Data CRYPT_Sm2Pub;
* @ingroup crypt_types
*
* DH public key parameter structure
*/
typedef CRYPT_Data CRYPT_DhPub;
* @ingroup crypt_types
*
* ECDH public key parameter structure
*/
typedef CRYPT_Data CRYPT_EcdhPub;
* @ingroup crypt_types
*
* ed25519/x25519 public key parameter structure
*/
typedef CRYPT_Data CRYPT_Curve25519Pub;
* @ingroup crypt_types
*
* kem encaps key parameter structure
*/
typedef CRYPT_Data CRYPT_KemEncapsKey;
* @ingroup crypt_types
*
* MLDSA public key parameter structure
*/
typedef CRYPT_Data CRYPT_MlDsaPub;
* @ingroup crypt_types
*
* Composite public key parameter structure
*/
typedef CRYPT_Data CRYPT_CompositePub;
* @ingroup crypt_types
*
* Para structure of the RSA algorithm
*/
typedef struct {
uint8_t *e;
uint32_t eLen;
uint32_t bits;
} CRYPT_RsaPara;
* @ingroup crypt_types
*
* Para structure of the DSA algorithm. This parameter cannot be null, and it is determined by the underlying structure.
*/
typedef struct {
uint8_t *p;
uint8_t *q;
uint8_t *g;
uint32_t pLen;
uint32_t qLen;
uint32_t gLen;
} CRYPT_DsaPara;
* @ingroup crypt_types
*
* Para structure of the DH algorithm
*/
typedef struct {
uint8_t *p;
uint8_t *q;
uint8_t *g;
uint32_t pLen;
uint32_t qLen;
uint32_t gLen;
} CRYPT_DhPara;
* @ingroup crypt_types
*
* Para structure of the Paillier algorithm
*/
typedef struct {
uint8_t *p;
uint8_t *q;
uint32_t pLen;
uint32_t qLen;
uint32_t bits;
} CRYPT_PaillierPara;
* @ingroup crypt_types
*
* Para structure of the ElGamal algorithm
*/
typedef struct {
uint8_t *q;
uint32_t qLen;
uint32_t bits;
uint32_t k_bits;
} CRYPT_ElGamalPara;
* @ingroup crypt_types
*
* Obtain the entropy source. If the default entropy source provided by HiTLS is not used,
* the API must be registered. the output data must meet requirements such as the length.
* The HiTLS does not check the entropy source. The data must be provided by the entropy source.
*
* @param ctx [IN] Context used by the caller.
* @param entropy [OUT] Indicates the obtained entropy source data. The length of the entropy source data
* must meet the following requirements: lenRange->min <= len <= lenRange->max.
* @param strength [IN] Entropy source strength.
* @param lenRange [IN] Entropy source length range.
* @retval 0 indicates success, and other values indicate failure.
*/
typedef int32_t (*CRYPT_EAL_GetEntropyCb)(void *ctx, CRYPT_Data *entropy, uint32_t strength, CRYPT_Range *lenRange);
* @ingroup crypt_types
* @brief The entropy source memory is cleared, this API is optional.
* @param ctx [IN] Context used by the caller
* @param entropy [OUT] Entropy source data
* @retval void
*/
typedef void (*CRYPT_EAL_CleanEntropyCb)(void *ctx, CRYPT_Data *entropy);
* @ingroup crypt_types
* @brief Obtain the random number. This API is not need to registered.
* For registration, the output data must meet requirements such as the length.
* The HiTLS does not check the entropy source, but will implement if provide the function.
*
* @param ctx [IN] Context used by the caller
* @param nonce [OUT] Obtained random number.
* The length of the random number must be lenRange->min <= len <= lenRange->max.
* @param strength [IN]: Random number strength
* @param lenRange [IN] Random number length range.
* @retval 0 indicates success, and other values indicate failure.
*/
typedef int32_t (*CRYPT_EAL_GetNonceCb)(void *ctx, CRYPT_Data *nonce, uint32_t strength, CRYPT_Range *lenRange);
* @ingroup crypt_types
* @brief Random number memory clearance. this API is optional.
* @param ctx [IN] Context used by the caller
* @param nonce [OUT] random number
* @retval void
*/
typedef void (*CRYPT_EAL_CleanNonceCb)(void *ctx, CRYPT_Data *nonce);
* @ingroup crypt_types
*
* Metohd structure of the RAND registration interface, including the entropy source obtaining and clearing
* interface and random number obtaining and clearing interface.
* For details about how to use the default entropy source of the HiTLS, see CRYPT_EAL_RandInit().
* If the default mode is not used, the entropy source obtaining interface cannot be null, interface for
* obtaining random numbers can be null.
*/
typedef struct {
CRYPT_EAL_GetEntropyCb getEntropy;
CRYPT_EAL_CleanEntropyCb cleanEntropy;
CRYPT_EAL_GetNonceCb getNonce;
CRYPT_EAL_CleanNonceCb cleanNonce;
} CRYPT_RandSeedMethod;
* @ingroup crypt_ctrl_param
*
* Set and obtain internal mode parameters.
*/
typedef enum {
CRYPT_CTRL_SET_IV = 0,
CRYPT_CTRL_GET_IV,
CRYPT_CTRL_GET_BLOCKSIZE,
CRYPT_CTRL_SET_COUNT,
the algorithm required is chacha20. */
CRYPT_CTRL_SET_AAD,
CRYPT_CTRL_GET_TAG,
CRYPT_CTRL_SET_TAGLEN,
encryption/decryption. the setting type is uint32_t. */
CRYPT_CTRL_SET_MSGLEN,
input for calculation. the length must be set before SET_AAD. The input data
type is int64_t. */
CRYPT_CTRL_SET_FEEDBACKSIZE,
CRYPT_CTRL_GET_FEEDBACKSIZE,
CRYPT_CTRL_DES_NOKEYCHECK,
CRYPT_CTRL_SET_PADDING,
CRYPT_CTRL_GET_PADDING,
CRYPT_CTRL_REINIT_STATUS,
CRYPT_CTRL_SET_TAG,
CRYPT_CTRL_MAX
} CRYPT_CipherCtrl;
* @ingroup crypt_ctrl_param
*
* Set and obtain internal parameters of pkey.
*/
typedef enum {
CRYPT_CTRL_UP_REFERENCES = 0,
It is applicable to asymmetric algorithms such as 25519, RSA, and ECC. */
CRYPT_CTRL_SET_PARA_BY_ID,
CRYPT_CTRL_SET_NO_PADDING,
CRYPT_CTRL_GET_PARAID,
CRYPT_CTRL_GET_BITS,
CRYPT_CTRL_GET_SIGNLEN,
CRYPT_CTRL_GET_SECBITS,
CRYPT_CTRL_GET_SHARED_KEY_LEN,
CRYPT_CTRL_GET_PUBKEY_LEN,
CRYPT_CTRL_GET_PRVKEY_LEN,
CRYPT_CTRL_GET_CIPHERTEXT_LEN,
CRYPT_CTRL_SET_DETERMINISTIC_FLAG,
Only supports switching from non-deterministic to deterministic.
Switching back to non-deterministic is not supported. */
CRYPT_CTRL_SET_CTX_INFO,
CRYPT_CTRL_SET_PREHASH_MODE,
CRYPT_CTRL_GEN_PARA,
CRYPT_CTRL_SET_GEN_FLAG,
CRYPT_CTRL_GET_PUB_KEY_BITS,
CRYPT_CTRL_SET_SIGN_MD,
CRYPT_CTRL_GET_ECC_POINT_FORMAT,
CRYPT_CTRL_CLEAN_PUB_KEY,
CRYPT_CTRL_SET_DH_FLAG = 150,
CRYPT_CTRL_SET_RSA_EMSA_PKCSV15 = 200,
CRYPT_CTRL_GET_RSA_SALT,
CRYPT_CTRL_SET_RSA_EMSA_PSS,
CRYPT_CTRL_SET_RSA_SALT,
specified. During signature, the user data address is directly saved
to the key. And the user data is used for the next signature, the caller
must ensure that the next signature is called within the life cycle
of the salt data. This option is not recommended and is used only for
KAT and self-verification. */
CRYPT_CTRL_SET_RSA_PADDING,
CRYPT_CTRL_SET_RSA_RSAES_OAEP,
CRYPT_CTRL_SET_RSA_OAEP_LABEL,
CRYPT_CTRL_SET_RSA_FLAG,
CRYPT_CTRL_SET_RSA_RSAES_PKCSV15,
CRYPT_CTRL_SET_RSA_RSAES_PKCSV15_TLS,
CRYPT_CTRL_GET_RSA_SALTLEN,
in sign or verify, which needs additional conversion during encoding.
If salt len = -3, the max salt len will be returned. */
CRYPT_CTRL_GET_RSA_PADDING,
CRYPT_CTRL_GET_RSA_MD,
CRYPT_CTRL_GET_RSA_MGF,
CRYPT_CTRL_CLR_RSA_FLAG,
CRYPT_CTRL_SET_RSA_BSSA_FACTOR_R,
CRYPT_CTRL_SET_RSA_EMSA_ISO9796_2,
CRYPT_CTRL_SET_RSA_E,
CRYPT_CTRL_SET_SM2_USER_ID = 300,
CRYPT_CTRL_SET_SM2_SERVER,
CRYPT_CTRL_SET_SM2_R,
CRYPT_CTRL_SET_SM2_RANDOM,
CRYPT_CTRL_SET_SM2_PKG,
CRYPT_CTRL_SET_SM2_K,
* HITLS_CRYPTO_ACVP_TESTS is enabled. For test vector verification
* only, must not be used in production. */
CRYPT_CTRL_SET_ECC_POINT_FORMAT,
see CRYPT_PKEY_PointFormat. */
CRYPT_CTRL_SET_ECC_USE_COFACTOR_MODE,
man-in-the-middle from tampering with the public key.
Set this parameter to 1 when used or 0 when not used. */
CRYPT_CTRL_SM2_GET_SEND_CHECK,
CRYPT_CTRL_GENE_SM2_R,
CRYPT_CTRL_SM2_DO_CHECK,
CRYPT_CTRL_GEN_ECC_PUBLICKEY,
CRYPT_CTRL_GET_ECC_PUB_X_BIN,
CRYPT_CTRL_GET_ECC_PUB_Y_BIN,
CRYPT_CTRL_GET_ECC_ORDER_BITS,
CRYPT_CTRL_GET_ECC_NAME,
CRYPT_CTRL_GEN_X25519_PUBLICKEY,
CRYPT_CTRL_GET_SM2_RANDOM,
* (e.g. ACVP test vector verification). Caller must ensure r is kept
* confidential and securely erased after use. */
CRYPT_CTRL_GET_FLAG,
CRYPT_CTRL_SET_FLAG,
CRYPT_CTRL_CLR_FLAG,
CRYPT_CTRL_GET_SM2_R,
CRYPT_CTRL_GET_SLH_DSA_KEY_LEN = 600,
CRYPT_CTRL_SET_SLH_DSA_ADDRAND,
CRYPT_CTRL_SET_MLDSA_MUMSG_FLAG = 701,
CRYPT_CTRL_GET_MLDSA_SEED,
CRYPT_CTRL_SET_MLDSA_PRVKEY_FORMAT,
CRYPT_CTRL_GET_MLDSA_PRVKEY_FORMAT,
CRYPT_CTRL_GET_MLKEM_SEED = 750,
CRYPT_CTRL_SET_MLKEM_DK_FORMAT,
CRYPT_CTRL_GET_MLKEM_DK_FORMAT,
CRYPT_CTRL_GET_XMSS_XDR_ALG_TYPE = 800,
CRYPT_CTRL_SET_XMSS_XDR_ALG_TYPE = 801,
CRYPT_CTRL_SET_SM9_USER_ID = 900,
} CRYPT_PkeyCtrl;
typedef enum {
CRYPT_CTRL_SET_GM_LEVEL,
CRYPT_CTRL_SET_RESEED_INTERVAL,
CRYPT_CTRL_SET_RESEED_TIME,
CRYPT_CTRL_GET_RESEED_INTERVAL,
CRYPT_CTRL_GET_RESEED_TIME,
CRYPT_CTRL_SET_PREDICTION_RESISTANCE,
CRYPT_CTRL_GET_WORKING_STATUS,
CRYPT_CTRL_RAND_MAX = 0xff,
} CRYPT_RandCtrl;
* @ingroup crypt_ctrl_param
*
* Set and obtain internal parameters of mac.
*/
typedef enum {
CRYPT_CTRL_SET_CBC_MAC_PADDING = 0,
CRYPT_CTRL_GET_MACLEN,
CRYPT_CTRL_MAC_MAX
} CRYPT_MacCtrl;
* @ingroup crypt_entropy_type
*
* Entropy setting type.
*/
typedef enum {
CRYPT_ENTROPY_SET_POOL_SIZE = 0,
CRYPT_ENTROPY_SET_CF,
CRYPT_ENTROPY_ADD_NS,
CRYPT_ENTROPY_REMOVE_NS,
CRYPT_ENTROPY_ENABLE_TEST,
CRYPT_ENTROPY_GET_STATE,
CRYPT_ENTROPY_GET_POOL_SIZE,
CRYPT_ENTROPY_POOL_GET_CURRSIZE,
CRYPT_ENTROPY_GET_CF_SIZE,
CRYPT_ENTROPY_GATHER_ENTROPY,
entropy data from each noise source, obtains the full entropy output
after adjustment by the conditioning function, and stores the full
entropy output in the entropy pool. The length of the entropy output
obtained each time is the output length of the adjustment function.
The caller can use this interface to implement the automatic collection
function of the entropy pool. */
CRYPT_ENTROPY_SET_LOG_CALLBACK,
source collection result. */
CRYPT_ENTROPY_MAX
} CRYPT_ENTROPY_TYPE;
* @ingroup crypt_padding_type
*
* Padding mode enumerated type
*/
typedef enum {
CRYPT_PADDING_NONE = 0,
CRYPT_PADDING_ZEROS,
CRYPT_PADDING_ISO7816,
CRYPT_PADDING_X923,
CRYPT_PADDING_PKCS5,
CRYPT_PADDING_PKCS7,
CRYPT_PADDING_MAX_COUNT
} CRYPT_PaddingType;
typedef enum {
CRYPT_EMSA_PKCSV15 = 1,
CRYPT_EMSA_PSS,
CRYPT_RSAES_OAEP,
CRYPT_RSAES_PKCSV15,
CRYPT_RSA_NO_PAD,
CRYPT_RSAES_PKCSV15_TLS,
prevent possible Bleichenbacher attacks */
CRYPT_EMSA_ISO9796_2,
CRYPT_RSA_PADDINGMAX,
} CRYPT_RsaPadType;
* @ingroup crypt_types
*
* Operation type
*/
typedef enum {
CRYPT_EVENT_ENC,
CRYPT_EVENT_DEC,
CRYPT_EVENT_GEN,
CRYPT_EVENT_SIGN,
CRYPT_EVENT_VERIFY,
CRYPT_EVENT_MD,
CRYPT_EVENT_MAC,
CRYPT_EVENT_KDF,
CRYPT_EVENT_KEYAGGREMENT,
CRYPT_EVENT_RANDGEN,
CRYPT_EVENT_ZERO,
CRYPT_EVENT_ERR,
CRYPT_EVENT_SETSSP,
CRYPT_EVENT_GETSSP,
CRYPT_EVENT_ENCAPS,
CRYPT_EVENT_DECAPS,
CRYPT_EVENT_BLIND,
CRYPT_EVENT_UNBLIND,
CRYPT_EVENT_PARAM_CHECK,
CRYPT_EVENT_PCT_TEST,
CRYPT_EVENT_KAT_TEST,
CRYPT_EVENT_ES_HEALTH_TEST,
CRYPT_EVENT_INTEGRITY_TEST,
CRYPT_EVENT_GET_VERSION,
CRYPT_EVENT_MAX
} CRYPT_EVENT_TYPE;
* @ingroup crypt_types
*
* Algorithm type
*/
typedef enum {
CRYPT_ALGO_CIPHER = 0,
CRYPT_ALGO_PKEY,
CRYPT_ALGO_MD,
CRYPT_ALGO_MAC,
CRYPT_ALGO_KDF,
CRYPT_ALGO_RAND
} CRYPT_ALGO_TYPE;
typedef enum {
CRYPT_ALGO_MLDSA_PRIV_FORMAT_NOT_SET = 0,
CRYPT_ALGO_MLDSA_PRIV_FORMAT_BOTH,
CRYPT_ALGO_MLDSA_PRIV_FORMAT_PRIV_ONLY,
CRYPT_ALGO_MLDSA_PRIV_FORMAT_SEED_ONLY,
CRYPT_ALGO_MLDSA_PRIV_FORMAT_END,
} CRYPT_ALGO_MLDSA_PRIV_KEY_FORMAT_TYPE;
typedef enum {
CRYPT_ALGO_MLKEM_DK_FORMAT_NOT_SET = 0,
CRYPT_ALGO_MLKEM_DK_FORMAT_BOTH,
CRYPT_ALGO_MLKEM_DK_FORMAT_DK_ONLY,
CRYPT_ALGO_MLKEM_DK_FORMAT_SEED_ONLY,
CRYPT_ALGO_MLKEM_DK_FORMAT_END,
} CRYPT_ALGO_MLKEM_DK_FORMAT_TYPE;
* @ingroup crypt_types
* @brief event report.
*
* @param oper [IN] Operation type.
* @param type [IN] Algorithm type.
* @param id [IN] Algorithm ID.
* @param err [IN] CRYPT_SUCCESS, if successful.
* For other error codes, see crypt_errno.h.
*
* @retval None
*/
typedef void (*EventReport)(CRYPT_EVENT_TYPE oper, CRYPT_ALGO_TYPE type, int32_t id, int32_t err);
* @ingroup crypt_types
*
* Event reporting callback registration interface, the EAL reports an event when the service is executed
* and an error is reported.
* If the CMVP feature is enabled, the default implementation is provided and registration is not allowed.
* Note that Multi-threading is not supported.
*
* @param func [IN] Event reporting and processing callback
*
* @retval NONE
*/
void CRYPT_EAL_RegEventReport(EventReport func);
* @ingroup crypt_getInfo_type
*
* Obtain the algorithm attribute type.
*/
typedef enum {
CRYPT_INFO_IS_AEAD = 0,
CRYPT_INFO_IS_STREAM,
CRYPT_INFO_IV_LEN,
CRYPT_INFO_KEY_LEN,
CRYPT_INFO_BLOCK_LEN,
CRYPT_INFO_MAX
} CRYPT_INFO_TYPE;
typedef enum {
CRYPT_KDF_HKDF_MODE_FULL = 0,
CRYPT_KDF_HKDF_MODE_EXTRACT,
CRYPT_KDF_HKDF_MODE_EXPAND,
} CRYPT_HKDF_MODE;
typedef enum {
CRYPT_ENCDEC_UNKNOW,
CRYPT_PRIKEY_PKCS8_UNENCRYPT,
CRYPT_PRIKEY_PKCS8_ENCRYPT,
CRYPT_PRIKEY_RSA,
CRYPT_PRIKEY_ECC,
CRYPT_PUBKEY_SUBKEY,
CRYPT_PUBKEY_RSA,
CRYPT_PUBKEY_SUBKEY_WITHOUT_SEQ,
} CRYPT_ENCDEC_TYPE;
typedef enum {
CRYPT_DERIVE_PBKDF2,
} CRYPT_DERIVE_MODE;
typedef struct {
uint32_t deriveMode;
void *param;
} CRYPT_EncodeParam;
typedef struct {
uint32_t pbesId;
uint32_t pbkdfId;
uint32_t hmacId;
uint32_t symId;
uint32_t saltLen;
uint8_t *pwd;
uint32_t pwdLen;
uint32_t itCnt;
} CRYPT_Pbkdf2Param;
typedef struct EAL_LibCtx CRYPT_EAL_LibCtx;
typedef struct EAL_ProviderMgrCtx CRYPT_EAL_ProvMgrCtx;
typedef struct {
int32_t id;
void *func;
} CRYPT_EAL_Func;
typedef enum {
CRYPT_CMVP_PROVIDER_SELFTEST = 0x01,
} CRYPT_CMVP_SELFTEST_AlgId;
#ifdef __cplusplus
}
#endif
#endif