WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
crypto_pke_struct.h
浏览该文件的文档.
1
9#ifndef CRYPTO_PKE_STRUCT_H
10#define CRYPTO_PKE_STRUCT_H
11
13
31
32typedef enum {
33 DRV_PKE_ECC_TYPE_RFC5639_P256 = 0, /* RFC 5639 - Brainpool P256/384/512 */
34 DRV_PKE_ECC_TYPE_RFC5639_P384, /* RFC 5639 - Brainpool P256/384/512 */
35 DRV_PKE_ECC_TYPE_RFC5639_P512, /* RFC 5639 - Brainpool P256/384/512 */
36 DRV_PKE_ECC_TYPE_FIPS_P256K, /* NIST FIPS 186-4 P192/224/256/384/521, suggest not to use */
37 DRV_PKE_ECC_TYPE_FIPS_P192R, /* NIST FIPS 186-4 P192/224/256/384/521, suggest not to use */
38 DRV_PKE_ECC_TYPE_FIPS_P224R, /* NIST FIPS 186-4 P192/224/256/384/521, suggest not to use */
39 DRV_PKE_ECC_TYPE_FIPS_P256R, /* NIST FIPS 186-4 P192/224/256/384/521, suggest not to use */
40 DRV_PKE_ECC_TYPE_FIPS_P384R, /* NIST FIPS 186-4 P192/224/256/384/521, suggest not to use */
41 DRV_PKE_ECC_TYPE_FIPS_P521R, /* NIST FIPS 186-4 P192/224/256/384/521, suggest not to use */
42 DRV_PKE_ECC_TYPE_RFC7748, /* RFC 7748 - Curve25519 */
43 DRV_PKE_ECC_TYPE_RFC7748_448, /* RFC 7748 - Curve448 */
44 DRV_PKE_ECC_TYPE_RFC8032, /* RFC 8032 - ED25519 */
45 DRV_PKE_ECC_TYPE_SM2, /* GMT 0003.2-2012 */
49
50typedef enum {
51 DRV_PKE_RSA_SCHEME_PKCS1_V15 = 0x00, /* PKCS#1 V15 */
52 DRV_PKE_RSA_SCHEME_PKCS1_V21, /* PKCS#1 V21, PSS for signning, OAEP for encryption */
56
67
73
74typedef struct {
78
79/* * struct of ecc point */
80typedef struct {
81 td_u8 *x; /* X coordinates of the generated public key, the caller ensures it is padded with leading
82 zeros if the effective size of this key is smaller than ecc key size. */
83 td_u8 *y; /* Y coordinates of the generated public key, the caller ensures it is padded with leading
84 zeros if the effective size of this key is smaller than ecc key size. */
87
88/* * struct of ecc signature */
89typedef struct {
90 td_u8 *r; /* r component of the signature. */
91 td_u8 *s; /* s component of the signature. */
94
95/* * struct of ecc curves parameters. */
96typedef struct {
97 const td_u8 *p; /* prime specifying the base field. It is p (RFC5639), p (FIPS), p (RFC7748). */
98 const td_u8 *a; /* Curve parameter a. It is A (RFC5639), c (FIPS), A24 (RFC7748), d(RFC8032). */
99 const td_u8 *b; /* Curve parameter b. It is B (RFC5639), b (FIPS), N/A (RFC7748, RFC8032). */
100 const td_u8 *gx; /* X coordinates of G which is a base point on the curve.
101 It is x (RFC5639), Gx (FIPS), U(P) (RFC7748). */
102 const td_u8 *gy; /* Y coordinates of G which is a base point on the curve.
103 It is y (RFC5639), Gy (FIPS), N/A (RFC7748). */
104 const td_u8 *n; /* Prime which is the order of G point. It is q (RFC5639), n (FIPS, RFC7748). */
105 td_u32 h; /* Cofactor, which is the order of the elliptic curve divided by the order of the point G.
106 It is h (RFC5639), h (FIPS), Cofactor (RFC7748). */
107 drv_pke_len ksize; /* Ecc key size in bytes. It corresponds to the size in bytes of the prime. */
108 drv_pke_ecc_curve_type ecc_type; /* Type of ECC curve */
110
116
117/* * RSA private key struct */
118typedef struct {
119 td_u8 *n; /* *< public modulus */
120 td_u8 *e; /* *< public exponent */
121 td_u8 *d; /* *< private exponent */
122 td_u8 *p; /* *< 1st prime factor */
123 td_u8 *q; /* *< 2nd prime factor */
124 td_u8 *dp; /* *< D % (P - 1) */
125 td_u8 *dq; /* *< D % (Q - 1) */
126 td_u8 *qp; /* *< 1 / (Q % P) */
127 td_u16 n_len; /* *< length of public modulus */
128 td_u16 e_len; /* *< length of public exponent */
129 td_u16 d_len; /* *< length of private exponent */
130 td_u16 p_len; /* *< length of 1st prime factor,should be half of u16NLen */
131 td_u16 q_len; /* *< length of 2nd prime factor,should be half of u16NLen */
132 td_u16 dp_len; /* *< length of D % (P - 1),should be half of u16NLen */
133 td_u16 dq_len; /* *< length of D % (Q - 1),should be half of u16NLen */
134 td_u16 qp_len; /* *< length of 1 / (Q % P),should be half of u16NLen */
136
137/* * struct of RSA public key */
138typedef struct {
139 td_u8 *n; /* point to public modulus */
140 td_u8 *e; /* point to public exponent */
141 td_u16 len; /* length of public modulus, max value is 512Byte */
143
144typedef struct {
145 const td_u8 *mont_a; /* the montgomerized of parameter a(RFC5639, FIPS, SM2), a24(RFC7748), d(RFC8032). */
146 const td_u8 *mont_b; /* the montgomerized of parameter b(RFC5639, FIPS, SM2), N/A(RFC7748), sqrt_m1(RFC8032). */
147 const td_u8 *mont_1_p; /* the montgomerized of const value 1 (modp) */
148 const td_u8 *mont_1_n; /* the montgomerized of const value 1 (modn) */
149 const td_u8 *rrp; /* the montgomery parameter when modulur is p */
150 const td_u8 *rrn; /* the montgomery parameter when modulur is n */
153 const td_u32 *mont_param_n; /* the montgomerized parameter when the modulur is n. */
154 const td_u32 *mont_param_p; /* the montgomerized parameter when the modulur is p. */
156
161
162#endif
drv_pke_rsa_scheme
Definition crypto_pke_struct.h:50
@ DRV_PKE_RSA_SCHEME_PKCS1_V15
Definition crypto_pke_struct.h:51
@ DRV_PKE_RSA_SCHEME_INVALID
Definition crypto_pke_struct.h:54
@ DRV_PKE_RSA_SCHEME_PKCS1_V21
Definition crypto_pke_struct.h:52
@ DRV_PKE_RSA_SCHEME_MAX
Definition crypto_pke_struct.h:53
drv_pke_len
Definition crypto_pke_struct.h:14
@ DRV_PKE_LEN_1024
Definition crypto_pke_struct.h:23
@ DRV_PKE_LEN_3072
Definition crypto_pke_struct.h:26
@ DRV_PKE_LEN_576
Definition crypto_pke_struct.h:22
@ DRV_PKE_LEN_4096
Definition crypto_pke_struct.h:27
@ DRV_PKE_LEN_MAX
Definition crypto_pke_struct.h:28
@ DRV_PKE_LEN_INVALID
Definition crypto_pke_struct.h:29
@ DRV_PKE_LEN_256
Definition crypto_pke_struct.h:17
@ DRV_PKE_LEN_521
Definition crypto_pke_struct.h:21
@ DRV_PKE_LEN_448
Definition crypto_pke_struct.h:19
@ DRV_PKE_LEN_192
Definition crypto_pke_struct.h:15
@ DRV_PKE_LEN_2048
Definition crypto_pke_struct.h:25
@ DRV_PKE_LEN_512
Definition crypto_pke_struct.h:20
@ DRV_PKE_LEN_384
Definition crypto_pke_struct.h:18
@ DRV_PKE_LEN_1536
Definition crypto_pke_struct.h:24
@ DRV_PKE_LEN_224
Definition crypto_pke_struct.h:16
drv_pke_hash_type
Definition crypto_pke_struct.h:57
@ DRV_PKE_HASH_TYPE_MAX
Definition crypto_pke_struct.h:64
@ DRV_PKE_HASH_TYPE_SHA512
Definition crypto_pke_struct.h:62
@ DRV_PKE_HASH_TYPE_SHA256
Definition crypto_pke_struct.h:60
@ DRV_PKE_HASH_TYPE_SHA224
Definition crypto_pke_struct.h:59
@ DRV_PKE_HASH_TYPE_SHA1
Definition crypto_pke_struct.h:58
@ DRV_PKE_HASH_TYPE_SM3
Definition crypto_pke_struct.h:63
@ DRV_PKE_HASH_TYPE_INVALID
Definition crypto_pke_struct.h:65
@ DRV_PKE_HASH_TYPE_SHA384
Definition crypto_pke_struct.h:61
drv_pke_ecc_curve_type
Definition crypto_pke_struct.h:32
@ DRV_PKE_ECC_TYPE_FIPS_P256K
Definition crypto_pke_struct.h:36
@ DRV_PKE_ECC_TYPE_MAX
Definition crypto_pke_struct.h:46
@ DRV_PKE_ECC_TYPE_RFC7748
Definition crypto_pke_struct.h:42
@ DRV_PKE_ECC_TYPE_FIPS_P384R
Definition crypto_pke_struct.h:40
@ DRV_PKE_ECC_TYPE_FIPS_P192R
Definition crypto_pke_struct.h:37
@ DRV_PKE_ECC_TYPE_RFC8032
Definition crypto_pke_struct.h:44
@ DRV_PKE_ECC_TYPE_INVALID
Definition crypto_pke_struct.h:47
@ DRV_PKE_ECC_TYPE_RFC5639_P256
Definition crypto_pke_struct.h:33
@ DRV_PKE_ECC_TYPE_RFC5639_P512
Definition crypto_pke_struct.h:35
@ DRV_PKE_ECC_TYPE_SM2
Definition crypto_pke_struct.h:45
@ DRV_PKE_ECC_TYPE_RFC7748_448
Definition crypto_pke_struct.h:43
@ DRV_PKE_ECC_TYPE_FIPS_P224R
Definition crypto_pke_struct.h:38
@ DRV_PKE_ECC_TYPE_FIPS_P256R
Definition crypto_pke_struct.h:39
@ DRV_PKE_ECC_TYPE_RFC5639_P384
Definition crypto_pke_struct.h:34
@ DRV_PKE_ECC_TYPE_FIPS_P521R
Definition crypto_pke_struct.h:41
drv_pke_buffer_secure
Definition crypto_pke_struct.h:68
@ DRV_PKE_BUF_SECURE
Definition crypto_pke_struct.h:70
@ DRV_PKE_BUF_INVALID
Definition crypto_pke_struct.h:71
@ DRV_PKE_BUF_NONSECURE
Definition crypto_pke_struct.h:69
Definition crypto_pke_struct.h:74
td_u32 length
Definition crypto_pke_struct.h:75
td_u8 * data
Definition crypto_pke_struct.h:76
Definition crypto_pke_struct.h:96
const td_u8 * a
Definition crypto_pke_struct.h:98
drv_pke_len ksize
Definition crypto_pke_struct.h:107
const td_u8 * gy
Definition crypto_pke_struct.h:102
drv_pke_ecc_curve_type ecc_type
Definition crypto_pke_struct.h:108
td_u32 h
Definition crypto_pke_struct.h:105
const td_u8 * b
Definition crypto_pke_struct.h:99
const td_u8 * gx
Definition crypto_pke_struct.h:100
const td_u8 * p
Definition crypto_pke_struct.h:97
const td_u8 * n
Definition crypto_pke_struct.h:104
Definition crypto_pke_struct.h:80
td_u32 length
Definition crypto_pke_struct.h:85
td_u8 * x
Definition crypto_pke_struct.h:81
td_u8 * y
Definition crypto_pke_struct.h:83
Definition crypto_pke_struct.h:89
td_u32 length
Definition crypto_pke_struct.h:92
td_u8 * r
Definition crypto_pke_struct.h:90
td_u8 * s
Definition crypto_pke_struct.h:91
Definition crypto_pke_struct.h:111
drv_pke_buffer_secure buf_sec
Definition crypto_pke_struct.h:114
td_u8 * data
Definition crypto_pke_struct.h:113
td_u32 length
Definition crypto_pke_struct.h:112
Definition crypto_pke_struct.h:118
td_u8 * q
Definition crypto_pke_struct.h:123
td_u16 q_len
Definition crypto_pke_struct.h:131
td_u8 * n
Definition crypto_pke_struct.h:119
td_u16 dp_len
Definition crypto_pke_struct.h:132
td_u16 dq_len
Definition crypto_pke_struct.h:133
td_u8 * qp
Definition crypto_pke_struct.h:126
td_u16 d_len
Definition crypto_pke_struct.h:129
td_u8 * p
Definition crypto_pke_struct.h:122
td_u16 n_len
Definition crypto_pke_struct.h:127
td_u16 e_len
Definition crypto_pke_struct.h:128
td_u16 p_len
Definition crypto_pke_struct.h:130
td_u8 * e
Definition crypto_pke_struct.h:120
td_u8 * d
Definition crypto_pke_struct.h:121
td_u8 * dp
Definition crypto_pke_struct.h:124
td_u16 qp_len
Definition crypto_pke_struct.h:134
td_u8 * dq
Definition crypto_pke_struct.h:125
Definition crypto_pke_struct.h:138
td_u8 * n
Definition crypto_pke_struct.h:139
td_u16 len
Definition crypto_pke_struct.h:141
td_u8 * e
Definition crypto_pke_struct.h:140
Definition crypto_pke_struct.h:157
const pke_ecc_init_param * default_param
Definition crypto_pke_struct.h:159
const drv_pke_ecc_curve * curve_param
Definition crypto_pke_struct.h:158
Definition crypto_pke_struct.h:144
const td_u32 * mont_param_p
Definition crypto_pke_struct.h:154
const td_u8 * rrn
Definition crypto_pke_struct.h:150
const td_u32 * mont_param_n
Definition crypto_pke_struct.h:153
const td_u8 * mont_1_n
Definition crypto_pke_struct.h:148
const td_u8 * mont_a
Definition crypto_pke_struct.h:145
const td_u8 * mont_b
Definition crypto_pke_struct.h:146
const td_u8 * mont_1_p
Definition crypto_pke_struct.h:147
const td_u8 * rrp
Definition crypto_pke_struct.h:149
const td_u8 * const_1
Definition crypto_pke_struct.h:151
const td_u8 * const_0
Definition crypto_pke_struct.h:152
unsigned short td_u16
Definition td_type.h:37
unsigned char td_u8
Definition td_type.h:36
unsigned int td_u32
Definition td_type.h:38