You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1335 lines
62 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/*
* 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 */
/* * @{ */ /* * <!-- [CIPHER] */
/* ---CIPHER--- */
/* *
\brief Init the pke device. CNcomment:初始化PKE设备。 CNend
\attention \n
This API is used to start the pke device.
CNcomment:调用此接口初始化PKE设备。 CNend
\param N/A CNcomment:无 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_pke_init(td_void);
/* *
\brief Deinit the pke device.
CNcomment:\brief 去初始化PKE设备。 CNend
\attention \n
This API is used to stop the pke device. If this API is called repeatedly, TD_SUCCESS is returned, but only the first
operation takes effect.
CNcomment:调用此接口关闭PKE设备。重复关闭返回成功第一次起作用。 CNend
\param N/A CNcomment:无 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_pke_deinit(td_void);
/* *
\brief Generate ECC public/private key pair.
CNcomment: 生成ECC公私密钥对。 CNend
\attention \n
N/A
\param[in] curve_type: ECC curve type. CNcomment: ECC 曲线类型. CNend
\param[in] input_priv_key: Buffer containing an optional input private key from which the public has to be generated.
The caller ensures it is padded with leading zeros if the effective size of this key is
smaller than the u32KeySize. If no private key is provided as
input (\c input_priv_key=NULL), function generates a random private key and stores it in
output_priv_key this buffer.
CNcomment: ECC的私钥长度不足Key的大小前面补0, 如果为空指针,该函数将生成一个私钥放到
output_priv_key中。 CNend
\param[out] output_priv_key: Buffer where to write the generated private key, in case no private key is provided as
input (input_priv_key==NULL). It must be padded with leading zeros if the effective size
of the private key is smaller than the buffer size.
CNcomment: ECC的私钥长度不足Key的大小前面补0, 如果input_priv_key为空指针该函数将生成
一个私钥放到这个buffer中。 CNend
\param[out] output_pub_key: Buffer where to write the X/Y coordinates of the generated public key.
It must be padded with leading zeros if the effective size of the public key X coordinates
is smaller than the buffer size. CNcomment: ECC公钥X/Y坐标. CNend
\retval ::TD_SUCCESS Call this API succussful. CNcomment:API系统调用成功。 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败。 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_pke_ecc_gen_key(uapi_cipher_pke_ecc_type curve_type,
const uapi_cipher_pke_data *input_priv_key, const uapi_cipher_pke_data *output_priv_key,
const uapi_cipher_ecc_point *output_pub_key);
/* *
\brief Generate ECDH key pair.
CNcomment: 生成ECDH共享密钥。 CNend
\attention \n
N/A
\param[in] curve_type: ECC curve type. CNcomment: ECC 曲线类型. CNend
\param[in] input_pub_key: Buffer containing ECC public key.
CNcomment: ECC的公钥长度不足Key的大小前面补0。 CNend
\param[in] input_priv_key: Buffer containing ECC private key.
CNcomment: ECC的私钥长度不足Key的大小前面补0。 CNend
\param[out] output_shared_key: Buffer containing output shared key. CNcomment: ECDH 共享密钥. CNend
\retval ::TD_SUCCESS Call this API succussful. CNcomment:API系统调用成功。 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败。 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_pke_ecc_gen_ecdh_key(uapi_cipher_pke_ecc_type curve_type,
const uapi_cipher_ecc_point *input_pub_key, const uapi_cipher_pke_data *input_priv_key,
const uapi_cipher_pke_data *output_shared_key);
/* *
\brief ECC ecdsa sign.
CNcomment: ECDSA 签名。 CNend
\attention \n
N/A
\param[in] curve_type: ECC curve type. CNcomment: ECC 曲线类型. CNend
\param[in] priv_key: Buffer containing ECC private key.
CNcomment: ECC的私钥长度不足Key的大小前面补0。 CNend
\param[in] hash: Buffer containing Hash.
CNcomment: 待签名的 Hash。 CNend
\param[out] sig: Buffer containing output signature. CNcomment: 生成的签名. CNend
\retval ::TD_SUCCESS Call this API succussful. CNcomment:API系统调用成功。 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败。 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_pke_ecdsa_sign(uapi_cipher_pke_ecc_type curve_type, const uapi_cipher_pke_data *priv_key,
const uapi_cipher_pke_data *hash, const uapi_cipher_ecc_sig *sig);
/* *
\brief ECC ecdsa verify.
CNcomment: ECDSA 验签。 CNend
\attention \n
N/A
\param[in] curve_type: ECC curve type. CNcomment: ECC 曲线类型. CNend
\param[in] pub_key: Buffer containing ECC public key.
CNcomment: ECC的公钥长度不足Key的大小前面补0。 CNend
\param[in] hash: Buffer containing Hash.
CNcomment: 待验签的 Hash。 CNend
\param[out] sig: Buffer containing signature. CNcomment: 验签的签名. CNend
\retval ::TD_SUCCESS Call this API succussful. CNcomment:API系统调用成功。 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败。 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_pke_ecdsa_verify(uapi_cipher_pke_ecc_type curve_type, const uapi_cipher_ecc_point *pub_key,
const uapi_cipher_pke_data *hash, const uapi_cipher_ecc_sig *sig);
/* *
\brief ECC check dot on curve.
CNcomment: ECC 检查点在曲线上。 CNend
\attention \n
N/A
\param[in] curve_type: ECC curve type. CNcomment: ECC 曲线类型. CNend
\param[in] pub_key: Buffer containing ECC public key.
CNcomment: ECC的公钥长度不足Key的大小前面补0。 CNend
\param[out] is_on_curve: The check result. CNcomment: 检查结果. CNend
\retval ::TD_SUCCESS Call this API succussful. CNcomment:API系统调用成功。 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败。 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_pke_check_dot_on_curve(uapi_cipher_pke_ecc_type curve_type,
const uapi_cipher_ecc_point *pub_key, td_bool *is_on_curve);
/* *
\brief SM2 dsa hash.
CNcomment: SM2 计算杂凑 Hash。 CNend
\attention \n
N/A
\param[in] sm2_id: Buffer containing sm2_id. CNcomment: sm2_id. CNend
\param[in] pub_key: Buffer containing ECC public key.
CNcomment: ECC的公钥长度不足Key的大小前面补0。 CNend
\param[in] msg: Buffer containing message.
CNcomment: 消息。 CNend
\param[out] hash: Buffer containing output hash. CNcomment: 计算的 hash 结果. CNend
\retval ::TD_SUCCESS Call this API succussful. CNcomment:API系统调用成功。 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败。 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_pke_sm2_dsa_hash(const uapi_cipher_pke_data *sm2_id, const uapi_cipher_ecc_point *pub_key,
const uapi_cipher_pke_msg *msg, uapi_cipher_pke_data *hash);
/* *
\brief SM2 public encrypt.
CNcomment: SM2 公钥加密。 CNend
\attention \n
N/A
\param[in] pub_key: Buffer containing SM2 public key.
CNcomment: SM2的公钥长度不足Key的大小前面补0。 CNend
\param[in] plain_text: Buffer containing plain Text.
CNcomment: 明文数据。 CNend
\param[out] cipher_text: Buffer containing output cipher Text.
CNcomment: 输出的密文数据。 CNend
\retval ::TD_SUCCESS Call this API succussful. CNcomment:API系统调用成功。 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败。 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_pke_sm2_public_encrypt(const uapi_cipher_ecc_point *pub_key,
const uapi_cipher_pke_data *plain_text, const uapi_cipher_pke_data *cipher_text);
/* *
\brief SM2 private decrypt.
CNcomment: SM2 私钥解密。 CNend
\attention \n
N/A
\param[in] priv_key: Buffer containing SM2 private key.
CNcomment: SM2的私钥长度不足Key的大小前面补0。 CNend
\param[in] cipher_text: Buffer containing cipher Text.
CNcomment: 密文数据。 CNend
\param[out] plain_text: Buffer containing output plain Text.
CNcomment: 输出的明文数据。 CNend
\retval ::TD_SUCCESS Call this API succussful. CNcomment:API系统调用成功。 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败。 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_pke_sm2_private_decrypt(const uapi_cipher_pke_data *priv_key,
const uapi_cipher_pke_data *cipher_text, const uapi_cipher_pke_data *plain_text);
/* *
\brief Generate RSA key pair.
CNcomment: 生成 RSA 公私钥对。 CNend
\attention \n
N/A
\param[in] input_e: Buffer containing e.
CNcomment: RSA E 值长度不足Key的大小前面补0。 CNend
\param[in] priv_key: Buffer containing private key.
CNcomment: RSA 私钥。 CNend
\retval ::TD_SUCCESS Call this API succussful. CNcomment:API系统调用成功。 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败。 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_pke_rsa_gen_key(const uapi_cipher_pke_data *input_e, uapi_cipher_rsa_priv_key *priv_key);
/* *
\brief RSA sign.
CNcomment: RSA 签名。 CNend
\attention \n
N/A
\param[in] priv_key: Buffer containing private key.
CNcomment: RSA 私钥。 CNend
\param[in] scheme: RSA Padding Type.
CNcomment: RSA 填充方式。 CNend
\param[in] hash_type: RSA Hash Type.
CNcomment: RSA Hash 算法。 CNend
\param[in] input_hash: Buffer containing hash.
CNcomment: 待签名的 Hash。 CNend
\param[out] sign: Buffer containing output signature.
CNcomment: 生成的签名。 CNend
\retval ::TD_SUCCESS Call this API succussful. CNcomment:API系统调用成功。 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败。 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_pke_rsa_sign(const uapi_cipher_rsa_priv_key *priv_key, uapi_cipher_rsa_scheme scheme,
uapi_cipher_pke_hash_type hash_type, const uapi_cipher_pke_data *input_hash, uapi_cipher_pke_data *sign);
/* *
\brief RSA Verify.
CNcomment: RSA 签名。 CNend
\attention \n
N/A
\param[in] pub_key: Buffer containing public key.
CNcomment: RSA 公钥。 CNend
\param[in] scheme: RSA Padding Type.
CNcomment: RSA 填充方式。 CNend
\param[in] hash_type: RSA Hash Type.
CNcomment: RSA Hash 算法。 CNend
\param[in] input_hash: Buffer containing hash.
CNcomment: 待签名的 Hash。 CNend
\param[out] sign: Buffer containing output signature.
CNcomment: 生成的签名。 CNend
\retval ::TD_SUCCESS Call this API succussful. CNcomment:API系统调用成功。 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败。 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_pke_rsa_verify(const uapi_cipher_rsa_pub_key *pub_key, uapi_cipher_rsa_scheme scheme,
uapi_cipher_pke_hash_type hash_type, uapi_cipher_pke_data *input_hash, const uapi_cipher_pke_data *sig);
/* *
\brief RSA Public Encrypt.
CNcomment: RSA 公钥加密。 CNend
\attention \n
N/A
\param[in] scheme: RSA Padding Type.
CNcomment: RSA 填充方式。 CNend
\param[in] hash_type: RSA Hash Type.
CNcomment: RSA Hash 算法。 CNend
\param[in] pub_key: Buffer containing public key.
CNcomment: RSA 公钥。 CNend
\param[in] input: Buffer containing plain text.
CNcomment: 明文数据。 CNend
\param[in] label: Buffer containing lable data, could be NULL.
CNcomment: lable 数据,可以为 NULL。 CNend
\param[out] output: Buffer containing output cipher text.
CNcomment: 生成的密文数据。 CNend
\retval ::TD_SUCCESS Call this API succussful. CNcomment:API系统调用成功。 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败。 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_pke_rsa_public_encrypt(uapi_cipher_rsa_scheme scheme, uapi_cipher_pke_hash_type hash_type,
const uapi_cipher_rsa_pub_key *pub_key, const uapi_cipher_pke_data *input, const uapi_cipher_pke_data *label,
const uapi_cipher_pke_data *output);
/* *
\brief RSA Private Decrypt.
CNcomment: RSA 私钥解密。 CNend
\attention \n
N/A
\param[in] scheme: RSA Padding Type.
CNcomment: RSA 填充方式。 CNend
\param[in] hash_type: RSA Hash Type.
CNcomment: RSA Hash 算法。 CNend
\param[in] priv_key: Buffer containing private key.
CNcomment: RSA 私钥。 CNend
\param[in] input: Buffer containing cipher text.
CNcomment: 密文数据。 CNend
\param[in] label: Buffer containing lable data, could be NULL.
CNcomment: lable 数据,可以为 NULL。 CNend
\param[out] output: Buffer containing output plain text.
CNcomment: 生成的明文数据。 CNend
\retval ::TD_SUCCESS Call this API succussful. CNcomment:API系统调用成功。 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败。 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_pke_rsa_private_decrypt(uapi_cipher_rsa_scheme scheme, uapi_cipher_pke_hash_type hash_type,
const uapi_cipher_rsa_priv_key *priv_key, const uapi_cipher_pke_data *input, const uapi_cipher_pke_data *label,
uapi_cipher_pke_data *output);
/* *
\brief Generate Diffie-Hellman public/private key pair from g and p parameters. The public key is equal to g^x mod p,
where x is random number considered as the private key.
CNcomment: 生成DH公私密钥对。 CNend
\attention \n
N/A
\param[in] g_data: DH's g parameter. CNcomment: DH的g参数长度不足Key的大小前面补0. CNend
\param[in] p_data: DH's p parameter. CNcomment: DH的p参数长度不足Key的大小前面补0. CNend
\param[in] input_priv_key: DH's private key.
CNcomment: DH的私钥长度不足Key的大小前面补0, 如果为空指针该函数将生成一个私钥放到output_priv_key中. CNend
\param[out] output_priv_key: DH's output private key.
CNcomment: DH的输出私钥. CNend
\param[in] input_priv_key: DH's private key.
CNcomment: DH的输出公钥. CNend
\retval ::TD_SUCCESS Call this API succussful. CNcomment:API系统调用成功。 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败。 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_pke_dh_gen_key(uapi_cipher_pke_data *g_data, uapi_cipher_pke_data *p_data,
uapi_cipher_pke_data *input_priv_key, uapi_cipher_pke_data *output_priv_key, uapi_cipher_pke_data *pub_key);
/* *
\brief Compute Diffie-Hellman shared secret as otherPubKey^privKey mod p.
CNcomment: 计算DH共享密钥。 CNend
\attention \n
N/A
\param[in] p_data: Buffer containing the DH prime modulus p used for the operation. CNcomment: DH参数p. CNend
\param[in] priv_key: Buffer containing the DH private key. The caller ensures it is padded with leading zeros if the
effective size of this key is smaller than the u32KeySize.
CNcomment: DH私钥长度不足Key的大小前面补0。 CNend
\param[in] other_pub_key: Buffer containing the DH public key of the other peer. The caller ensures it is padded with
leading zeros if the effective size of this key is smaller than the u32KeySize.
CNcomment: 对方的DH公钥长度不足Key的大小前面补0。 CNend
\param[out] shared_secret: Buffer where to write the computed shared secret. The caller ensures it is padded with
leading zeros if the effective size of this key is smaller than the u32KeySize.
CNcomment: DH共享密钥长度不足Key的大小前面补0。 CNend
\param[in] key_size: DH key size. CNcomment: DH密钥长度. CNend
\retval ::TD_SUCCESS Call this API succussful. CNcomment:API系统调用成功。 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败。 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_pke_dh_compute_key(uapi_cipher_pke_data *p_data, uapi_cipher_pke_data *priv_key,
uapi_cipher_pke_data *other_pub_key, uapi_cipher_pke_data *shared_secret);
/* *
\brief Hash Calculate. CNcomment:Hash 单次计算。 CNend
CNcomment:调用此接口初始化hash设备。 CNend
\param[in] hash_type: Hash Type.
CNcomment: Hash 算法。 CNend
\param[in] input: Buffer containing Message.
CNcomment: 输入的消息。 CNend
\param[in] input_len: Message Length.
CNcomment: 输入的消息长度。 CNend
\param[output] hash: Buffer containing output hash.
CNcomment: 输出的 Hash。 CNend
\param[in] hash_len: Hash Buffer Length.
CNcomment: Hash Buffer 长度。 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_hash(uapi_cipher_hash_type hash_type, const td_u8 *input,
td_u32 input_len, td_u8 *hash, td_u32 hash_len);
/* *
\brief Init the hash device. CNcomment:初始化hash设备。 CNend
\attention \n
This API is used to start the hash device.
CNcomment:调用此接口初始化hash设备。 CNend
\param N/A CNcomment:无 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_hash_init(td_void);
/* *
\brief Deinit the hash device.
CNcomment:\brief 去初始化hash设备。 CNend
\attention \n
This API is used to stop the hash device. If this API is called repeatedly, TD_SUCCESS is returned, but only the first
operation takes effect.
CNcomment:调用此接口关闭hash设备。重复关闭返回成功第一次起作用。 CNend
\param N/A CNcomment:无 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_hash_deinit(td_void);
/* *
\brief Hash Start. CNcomment:启动 hash 计算。 CNend
\param[output] hash_handle: created hash handle.
CNcomment: 创建的 hash 句柄。 CNend
\param[in] hash_attr: Hash channel attribute.
CNcomment: Hash 通道属性。 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_hash_start(td_handle *hash_handle, const uapi_cipher_hash_attr *hash_attr);
/* *
\brief Hash Update. CNcomment:Hash Update Data。 CNend
\param[in] hash_handle: hash handle.
CNcomment: hash 句柄。 CNend
\param[in] src_buf: Buffer containing data.
CNcomment: Hash Update 传入的数据。 CNend
\param[in] len: Data Length.
CNcomment: Hash Update 传入的数据长度。 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_hash_update(td_handle hash_handle, const uapi_cipher_buf_attr *src_buf,
const td_u32 len);
/* *
\brief Hash Update. CNcomment:Hash Update Data。 CNend
\param[in] hash_handle: hash handle.
CNcomment: hash 句柄。 CNend
\param[output] out: Buffer containing output hash.
CNcomment: 输出的 hash。 CNend
\param[in/output] out_len: Hash Buffer Length.
CNcomment: 输入为 out buffer 的大小,输出为实际的 hash 长度。 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_hash_finish(td_handle hash_handle, td_u8 *out, td_u32 *out_len);
/* *
\brief Hash Get. CNcomment:Hash 获取上下文信息 CNend
\param[in] hash_handle: hash handle.
CNcomment: hash 句柄。 CNend
\param[output] hash_clone_ctx: Hash Context.
CNcomment: 输出的 hash 上下文信息。 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_hash_get(td_handle hash_handle, uapi_cipher_hash_clone_ctx *hash_clone_ctx);
/* *
\brief Hash Get. CNcomment:Hash 获取上下文信息 CNend
\param[in] hash_handle: hash handle.
CNcomment: hash 句柄。 CNend
\param[in] hash_clone_ctx: Hash Context.
CNcomment: hash 上下文信息,通过 uapi_cipher_hash_get 获取。 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_hash_set(td_handle hash_handle, const uapi_cipher_hash_clone_ctx *hash_clone_ctx);
/* *
\brief Hash Destroy. CNcomment:Hash 销毁通道 CNend
\param[in] hash_handle: hash handle.
CNcomment: hash 句柄。 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_hash_destroy(td_handle hash_handle);
/* *
\brief Init the cipher device. CNcomment:初始化cipher设备。 CNend
\attention \n
This API is used to start the cipher device.
CNcomment:调用此接口初始化cipher设备。 CNend
\param N/A CNcomment:无 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_symc_init(td_void);
/* *
\brief Deinit the cipher device.
CNcomment:\brief 去初始化cipher设备。 CNend
\attention \n
This API is used to stop the cipher device. If this API is called repeatedly, TD_SUCCESS is returned, but only the first
operation takes effect.
CNcomment:调用此接口关闭cipher设备。重复关闭返回成功第一次起作用。 CNend
\param N/A CNcomment:无 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_symc_deinit(td_void);
/* *
\brief SYMC Start. CNcomment:创建通道,启动对称加解密计算。 CNend
\param[output] symc_handle: created symc handle.
CNcomment: 创建的 symc 句柄。 CNend
\param[in] symc_attr: symc channel attribute.
CNcomment: symc 通道属性。 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_symc_create(td_handle *symc_handle, const uapi_cipher_symc_attr *symc_attr);
/* *
\brief SYMC Destroy. CNcomment:symc 销毁通道。 CNend
\param[in] symc_handle: symc handle.
CNcomment: symc 句柄。 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_symc_destroy(td_handle symc_handle);
/* *
\brief SYMC Set Crypto Config. CNcomment:配置对称加解密算法属性。 CNend
\param[in] symc_handle: symc handle.
CNcomment: symc 句柄。 CNend
\param[in] symc_ctrl: symc Config.
CNcomment: 对称加解密算法属性。 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_symc_set_config(td_handle symc_handle, const uapi_cipher_symc_ctrl_t *symc_ctrl);
/* *
\brief SYMC Attach Keyslot. CNcomment:绑定 keyslot 通道。 CNend
\param[in] symc_handle: symc handle.
CNcomment: symc 句柄。 CNend
\param[in] keyslot_handle: keyslot handle.
CNcomment: keyslot 句柄。 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_symc_attach(td_handle symc_handle, td_handle keyslot_handle);
/* *
\brief SYMC Detach Keyslot. CNcomment:解绑 keyslot 通道。 CNend
\param[in] symc_handle: symc handle.
CNcomment: symc 句柄。 CNend
\param[in] keyslot_handle: keyslot handle.
CNcomment: keyslot 句柄。 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_symc_detach(td_handle symc_handle, td_handle keyslot_handle);
/* *
\brief Get a keyslot handle which banding to cipher handle.
CNcomment获取绑定到Cipher句柄的KeySlot句柄。 CNend
\param[in] symc_handle: cipher handle CNcomment:CIPHER句柄。 CNend
\param[out] keyslot_handle: KeySlot handle CNcomment:KeySlot句柄。 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment: API系统调用失败 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_symc_get_keyslot_handle(td_handle symc_handle, td_handle *keyslot_handle);
/* *
\brief SYMC Set Key. CNcomment:对称加解密设置加解密密钥。 CNend
\param[in] symc_handle: symc handle.
CNcomment: symc 句柄。 CNend
\param[in] key: Buffer containing key.
CNcomment: 对称加解密密钥。 CNend
\param[in] key_len: Buffer containing key_len.
CNcomment: 对称加解密密钥长度。 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_symc_set_key(td_handle symc_handle, td_u8 *key, td_u32 key_len);
/* *
\brief SYMC Encryot. CNcomment:对称加密。 CNend
\param[in] symc_handle: symc handle.
CNcomment: symc 句柄。 CNend
\param[in] src_buf: Buffer containing plain text.
CNcomment: 明文数据。 CNend
\param[out] dst_buf: Buffer containing output cipher text.
CNcomment: 输出的密文数据。 CNend
\param[in] length: Data Length.
CNcomment: 加解密数据长度。 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_symc_encrypt(td_handle symc_handle, uapi_cipher_buf_attr *src_buf,
uapi_cipher_buf_attr *dst_buf, td_u32 length);
/* *
\brief SYMC Decryot. CNcomment:对称解密。 CNend
\param[in] symc_handle: symc handle.
CNcomment: symc 句柄。 CNend
\param[in] src_buf: Buffer containing plain text.
CNcomment: 密文数据。 CNend
\param[out] dst_buf: Buffer containing output cipher text.
CNcomment: 输出的明文数据。 CNend
\param[in] length: Data Length.
CNcomment: 加解密数据长度。 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_symc_decrypt(td_handle symc_handle, uapi_cipher_buf_attr *src_buf,
uapi_cipher_buf_attr *dst_buf, td_u32 length);
/* *
\brief SYMC Multiple Encryot. CNcomment:多包对称加密。 CNend
\param[in] symc_handle: symc handle.
CNcomment: symc 句柄。 CNend
\param[in] symc_ctrl: symc config.
CNcomment: 算法参数。 CNend
\param[in] src_buf_pack: Buffer containing multiple plain text packs.
CNcomment: 多个明文数据包。 CNend
\param[out] dst_buf_pack: Buffer containing multiple output cipher text packs.
CNcomment: 输出的多个密文数据包。 CNend
\param[in] pack_num: Pacakge Number.
CNcomment: 数据包数量。 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_symc_encrypt_multi(td_handle symc_handle, const uapi_cipher_symc_ctrl_t *symc_ctrl,
const uapi_cipher_symc_pack *src_buf_pack, const uapi_cipher_symc_pack *dst_buf_pack, td_u32 pack_num);
/* *
\brief SYMC Multiple Decryot. CNcomment:多包对称解密。 CNend
\param[in] symc_handle: symc handle.
CNcomment: symc 句柄。 CNend
\param[in] symc_ctrl: symc config.
CNcomment: 算法参数。 CNend
\param[in] src_buf_pack: Buffer containing multiple plain text packs.
CNcomment: 多个密文数据包。 CNend
\param[out] dst_buf_pack: Buffer containing multiple output cipher text packs.
CNcomment: 输出的多个明文数据包。 CNend
\param[in] pack_num: Pacakge Number.
CNcomment: 数据包数量。 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_symc_decrypt_multi(td_handle symc_handle, const uapi_cipher_symc_ctrl_t *symc_ctrl,
const uapi_cipher_symc_pack *src_buf_pack, const uapi_cipher_symc_pack *dst_buf_pack, td_u32 pack_num);
/* *
\brief SYMC Multiple Decryot. CNcomment:多包对称解密。 CNend
\param[in] symc_handle: symc handle.
CNcomment: symc 句柄。 CNend
\param[in] cenc_param: cenc config.
CNcomment: CENC 算法参数。 CNend
\param[in] src_buf: Buffer containing CENC cipher text.
CNcomment: CENC 密文数据。 CNend
\param[out] dst_buf: Buffer containing output plain text.
CNcomment: 输出的 CENC 明文数据。 CNend
\param[in] length: Data Length.
CNcomment: 解密数据长度。 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_symc_cenc_decrypt(td_handle symc_handle, const uapi_cipher_symc_cenc_param *cenc_param,
const uapi_cipher_buf_attr *src_buf, const uapi_cipher_buf_attr *dst_buf, td_u32 length);
/* *
\brief SYMC Get TAG. CNcomment:CCM/GCM 算法获取 TAG 值。 CNend
\param[in] symc_handle: symc handle.
CNcomment: symc 句柄。 CNend
\param[out] tag: Buffer containing output tag.
CNcomment: 生成的 tag 值。 CNend
\param[in] tag_length: tag length.
CNcomment: tag 长度。 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_symc_get_tag(td_handle symc_handle, td_u8 *tag, td_u32 tag_length);
/* *
\brief MAC Start. CNcomment:启动 MAC 计算。 CNend
\param[out] symc_handle: symc handle.
CNcomment: 创建的 symc 句柄。 CNend
\param[in] mac_attr: mac config.
CNcomment: MAC 算法参数。 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_mac_start(td_handle *symc_handle, const uapi_cipher_symc_mac_attr *mac_attr);
/* *
\brief MAC Update. CNcomment:mac 计算更新数据。 CNend
\param[in] symc_handle: symc handle.
CNcomment: symc 句柄。 CNend
\param[in] src_buf: Buffer Containing data.
CNcomment: 更新的数据。 CNend
\param[in] length: Data length.
CNcomment: 更新的数据长度。 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_mac_update(td_handle symc_handle, const uapi_cipher_buf_attr *src_buf, td_u32 length);
/* *
\brief MAC Finish. CNcomment:MAC 获取计算结果。 CNend
\param[in] symc_handle: symc handle.
CNcomment: symc 句柄。 CNend
\param[out] mac: Buffer containing output mac.
CNcomment: 输出的 mac。 CNend
\param[in/out] mac_length: MAC Buffer Length.
CNcomment: 输入为 out mac 的大小,输出为实际的 mac 长度。 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_mac_finish(td_handle symc_handle, td_u8 *mac, td_u32 *mac_length);
/* *
\brief Get the random number.
CNcomment:\brief 获取随机数。 CNend
\attention \n
This API is used to obtain the random number from the hardware.
CNcomment:调用此接口用于获取随机数。 CNend
\param[out] random_number Point to the random number. CNcomment:随机数数值。 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功。 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment:API系统调用失败。 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_trng_get_random(td_u32 *randnum);
/* *
\brief Get the random bytes.
CNcomment:\brief 获取随机数。 CNend
\attention \n
This API is used to obtain the random number from the hardware.
CNcomment:调用此接口用于获取随机数。 CNend
\param[in] bytes size of the random bytes. CNcomment:随机数大小。 CNend
\param[out] random_byte Point to the random number. CNcomment:随机数数值。 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功。 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment: API系统调用失败。 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_trng_get_multi_random(td_u32 size, td_u8 *randnum);
/* *
\brief PBKDF2 Calculate.
CNcomment:\brief PBDKF2 计算。 CNend
\param[in] param: pbkdf2 parameters.
CNcomment:PBKDF2 算法参数。 CNend
\param[out] out: Buffer containing output data.
CNcomment: 输出的派生结果 CNend
\param[in/out] out_len: Output Length.
CNcomment: 派生长度。 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功。 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment: API系统调用失败。 CNend
\see \n
N/A
*/
td_s32 uapi_cipher_pbkdf2(const uapi_cipher_kdf_pbkdf2_param *param, td_u8 *out, const td_u32 out_len);
/* *
\brief HDCP encryt/decrypt
CNcomment:\brief HDCP 加密/解密。 CNend
\param[in] hdcp_attr: hdcp parameters.
CNcomment:HDCP 算法参数。 CNend
\param[in] in: Buffer containing input data.
CNcomment: 输入数据 CNend
\param[out] out: Buffer containing output data.
CNcomment: 输出数据 CNend
\param[in] len: Data Length.
CNcomment: 数据长度。 CNend
\param[in] is_decrypt: operation flag.
CNcomment: 加解密标志。 CNend
\retval ::TD_SUCCESS Call this API successful. CNcomment:API系统调用成功。 CNend
\retval ::TD_FAILURE Call this API fails. CNcomment: API系统调用失败。 CNend
\see \n
N/A
*/
td_s32 uapi_hdcp_operation(uapi_cipher_hdcp_attr *hdcp_attr,
const td_u8 *in, td_u8 *out, td_u32 len, td_bool is_decrypt);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */
#endif