/* * Copyright (c) Hisilicon Technologies Co., Ltd. 2019-2023. All rights reserved. * Description: IAPI header file for Huanglong cipher module * Author: Hisilicon * Create: 2019-11-15 */ #ifndef UAPI_CIPHER_H #define UAPI_CIPHER_H #include "td_type.h" #ifdef __cplusplus #if __cplusplus extern "C" { #endif #endif /* __cplusplus */ #define UAPI_CIPHER_HASH_RESULT_SIZE_MAX_IN_WORD 16 #define UAPI_CIPHER_HASH_BLOCK_SIZE_MAX 128 #define UAPI_CIPHER_IV_LEN_IN_BYTES 16 #define UAPI_CIPHER_AES_IV_SIZE_IN_WORD 4 #define UAPI_CIPHER_HASH_TYPE 0 #define UAPI_CIPHER_HMAC_TYPE 1 #define UAPI_CIPHER_HASH_ALG_SHA1 0 #define UAPI_CIPHER_HASH_ALG_SHA2 1 #define UAPI_CIPHER_HASH_ALG_SM3 2 #define UAPI_CIPHER_HASH_MODE_224 0 #define UAPI_CIPHER_HASH_MODE_256 1 #define UAPI_CIPHER_HASH_MODE_384 2 #define UAPI_CIPHER_HASH_MODE_512 3 #define UAPI_CIPHER_HASH_MODE_UNDEF 0xf #define UAPI_CIPHER_HASH_MAX_MESSAGE_LEN_64BIT 0x6 #define UAPI_CIPHER_HASH_MAX_MESSAGE_LEN_128BIT 0x7 #define UAPI_CIPHER_HASH_BLOCK_SIZE_512BIT 0x9 #define UAPI_CIPHER_HASH_BLOCK_SIZE_1024BIT 0xa #define UAPI_CIPHER_HASH_RESULT_SIZE_160BIT 0xa0 #define UAPI_CIPHER_HASH_RESULT_SIZE_224BIT 0xe0 #define UAPI_CIPHER_HASH_RESULT_SIZE_256BIT 0x100 #define UAPI_CIPHER_HASH_RESULT_SIZE_384BIT 0x180 #define UAPI_CIPHER_HASH_RESULT_SIZE_512BIT 0x200 #define UAPI_CIPHER_HDCP_AES_GCM_AAD_LEN 16 #define UAPI_CIPHER_HDCP_AES_GCM_IV_LEN 16 #define UAPI_CIPHER_HDCP_AES_GCM_TAG_LEN 16 #define uapi_cipher_compat_hash_type(is_hmac, alg, mode, max_message_length, block_size, result_size) \ ((((is_hmac) & 0xF) << 28) | (((alg) & 0xF) << 24) | (((mode) & 0xF) << 20) | \ (((max_message_length) & 0xF) << 16) | (((block_size) & 0xF) << 12) | ((result_size) & 0xFFF)) /* * ECC Curve type selecting */ /* * CNcomment: ECC 曲线类型选择 */ typedef enum { UAPI_CIPHER_PKE_ECC_TYPE_RFC5639_P256 = 0, /* *< RFC 5639 - Brainpool P256 */ /* *< CNcomment: RFC 5639类型,Brainpool P256曲线 */ UAPI_CIPHER_PKE_ECC_TYPE_RFC5639_P384, /* *< RFC 5639 - Brainpool P384 */ /* *< CNcomment: RFC 5639类型,Brainpool P384曲线 */ UAPI_CIPHER_PKE_ECC_TYPE_RFC5639_P512, /* *< RFC 5639 - Brainpool P512 */ /* *< CNcomment: RFC 5639类型,Brainpool P512曲线 */ UAPI_CIPHER_PKE_ECC_TYPE_FIPS_P256K, /* *< NIST FIPS 186-4 P256K, suggest not to use */ /* *< CNcomment: FIPS 186-4类型,P256K曲线,不建议使用 */ UAPI_CIPHER_PKE_ECC_TYPE_FIPS_P256R, /* *< NIST FIPS 186-4 P256R, suggest not to use */ /* *< CNcomment: FIPS 186-4类型,P256R曲线,不建议使用 */ UAPI_CIPHER_PKE_ECC_TYPE_FIPS_P384R, /* *< NIST FIPS 186-4 P384, suggest not to use */ /* *< CNcomment: FIPS 186-4类型,P384R曲线,不建议使用 */ UAPI_CIPHER_PKE_ECC_TYPE_FIPS_P521R, /* *< NIST FIPS 186-4 P521R, suggest not to use */ /* *< CNcomment: FIPS 186-4类型,P512R曲线,不建议使用 */ UAPI_CIPHER_PKE_ECC_TYPE_RFC7748, /* *< RFC 7748 - Curve25519 */ /* *< CNcomment: RFC 7748曲线 */ UAPI_CIPHER_PKE_ECC_TYPE_RFC8032, /* *< RFC 8032 - ED25519 */ /* *< CNcomment: RFC 8032曲线 */ UAPI_CIPHER_PKE_ECC_TYPE_SM2, /* *< SM2 curve */ /* *< CNcomment: SM2椭圆曲线 */ UAPI_CIPHER_PKE_ECC_TYPE_MAX, UAPI_CIPHER_PKE_ECC_TYPE_INVALID = 0xffffffff, } uapi_cipher_pke_ecc_type; /* * RSA Padding type selecting */ /* * CNcomment: RSA 填充方式选择 */ typedef enum { /* *< PKCS#1 V15 */ /* *< CNcomment: PKCS#1 V15填充 */ UAPI_CIPHER_PKE_RSA_SCHEME_PKCS1_V15 = 0x00, /* *< PKCS#1 V21, PSS for signning, OAEP for encryption */ /* *< CNcomment: PKCS#1 V21填充,用于签名的PSS,用于加密的OAEP填充 */ UAPI_CIPHER_PKE_RSA_SCHEME_PKCS1_V21, UAPI_CIPHER_PKE_RSA_SCHEME_MAX, UAPI_CIPHER_PKE_RSA_SCHEME_INVALID = 0xffffffff, } uapi_cipher_rsa_scheme; /* * Hash type selecting */ /* * CNcomment: Hash 算法选择 */ typedef enum { UAPI_CIPHER_PKE_HASH_TYPE_SHA1 = 0x00, /* *< Suggest Not to use */ /* *< CNcomment: 不建议使用 */ UAPI_CIPHER_PKE_HASH_TYPE_SHA224, UAPI_CIPHER_PKE_HASH_TYPE_SHA256, UAPI_CIPHER_PKE_HASH_TYPE_SHA384, UAPI_CIPHER_PKE_HASH_TYPE_SHA512, UAPI_CIPHER_PKE_HASH_TYPE_SM3, UAPI_CIPHER_PKE_HASH_TYPE_MAX, UAPI_CIPHER_PKE_HASH_TYPE_INVALID = 0xffffffff, } uapi_cipher_pke_hash_type; /* * Hash type selecting */ /* * CNcomment: Hash/HMAC 算法选择 */ typedef enum { UAPI_CIPHER_HASH_TYPE_SHA1 = uapi_cipher_compat_hash_type( UAPI_CIPHER_HASH_TYPE, UAPI_CIPHER_HASH_ALG_SHA1, UAPI_CIPHER_HASH_MODE_UNDEF, UAPI_CIPHER_HASH_MAX_MESSAGE_LEN_64BIT, UAPI_CIPHER_HASH_BLOCK_SIZE_512BIT, UAPI_CIPHER_HASH_RESULT_SIZE_160BIT ), UAPI_CIPHER_HASH_TYPE_SHA224 = uapi_cipher_compat_hash_type( UAPI_CIPHER_HASH_TYPE, UAPI_CIPHER_HASH_ALG_SHA2, UAPI_CIPHER_HASH_MODE_224, UAPI_CIPHER_HASH_MAX_MESSAGE_LEN_64BIT, UAPI_CIPHER_HASH_BLOCK_SIZE_512BIT, UAPI_CIPHER_HASH_RESULT_SIZE_224BIT ), UAPI_CIPHER_HASH_TYPE_SHA256 = uapi_cipher_compat_hash_type( UAPI_CIPHER_HASH_TYPE, UAPI_CIPHER_HASH_ALG_SHA2, UAPI_CIPHER_HASH_MODE_256, UAPI_CIPHER_HASH_MAX_MESSAGE_LEN_64BIT, UAPI_CIPHER_HASH_BLOCK_SIZE_512BIT, UAPI_CIPHER_HASH_RESULT_SIZE_256BIT ), UAPI_CIPHER_HASH_TYPE_SHA384 = uapi_cipher_compat_hash_type( UAPI_CIPHER_HASH_TYPE, UAPI_CIPHER_HASH_ALG_SHA2, UAPI_CIPHER_HASH_MODE_384, UAPI_CIPHER_HASH_MAX_MESSAGE_LEN_128BIT, UAPI_CIPHER_HASH_BLOCK_SIZE_1024BIT, UAPI_CIPHER_HASH_RESULT_SIZE_384BIT ), UAPI_CIPHER_HASH_TYPE_SHA512 = uapi_cipher_compat_hash_type( UAPI_CIPHER_HASH_TYPE, UAPI_CIPHER_HASH_ALG_SHA2, UAPI_CIPHER_HASH_MODE_512, UAPI_CIPHER_HASH_MAX_MESSAGE_LEN_128BIT, UAPI_CIPHER_HASH_BLOCK_SIZE_1024BIT, UAPI_CIPHER_HASH_RESULT_SIZE_512BIT ), UAPI_CIPHER_HASH_TYPE_SM3 = uapi_cipher_compat_hash_type( UAPI_CIPHER_HASH_TYPE, UAPI_CIPHER_HASH_ALG_SM3, UAPI_CIPHER_HASH_MODE_256, UAPI_CIPHER_HASH_MAX_MESSAGE_LEN_64BIT, UAPI_CIPHER_HASH_BLOCK_SIZE_512BIT, UAPI_CIPHER_HASH_RESULT_SIZE_256BIT ), UAPI_CIPHER_HASH_TYPE_HMAC_SHA224 = uapi_cipher_compat_hash_type( UAPI_CIPHER_HMAC_TYPE, UAPI_CIPHER_HASH_ALG_SHA2, UAPI_CIPHER_HASH_MODE_224, UAPI_CIPHER_HASH_MAX_MESSAGE_LEN_64BIT, UAPI_CIPHER_HASH_BLOCK_SIZE_512BIT, UAPI_CIPHER_HASH_RESULT_SIZE_224BIT ), UAPI_CIPHER_HASH_TYPE_HMAC_SHA256 = uapi_cipher_compat_hash_type( UAPI_CIPHER_HMAC_TYPE, UAPI_CIPHER_HASH_ALG_SHA2, UAPI_CIPHER_HASH_MODE_256, UAPI_CIPHER_HASH_MAX_MESSAGE_LEN_64BIT, UAPI_CIPHER_HASH_BLOCK_SIZE_512BIT, UAPI_CIPHER_HASH_RESULT_SIZE_256BIT ), UAPI_CIPHER_HASH_TYPE_HMAC_SHA384 = uapi_cipher_compat_hash_type( UAPI_CIPHER_HMAC_TYPE, UAPI_CIPHER_HASH_ALG_SHA2, UAPI_CIPHER_HASH_MODE_384, UAPI_CIPHER_HASH_MAX_MESSAGE_LEN_128BIT, UAPI_CIPHER_HASH_BLOCK_SIZE_1024BIT, UAPI_CIPHER_HASH_RESULT_SIZE_384BIT ), UAPI_CIPHER_HASH_TYPE_HMAC_SHA512 = uapi_cipher_compat_hash_type( UAPI_CIPHER_HMAC_TYPE, UAPI_CIPHER_HASH_ALG_SHA2, UAPI_CIPHER_HASH_MODE_512, UAPI_CIPHER_HASH_MAX_MESSAGE_LEN_128BIT, UAPI_CIPHER_HASH_BLOCK_SIZE_1024BIT, UAPI_CIPHER_HASH_RESULT_SIZE_512BIT ), UAPI_CIPHER_HASH_TYPE_HMAC_SM3 = uapi_cipher_compat_hash_type( UAPI_CIPHER_HMAC_TYPE, UAPI_CIPHER_HASH_ALG_SM3, UAPI_CIPHER_HASH_MODE_256, UAPI_CIPHER_HASH_MAX_MESSAGE_LEN_64BIT, UAPI_CIPHER_HASH_BLOCK_SIZE_512BIT, UAPI_CIPHER_HASH_RESULT_SIZE_256BIT ), UAPI_CIPHER_HASH_TYPE_INVALID = 0xffffffff, } uapi_cipher_hash_type; /* * SYMC Crypto alg selecting */ /* * CNcomment: 对称加解密算法选择 */ typedef enum { UAPI_CIPHER_SYMC_ALG_TDES = 0x0, UAPI_CIPHER_SYMC_ALG_AES = 0x1, UAPI_CIPHER_SYMC_ALG_SM4 = 0x2, UAPI_CIPHER_SYMC_ALG_LEA = 0x3, UAPI_CIPHER_SYMC_ALG_DMA = 0x4, UAPI_CIPHER_SYMC_ALG_MAX, UAPI_CIPHER_SYMC_ALG_INVALID = 0xffffffff, } uapi_cipher_symc_alg; /* * SYMC Crypto work mode selecting */ /* * CNcomment: 对称加解密工作模式选择 */ typedef enum { UAPI_CIPHER_SYMC_WORK_MODE_ECB = 0x0, UAPI_CIPHER_SYMC_WORK_MODE_CBC, UAPI_CIPHER_SYMC_WORK_MODE_CTR, UAPI_CIPHER_SYMC_WORK_MODE_OFB, UAPI_CIPHER_SYMC_WORK_MODE_CFB, UAPI_CIPHER_SYMC_WORK_MODE_CCM, UAPI_CIPHER_SYMC_WORK_MODE_GCM, UAPI_CIPHER_SYMC_WORK_MODE_CBC_MAC, UAPI_CIPHER_SYMC_WORK_MODE_CMAC, UAPI_CIPHER_SYMC_WORK_MODE_MAX, UAPI_CIPHER_SYMC_WORK_MODE_INVALID = 0xffffffff, } uapi_cipher_symc_work_mode; /* * SYMC Channel type selecting */ /* * CNcomment: 对称算法通道类型选择 */ typedef enum { UAPI_CIPHER_SYMC_TYPE_NORMAL = 0x0, UAPI_CIPHER_SYMC_TYPE_REG, UAPI_CIPHER_SYMC_TYPE_MAX, UAPI_CIPHER_SYMC_TYPE_INVALID = 0xffffffff, } uapi_cipher_symc_type; /* * SYMC Crypto key length selecting */ /* * CNcomment: 对称加解密密钥长度选择 */ typedef enum { UAPI_CIPHER_SYMC_KEY_64BIT = 0x0, UAPI_CIPHER_SYMC_KEY_128BIT = 0x1, UAPI_CIPHER_SYMC_KEY_192BIT = 0x2, UAPI_CIPHER_SYMC_KEY_256BIT = 0x3, UAPI_CIPHER_SYMC_KEY_LENGTH_MAX, UAPI_CIPHER_SYMC_KEY_LENGTH_INVALID = 0xffffffff, } uapi_cipher_symc_key_length; /* * SYMC Crypto key parity selecting */ /* * CNcomment: 对称加解密 key 奇偶属性选择 */ typedef enum { UAPI_CIPHER_SYMC_KEY_EVEN = 0x0, UAPI_CIPHER_SYMC_KEY_ODD = 0x1, UAPI_CIPHER_SYMC_KEY_PARITY_MAX, UAPI_CIPHER_SYMC_KEY_PARITY_INVALID = 0xffffffff, } uapi_cipher_symc_key_parity; /* * SYMC Crypto bit width selecting */ /* * CNcomment: 对称加解密位宽选择 */ typedef enum { UAPI_CIPHER_SYMC_BIT_WIDTH_1BIT = 0x0, UAPI_CIPHER_SYMC_BIT_WIDTH_8BIT = 0x1, UAPI_CIPHER_SYMC_BIT_WIDTH_64BIT = 0x2, UAPI_CIPHER_SYMC_BIT_WIDTH_128BIT = 0x3, UAPI_CIPHER_SYMC_BIT_WIDTH_MAX, UAPI_CIPHER_SYMC_BIT_WIDTH_INVALID = 0xffffffff, } uapi_cipher_symc_bit_width; /* * SYMC Crypto iv change flag selecting */ /* * CNcomment: 对称加解密 iv 修改标志位选择 */ typedef enum { UAPI_CIPHER_SYMC_IV_DO_NOT_CHANGE = 0, UAPI_CIPHER_SYMC_IV_CHANGE_ONE_PKG, UAPI_CIPHER_SYMC_IV_CHANGE_ALL_PKG, UAPI_CIPHER_SYMC_GCM_IV_DO_NOT_CHANGE, UAPI_CIPHER_SYMC_GCM_IV_CHANGE_START, UAPI_CIPHER_SYMC_GCM_IV_CHANGE_UPDATE, UAPI_CIPHER_SYMC_GCM_IV_CHANGE_FINISH, UAPI_CIPHER_SYMC_CCM_IV_DO_NOT_CHANGE, UAPI_CIPHER_SYMC_CCM_IV_CHANGE_START, UAPI_CIPHER_SYMC_CCM_IV_CHANGE_UPDATE, UAPI_CIPHER_SYMC_CCM_IV_CHANGE_FINISH, UAPI_CIPHER_SYMC_IV_CHANGE_MAX, UAPI_CIPHER_SYMC_IV_CHANGE_INVALID = 0xffffffff, } uapi_cipher_symc_iv_change_type; /* * Buffer Secure Attribute selecting */ /* * CNcomment: Buffer 安全属性选择 */ typedef enum { UAPI_CIPHER_BUF_NONSECURE, UAPI_CIPHER_BUF_SECURE, UAPI_CIPHER_BUF_INVALID = 0xffffffff, } uapi_cipher_buffer_secure; /* * PKE Common Data. */ /* * CNcomment: PKE 通用数据结构 */ typedef struct { td_u32 length; td_u8 *data; } uapi_cipher_pke_data; /* * ecdsa public key struct information */ /* * CNcomment: ecdsa 公钥结构体 */ typedef struct { /* *< X coordinates of the generated public key, the caller ensures it is padded with leading zeros if the effective size of this key is smaller than ecc key size. */ /* *< CNcomment: 生成公钥的X坐标,长度不足key的大小,前面补零 */ td_u8 *x; /* *< Y coordinates of the generated public key, the caller ensures it is padded with leading zeros if the effective size of this key is smaller than ecc key size. */ /* *< CNcomment: 生成公钥的Y坐标,长度不足key的大小,前面补零 */ td_u8 *y; td_u32 length; } uapi_cipher_ecc_point; /* * ecdsa message struct information */ /* * CNcomment: ecdsa 消息结构体 */ typedef struct { td_u32 length; td_u8 *data; uapi_cipher_buffer_secure buf_sec; } uapi_cipher_pke_msg; /* * ecdsa signature struct information */ /* * CNcomment: ecdsa 签名结构体 */ typedef struct { td_u8 *r; /* *< r component of the signature. */ /* *< CNcomment: 签名的r部分 */ td_u8 *s; /* *< s component of the signature. */ /* *< CNcomment: 签名的s部分 */ td_u32 length; } uapi_cipher_ecc_sig; /* * RSA private key struct information */ /* * CNcomment: RSA 私钥结构体 */ typedef struct { td_u8 *n; /* *< public modulus */ /* *< CNcomment: 公共模数n */ td_u8 *e; /* *< public exponent */ /* *< CNcomment: 公共指数e */ td_u8 *d; /* *< private exponent */ /* *< CNcomment: 公共指数d */ td_u8 *p; /* *< 1st prime factor */ /* *< CNcomment: 第一素因子p */ td_u8 *q; /* *< 2nd prime factor */ /* *< CNcomment: 第二素因子q */ td_u8 *dp; /* *< D % (P - 1) */ /* *< CNcomment: dp参数 */ td_u8 *dq; /* *< D % (Q - 1) */ /* *< CNcomment: dq参数 */ td_u8 *qp; /* *< 1 / (Q % P) */ /* *< CNcomment: qp参数 */ td_u16 n_len; /* *< length of public modulus */ /* *< CNcomment: 公共模数n的长度n_len */ td_u16 e_len; /* *< length of public exponent */ /* *< CNcomment: 公共模数e的长度e_len */ td_u16 d_len; /* *< length of private exponent */ /* *< CNcomment: 公共模数d的长度d_len */ td_u16 p_len; /* *< length of 1st prime factor,should be half of u16NLen */ /* *< CNcomment: 第一素因子p的长度,应该为u16NLen的一半 */ td_u16 q_len; /* *< length of 2nd prime factor,should be half of u16NLen */ /* *< CNcomment: 第二素因子q的长度,应该为u16NLen的一半 */ td_u16 dp_len; /* *< length of D % (P - 1),should be half of u16NLen */ /* *< CNcomment: dp参数的长度,应该为u16NLen的一半 */ td_u16 dq_len; /* *< length of D % (Q - 1),should be half of u16NLen */ /* *< CNcomment: dq参数的长度,应该为u16NLen的一半 */ td_u16 qp_len; /* *< length of 1 / (Q % P),should be half of u16NLen */ /* *< CNcomment: qp参数的长度,应该为u16NLen的一半 */ } uapi_cipher_rsa_priv_key; /* * RSA public key struct information */ /* * CNcomment: RSA 公钥结构体 */ typedef struct { td_u8 *n; /* *< point to public modulus */ /* *< CNcomment: 指向公共模数n */ td_u8 *e; /* *< point to public exponent */ /* *< CNcomment: 指向公共指数e */ td_u16 len; /* *< length of public modulus, max value is 512Byte */ /* *< CNcomment: 公共模数的长度,最大值为512字节 */ } uapi_cipher_rsa_pub_key; /* * Hash Channel Attribute struct information */ /* * CNcomment: HASH 通道参数结构体 */ typedef struct { td_u8 *key; td_u32 key_len; td_handle drv_keyslot_handle; uapi_cipher_hash_type hash_type; td_bool is_keyslot; td_bool is_long_term; } uapi_cipher_hash_attr; /* * Hash Clone Context struct information */ /* * CNcomment: HASH Clone 上下文结构体 */ typedef struct { td_u32 length[2]; td_u32 state[UAPI_CIPHER_HASH_RESULT_SIZE_MAX_IN_WORD]; td_u32 tail_len; uapi_cipher_hash_type hash_type; td_u8 o_key_pad[UAPI_CIPHER_HASH_BLOCK_SIZE_MAX]; td_u8 i_key_pad[UAPI_CIPHER_HASH_BLOCK_SIZE_MAX]; td_u8 tail[UAPI_CIPHER_HASH_BLOCK_SIZE_MAX]; } uapi_cipher_hash_clone_ctx; /* * SYMC Channel Attribute struct information */ /* * CNcomment: 对称加解密通道参数结构体 */ typedef struct { uapi_cipher_symc_alg symc_alg; uapi_cipher_symc_work_mode work_mode; uapi_cipher_symc_type symc_type; td_bool is_long_term; } uapi_cipher_symc_attr; /* * Common Buffer struct information */ /* * CNcomment: 通用 Buffer 结构体 */ typedef struct { td_u64 uapi_mem_handle; /* *< Handle to buffer header address in User Space. */ /* *< CNcomment: 用户空间中缓冲区头地址的句柄 */ td_u64 addr_offset; /* *< buffer offset. */ /* *< CNcomment: 缓冲区偏移量 */ td_void *kapi_mem_handle; /* *< Handle to buffer header address in Kernel Space. */ /* *< CNcomment: 内核空间中缓冲区报头地址的句柄 */ td_ulong phys_addr; /* *< phys_addr, used in drv. */ /* *< CNcomment: 驱动中使用的物理地址 */ td_void *virt_addr; /* *< virt_addr, used for hash, aad, mac */ /* *< CNcomment: 哈希、aad、mac中使用的虚拟地址 */ uapi_cipher_buffer_secure buf_sec; /* *< NONSECURE or SECURE */ /* *< CNcomment: 非安全或安全 */ } uapi_cipher_buf_attr; /* * SYMC CCM/GCM parameters struct information */ /* * CNcomment: 对称加解密 CCM/GCM 算法参数结构体 */ typedef struct { uapi_cipher_buf_attr aad_buf; td_u32 aad_len; /* *< Addition Data Length In Bytes. */ /* *< CNcomment: 增加的数据字节长度 */ td_u32 data_len; /* *< Crypto Data Length In Bytes. */ /* *< CNcomment: 加密的数据字节长度 */ td_u32 tag_len; /* *< Tag Length In Bytes. */ /* *< CNcomment: 标记的数据字节长度 */ } uapi_cipher_symc_config_aes_ccm_gcm; /* * SYMC parameters struct information */ /* * CNcomment: 对称加解密算法参数结构体 */ typedef struct { uapi_cipher_symc_alg symc_alg; uapi_cipher_symc_work_mode work_mode; uapi_cipher_symc_key_length symc_key_length; uapi_cipher_symc_key_parity key_parity; uapi_cipher_symc_bit_width symc_bit_width; uapi_cipher_symc_iv_change_type iv_change_flag; td_u8 iv[UAPI_CIPHER_IV_LEN_IN_BYTES]; td_u32 iv_length; /* *< Parameter for special algorithm for AES_CCM or AES_GCM, the pointer should point to uapi_cipher_symc_config_aes_ccm_gcm; for others, the pointer is NULL. */ /* *< CNcomment: 算法的专用参数 对于 AES_CCM 或 AES_GCM, 指针应指向 uapi_cipher_symc_config_aes_ccm_gcm; 其余算法,该指针为 NULL. */ td_void *param; } uapi_cipher_symc_ctrl_t; /* * SYMC multiple pack struct information */ /* * CNcomment: 对称加解密多包结构体 */ typedef struct { uapi_cipher_buf_attr buf_attr; td_u32 length; } uapi_cipher_symc_pack; /* * CENC subsample struct information */ /* * CNcomment: CENC subsample 结构体 */ typedef struct { td_u32 clear_header_len; td_u32 payload_len; td_u32 payload_pattern_encrypt_len; td_u32 payload_pattern_clear_len; td_u32 payload_pattern_offset_len; td_bool iv_change; td_u32 iv[UAPI_CIPHER_AES_IV_SIZE_IN_WORD]; } uapi_cipher_symc_cenc_subsample; /* * CENC decrypt parameters struct information */ /* * CNcomment: CENC 解密算法参数结构体 */ typedef struct { td_bool use_odd_key; td_u32 first_encrypt_offset; uapi_cipher_symc_cenc_subsample *subsample; td_u32 subsample_num; uapi_cipher_symc_alg alg; uapi_cipher_symc_work_mode work_mode; td_u32 iv[UAPI_CIPHER_AES_IV_SIZE_IN_WORD]; } uapi_cipher_symc_cenc_param; /* * MAC channel attribute struct information */ /* * CNcomment: MAC 通道属性结构体 */ typedef struct { td_bool is_long_term; uapi_cipher_symc_alg symc_alg; uapi_cipher_symc_work_mode work_mode; uapi_cipher_symc_key_length symc_key_length; td_u32 keyslot_chn; } uapi_cipher_symc_mac_attr; /* * PBKDF2 parameters struct information */ /* * CNcomment: PBKDF2 算法参数结构体 */ typedef struct { uapi_cipher_hash_type hash_type; td_u8 *password; td_u32 plen; td_u8 *salt; td_u32 slen; td_u16 count; } uapi_cipher_kdf_pbkdf2_param; /* * HDMI RAM type selecting */ /* * CNcomment: HDMI RAM 类型选择 */ typedef enum { UAPI_CIPHER_HDMI_RAM_SEL_NONE = 0x00, /* *< don't write data to hdmi ram */ /* *< CNcomment: 不将数据写入hdmi ram */ UAPI_CIPHER_HDMI_RAM_SEL_RX_14, /* *< hmdi rx 1.4 */ /* *< CNcomment: hdmi rx 1.4 */ UAPI_CIPHER_HDMI_RAM_SEL_TX_14, /* *< hmdi tx 1.4 */ /* *< CNcomment: hdmi tx 1.4 */ UAPI_CIPHER_HDMI_RAM_SEL_RX_22, /* *< hmdi rx 2.2 */ /* *< CNcomment: hdmi rx 2.2 */ UAPI_CIPHER_HDMI_RAM_SEL_TX_22, /* *< hmdi tx 2.2 */ /* *< CNcomment: hdmi tx 2.2 */ UAPI_CIPHER_HDMI_RAM_SEL_COUNT, } uapi_cipher_hdmi_ram_sel; /* * HDCP rootkey selecting */ /* * CNcomment: HDCP rootkey 选择 */ typedef enum { UAPI_CIPHER_HDCP_KEY_SEL_KLAD = 0x00, /* *< OTP HDCP Root Key */ /* *< CNcomment: OTP HDCP根秘钥 */ UAPI_CIPHER_HDCP_KEY_SEL_HUANGLONG, /* *< Huanglong Fixed Key */ /* *< CNcomment: Huanglong固定密钥 */ UAPI_CIPHER_HDCP_KEY_SEL_COUNT, } uapi_cipher_hdcp_rootkey_sel; /* * HDCP parameters struct information */ /* * CNcomment: HDCP 参数结构体 */ typedef struct { uapi_cipher_hdmi_ram_sel ram_sel; td_u32 ram_num; uapi_cipher_hdcp_rootkey_sel key_sel; td_u32 key_slot; uapi_cipher_symc_alg alg; uapi_cipher_symc_work_mode mode; td_u8 aad[UAPI_CIPHER_HDCP_AES_GCM_AAD_LEN]; td_u8 iv[UAPI_CIPHER_HDCP_AES_GCM_IV_LEN]; td_u8 tag[UAPI_CIPHER_HDCP_AES_GCM_TAG_LEN]; } uapi_cipher_hdcp_attr; /* ****************************** API Declaration **************************** */ /* * \addtogroup CIPHER */ /* * @{ */ /* *