Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Side by Side Diff: nss/lib/cryptohi/keythi.h

Issue 1843333003: Update NSPR to 4.12 and NSS to 3.23 on iOS (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/nss.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* This Source Code Form is subject to the terms of the Mozilla Public 1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 #ifndef _KEYTHI_H_ 4 #ifndef _KEYTHI_H_
5 #define _KEYTHI_H_ 1 5 #define _KEYTHI_H_ 1
6 6
7 #include "plarena.h" 7 #include "plarena.h"
8 #include "pkcs11t.h" 8 #include "pkcs11t.h"
9 #include "secmodt.h" 9 #include "secmodt.h"
10 #include "prclist.h" 10 #include "prclist.h"
11 11
12 /* 12 /*
13 ** RFC 4055 Section 1.2 specifies three different RSA key types. 13 ** RFC 4055 Section 1.2 specifies three different RSA key types.
14 ** 14 **
15 ** rsaKey maps to keys with SEC_OID_PKCS1_RSA_ENCRYPTION and can be used for 15 ** rsaKey maps to keys with SEC_OID_PKCS1_RSA_ENCRYPTION and can be used for
16 ** both encryption and signatures with old (PKCS #1 v1.5) and new (PKCS #1 16 ** both encryption and signatures with old (PKCS #1 v1.5) and new (PKCS #1
17 ** v2.1) padding schemes. 17 ** v2.1) padding schemes.
18 ** 18 **
19 ** rsaPssKey maps to keys with SEC_OID_PKCS1_RSA_PSS_SIGNATURE and may only 19 ** rsaPssKey maps to keys with SEC_OID_PKCS1_RSA_PSS_SIGNATURE and may only
20 ** be used for signatures with PSS padding (PKCS #1 v2.1). 20 ** be used for signatures with PSS padding (PKCS #1 v2.1).
21 ** 21 **
22 ** rsaOaepKey maps to keys with SEC_OID_PKCS1_RSA_OAEP_ENCRYPTION and may only 22 ** rsaOaepKey maps to keys with SEC_OID_PKCS1_RSA_OAEP_ENCRYPTION and may only
23 ** be used for encryption with OAEP padding (PKCS #1 v2.1). 23 ** be used for encryption with OAEP padding (PKCS #1 v2.1).
24 */ 24 */
25 25
26 typedef enum { 26 typedef enum {
27 nullKey = 0, 27 nullKey = 0,
28 rsaKey = 1, 28 rsaKey = 1,
29 dsaKey = 2, 29 dsaKey = 2,
30 fortezzaKey = 3, /* deprecated */ 30 fortezzaKey = 3, /* deprecated */
31 dhKey = 4, 31 dhKey = 4,
32 keaKey = 5, /* deprecated */ 32 keaKey = 5, /* deprecated */
33 ecKey = 6, 33 ecKey = 6,
34 rsaPssKey = 7, 34 rsaPssKey = 7,
35 rsaOaepKey = 8 35 rsaOaepKey = 8
36 } KeyType; 36 } KeyType;
37 37
38 /* 38 /*
39 ** Template Definitions 39 ** Template Definitions
40 **/ 40 **/
41 41
42 SEC_BEGIN_PROTOS 42 SEC_BEGIN_PROTOS
43 extern const SEC_ASN1Template SECKEY_RSAPublicKeyTemplate[]; 43 extern const SEC_ASN1Template SECKEY_RSAPublicKeyTemplate[];
44 extern const SEC_ASN1Template SECKEY_RSAPSSParamsTemplate[]; 44 extern const SEC_ASN1Template SECKEY_RSAPSSParamsTemplate[];
45 extern const SEC_ASN1Template SECKEY_DSAPublicKeyTemplate[]; 45 extern const SEC_ASN1Template SECKEY_DSAPublicKeyTemplate[];
46 extern const SEC_ASN1Template SECKEY_DHPublicKeyTemplate[]; 46 extern const SEC_ASN1Template SECKEY_DHPublicKeyTemplate[];
47 extern const SEC_ASN1Template SECKEY_DHParamKeyTemplate[]; 47 extern const SEC_ASN1Template SECKEY_DHParamKeyTemplate[];
48 extern const SEC_ASN1Template SECKEY_PQGParamsTemplate[]; 48 extern const SEC_ASN1Template SECKEY_PQGParamsTemplate[];
49 extern const SEC_ASN1Template SECKEY_DSAPrivateKeyExportTemplate[]; 49 extern const SEC_ASN1Template SECKEY_DSAPrivateKeyExportTemplate[];
50 50
51 /* Windows DLL accessor functions */ 51 /* Windows DLL accessor functions */
52 SEC_ASN1_CHOOSER_DECLARE(SECKEY_DSAPublicKeyTemplate) 52 SEC_ASN1_CHOOSER_DECLARE(SECKEY_DSAPublicKeyTemplate)
53 SEC_ASN1_CHOOSER_DECLARE(SECKEY_RSAPublicKeyTemplate) 53 SEC_ASN1_CHOOSER_DECLARE(SECKEY_RSAPublicKeyTemplate)
54 SEC_ASN1_CHOOSER_DECLARE(SECKEY_RSAPSSParamsTemplate) 54 SEC_ASN1_CHOOSER_DECLARE(SECKEY_RSAPSSParamsTemplate)
55 SEC_END_PROTOS 55 SEC_END_PROTOS
56 56
57
58 /* 57 /*
59 ** RSA Public Key structures 58 ** RSA Public Key structures
60 ** member names from PKCS#1, section 7.1 59 ** member names from PKCS#1, section 7.1
61 */ 60 */
62 61
63 struct SECKEYRSAPublicKeyStr { 62 struct SECKEYRSAPublicKeyStr {
64 PLArenaPool * arena; 63 PLArenaPool *arena;
65 SECItem modulus; 64 SECItem modulus;
66 SECItem publicExponent; 65 SECItem publicExponent;
67 }; 66 };
68 typedef struct SECKEYRSAPublicKeyStr SECKEYRSAPublicKey; 67 typedef struct SECKEYRSAPublicKeyStr SECKEYRSAPublicKey;
69 68
70 /* 69 /*
71 ** RSA-PSS parameters 70 ** RSA-PSS parameters
72 */ 71 */
73 struct SECKEYRSAPSSParamsStr { 72 struct SECKEYRSAPSSParamsStr {
74 SECAlgorithmID *hashAlg; 73 SECAlgorithmID *hashAlg;
75 SECAlgorithmID *maskAlg; 74 SECAlgorithmID *maskAlg;
76 SECItem saltLength; 75 SECItem saltLength;
77 SECItem trailerField; 76 SECItem trailerField;
78 }; 77 };
79 typedef struct SECKEYRSAPSSParamsStr SECKEYRSAPSSParams; 78 typedef struct SECKEYRSAPSSParamsStr SECKEYRSAPSSParams;
80 79
81 /* 80 /*
82 ** DSA Public Key and related structures 81 ** DSA Public Key and related structures
83 */ 82 */
84 83
85 struct SECKEYPQGParamsStr { 84 struct SECKEYPQGParamsStr {
86 PLArenaPool *arena; 85 PLArenaPool *arena;
87 SECItem prime; /* p */ 86 SECItem prime; /* p */
88 SECItem subPrime; /* q */ 87 SECItem subPrime; /* q */
89 SECItem base; /* g */ 88 SECItem base; /* g */
90 /* XXX chrisk: this needs to be expanded to hold j and validationParms (RFC2 459 7.3.2) */ 89 /* XXX chrisk: this needs to be expanded to hold j and validationParms (RFC2 459 7.3.2) */
91 }; 90 };
92 typedef struct SECKEYPQGParamsStr SECKEYPQGParams; 91 typedef struct SECKEYPQGParamsStr SECKEYPQGParams;
93 92
94 struct SECKEYDSAPublicKeyStr { 93 struct SECKEYDSAPublicKeyStr {
95 SECKEYPQGParams params; 94 SECKEYPQGParams params;
96 SECItem publicValue; 95 SECItem publicValue;
97 }; 96 };
98 typedef struct SECKEYDSAPublicKeyStr SECKEYDSAPublicKey; 97 typedef struct SECKEYDSAPublicKeyStr SECKEYDSAPublicKey;
99 98
100
101 /* 99 /*
102 ** Diffie-Hellman Public Key structure 100 ** Diffie-Hellman Public Key structure
103 ** Structure member names suggested by PKCS#3. 101 ** Structure member names suggested by PKCS#3.
104 */ 102 */
105 struct SECKEYDHParamsStr { 103 struct SECKEYDHParamsStr {
106 PLArenaPool * arena; 104 PLArenaPool *arena;
107 SECItem prime; /* p */ 105 SECItem prime; /* p */
108 SECItem base; /* g */ 106 SECItem base; /* g */
109 }; 107 };
110 typedef struct SECKEYDHParamsStr SECKEYDHParams; 108 typedef struct SECKEYDHParamsStr SECKEYDHParams;
111 109
112 struct SECKEYDHPublicKeyStr { 110 struct SECKEYDHPublicKeyStr {
113 PLArenaPool * arena; 111 PLArenaPool *arena;
114 SECItem prime; 112 SECItem prime;
115 SECItem base; 113 SECItem base;
116 SECItem publicValue; 114 SECItem publicValue;
117 }; 115 };
118 typedef struct SECKEYDHPublicKeyStr SECKEYDHPublicKey; 116 typedef struct SECKEYDHPublicKeyStr SECKEYDHPublicKey;
119 117
120 /* 118 /*
121 ** Elliptic curve Public Key structure 119 ** Elliptic curve Public Key structure
122 ** The PKCS#11 layer needs DER encoding of ANSI X9.62 120 ** The PKCS#11 layer needs DER encoding of ANSI X9.62
123 ** parameters value 121 ** parameters value
124 */ 122 */
125 typedef SECItem SECKEYECParams; 123 typedef SECItem SECKEYECParams;
126 124
127 struct SECKEYECPublicKeyStr { 125 struct SECKEYECPublicKeyStr {
128 SECKEYECParams DEREncodedParams; 126 SECKEYECParams DEREncodedParams;
129 int size; /* size in bits */ 127 int size; /* size in bits */
130 SECItem publicValue; /* encoded point */ 128 SECItem publicValue; /* encoded point */
131 /* XXX Even though the PKCS#11 interface takes encoded parameters, 129 /* XXX Even though the PKCS#11 interface takes encoded parameters,
132 * we may still wish to decode them above PKCS#11 for things like 130 * we may still wish to decode them above PKCS#11 for things like
133 * printing key information. For named curves, which is what 131 * printing key information. For named curves, which is what
134 * we initially support, we ought to have the curve name at the 132 * we initially support, we ought to have the curve name at the
135 * very least. 133 * very least.
136 */ 134 */
137 }; 135 };
138 typedef struct SECKEYECPublicKeyStr SECKEYECPublicKey; 136 typedef struct SECKEYECPublicKeyStr SECKEYECPublicKey;
139 137
140 /* 138 /*
141 ** FORTEZZA Public Key structures 139 ** FORTEZZA Public Key structures
142 */ 140 */
143 struct SECKEYFortezzaPublicKeyStr { 141 struct SECKEYFortezzaPublicKeyStr {
144 int KEAversion; 142 int KEAversion;
145 int DSSversion; 143 int DSSversion;
146 unsigned char KMID[8]; 144 unsigned char KMID[8];
147 SECItem clearance; 145 SECItem clearance;
148 SECItem KEApriviledge; 146 SECItem KEApriviledge;
149 SECItem DSSpriviledge; 147 SECItem DSSpriviledge;
150 SECItem KEAKey; 148 SECItem KEAKey;
151 SECItem DSSKey; 149 SECItem DSSKey;
152 SECKEYPQGParams params; 150 SECKEYPQGParams params;
153 SECKEYPQGParams keaParams; 151 SECKEYPQGParams keaParams;
154 }; 152 };
155 typedef struct SECKEYFortezzaPublicKeyStr SECKEYFortezzaPublicKey; 153 typedef struct SECKEYFortezzaPublicKeyStr SECKEYFortezzaPublicKey;
156 #define KEAprivilege KEApriviledge /* corrected spelling */ 154 #define KEAprivilege KEApriviledge /* corrected spelling */
157 #define DSSprivilege DSSpriviledge /* corrected spelling */ 155 #define DSSprivilege DSSpriviledge /* corrected spelling */
158 156
159 struct SECKEYDiffPQGParamsStr { 157 struct SECKEYDiffPQGParamsStr {
160 SECKEYPQGParams DiffKEAParams; 158 SECKEYPQGParams DiffKEAParams;
161 SECKEYPQGParams DiffDSAParams; 159 SECKEYPQGParams DiffDSAParams;
162 }; 160 };
163 typedef struct SECKEYDiffPQGParamsStr SECKEYDiffPQGParams; 161 typedef struct SECKEYDiffPQGParamsStr SECKEYDiffPQGParams;
164 162
165 struct SECKEYPQGDualParamsStr { 163 struct SECKEYPQGDualParamsStr {
166 SECKEYPQGParams CommParams; 164 SECKEYPQGParams CommParams;
167 SECKEYDiffPQGParams DiffParams; 165 SECKEYDiffPQGParams DiffParams;
168 }; 166 };
169 typedef struct SECKEYPQGDualParamsStr SECKEYPQGDualParams; 167 typedef struct SECKEYPQGDualParamsStr SECKEYPQGDualParams;
170 168
171 struct SECKEYKEAParamsStr { 169 struct SECKEYKEAParamsStr {
172 PLArenaPool *arena; 170 PLArenaPool *arena;
173 SECItem hash; 171 SECItem hash;
174 }; 172 };
175 typedef struct SECKEYKEAParamsStr SECKEYKEAParams; 173 typedef struct SECKEYKEAParamsStr SECKEYKEAParams;
176 174
177 struct SECKEYKEAPublicKeyStr { 175 struct SECKEYKEAPublicKeyStr {
178 SECKEYKEAParams params; 176 SECKEYKEAParams params;
179 SECItem publicValue; 177 SECItem publicValue;
180 }; 178 };
181 typedef struct SECKEYKEAPublicKeyStr SECKEYKEAPublicKey; 179 typedef struct SECKEYKEAPublicKeyStr SECKEYKEAPublicKey;
182 180
183 /* 181 /*
184 ** A Generic public key object. 182 ** A Generic public key object.
185 */ 183 */
186 struct SECKEYPublicKeyStr { 184 struct SECKEYPublicKeyStr {
187 PLArenaPool *arena; 185 PLArenaPool *arena;
188 KeyType keyType; 186 KeyType keyType;
189 PK11SlotInfo *pkcs11Slot; 187 PK11SlotInfo *pkcs11Slot;
190 CK_OBJECT_HANDLE pkcs11ID; 188 CK_OBJECT_HANDLE pkcs11ID;
191 union { 189 union {
192 SECKEYRSAPublicKey rsa; 190 SECKEYRSAPublicKey rsa;
193 » SECKEYDSAPublicKey dsa; 191 SECKEYDSAPublicKey dsa;
194 » SECKEYDHPublicKey dh; 192 SECKEYDHPublicKey dh;
195 SECKEYKEAPublicKey kea; 193 SECKEYKEAPublicKey kea;
196 SECKEYFortezzaPublicKey fortezza; 194 SECKEYFortezzaPublicKey fortezza;
197 » SECKEYECPublicKey ec; 195 SECKEYECPublicKey ec;
198 } u; 196 } u;
199 }; 197 };
200 typedef struct SECKEYPublicKeyStr SECKEYPublicKey; 198 typedef struct SECKEYPublicKeyStr SECKEYPublicKey;
201 199
202 /* bit flag definitions for staticflags */ 200 /* bit flag definitions for staticflags */
203 #define SECKEY_Attributes_Cached 0x1 /* bit 0 states 201 #define SECKEY_Attributes_Cached 0x1 /* bit 0 states \
204 whether attributes are cached */ 202 whether attributes are cached */
205 #define SECKEY_CKA_PRIVATE (1U << 1) /* bit 1 is the value of CKA_PRIVATE */ 203 #define SECKEY_CKA_PRIVATE (1U << 1) /* bit 1 is the value of CKA_PRIVATE */
206 #define SECKEY_CKA_ALWAYS_AUTHENTICATE (1U << 2) 204 #define SECKEY_CKA_ALWAYS_AUTHENTICATE (1U << 2)
207 205
208 #define SECKEY_ATTRIBUTES_CACHED(key) \ 206 #define SECKEY_ATTRIBUTES_CACHED(key) \
209 (0 != (key->staticflags & SECKEY_Attributes_Cached)) 207 (0 != (key->staticflags & SECKEY_Attributes_Cached))
210 208
211 #define SECKEY_ATTRIBUTE_VALUE(key,attribute) \ 209 #define SECKEY_ATTRIBUTE_VALUE(key,attribute) \
212 (0 != (key->staticflags & SECKEY_##attribute)) 210 (0 != (key->staticflags & SECKEY_##attribute))
213 211
214 #define SECKEY_HAS_ATTRIBUTE_SET(key,attribute) \ 212 #define SECKEY_HAS_ATTRIBUTE_SET(key,attribute) \
215 (0 != (key->staticflags & SECKEY_Attributes_Cached)) ? \ 213 (0 != (key->staticflags & SECKEY_Attributes_Cached)) ? \
216 (0 != (key->staticflags & SECKEY_##attribute)) : \ 214 (0 != (key->staticflags & SECKEY_##attribute)) : \
217 PK11_HasAttributeSet(key->pkcs11Slot,key->pkcs11ID,attribute, PR_FALSE) 215 PK11_HasAttributeSet(key->pkcs11Slot,key->pkcs11ID,attribute, PR_FALSE)
218 216
219 #define SECKEY_HAS_ATTRIBUTE_SET_LOCK(key,attribute, haslock) \ 217 #define SECKEY_HAS_ATTRIBUTE_SET_LOCK(key,attribute, haslock) \
220 (0 != (key->staticflags & SECKEY_Attributes_Cached)) ? \ 218 (0 != (key->staticflags & SECKEY_Attributes_Cached)) ? \
221 (0 != (key->staticflags & SECKEY_##attribute)) : \ 219 (0 != (key->staticflags & SECKEY_##attribute)) : \
222 PK11_HasAttributeSet(key->pkcs11Slot,key->pkcs11ID,attribute, haslock) 220 PK11_HasAttributeSet(key->pkcs11Slot,key->pkcs11ID,attribute, haslock)
223 221
224 /* 222 /*
225 ** A generic key structure 223 ** A generic key structure
226 */ 224 */
227 struct SECKEYPrivateKeyStr { 225 struct SECKEYPrivateKeyStr {
228 PLArenaPool *arena; 226 PLArenaPool *arena;
229 KeyType keyType; 227 KeyType keyType;
230 PK11SlotInfo *pkcs11Slot;» /* pkcs11 slot this key lives in */ 228 PK11SlotInfo *pkcs11Slot; /* pkcs11 slot this key lives in */
231 CK_OBJECT_HANDLE pkcs11ID; /* ID of pkcs11 object */ 229 CK_OBJECT_HANDLE pkcs11ID; /* ID of pkcs11 object */
232 PRBool pkcs11IsTemp;» /* temp pkcs11 object, delete it when done */ 230 PRBool pkcs11IsTemp; /* temp pkcs11 object, delete it when done */
233 void *wincx;» » /* context for errors and pw prompts */ 231 void *wincx; /* context for errors and pw prompts */
234 PRUint32 staticflags; /* bit flag of cached PKCS#11 attributes */ 232 PRUint32 staticflags; /* bit flag of cached PKCS#11 attributes */
235 }; 233 };
236 typedef struct SECKEYPrivateKeyStr SECKEYPrivateKey; 234 typedef struct SECKEYPrivateKeyStr SECKEYPrivateKey;
237 235
238 typedef struct { 236 typedef struct {
239 PRCList links; 237 PRCList links;
240 SECKEYPrivateKey *key; 238 SECKEYPrivateKey *key;
241 } SECKEYPrivateKeyListNode; 239 } SECKEYPrivateKeyListNode;
242 240
243 typedef struct { 241 typedef struct {
244 PRCList list; 242 PRCList list;
245 PLArenaPool *arena; 243 PLArenaPool *arena;
246 } SECKEYPrivateKeyList; 244 } SECKEYPrivateKeyList;
247 245
248 typedef struct { 246 typedef struct {
249 PRCList links; 247 PRCList links;
250 SECKEYPublicKey *key; 248 SECKEYPublicKey *key;
251 } SECKEYPublicKeyListNode; 249 } SECKEYPublicKeyListNode;
252 250
253 typedef struct { 251 typedef struct {
254 PRCList list; 252 PRCList list;
255 PLArenaPool *arena; 253 PLArenaPool *arena;
256 } SECKEYPublicKeyList; 254 } SECKEYPublicKeyList;
257 #endif /* _KEYTHI_H_ */ 255 #endif /* _KEYTHI_H_ */
258
OLDNEW
« no previous file with comments | « nss/lib/cryptohi/keyi.h ('k') | nss/lib/cryptohi/sechash.h » ('j') | nss/lib/util/secoid.c » ('J')

Powered by Google App Engine
This is Rietveld 408576698