5#ifndef __DAO_LIQUID_CRYPTO_H__
6#define __DAO_LIQUID_CRYPTO_H__
20#define DAO_LC_VERSION "26.01.0"
22#define DAO_CRYPTO_VERSION_LEN 32
24#define DAO_CRYPTO_MAX_NB_DEV 1
26#define DAO_CMD_QP_IDX_INVALID 0xFFFF
28#define DAO_LC_SESS_ID_INVALID 0
30#define DAO_LC_SESS_ID_HASH 1
32#define DAO_LC_SESS_ID_AES_KEY_WRAP 2
34#define DAO_LC_MAX_DIGEST_LEN 255
36#define DAO_LC_MAX_AUTH_KEY_LEN 1024
38#define DAO_LC_AES_KEY_WRAP_MAX_KEY_DATA_LEN 3072
40#define DAO_LC_AES_MAX_KEY_ENC_KEY_LEN 32
42#define DAO_LC_AES_KEY_WRAP_IV_LEN 8
44#define DAO_LC_RSA_OAEP_MAX_LABEL_LEN 1024
46#define DAO_LC_RSA_OAEP_MAX_MOD_LEN 988
48#define DAO_LC_SHA3_MAX_CUSTOM_STRING_LEN 511
50#define DAO_LC_SHA3_MAX_FUNCTION_NAME_LEN 511
52#define DAO_LC_KMAC_MAX_AUTH_KEY_LEN 511
587 DAO_LC_FC_CIPHER_THEN_AUTH = 0,
589 DAO_LC_FC_AUTH_THEN_CIPHER = 1
681 DAO_LC_AE_EC_ID_P192 = 0,
683 DAO_LC_AE_EC_ID_P224 = 1,
685 DAO_LC_AE_EC_ID_P256 = 2,
687 DAO_LC_AE_EC_ID_P384 = 3,
689 DAO_LC_AE_EC_ID_P521 = 4,
976struct dao_lc_random_op {
1249 uint16_t mod_len, uint16_t exp_len, uint16_t msg_len,
1250 const uint8_t *mod,
const uint8_t *exp,
const uint8_t *msg,
1251 uint8_t *em, uint64_t op_cookie);
1291 uint16_t mod_len, uint16_t exp_len,
const uint8_t *mod,
1292 const uint8_t *exp,
const uint8_t *em, uint8_t *msg,
1293 uint64_t op_cookie);
1339 uint16_t msg_len,
const uint8_t *q,
const uint8_t *dQ,
1340 const uint8_t *p,
const uint8_t *dP,
1341 const uint8_t *qInv,
const uint8_t *msg, uint8_t *em,
1342 uint64_t op_cookie);
1387 const uint8_t *q,
const uint8_t *dQ,
const uint8_t *p,
1388 const uint8_t *dP,
const uint8_t *qInv,
1389 const uint8_t *em, uint8_t *msg, uint64_t op_cookie);
1433#define DAO_LC_ML_KEYPAIR_SEED_LEN (64)
1434#define DAO_LC_ML_KEM_SHARED_SECRET_LEN (32)
1437#define DAO_LC_ML_DSA_CTX_LEN_MAX (255)
1439#define DAO_LC_ML_KEM_512_PUB_KEY_LEN (800)
1440#define DAO_LC_ML_KEM_512_PRIV_KEY_LEN (1632)
1441#define DAO_LC_ML_KEM_512_CIPHERTEXT_LEN (768)
1443#define DAO_LC_ML_KEM_768_PUB_KEY_LEN (1184)
1444#define DAO_LC_ML_KEM_768_PRIV_KEY_LEN (2400)
1445#define DAO_LC_ML_KEM_768_CIPHERTEXT_LEN (1088)
1447#define DAO_LC_ML_KEM_1024_PUB_KEY_LEN (1568)
1448#define DAO_LC_ML_KEM_1024_PRIV_KEY_LEN (3168)
1449#define DAO_LC_ML_KEM_1024_CIPHERTEXT_LEN (1568)
1451#define DAO_LC_ML_DSA_44_PUB_KEY_LEN (1312)
1452#define DAO_LC_ML_DSA_44_PRIV_KEY_LEN (2560)
1453#define DAO_LC_ML_DSA_44_SIGNATURE_LEN (2420)
1455#define DAO_LC_ML_DSA_65_PUB_KEY_LEN (1952)
1456#define DAO_LC_ML_DSA_65_PRIV_KEY_LEN (4032)
1457#define DAO_LC_ML_DSA_65_SIGNATURE_LEN (3309)
1459#define DAO_LC_ML_DSA_87_PUB_KEY_LEN (2592)
1460#define DAO_LC_ML_DSA_87_PRIV_KEY_LEN (4896)
1461#define DAO_LC_ML_DSA_87_SIGNATURE_LEN (4627)
1464#define DAO_LC_ML_DSA_MAX_MSG_LEN (10240)
1466static uint16_t pqc_ml_pub_key_len[] = {[
DAO_LC_ML_KEM_512] = DAO_LC_ML_KEM_512_PUB_KEY_LEN,
1473static uint16_t pqc_ml_priv_key_len[] = {[
DAO_LC_ML_KEM_512] = DAO_LC_ML_KEM_512_PRIV_KEY_LEN,
1480static uint16_t pqc_ml_signature_len[] = {
1490static uint16_t pqc_ml_ciphertext_len[] = {
1499static inline uint16_t
1502 return pqc_ml_pub_key_len[alg];
1505static inline uint16_t
1508 return pqc_ml_priv_key_len[alg];
1511static inline uint16_t
1514 return pqc_ml_signature_len[alg];
1517static inline uint16_t
1520 return pqc_ml_ciphertext_len[alg];
1626 uint64_t op_cookie);
1724 uint64_t sess_cookie);
1772 uint16_t nb_events);
1838 uint16_t nonce_len, uint16_t pkey_len, uint16_t digest_len,
1839 const uint8_t *nonce,
const uint8_t *pkey,
1840 const uint8_t *digest, uint8_t *rs_outdata,
1841 uint64_t op_cookie);
1905 uint16_t r_len, uint16_t s_len, uint16_t digest_len,
1906 uint16_t qx_len, uint16_t qy_len,
const uint8_t *r_data,
1907 const uint8_t *s_data,
const uint8_t *digest,
1908 const uint8_t *qx_data,
const uint8_t *qy_data,
1909 uint64_t op_cookie);
1985 uint16_t mod_len, uint16_t exp_len, uint16_t msg_len,
1986 const uint8_t *mod,
const uint8_t *exp,
1987 const uint8_t *msg, uint8_t *em, uint64_t op_cookie);
2039 uint16_t label_len, uint8_t *label,
2041 const uint8_t *mod, uint16_t exp_len,
2042 const uint8_t *exp,
const uint8_t *em,
2043 uint8_t *msg, uint64_t op_cookie);
2105 uint8_t *p, uint8_t *dP, uint8_t *q, uint8_t *dQ,
2106 uint8_t *qInv, uint8_t *em, uint8_t *msg,
2107 uint64_t op_cookie);
int dao_liquid_crypto_enq_op_pkcs1v15enc_crt(uint8_t dev_id, uint16_t qp_id, uint16_t mod_len, uint16_t msg_len, const uint8_t *q, const uint8_t *dQ, const uint8_t *p, const uint8_t *dP, const uint8_t *qInv, const uint8_t *msg, uint8_t *em, uint64_t op_cookie)
int dao_liquid_crypto_enq_op_rsa_oaep_pvt_crt_dec(uint8_t dev_id, uint16_t qp_id, uint8_t *label, uint16_t label_len, enum dao_lc_hash_type hash_type, uint16_t mod_len, uint8_t *p, uint8_t *dP, uint8_t *q, uint8_t *dQ, uint8_t *qInv, uint8_t *em, uint8_t *msg, uint64_t op_cookie)
@ DAO_LC_ML_DSA_OP_VERIFY
@ DAO_LC_ML_DSA_OP_KEYGEN
@ DAO_LC_ML_KEM_OP_KEYGEN
int dao_liquid_crypto_fini(void)
dao_liquid_crypto_ec_curve_type
@ DAO_LC_HASH_DIGEST_SIZE_SHA2_SHA512
@ DAO_LC_HASH_DIGEST_SIZE_SHA2_SHA384
@ DAO_LC_HASH_DIGEST_SIZE_SHA1
@ DAO_LC_HASH_DIGEST_SIZE_SHA2_SHA256
@ DAO_LC_HASH_DIGEST_SIZE_SHA2_SHA224
int dao_liquid_crypto_info_get(struct dao_lc_info *info)
@ DAO_PQC_COMP_LIB_ERROR_LIBOQS
@ DAO_LC_FC_AUTH_KEY_SRC_OP
@ DAO_LC_FC_AUTH_KEY_SRC_CTX
int dao_liquid_crypto_sym_sess_create(uint8_t dev_id, const struct dao_lc_sym_ctx *ctx, uint64_t sess_cookie)
int dao_liquid_crypto_qp_configure(uint8_t dev_id, uint16_t qp_id, struct dao_lc_qp_conf *conf)
@ DAO_LC_FC_AES_KEY_LEN_192
@ DAO_LC_FC_AES_KEY_LEN_128
@ DAO_LC_FC_AES_KEY_LEN_256
@ DAO_LC_SYM_OPCODE_AES_KEY_WRAP
@ DAO_LC_AES_KEY_LEN_32_BYTES
@ DAO_LC_AES_KEY_LEN_24_BYTES
@ DAO_LC_AES_KEY_LEN_16_BYTES
dao_lc_fc_auth_input_type
@ DAO_LC_FC_AUTH_INPUT_OPAD_IPAD
@ DAO_LC_FC_AUTH_INPUT_KEY
uint16_t dao_liquid_crypto_seg_size_calc(struct dao_lc_feature_params *params)
int dao_liquid_crypto_enq_op_ecdsa_verify(uint8_t dev_id, uint16_t qp_id, enum dao_liquid_crypto_ec_curve_type curve_id, uint16_t r_len, uint16_t s_len, uint16_t digest_len, uint16_t qx_len, uint16_t qy_len, const uint8_t *r_data, const uint8_t *s_data, const uint8_t *digest, const uint8_t *qx_data, const uint8_t *qy_data, uint64_t op_cookie)
int dao_liquid_crypto_dev_destroy(uint8_t dev_id)
@ DAO_UC_ERR_GC_CIPHER_UNSUPPORTED
@ DAO_UC_ERR_GC_ICV_MISCOMPARE
@ DAO_UC_ECC_SIGN_S_INVALID
@ DAO_UC_RSA_MOD_LEN_INVALID
@ DAO_UC_RSA_MOD_LEN_NOT_EVEN
@ DAO_UC_ECC_CURVE_INVALID
@ DAO_UC_RSA_OAEP_DECODING_ERROR
@ DAO_UC_ECC_PUB_KEY_INVALID
@ DAO_UC_ECC_DATA_LEN_INVALID
@ DAO_UC_RSA_PKCS_DEC_INCORRECT
@ DAO_UC_ECC_SIGN_R_INVALID
@ DAO_UC_ERR_GC_CTX_LEN_INVALID
@ DAO_UC_ERR_GC_DATA_LEN_INVALID
@ DAO_UC_ERR_GC_KEY_DATA_LEN_INVALID
@ DAO_UC_ERR_GC_OFFSET_INVALID
@ DAO_UC_ERR_GC_DATA_UNALIGNED
@ DAO_UC_ERR_GC_KEY_LEN_INVALID
@ DAO_UC_RSA_SG_NOT_SUPPORTED
@ DAO_UC_ECC_VERIFY_MISMATCH
@ DAO_UC_ERR_GC_AUTH_UNSUPPORTED
int dao_liquid_crypto_qp_inflight_req_count(uint8_t dev_id, uint16_t qp_id)
int dao_liquid_crypto_enq_op_pkcs1v15dec_crt(uint8_t dev_id, uint16_t qp_id, uint16_t mod_len, const uint8_t *q, const uint8_t *dQ, const uint8_t *p, const uint8_t *dP, const uint8_t *qInv, const uint8_t *em, uint8_t *msg, uint64_t op_cookie)
int dao_liquid_crypto_enq_op_pkcs1v15enc(uint8_t dev_id, uint16_t qp_id, enum dao_liquid_crypto_rsa_key_type key_type, uint16_t mod_len, uint16_t exp_len, uint16_t msg_len, const uint8_t *mod, const uint8_t *exp, const uint8_t *msg, uint8_t *em, uint64_t op_cookie)
int dao_liquid_crypto_dev_start(uint8_t dev_id)
int dao_liquid_crypto_sym_sess_destroy(uint8_t dev_id, uint64_t sess_id, uint64_t sess_cookie)
#define DAO_CRYPTO_VERSION_LEN
#define DAO_LC_MAX_AUTH_KEY_LEN
int dao_liquid_crypto_enq_op_rsa_oaep_pvt_exp_dec(uint8_t dev_id, uint16_t qp_id, uint16_t label_len, uint8_t *label, enum dao_lc_hash_type hash_type, uint16_t mod_len, const uint8_t *mod, uint16_t exp_len, const uint8_t *exp, const uint8_t *em, uint8_t *msg, uint64_t op_cookie)
@ DAO_LC_FC_ENC_CIPHER_CHACHA
@ DAO_LC_FC_ENC_CIPHER_AES_CCM
@ DAO_LC_FC_ENC_CIPHER_AES_CTR
@ DAO_LC_FC_ENC_CIPHER_3DES_CBC
@ DAO_LC_FC_ENC_CIPHER_AES_CFB
@ DAO_LC_FC_ENC_CIPHER_3DES_ECB
@ DAO_LC_FC_ENC_CIPHER_AES_XTS
@ DAO_LC_FC_ENC_CIPHER_AES_CBC
@ DAO_LC_FC_ENC_CIPHER_AES_GCM
@ DAO_LC_FC_ENC_CIPHER_NULL
@ DAO_LC_FC_ENC_CIPHER_AES_ECB
#define DAO_CRYPTO_MAX_NB_DEV
int dao_liquid_crypto_dev_stop(uint8_t dev_id)
int dao_liquid_crypto_enqueue_op_passthrough(uint8_t dev_id, uint16_t qp_id, uint64_t op_cookie)
@ DAO_LC_HASH_TYPE_SHA3_CSHAKE256
@ DAO_LC_HASH_TYPE_SHA3_SHAKE128
@ DAO_LC_HASH_TYPE_SHA3_SHA384
@ DAO_LC_HASH_TYPE_SHA2_SHA256
@ DAO_LC_HASH_TYPE_POLY1305
@ DAO_LC_HASH_TYPE_SHA3_SHA256
@ DAO_LC_HASH_TYPE_SHA3_SHAKE256
@ DAO_LC_HASH_TYPE_SHA2_SHA224
@ DAO_LC_HASH_TYPE_SHA3_KMAC128
@ DAO_LC_HASH_TYPE_SHA2_SHA512
@ DAO_LC_HASH_TYPE_SHA3_SHA224
@ DAO_LC_HASH_TYPE_SHA3_CSHAKE128
@ DAO_LC_HASH_TYPE_SHA2_SHA384
@ DAO_LC_HASH_TYPE_SHA3_KMAC256
@ DAO_LC_HASH_TYPE_SHA3_SHA512
int dao_liquid_crypto_pqc_enqueue(uint8_t dev_id, uint16_t qp_id, struct dao_lc_pqc_op *op, uint64_t op_cookie)
uint16_t dao_liquid_crypto_dequeue_burst(uint8_t dev_id, uint16_t qp_id, struct dao_lc_res *res, uint16_t nb_ops)
int dao_liquid_crypto_dev_caps_get(struct dao_lc_dev_caps *lc_caps)
@ DAO_LC_RANDOM_TYPE_X9_17
#define DAO_LC_AES_MAX_KEY_ENC_KEY_LEN
@ DAO_LC_CMD_EVENT_SESS_CREATE
@ DAO_LC_CMD_EVENT_SESS_DESTROY
uint16_t dao_liquid_crypto_cmd_event_dequeue(uint8_t dev_id, struct dao_lc_cmd_event *events, uint16_t nb_events)
int dao_liquid_crypto_enq_op_rsa_oaep_enc(uint8_t dev_id, uint16_t qp_id, uint8_t *label, uint16_t label_len, enum dao_lc_hash_type hash_type, uint16_t mod_len, uint16_t exp_len, uint16_t msg_len, const uint8_t *mod, const uint8_t *exp, const uint8_t *msg, uint8_t *em, uint64_t op_cookie)
int dao_liquid_crypto_enq_op_pkcs1v15dec(uint8_t dev_id, uint16_t qp_id, enum dao_liquid_crypto_rsa_key_type key_type, uint16_t mod_len, uint16_t exp_len, const uint8_t *mod, const uint8_t *exp, const uint8_t *em, uint8_t *msg, uint64_t op_cookie)
int dao_liquid_crypto_enq_op_ecdsa_sign(uint8_t dev_id, uint16_t qp_id, enum dao_liquid_crypto_ec_curve_type curve_id, uint16_t nonce_len, uint16_t pkey_len, uint16_t digest_len, const uint8_t *nonce, const uint8_t *pkey, const uint8_t *digest, uint8_t *rs_outdata, uint64_t op_cookie)
int dao_liquid_crypto_init(void)
int dao_liquid_crypto_enq_op_random(uint8_t dev_id, uint16_t qp_id, struct dao_lc_random_op *op)
uint16_t dao_liquid_crypto_sym_enqueue_burst(uint8_t dev_id, uint16_t qp_id, struct dao_lc_sym_op *op, uint16_t nb_ops)
int dao_liquid_crypto_dev_create(struct dao_lc_dev_conf *conf)
dao_liquid_crypto_rsa_key_type
@ DAO_LC_RSA_KEY_TYPE_PRIVATE
@ DAO_LC_RSA_KEY_TYPE_PUBLIC
uint8_t kek[DAO_LC_AES_MAX_KEY_ENC_KEY_LEN]
enum dao_lc_fc_aes_key_len aes_kek_type
struct dao_lc_cmd_sess_event sess_event
struct dao_lc_feature_params::@19 rsa_oaep
uint16_t cipher_auth_payload_len
struct dao_lc_feature_params::@16 rsa
struct dao_lc_feature_params::@17 rng
enum dao_liquid_crypto_ec_curve_type curve_id
struct dao_lc_feature_params::@15 sym
uint16_t hmac_auth_key_len
struct dao_lc_feature_params::@18 ecc
enum dao_lc_hash_type hash_type
uint8_t is_rsa_oaep_enabled
enum dao_lc_fc_aes_key_len aes_kek_type
enum dao_lc_hash_type hmac_hash_type
uint8_t hmac_auth_key[DAO_LC_MAX_AUTH_KEY_LEN]
uint16_t nb_qp[DAO_CRYPTO_MAX_NB_DEV]
char version[DAO_CRYPTO_VERSION_LEN]
enum dao_lc_pqc_op_type op_type
const uint8_t * signature
struct dao_lc_pqc_op::@25::@30 sign
struct dao_lc_pqc_op::@25::@29 decap
struct dao_lc_pqc_op::@25::@31 verify
const uint8_t * ciphertext
struct dao_lc_pqc_op::@25::@27 keygen
struct dao_lc_pqc_op::@25::@28 encap
bool out_of_order_delivery_en
uint16_t wrap_unwrap_key_len
enum dao_lc_fc_chain_order chain_order
struct dao_lc_sym_fc_ctx fc
struct dao_lc_hmac_hash_ctx hash
struct dao_lc_aes_key_wrap_ctx aes_key_wrap
enum dao_lc_sym_opcode opcode
uint16_t custom_string_len
uint16_t function_name_len
uint16_t custom_string_len
uint32_t wrap_unwrap_key_len
struct dao_lc_sym_op_kmac_params kmac_params
struct dao_lc_buf * in_buffer
struct dao_lc_sym_op_cshake_params cshake_params
struct dao_lc_buf * out_buffer