]> git.saurik.com Git - apple/security.git/blob - libsecurity_smime/lib/secoid.c
Security-57740.1.18.tar.gz
[apple/security.git] / libsecurity_smime / lib / secoid.c
1 /*
2 * The contents of this file are subject to the Mozilla Public
3 * License Version 1.1 (the "License"); you may not use this file
4 * except in compliance with the License. You may obtain a copy of
5 * the License at http://www.mozilla.org/MPL/
6 *
7 * Software distributed under the License is distributed on an "AS
8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9 * implied. See the License for the specific language governing
10 * rights and limitations under the License.
11 *
12 * The Original Code is the Netscape security libraries.
13 *
14 * The Initial Developer of the Original Code is Netscape
15 * Communications Corporation. Portions created by Netscape are
16 * Copyright (C) 1994-2000 Netscape Communications Corporation. All
17 * Rights Reserved.
18 *
19 * Contributor(s):
20 *
21 * Alternatively, the contents of this file may be used under the
22 * terms of the GNU General Public License Version 2 or later (the
23 * "GPL"), in which case the provisions of the GPL are applicable
24 * instead of those above. If you wish to allow use of your
25 * version of this file only under the terms of the GPL and not to
26 * allow others to use your version of this file under the MPL,
27 * indicate your decision by deleting the provisions above and
28 * replace them with the notice and other provisions required by
29 * the GPL. If you do not delete the provisions above, a recipient
30 * may use your version of this file under either the MPL or the
31 * GPL.
32 */
33
34 #include "secoid.h"
35 #include "SecAsn1Item.h"
36 #include "plhash.h"
37
38 #include <security_asn1/secerr.h>
39 #include <security_asn1/secport.h>
40
41 #if USE_CDSA_CRYPTO
42 #include <Security/cssmapple.h>
43 #else
44 #include <Security/oidsalg.h>
45 #include <CommonCrypto/CommonCryptor.h>
46 #endif
47 #include <pthread.h>
48
49 /* MISSI Mosaic Object ID space */
50 #define USGOV 0x60, 0x86, 0x48, 0x01, 0x65
51 #define MISSI USGOV, 0x02, 0x01, 0x01
52 #define MISSI_OLD_KEA_DSS MISSI, 0x0c
53 #define MISSI_OLD_DSS MISSI, 0x02
54 #define MISSI_KEA_DSS MISSI, 0x14
55 #define MISSI_DSS MISSI, 0x13
56 #define MISSI_KEA MISSI, 0x0a
57 #define MISSI_ALT_KEA MISSI, 0x16
58
59 #define NISTALGS USGOV, 3, 4
60 #define AES NISTALGS, 1
61 #define SHAXXX NISTALGS, 2
62
63 /**
64 ** The Netscape OID space is allocated by Terry Hayes. If you need
65 ** a piece of the space, contact him at thayes@netscape.com.
66 **/
67
68 /* Netscape Communications Corporation Object ID space */
69 /* { 2 16 840 1 113730 } */
70 #define NETSCAPE_OID 0x60, 0x86, 0x48, 0x01, 0x86, 0xf8, 0x42
71 #define NETSCAPE_CERT_EXT NETSCAPE_OID, 0x01
72 #define NETSCAPE_DATA_TYPE NETSCAPE_OID, 0x02
73 /* netscape directory oid - owned by Mark Smith (mcs@netscape.com) */
74 #define NETSCAPE_DIRECTORY NETSCAPE_OID, 0x03
75 #define NETSCAPE_POLICY NETSCAPE_OID, 0x04
76 #define NETSCAPE_CERT_SERVER NETSCAPE_OID, 0x05
77 #define NETSCAPE_ALGS NETSCAPE_OID, 0x06 /* algorithm OIDs */
78 #define NETSCAPE_NAME_COMPONENTS NETSCAPE_OID, 0x07
79
80 #define NETSCAPE_CERT_EXT_AIA NETSCAPE_CERT_EXT, 0x10
81 #define NETSCAPE_CERT_SERVER_CRMF NETSCAPE_CERT_SERVER, 0x01
82
83 /* these are old and should go away soon */
84 #define OLD_NETSCAPE 0x60, 0x86, 0x48, 0xd8, 0x6a
85 #define NS_CERT_EXT OLD_NETSCAPE, 0x01
86 #define NS_FILE_TYPE OLD_NETSCAPE, 0x02
87 #define NS_IMAGE_TYPE OLD_NETSCAPE, 0x03
88
89 /* RSA OID name space */
90 #define RSADSI 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d
91 #define PKCS RSADSI, 0x01
92 #define DIGEST RSADSI, 0x02
93 #define CIPHER RSADSI, 0x03
94 #define PKCS1 PKCS, 0x01
95 #define PKCS5 PKCS, 0x05
96 #define PKCS7 PKCS, 0x07
97 #define PKCS9 PKCS, 0x09
98 #define PKCS12 PKCS, 0x0c
99
100 /* Fortezza algorithm OID space: { 2 16 840 1 101 2 1 1 } */
101 /* ### mwelch -- Is this just for algorithms, or all of Fortezza? */
102 #define FORTEZZA_ALG 0x60, 0x86, 0x48, 0x01, 0x65, 0x02, 0x01, 0x01
103
104 /* Other OID name spaces */
105 #define ALGORITHM 0x2b, 0x0e, 0x03, 0x02
106 #define X500 0x55
107 #define X520_ATTRIBUTE_TYPE X500, 0x04
108 #define X500_ALG X500, 0x08
109 #define X500_ALG_ENCRYPTION X500_ALG, 0x01
110
111 /** X.509 v3 Extension OID
112 ** {joint-iso-ccitt (2) ds(5) 29}
113 **/
114 #define ID_CE_OID X500, 0x1d
115
116 #define RFC1274_ATTR_TYPE 0x09, 0x92, 0x26, 0x89, 0x93, 0xf2, 0x2c, 0x64, 0x1
117 /* #define RFC2247_ATTR_TYPE 0x09, 0x92, 0x26, 0xf5, 0x98, 0x1e, 0x64, 0x1 this is WRONG! */
118
119 /* PKCS #12 name spaces */
120 #define PKCS12_MODE_IDS PKCS12, 0x01
121 #define PKCS12_ESPVK_IDS PKCS12, 0x02
122 #define PKCS12_BAG_IDS PKCS12, 0x03
123 #define PKCS12_CERT_BAG_IDS PKCS12, 0x04
124 #define PKCS12_OIDS PKCS12, 0x05
125 #define PKCS12_PBE_IDS PKCS12_OIDS, 0x01
126 #define PKCS12_ENVELOPING_IDS PKCS12_OIDS, 0x02
127 #define PKCS12_SIGNATURE_IDS PKCS12_OIDS, 0x03
128 #define PKCS12_V2_PBE_IDS PKCS12, 0x01
129 #define PKCS9_CERT_TYPES PKCS9, 0x16
130 #define PKCS9_CRL_TYPES PKCS9, 0x17
131 #define PKCS9_SMIME_IDS PKCS9, 0x10
132 #define PKCS9_SMIME_CTYPE PKCS9_SMIME_IDS, 1
133 #define PKCS9_SMIME_ATTRS PKCS9_SMIME_IDS, 2
134 #define PKCS9_SMIME_ALGS PKCS9_SMIME_IDS, 3
135 #define PKCS12_VERSION1 PKCS12, 0x0a
136 #define PKCS12_V1_BAG_IDS PKCS12_VERSION1, 1
137
138 /* for DSA algorithm */
139 /* { iso(1) member-body(2) us(840) x9-57(10040) x9algorithm(4) } */
140 #define ANSI_X9_ALGORITHM 0x2a, 0x86, 0x48, 0xce, 0x38, 0x4
141
142 /* for DH algorithm */
143 /* { iso(1) member-body(2) us(840) x9-57(10046) number-type(2) } */
144 /* need real OID person to look at this, copied the above line
145 * and added 6 to second to last value (and changed '4' to '2' */
146 #define ANSI_X942_ALGORITHM 0x2a, 0x86, 0x48, 0xce, 0x3e, 0x2
147
148 #define VERISIGN 0x60, 0x86, 0x48, 0x01, 0x86, 0xf8, 0x45
149
150 #define PKIX 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07
151 #define PKIX_CERT_EXTENSIONS PKIX, 1
152 #define PKIX_POLICY_QUALIFIERS PKIX, 2
153 #define PKIX_KEY_USAGE PKIX, 3
154 #define PKIX_ACCESS_DESCRIPTION PKIX, 0x30
155 #define PKIX_OCSP PKIX_ACCESS_DESCRIPTION, 1
156
157 #define PKIX_ID_PKIP PKIX, 5
158 #define PKIX_ID_REGCTRL PKIX_ID_PKIP, 1
159 #define PKIX_ID_REGINFO PKIX_ID_PKIP, 2
160
161 /* Microsoft Object ID space */
162 /* { 1.3.6.1.4.1.311 } */
163 #define MICROSOFT_OID 0x2b, 0x6, 0x1, 0x4, 0x1, 0x82, 0x37
164
165 /* ECDSA OIDs from X9.62 */
166 #define ANSI_X9_62 0x2A, 0x86, 0x48, 0xCE, 0x3D
167 #define ANSI_X9_62_FIELD_TYPE ANSI_X9_62, 1
168 #define ANSI_X9_62_PUBKEY_TYPE ANSI_X9_62, 2
169 #define ANSI_X9_62_SIG_TYPE ANSI_X9_62, 4
170 #define ECDSA_WITH_SHA2 ANSI_X9_62_SIG_TYPE, 3
171
172 /* X9.63 schemes */
173 #define ANSI_X9_63 0x2B, 0x81, 0x05, 0x10, 0x86, 0x48, 0x3F
174 #define ANSI_X9_63_SCHEME ANSI_X9_63, 0
175
176 /* ECDH curves */
177 #define CERTICOM_ELL_CURVE 0x2B, 0x81, 0x04, 0x00
178
179 /* Apple OID sapce */
180 /* 1.2.840.113635 */
181 #define APPLE_OID 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x63
182 #define APPLE_DATA_SECURITY APPLE_OID, 0x64
183 #define APPLE_CMS_ATTRIBUTES APPLE_DATA_SECURITY, 0x9
184
185 #define CONST_OID static const unsigned char
186
187 CONST_OID null_oid[] = { };
188
189 CONST_OID md2[] = { DIGEST, 0x02 };
190 CONST_OID md4[] = { DIGEST, 0x04 };
191 CONST_OID md5[] = { DIGEST, 0x05 };
192
193 CONST_OID rc2cbc[] = { CIPHER, 0x02 };
194 CONST_OID rc4[] = { CIPHER, 0x04 };
195 CONST_OID desede3cbc[] = { CIPHER, 0x07 };
196 CONST_OID rc5cbcpad[] = { CIPHER, 0x09 };
197
198 CONST_OID desecb[] = { ALGORITHM, 0x06 };
199 CONST_OID descbc[] = { ALGORITHM, 0x07 };
200 CONST_OID desofb[] = { ALGORITHM, 0x08 };
201 CONST_OID descfb[] = { ALGORITHM, 0x09 };
202 CONST_OID desmac[] = { ALGORITHM, 0x0a };
203 CONST_OID sdn702DSASignature[] = { ALGORITHM, 0x0c };
204 CONST_OID isoSHAWithRSASignature[] = { ALGORITHM, 0x0f };
205 CONST_OID desede[] = { ALGORITHM, 0x11 };
206 CONST_OID sha1[] = { ALGORITHM, 0x1a };
207 CONST_OID bogusDSASignaturewithSHA1Digest[] = { ALGORITHM, 0x1b };
208
209 CONST_OID pkcs1RSAEncryption[] = { PKCS1, 0x01 };
210 CONST_OID pkcs1MD2WithRSAEncryption[] = { PKCS1, 0x02 };
211 CONST_OID pkcs1MD4WithRSAEncryption[] = { PKCS1, 0x03 };
212 CONST_OID pkcs1MD5WithRSAEncryption[] = { PKCS1, 0x04 };
213 CONST_OID pkcs1SHA1WithRSAEncryption[] = { PKCS1, 0x05 };
214 CONST_OID pkcs1SHA256WithRSAEncryption[] = { PKCS1, 11 };
215 CONST_OID pkcs1SHA384WithRSAEncryption[] = { PKCS1, 12 };
216 CONST_OID pkcs1SHA512WithRSAEncryption[] = { PKCS1, 13 };
217
218 CONST_OID pkcs5PbeWithMD2AndDEScbc[] = { PKCS5, 0x01 };
219 CONST_OID pkcs5PbeWithMD5AndDEScbc[] = { PKCS5, 0x03 };
220 CONST_OID pkcs5PbeWithSha1AndDEScbc[] = { PKCS5, 0x0a };
221
222 CONST_OID pkcs7[] = { PKCS7 };
223 CONST_OID pkcs7Data[] = { PKCS7, 0x01 };
224 CONST_OID pkcs7SignedData[] = { PKCS7, 0x02 };
225 CONST_OID pkcs7EnvelopedData[] = { PKCS7, 0x03 };
226 CONST_OID pkcs7SignedEnvelopedData[] = { PKCS7, 0x04 };
227 CONST_OID pkcs7DigestedData[] = { PKCS7, 0x05 };
228 CONST_OID pkcs7EncryptedData[] = { PKCS7, 0x06 };
229
230 CONST_OID pkcs9EmailAddress[] = { PKCS9, 0x01 };
231 CONST_OID pkcs9UnstructuredName[] = { PKCS9, 0x02 };
232 CONST_OID pkcs9ContentType[] = { PKCS9, 0x03 };
233 CONST_OID pkcs9MessageDigest[] = { PKCS9, 0x04 };
234 CONST_OID pkcs9SigningTime[] = { PKCS9, 0x05 };
235 CONST_OID pkcs9CounterSignature[] = { PKCS9, 0x06 };
236 CONST_OID pkcs9ChallengePassword[] = { PKCS9, 0x07 };
237 CONST_OID pkcs9UnstructuredAddress[] = { PKCS9, 0x08 };
238 CONST_OID pkcs9ExtendedCertificateAttributes[] = { PKCS9, 0x09 };
239 CONST_OID pkcs9SMIMECapabilities[] = { PKCS9, 15 };
240 CONST_OID pkcs9FriendlyName[] = { PKCS9, 20 };
241 CONST_OID pkcs9LocalKeyID[] = { PKCS9, 21 };
242
243 CONST_OID pkcs9X509Certificate[] = { PKCS9_CERT_TYPES, 1 };
244 CONST_OID pkcs9SDSICertificate[] = { PKCS9_CERT_TYPES, 2 };
245 CONST_OID pkcs9X509CRL[] = { PKCS9_CRL_TYPES, 1 };
246
247 /* RFC2630 (CMS) OIDs */
248 CONST_OID cmsESDH[] = { PKCS9_SMIME_ALGS, 5 };
249 CONST_OID cms3DESwrap[] = { PKCS9_SMIME_ALGS, 6 };
250 CONST_OID cmsRC2wrap[] = { PKCS9_SMIME_ALGS, 7 };
251
252 /* RFC2633 SMIME message attributes */
253 CONST_OID smimeEncryptionKeyPreference[] = { PKCS9_SMIME_ATTRS, 11 };
254 CONST_OID ms_smimeEncryptionKeyPreference[] = { MICROSOFT_OID, 0x10, 0x4 };
255
256 CONST_OID smimeSigningCertificate[] = { PKCS9_SMIME_ATTRS, 12 };
257 CONST_OID smimeTimeStampToken[] = { PKCS9_SMIME_ATTRS, 14 };
258 CONST_OID smimeTimeStampTokenInfo[] = { PKCS9_SMIME_CTYPE, 0x04 };
259
260 CONST_OID x520CommonName[] = { X520_ATTRIBUTE_TYPE, 3 };
261 CONST_OID x520CountryName[] = { X520_ATTRIBUTE_TYPE, 6 };
262 CONST_OID x520LocalityName[] = { X520_ATTRIBUTE_TYPE, 7 };
263 CONST_OID x520StateOrProvinceName[] = { X520_ATTRIBUTE_TYPE, 8 };
264 CONST_OID x520OrgName[] = { X520_ATTRIBUTE_TYPE, 10 };
265 CONST_OID x520OrgUnitName[] = { X520_ATTRIBUTE_TYPE, 11 };
266 CONST_OID x520DnQualifier[] = { X520_ATTRIBUTE_TYPE, 46 };
267
268 CONST_OID nsTypeGIF[] = { NETSCAPE_DATA_TYPE, 0x01 };
269 CONST_OID nsTypeJPEG[] = { NETSCAPE_DATA_TYPE, 0x02 };
270 CONST_OID nsTypeURL[] = { NETSCAPE_DATA_TYPE, 0x03 };
271 CONST_OID nsTypeHTML[] = { NETSCAPE_DATA_TYPE, 0x04 };
272 CONST_OID nsTypeCertSeq[] = { NETSCAPE_DATA_TYPE, 0x05 };
273
274 CONST_OID missiCertKEADSSOld[] = { MISSI_OLD_KEA_DSS };
275 CONST_OID missiCertDSSOld[] = { MISSI_OLD_DSS };
276 CONST_OID missiCertKEADSS[] = { MISSI_KEA_DSS };
277 CONST_OID missiCertDSS[] = { MISSI_DSS };
278 CONST_OID missiCertKEA[] = { MISSI_KEA };
279 CONST_OID missiCertAltKEA[] = { MISSI_ALT_KEA };
280 CONST_OID x500RSAEncryption[] = { X500_ALG_ENCRYPTION, 0x01 };
281
282 /* added for alg 1485 */
283 CONST_OID rfc1274Uid[] = { RFC1274_ATTR_TYPE, 1 };
284 CONST_OID rfc1274Mail[] = { RFC1274_ATTR_TYPE, 3 };
285 CONST_OID rfc2247DomainComponent[] = { RFC1274_ATTR_TYPE, 25 };
286
287 /* Netscape private certificate extensions */
288 CONST_OID nsCertExtNetscapeOK[] = { NS_CERT_EXT, 1 };
289 CONST_OID nsCertExtIssuerLogo[] = { NS_CERT_EXT, 2 };
290 CONST_OID nsCertExtSubjectLogo[] = { NS_CERT_EXT, 3 };
291 CONST_OID nsExtCertType[] = { NETSCAPE_CERT_EXT, 0x01 };
292 CONST_OID nsExtBaseURL[] = { NETSCAPE_CERT_EXT, 0x02 };
293 CONST_OID nsExtRevocationURL[] = { NETSCAPE_CERT_EXT, 0x03 };
294 CONST_OID nsExtCARevocationURL[] = { NETSCAPE_CERT_EXT, 0x04 };
295 CONST_OID nsExtCACRLURL[] = { NETSCAPE_CERT_EXT, 0x05 };
296 CONST_OID nsExtCACertURL[] = { NETSCAPE_CERT_EXT, 0x06 };
297 CONST_OID nsExtCertRenewalURL[] = { NETSCAPE_CERT_EXT, 0x07 };
298 CONST_OID nsExtCAPolicyURL[] = { NETSCAPE_CERT_EXT, 0x08 };
299 CONST_OID nsExtHomepageURL[] = { NETSCAPE_CERT_EXT, 0x09 };
300 CONST_OID nsExtEntityLogo[] = { NETSCAPE_CERT_EXT, 0x0a };
301 CONST_OID nsExtUserPicture[] = { NETSCAPE_CERT_EXT, 0x0b };
302 CONST_OID nsExtSSLServerName[] = { NETSCAPE_CERT_EXT, 0x0c };
303 CONST_OID nsExtComment[] = { NETSCAPE_CERT_EXT, 0x0d };
304
305 /* the following 2 extensions are defined for and used by Cartman(NSM) */
306 CONST_OID nsExtLostPasswordURL[] = { NETSCAPE_CERT_EXT, 0x0e };
307 CONST_OID nsExtCertRenewalTime[] = { NETSCAPE_CERT_EXT, 0x0f };
308
309 CONST_OID nsExtAIACertRenewal[] = { NETSCAPE_CERT_EXT_AIA, 0x01 };
310 CONST_OID nsExtCertScopeOfUse[] = { NETSCAPE_CERT_EXT, 0x11 };
311 /* Reserved Netscape (2 16 840 1 113730 1 18) = { NETSCAPE_CERT_EXT, 0x12 }; */
312
313 /* Netscape policy values */
314 CONST_OID nsKeyUsageGovtApproved[] = { NETSCAPE_POLICY, 0x01 };
315
316 /* Netscape other name types */
317 CONST_OID netscapeNickname[] = { NETSCAPE_NAME_COMPONENTS, 0x01};
318 /* Reserved Netscape REF605437
319 (2 16 840 1 113730 7 2) = { NETSCAPE_NAME_COMPONENTS, 0x02 }; */
320
321 /* OIDs needed for cert server */
322 CONST_OID netscapeRecoveryRequest[] = { NETSCAPE_CERT_SERVER_CRMF, 0x01 };
323
324
325 /* Standard x.509 v3 Certificate Extensions */
326 CONST_OID x509SubjectDirectoryAttr[] = { ID_CE_OID, 9 };
327 CONST_OID x509SubjectKeyID[] = { ID_CE_OID, 14 };
328 CONST_OID x509KeyUsage[] = { ID_CE_OID, 15 };
329 CONST_OID x509PrivateKeyUsagePeriod[] = { ID_CE_OID, 16 };
330 CONST_OID x509SubjectAltName[] = { ID_CE_OID, 17 };
331 CONST_OID x509IssuerAltName[] = { ID_CE_OID, 18 };
332 CONST_OID x509BasicConstraints[] = { ID_CE_OID, 19 };
333 CONST_OID x509NameConstraints[] = { ID_CE_OID, 30 };
334 CONST_OID x509CRLDistPoints[] = { ID_CE_OID, 31 };
335 CONST_OID x509CertificatePolicies[] = { ID_CE_OID, 32 };
336 CONST_OID x509PolicyMappings[] = { ID_CE_OID, 33 };
337 CONST_OID x509PolicyConstraints[] = { ID_CE_OID, 34 };
338 CONST_OID x509AuthKeyID[] = { ID_CE_OID, 35 };
339 CONST_OID x509ExtKeyUsage[] = { ID_CE_OID, 37 };
340 CONST_OID x509AuthInfoAccess[] = { PKIX_CERT_EXTENSIONS, 1 };
341
342 /* Standard x.509 v3 CRL Extensions */
343 CONST_OID x509CrlNumber[] = { ID_CE_OID, 20};
344 CONST_OID x509ReasonCode[] = { ID_CE_OID, 21};
345 CONST_OID x509InvalidDate[] = { ID_CE_OID, 24};
346
347 /* pkcs 12 additions */
348 CONST_OID pkcs12[] = { PKCS12 };
349 CONST_OID pkcs12ModeIDs[] = { PKCS12_MODE_IDS };
350 CONST_OID pkcs12ESPVKIDs[] = { PKCS12_ESPVK_IDS };
351 CONST_OID pkcs12BagIDs[] = { PKCS12_BAG_IDS };
352 CONST_OID pkcs12CertBagIDs[] = { PKCS12_CERT_BAG_IDS };
353 CONST_OID pkcs12OIDs[] = { PKCS12_OIDS };
354 CONST_OID pkcs12PBEIDs[] = { PKCS12_PBE_IDS };
355 CONST_OID pkcs12EnvelopingIDs[] = { PKCS12_ENVELOPING_IDS };
356 CONST_OID pkcs12SignatureIDs[] = { PKCS12_SIGNATURE_IDS };
357 CONST_OID pkcs12PKCS8KeyShrouding[] = { PKCS12_ESPVK_IDS, 0x01 };
358 CONST_OID pkcs12KeyBagID[] = { PKCS12_BAG_IDS, 0x01 };
359 CONST_OID pkcs12CertAndCRLBagID[] = { PKCS12_BAG_IDS, 0x02 };
360 CONST_OID pkcs12SecretBagID[] = { PKCS12_BAG_IDS, 0x03 };
361 CONST_OID pkcs12X509CertCRLBag[] = { PKCS12_CERT_BAG_IDS, 0x01 };
362 CONST_OID pkcs12SDSICertBag[] = { PKCS12_CERT_BAG_IDS, 0x02 };
363 CONST_OID pkcs12PBEWithSha1And128BitRC4[] = { PKCS12_PBE_IDS, 0x01 };
364 CONST_OID pkcs12PBEWithSha1And40BitRC4[] = { PKCS12_PBE_IDS, 0x02 };
365 CONST_OID pkcs12PBEWithSha1AndTripleDESCBC[] = { PKCS12_PBE_IDS, 0x03 };
366 CONST_OID pkcs12PBEWithSha1And128BitRC2CBC[] = { PKCS12_PBE_IDS, 0x04 };
367 CONST_OID pkcs12PBEWithSha1And40BitRC2CBC[] = { PKCS12_PBE_IDS, 0x05 };
368 CONST_OID pkcs12RSAEncryptionWith128BitRC4[] = { PKCS12_ENVELOPING_IDS, 0x01 };
369 CONST_OID pkcs12RSAEncryptionWith40BitRC4[] = { PKCS12_ENVELOPING_IDS, 0x02 };
370 CONST_OID pkcs12RSAEncryptionWithTripleDES[] = { PKCS12_ENVELOPING_IDS, 0x03 };
371 CONST_OID pkcs12RSASignatureWithSHA1Digest[] = { PKCS12_SIGNATURE_IDS, 0x01 };
372
373 /* pkcs 12 version 1.0 ids */
374 CONST_OID pkcs12V2PBEWithSha1And128BitRC4[] = { PKCS12_V2_PBE_IDS, 0x01 };
375 CONST_OID pkcs12V2PBEWithSha1And40BitRC4[] = { PKCS12_V2_PBE_IDS, 0x02 };
376 CONST_OID pkcs12V2PBEWithSha1And3KeyTripleDEScbc[]= { PKCS12_V2_PBE_IDS, 0x03 };
377 CONST_OID pkcs12V2PBEWithSha1And2KeyTripleDEScbc[]= { PKCS12_V2_PBE_IDS, 0x04 };
378 CONST_OID pkcs12V2PBEWithSha1And128BitRC2cbc[] = { PKCS12_V2_PBE_IDS, 0x05 };
379 CONST_OID pkcs12V2PBEWithSha1And40BitRC2cbc[] = { PKCS12_V2_PBE_IDS, 0x06 };
380
381 CONST_OID pkcs12SafeContentsID[] = { PKCS12_BAG_IDS, 0x04 };
382 CONST_OID pkcs12PKCS8ShroudedKeyBagID[] = { PKCS12_BAG_IDS, 0x05 };
383
384 CONST_OID pkcs12V1KeyBag[] = { PKCS12_V1_BAG_IDS, 0x01 };
385 CONST_OID pkcs12V1PKCS8ShroudedKeyBag[] = { PKCS12_V1_BAG_IDS, 0x02 };
386 CONST_OID pkcs12V1CertBag[] = { PKCS12_V1_BAG_IDS, 0x03 };
387 CONST_OID pkcs12V1CRLBag[] = { PKCS12_V1_BAG_IDS, 0x04 };
388 CONST_OID pkcs12V1SecretBag[] = { PKCS12_V1_BAG_IDS, 0x05 };
389 CONST_OID pkcs12V1SafeContentsBag[] = { PKCS12_V1_BAG_IDS, 0x06 };
390
391 CONST_OID pkcs12KeyUsageAttr[] = { 2, 5, 29, 15 };
392
393 CONST_OID ansix9DSASignature[] = { ANSI_X9_ALGORITHM, 0x01 };
394 CONST_OID ansix9DSASignaturewithSHA1Digest[] = { ANSI_X9_ALGORITHM, 0x03 };
395
396 /* verisign OIDs */
397 CONST_OID verisignUserNotices[] = { VERISIGN, 1, 7, 1, 1 };
398
399 /* pkix OIDs */
400 CONST_OID pkixCPSPointerQualifier[] = { PKIX_POLICY_QUALIFIERS, 1 };
401 CONST_OID pkixUserNoticeQualifier[] = { PKIX_POLICY_QUALIFIERS, 2 };
402
403 CONST_OID pkixOCSP[] = { PKIX_OCSP };
404 CONST_OID pkixOCSPBasicResponse[] = { PKIX_OCSP, 1 };
405 CONST_OID pkixOCSPNonce[] = { PKIX_OCSP, 2 };
406 CONST_OID pkixOCSPCRL[] = { PKIX_OCSP, 3 };
407 CONST_OID pkixOCSPResponse[] = { PKIX_OCSP, 4 };
408 CONST_OID pkixOCSPNoCheck[] = { PKIX_OCSP, 5 };
409 CONST_OID pkixOCSPArchiveCutoff[] = { PKIX_OCSP, 6 };
410 CONST_OID pkixOCSPServiceLocator[] = { PKIX_OCSP, 7 };
411
412 CONST_OID pkixRegCtrlRegToken[] = { PKIX_ID_REGCTRL, 1};
413 CONST_OID pkixRegCtrlAuthenticator[] = { PKIX_ID_REGCTRL, 2};
414 CONST_OID pkixRegCtrlPKIPubInfo[] = { PKIX_ID_REGCTRL, 3};
415 CONST_OID pkixRegCtrlPKIArchOptions[] = { PKIX_ID_REGCTRL, 4};
416 CONST_OID pkixRegCtrlOldCertID[] = { PKIX_ID_REGCTRL, 5};
417 CONST_OID pkixRegCtrlProtEncKey[] = { PKIX_ID_REGCTRL, 6};
418 CONST_OID pkixRegInfoUTF8Pairs[] = { PKIX_ID_REGINFO, 1};
419 CONST_OID pkixRegInfoCertReq[] = { PKIX_ID_REGINFO, 2};
420
421 CONST_OID pkixExtendedKeyUsageServerAuth[] = { PKIX_KEY_USAGE, 1 };
422 CONST_OID pkixExtendedKeyUsageClientAuth[] = { PKIX_KEY_USAGE, 2 };
423 CONST_OID pkixExtendedKeyUsageCodeSign[] = { PKIX_KEY_USAGE, 3 };
424 CONST_OID pkixExtendedKeyUsageEMailProtect[] = { PKIX_KEY_USAGE, 4 };
425 CONST_OID pkixExtendedKeyUsageTimeStamp[] = { PKIX_KEY_USAGE, 8 };
426 CONST_OID pkixOCSPResponderExtendedKeyUsage[] = { PKIX_KEY_USAGE, 9 };
427
428 /* OIDs for Netscape defined algorithms */
429 CONST_OID netscapeSMimeKEA[] = { NETSCAPE_ALGS, 0x01 };
430
431 /* Fortezza algorithm OIDs */
432 CONST_OID skipjackCBC[] = { FORTEZZA_ALG, 0x04 };
433 CONST_OID dhPublicKey[] = { ANSI_X942_ALGORITHM, 0x1 };
434
435 CONST_OID aes128_ECB[] = { AES, 1 };
436 CONST_OID aes128_CBC[] = { AES, 2 };
437 #ifdef DEFINE_ALL_AES_CIPHERS
438 CONST_OID aes128_OFB[] = { AES, 3 };
439 CONST_OID aes128_CFB[] = { AES, 4 };
440 #endif
441 CONST_OID aes128_KEY_WRAP[] = { AES, 5 };
442
443 CONST_OID aes192_ECB[] = { AES, 21 };
444 CONST_OID aes192_CBC[] = { AES, 22 };
445 #ifdef DEFINE_ALL_AES_CIPHERS
446 CONST_OID aes192_OFB[] = { AES, 23 };
447 CONST_OID aes192_CFB[] = { AES, 24 };
448 #endif
449 CONST_OID aes192_KEY_WRAP[] = { AES, 25 };
450
451 CONST_OID aes256_ECB[] = { AES, 41 };
452 CONST_OID aes256_CBC[] = { AES, 42 };
453 #ifdef DEFINE_ALL_AES_CIPHERS
454 CONST_OID aes256_OFB[] = { AES, 43 };
455 CONST_OID aes256_CFB[] = { AES, 44 };
456 #endif
457 CONST_OID aes256_KEY_WRAP[] = { AES, 45 };
458
459 CONST_OID sha256[] = { SHAXXX, 1 };
460 CONST_OID sha384[] = { SHAXXX, 2 };
461 CONST_OID sha512[] = { SHAXXX, 3 };
462 CONST_OID sha224[] = { SHAXXX, 4 };
463
464 CONST_OID ecdsaWithSHA1[] = { ANSI_X9_62_SIG_TYPE, 1 };
465 CONST_OID ecdsaWithSHA256[] = { ECDSA_WITH_SHA2, 2 };
466 CONST_OID ecdsaWithSHA384[] = { ECDSA_WITH_SHA2, 3 };
467 CONST_OID ecdsaWithSHA512[] = { ECDSA_WITH_SHA2, 4 };
468 CONST_OID ecPublicKey[] = { ANSI_X9_62_PUBKEY_TYPE, 1 };
469 /* This OID doesn't appear in a CMS msg */
470 __unused CONST_OID ecdsaSig[] = { ANSI_X9_62_SIG_TYPE };
471
472 /* ECDH curves */
473 CONST_OID secp256r1[] = { 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07 };
474 CONST_OID secp384r1[] = { CERTICOM_ELL_CURVE, 0x22 };
475 CONST_OID secp521r1[] = { CERTICOM_ELL_CURVE, 0x23 };
476
477 /* RFC 3278 */
478 CONST_OID dhSinglePassStdDHsha1kdf[] = {ANSI_X9_63_SCHEME, 2 };
479 __unused CONST_OID dhSinglePassCofactorDHsha1kdf[] = {ANSI_X9_63_SCHEME, 3 };
480 __unused CONST_OID mqvSinglePassSha1kdf[] = {ANSI_X9_63_SCHEME, 4 };
481
482 /* Apple Hash Agility */
483 CONST_OID appleHashAgility[] = {APPLE_CMS_ATTRIBUTES, 1};
484
485 /* a special case: always associated with a caller-specified OID */
486 CONST_OID noOid[] = { 0 };
487
488 #define OI(x) { sizeof x, (uint8_t *)x }
489 #ifndef SECOID_NO_STRINGS
490 #if USE_CDSA_CRYPTO
491 #define OD(oid,tag,desc,mech,ext) { OI(oid), tag, desc, mech, ext }
492 #else
493 #define OD(oid,tag,desc,mech,ext) { OI(oid), tag, desc, ext }
494 #endif
495 #else
496 #define OD(oid,tag,desc,mech,ext) { OI(oid), tag, 0, mech, ext }
497 #endif
498
499 /*
500 NOTE: the order of these entries must match the SECOidTag enum in secoidt.h!
501 @@@ We are sticking a enum type in a field of type SecAsn1AlgId, which is
502 defined as:
503 typedef struct {
504 SecAsn1Oid algorithm;
505 SecAsn1Item parameters;
506 } SecAsn1AlgId;
507 */
508 static const SECOidData oids[] = {
509 OD( null_oid, SEC_OID_UNKNOWN, "Unknown OID", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
510 OD( md2, SEC_OID_MD2, "MD2", CSSM_ALGID_MD2, INVALID_CERT_EXTENSION ),
511 OD( md4, SEC_OID_MD4, "MD4", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
512 OD( md5, SEC_OID_MD5, "MD5", CSSM_ALGID_MD5, INVALID_CERT_EXTENSION ),
513 OD( sha1, SEC_OID_SHA1, "SHA-1", CSSM_ALGID_SHA1, INVALID_CERT_EXTENSION ),
514 OD( rc2cbc, SEC_OID_RC2_CBC,
515 "RC2-CBC", CSSM_ALGID_RC2, INVALID_CERT_EXTENSION ),
516 OD( rc4, SEC_OID_RC4, "RC4", CSSM_ALGID_RC4, INVALID_CERT_EXTENSION ),
517 OD( desede3cbc, SEC_OID_DES_EDE3_CBC,
518 "DES-EDE3-CBC", CSSM_ALGID_3DES_3KEY_EDE, INVALID_CERT_EXTENSION ),
519 OD( rc5cbcpad, SEC_OID_RC5_CBC_PAD,
520 "RC5-CBCPad", CSSM_ALGID_RC5, INVALID_CERT_EXTENSION ),
521 OD( desecb, SEC_OID_DES_ECB,
522 "DES-ECB", CSSM_ALGID_DES, INVALID_CERT_EXTENSION ),
523 OD( descbc, SEC_OID_DES_CBC,
524 "DES-CBC", CSSM_ALGID_DES, INVALID_CERT_EXTENSION ),
525 OD( desofb, SEC_OID_DES_OFB,
526 "DES-OFB", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
527 OD( descfb, SEC_OID_DES_CFB,
528 "DES-CFB", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
529 OD( desmac, SEC_OID_DES_MAC,
530 "DES-MAC", CSSM_ALGID_DES, INVALID_CERT_EXTENSION ),
531 OD( desede, SEC_OID_DES_EDE,
532 "DES-EDE", CSSM_ALGID_3DES_3KEY_EDE, INVALID_CERT_EXTENSION ),
533 OD( isoSHAWithRSASignature, SEC_OID_ISO_SHA_WITH_RSA_SIGNATURE,
534 "ISO SHA with RSA Signature",
535 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
536 OD( pkcs1RSAEncryption, SEC_OID_PKCS1_RSA_ENCRYPTION,
537 "PKCS #1 RSA Encryption", CSSM_ALGID_RSA, INVALID_CERT_EXTENSION ),
538
539 /* the following Signing CSSM_ALGORITHMS should get new CKM_ values when
540 * values for CKM_RSA_WITH_MDX and CKM_RSA_WITH_SHA_1 get defined in
541 * PKCS #11.
542 */
543 OD( pkcs1MD2WithRSAEncryption, SEC_OID_PKCS1_MD2_WITH_RSA_ENCRYPTION,
544 "PKCS #1 MD2 With RSA Encryption", CSSM_ALGID_MD2WithRSA,
545 INVALID_CERT_EXTENSION ),
546 OD( pkcs1MD4WithRSAEncryption, SEC_OID_PKCS1_MD4_WITH_RSA_ENCRYPTION,
547 "PKCS #1 MD4 With RSA Encryption",
548 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
549 OD( pkcs1MD5WithRSAEncryption, SEC_OID_PKCS1_MD5_WITH_RSA_ENCRYPTION,
550 "PKCS #1 MD5 With RSA Encryption", CSSM_ALGID_MD5WithRSA,
551 INVALID_CERT_EXTENSION ),
552 OD( pkcs1SHA1WithRSAEncryption, SEC_OID_PKCS1_SHA1_WITH_RSA_ENCRYPTION,
553 "PKCS #1 SHA-1 With RSA Encryption", CSSM_ALGID_SHA1WithRSA,
554 INVALID_CERT_EXTENSION ),
555
556 OD( pkcs5PbeWithMD2AndDEScbc, SEC_OID_PKCS5_PBE_WITH_MD2_AND_DES_CBC,
557 "PKCS #5 Password Based Encryption with MD2 and DES CBC",
558 CSSM_ALGID_PKCS5_PBKDF1_MD2, INVALID_CERT_EXTENSION ),
559 OD( pkcs5PbeWithMD5AndDEScbc, SEC_OID_PKCS5_PBE_WITH_MD5_AND_DES_CBC,
560 "PKCS #5 Password Based Encryption with MD5 and DES CBC",
561 CSSM_ALGID_PKCS5_PBKDF1_MD5, INVALID_CERT_EXTENSION ),
562 OD( pkcs5PbeWithSha1AndDEScbc, SEC_OID_PKCS5_PBE_WITH_SHA1_AND_DES_CBC,
563 "PKCS #5 Password Based Encryption with SHA1 and DES CBC",
564 CSSM_ALGID_PKCS5_PBKDF1_SHA1, INVALID_CERT_EXTENSION ),
565 OD( pkcs7, SEC_OID_PKCS7,
566 "PKCS #7", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
567 OD( pkcs7Data, SEC_OID_PKCS7_DATA,
568 "PKCS #7 Data", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
569 OD( pkcs7SignedData, SEC_OID_PKCS7_SIGNED_DATA,
570 "PKCS #7 Signed Data", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
571 OD( pkcs7EnvelopedData, SEC_OID_PKCS7_ENVELOPED_DATA,
572 "PKCS #7 Enveloped Data",
573 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
574 OD( pkcs7SignedEnvelopedData, SEC_OID_PKCS7_SIGNED_ENVELOPED_DATA,
575 "PKCS #7 Signed And Enveloped Data",
576 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
577 OD( pkcs7DigestedData, SEC_OID_PKCS7_DIGESTED_DATA,
578 "PKCS #7 Digested Data",
579 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
580 OD( pkcs7EncryptedData, SEC_OID_PKCS7_ENCRYPTED_DATA,
581 "PKCS #7 Encrypted Data",
582 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
583 OD( pkcs9EmailAddress, SEC_OID_PKCS9_EMAIL_ADDRESS,
584 "PKCS #9 Email Address",
585 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
586 OD( pkcs9UnstructuredName, SEC_OID_PKCS9_UNSTRUCTURED_NAME,
587 "PKCS #9 Unstructured Name",
588 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
589 OD( pkcs9ContentType, SEC_OID_PKCS9_CONTENT_TYPE,
590 "PKCS #9 Content Type",
591 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
592 OD( pkcs9MessageDigest, SEC_OID_PKCS9_MESSAGE_DIGEST,
593 "PKCS #9 Message Digest",
594 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
595 OD( pkcs9SigningTime, SEC_OID_PKCS9_SIGNING_TIME,
596 "PKCS #9 Signing Time",
597 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
598 OD( pkcs9CounterSignature, SEC_OID_PKCS9_COUNTER_SIGNATURE,
599 "PKCS #9 Counter Signature",
600 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
601 OD( pkcs9ChallengePassword, SEC_OID_PKCS9_CHALLENGE_PASSWORD,
602 "PKCS #9 Challenge Password",
603 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
604 OD( pkcs9UnstructuredAddress, SEC_OID_PKCS9_UNSTRUCTURED_ADDRESS,
605 "PKCS #9 Unstructured Address",
606 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
607 OD( pkcs9ExtendedCertificateAttributes,
608 SEC_OID_PKCS9_EXTENDED_CERTIFICATE_ATTRIBUTES,
609 "PKCS #9 Extended Certificate Attributes",
610 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
611 OD( pkcs9SMIMECapabilities, SEC_OID_PKCS9_SMIME_CAPABILITIES,
612 "PKCS #9 S/MIME Capabilities",
613 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
614 OD( x520CommonName, SEC_OID_AVA_COMMON_NAME,
615 "X520 Common Name", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
616 OD( x520CountryName, SEC_OID_AVA_COUNTRY_NAME,
617 "X520 Country Name", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
618 OD( x520LocalityName, SEC_OID_AVA_LOCALITY,
619 "X520 Locality Name", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
620 OD( x520StateOrProvinceName, SEC_OID_AVA_STATE_OR_PROVINCE,
621 "X520 State Or Province Name",
622 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
623 OD( x520OrgName, SEC_OID_AVA_ORGANIZATION_NAME,
624 "X520 Organization Name",
625 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
626 OD( x520OrgUnitName, SEC_OID_AVA_ORGANIZATIONAL_UNIT_NAME,
627 "X520 Organizational Unit Name",
628 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
629 OD( x520DnQualifier, SEC_OID_AVA_DN_QUALIFIER,
630 "X520 DN Qualifier", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
631 OD( rfc2247DomainComponent, SEC_OID_AVA_DC,
632 "RFC 2247 Domain Component",
633 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
634
635 OD( nsTypeGIF, SEC_OID_NS_TYPE_GIF,
636 "GIF", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
637 OD( nsTypeJPEG, SEC_OID_NS_TYPE_JPEG,
638 "JPEG", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
639 OD( nsTypeURL, SEC_OID_NS_TYPE_URL,
640 "URL", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
641 OD( nsTypeHTML, SEC_OID_NS_TYPE_HTML,
642 "HTML", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
643 OD( nsTypeCertSeq, SEC_OID_NS_TYPE_CERT_SEQUENCE,
644 "Certificate Sequence",
645 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
646 OD( missiCertKEADSSOld, SEC_OID_MISSI_KEA_DSS_OLD,
647 "MISSI KEA and DSS Algorithm (Old)",
648 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
649 OD( missiCertDSSOld, SEC_OID_MISSI_DSS_OLD,
650 "MISSI DSS Algorithm (Old)",
651 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
652 OD( missiCertKEADSS, SEC_OID_MISSI_KEA_DSS,
653 "MISSI KEA and DSS Algorithm",
654 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
655 OD( missiCertDSS, SEC_OID_MISSI_DSS,
656 "MISSI DSS Algorithm",
657 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
658 OD( missiCertKEA, SEC_OID_MISSI_KEA,
659 "MISSI KEA Algorithm",
660 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
661 OD( missiCertAltKEA, SEC_OID_MISSI_ALT_KEA,
662 "MISSI Alternate KEA Algorithm",
663 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
664
665 /* Netscape private extensions */
666 OD( nsCertExtNetscapeOK, SEC_OID_NS_CERT_EXT_NETSCAPE_OK,
667 "Netscape says this cert is OK",
668 CSSM_ALGID_NONE, UNSUPPORTED_CERT_EXTENSION ),
669 OD( nsCertExtIssuerLogo, SEC_OID_NS_CERT_EXT_ISSUER_LOGO,
670 "Certificate Issuer Logo",
671 CSSM_ALGID_NONE, UNSUPPORTED_CERT_EXTENSION ),
672 OD( nsCertExtSubjectLogo, SEC_OID_NS_CERT_EXT_SUBJECT_LOGO,
673 "Certificate Subject Logo",
674 CSSM_ALGID_NONE, UNSUPPORTED_CERT_EXTENSION ),
675 OD( nsExtCertType, SEC_OID_NS_CERT_EXT_CERT_TYPE,
676 "Certificate Type",
677 CSSM_ALGID_NONE, SUPPORTED_CERT_EXTENSION ),
678 OD( nsExtBaseURL, SEC_OID_NS_CERT_EXT_BASE_URL,
679 "Certificate Extension Base URL",
680 CSSM_ALGID_NONE, SUPPORTED_CERT_EXTENSION ),
681 OD( nsExtRevocationURL, SEC_OID_NS_CERT_EXT_REVOCATION_URL,
682 "Certificate Revocation URL",
683 CSSM_ALGID_NONE, SUPPORTED_CERT_EXTENSION ),
684 OD( nsExtCARevocationURL, SEC_OID_NS_CERT_EXT_CA_REVOCATION_URL,
685 "Certificate Authority Revocation URL",
686 CSSM_ALGID_NONE, SUPPORTED_CERT_EXTENSION ),
687 OD( nsExtCACRLURL, SEC_OID_NS_CERT_EXT_CA_CRL_URL,
688 "Certificate Authority CRL Download URL",
689 CSSM_ALGID_NONE, UNSUPPORTED_CERT_EXTENSION ),
690 OD( nsExtCACertURL, SEC_OID_NS_CERT_EXT_CA_CERT_URL,
691 "Certificate Authority Certificate Download URL",
692 CSSM_ALGID_NONE, UNSUPPORTED_CERT_EXTENSION ),
693 OD( nsExtCertRenewalURL, SEC_OID_NS_CERT_EXT_CERT_RENEWAL_URL,
694 "Certificate Renewal URL",
695 CSSM_ALGID_NONE, SUPPORTED_CERT_EXTENSION ),
696 OD( nsExtCAPolicyURL, SEC_OID_NS_CERT_EXT_CA_POLICY_URL,
697 "Certificate Authority Policy URL",
698 CSSM_ALGID_NONE, SUPPORTED_CERT_EXTENSION ),
699 OD( nsExtHomepageURL, SEC_OID_NS_CERT_EXT_HOMEPAGE_URL,
700 "Certificate Homepage URL",
701 CSSM_ALGID_NONE, UNSUPPORTED_CERT_EXTENSION ),
702 OD( nsExtEntityLogo, SEC_OID_NS_CERT_EXT_ENTITY_LOGO,
703 "Certificate Entity Logo",
704 CSSM_ALGID_NONE, UNSUPPORTED_CERT_EXTENSION ),
705 OD( nsExtUserPicture, SEC_OID_NS_CERT_EXT_USER_PICTURE,
706 "Certificate User Picture",
707 CSSM_ALGID_NONE, UNSUPPORTED_CERT_EXTENSION ),
708 OD( nsExtSSLServerName, SEC_OID_NS_CERT_EXT_SSL_SERVER_NAME,
709 "Certificate SSL Server Name",
710 CSSM_ALGID_NONE, SUPPORTED_CERT_EXTENSION ),
711 OD( nsExtComment, SEC_OID_NS_CERT_EXT_COMMENT,
712 "Certificate Comment",
713 CSSM_ALGID_NONE, SUPPORTED_CERT_EXTENSION ),
714 OD( nsExtLostPasswordURL, SEC_OID_NS_CERT_EXT_LOST_PASSWORD_URL,
715 "Lost Password URL",
716 CSSM_ALGID_NONE, SUPPORTED_CERT_EXTENSION ),
717 OD( nsExtCertRenewalTime, SEC_OID_NS_CERT_EXT_CERT_RENEWAL_TIME,
718 "Certificate Renewal Time",
719 CSSM_ALGID_NONE, SUPPORTED_CERT_EXTENSION ),
720 OD( nsKeyUsageGovtApproved, SEC_OID_NS_KEY_USAGE_GOVT_APPROVED,
721 "Strong Crypto Export Approved",
722 CSSM_ALGID_NONE, UNSUPPORTED_CERT_EXTENSION ),
723
724
725 /* x.509 v3 certificate extensions */
726 OD( x509SubjectDirectoryAttr, SEC_OID_X509_SUBJECT_DIRECTORY_ATTR,
727 "Certificate Subject Directory Attributes",
728 CSSM_ALGID_NONE, UNSUPPORTED_CERT_EXTENSION),
729 OD( x509SubjectKeyID, SEC_OID_X509_SUBJECT_KEY_ID,
730 "Certificate Subject Key ID",
731 CSSM_ALGID_NONE, SUPPORTED_CERT_EXTENSION ),
732 OD( x509KeyUsage, SEC_OID_X509_KEY_USAGE,
733 "Certificate Key Usage",
734 CSSM_ALGID_NONE, SUPPORTED_CERT_EXTENSION ),
735 OD( x509PrivateKeyUsagePeriod, SEC_OID_X509_PRIVATE_KEY_USAGE_PERIOD,
736 "Certificate Private Key Usage Period",
737 CSSM_ALGID_NONE, UNSUPPORTED_CERT_EXTENSION ),
738 OD( x509SubjectAltName, SEC_OID_X509_SUBJECT_ALT_NAME,
739 "Certificate Subject Alt Name",
740 CSSM_ALGID_NONE, SUPPORTED_CERT_EXTENSION ),
741 OD( x509IssuerAltName, SEC_OID_X509_ISSUER_ALT_NAME,
742 "Certificate Issuer Alt Name",
743 CSSM_ALGID_NONE, UNSUPPORTED_CERT_EXTENSION ),
744 OD( x509BasicConstraints, SEC_OID_X509_BASIC_CONSTRAINTS,
745 "Certificate Basic Constraints",
746 CSSM_ALGID_NONE, SUPPORTED_CERT_EXTENSION ),
747 OD( x509NameConstraints, SEC_OID_X509_NAME_CONSTRAINTS,
748 "Certificate Name Constraints",
749 CSSM_ALGID_NONE, SUPPORTED_CERT_EXTENSION ),
750 OD( x509CRLDistPoints, SEC_OID_X509_CRL_DIST_POINTS,
751 "CRL Distribution Points",
752 CSSM_ALGID_NONE, UNSUPPORTED_CERT_EXTENSION ),
753 OD( x509CertificatePolicies, SEC_OID_X509_CERTIFICATE_POLICIES,
754 "Certificate Policies",
755 CSSM_ALGID_NONE, UNSUPPORTED_CERT_EXTENSION ),
756 OD( x509PolicyMappings, SEC_OID_X509_POLICY_MAPPINGS,
757 "Certificate Policy Mappings",
758 CSSM_ALGID_NONE, UNSUPPORTED_CERT_EXTENSION ),
759 OD( x509PolicyConstraints, SEC_OID_X509_POLICY_CONSTRAINTS,
760 "Certificate Policy Constraints",
761 CSSM_ALGID_NONE, UNSUPPORTED_CERT_EXTENSION ),
762 OD( x509AuthKeyID, SEC_OID_X509_AUTH_KEY_ID,
763 "Certificate Authority Key Identifier",
764 CSSM_ALGID_NONE, SUPPORTED_CERT_EXTENSION ),
765 OD( x509ExtKeyUsage, SEC_OID_X509_EXT_KEY_USAGE,
766 "Extended Key Usage",
767 CSSM_ALGID_NONE, SUPPORTED_CERT_EXTENSION ),
768 OD( x509AuthInfoAccess, SEC_OID_X509_AUTH_INFO_ACCESS,
769 "Authority Information Access",
770 CSSM_ALGID_NONE, SUPPORTED_CERT_EXTENSION ),
771
772 /* x.509 v3 CRL extensions */
773 OD( x509CrlNumber, SEC_OID_X509_CRL_NUMBER,
774 "CRL Number", CSSM_ALGID_NONE, SUPPORTED_CERT_EXTENSION ),
775 OD( x509ReasonCode, SEC_OID_X509_REASON_CODE,
776 "CRL reason code", CSSM_ALGID_NONE, SUPPORTED_CERT_EXTENSION ),
777 OD( x509InvalidDate, SEC_OID_X509_INVALID_DATE,
778 "Invalid Date", CSSM_ALGID_NONE, SUPPORTED_CERT_EXTENSION ),
779 OD( x500RSAEncryption, SEC_OID_X500_RSA_ENCRYPTION,
780 "X500 RSA Encryption", CSSM_ALGID_RSA, INVALID_CERT_EXTENSION ),
781 /* added for alg 1485 */
782 OD( rfc1274Uid, SEC_OID_RFC1274_UID,
783 "RFC1274 User Id", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
784 OD( rfc1274Mail, SEC_OID_RFC1274_MAIL,
785 "RFC1274 E-mail Address",
786 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
787
788 /* pkcs 12 additions */
789 OD( pkcs12, SEC_OID_PKCS12,
790 "PKCS #12", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
791 OD( pkcs12ModeIDs, SEC_OID_PKCS12_MODE_IDS,
792 "PKCS #12 Mode IDs", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
793 OD( pkcs12ESPVKIDs, SEC_OID_PKCS12_ESPVK_IDS,
794 "PKCS #12 ESPVK IDs", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
795 OD( pkcs12BagIDs, SEC_OID_PKCS12_BAG_IDS,
796 "PKCS #12 Bag IDs", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
797 OD( pkcs12CertBagIDs, SEC_OID_PKCS12_CERT_BAG_IDS,
798 "PKCS #12 Cert Bag IDs",
799 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
800 OD( pkcs12OIDs, SEC_OID_PKCS12_OIDS,
801 "PKCS #12 OIDs", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
802 OD( pkcs12PBEIDs, SEC_OID_PKCS12_PBE_IDS,
803 "PKCS #12 PBE IDs", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
804 OD( pkcs12SignatureIDs, SEC_OID_PKCS12_SIGNATURE_IDS,
805 "PKCS #12 Signature IDs",
806 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
807 OD( pkcs12EnvelopingIDs, SEC_OID_PKCS12_ENVELOPING_IDS,
808 "PKCS #12 Enveloping IDs",
809 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
810 OD( pkcs12PKCS8KeyShrouding, SEC_OID_PKCS12_PKCS8_KEY_SHROUDING,
811 "PKCS #12 Key Shrouding",
812 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
813 OD( pkcs12KeyBagID, SEC_OID_PKCS12_KEY_BAG_ID,
814 "PKCS #12 Key Bag ID",
815 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
816 OD( pkcs12CertAndCRLBagID, SEC_OID_PKCS12_CERT_AND_CRL_BAG_ID,
817 "PKCS #12 Cert And CRL Bag ID",
818 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
819 OD( pkcs12SecretBagID, SEC_OID_PKCS12_SECRET_BAG_ID,
820 "PKCS #12 Secret Bag ID",
821 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
822 OD( pkcs12X509CertCRLBag, SEC_OID_PKCS12_X509_CERT_CRL_BAG,
823 "PKCS #12 X509 Cert CRL Bag",
824 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
825 OD( pkcs12SDSICertBag, SEC_OID_PKCS12_SDSI_CERT_BAG,
826 "PKCS #12 SDSI Cert Bag",
827 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
828 OD( pkcs12PBEWithSha1And128BitRC4,
829 SEC_OID_PKCS12_PBE_WITH_SHA1_AND_128_BIT_RC4,
830 "PKCS #12 PBE With Sha1 and 128 Bit RC4",
831 CSSM_ALGID_PKCS12_SHA1_PBE, INVALID_CERT_EXTENSION ),
832 OD( pkcs12PBEWithSha1And40BitRC4,
833 SEC_OID_PKCS12_PBE_WITH_SHA1_AND_40_BIT_RC4,
834 "PKCS #12 PBE With Sha1 and 40 Bit RC4",
835 CSSM_ALGID_PKCS12_SHA1_PBE, INVALID_CERT_EXTENSION ),
836 OD( pkcs12PBEWithSha1AndTripleDESCBC,
837 SEC_OID_PKCS12_PBE_WITH_SHA1_AND_TRIPLE_DES_CBC,
838 "PKCS #12 PBE With Sha1 and Triple DES CBC",
839 CSSM_ALGID_PKCS12_SHA1_PBE, INVALID_CERT_EXTENSION ),
840 OD( pkcs12PBEWithSha1And128BitRC2CBC,
841 SEC_OID_PKCS12_PBE_WITH_SHA1_AND_128_BIT_RC2_CBC,
842 "PKCS #12 PBE With Sha1 and 128 Bit RC2 CBC",
843 CSSM_ALGID_PKCS12_SHA1_PBE, INVALID_CERT_EXTENSION ),
844 OD( pkcs12PBEWithSha1And40BitRC2CBC,
845 SEC_OID_PKCS12_PBE_WITH_SHA1_AND_40_BIT_RC2_CBC,
846 "PKCS #12 PBE With Sha1 and 40 Bit RC2 CBC",
847 CSSM_ALGID_PKCS12_SHA1_PBE, INVALID_CERT_EXTENSION ),
848 OD( pkcs12RSAEncryptionWith128BitRC4,
849 SEC_OID_PKCS12_RSA_ENCRYPTION_WITH_128_BIT_RC4,
850 "PKCS #12 RSA Encryption with 128 Bit RC4",
851 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
852 OD( pkcs12RSAEncryptionWith40BitRC4,
853 SEC_OID_PKCS12_RSA_ENCRYPTION_WITH_40_BIT_RC4,
854 "PKCS #12 RSA Encryption with 40 Bit RC4",
855 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
856 OD( pkcs12RSAEncryptionWithTripleDES,
857 SEC_OID_PKCS12_RSA_ENCRYPTION_WITH_TRIPLE_DES,
858 "PKCS #12 RSA Encryption with Triple DES",
859 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
860 OD( pkcs12RSASignatureWithSHA1Digest,
861 SEC_OID_PKCS12_RSA_SIGNATURE_WITH_SHA1_DIGEST,
862 "PKCS #12 RSA Encryption with Triple DES",
863 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
864
865 /* DSA signatures */
866 OD( ansix9DSASignature, SEC_OID_ANSIX9_DSA_SIGNATURE,
867 "ANSI X9.57 DSA Signature", CSSM_ALGID_DSA, INVALID_CERT_EXTENSION ),
868 OD( ansix9DSASignaturewithSHA1Digest,
869 SEC_OID_ANSIX9_DSA_SIGNATURE_WITH_SHA1_DIGEST,
870 "ANSI X9.57 DSA Signature with SHA1 Digest",
871 CSSM_ALGID_SHA1WithDSA, INVALID_CERT_EXTENSION ),
872 OD( bogusDSASignaturewithSHA1Digest,
873 SEC_OID_BOGUS_DSA_SIGNATURE_WITH_SHA1_DIGEST,
874 "FORTEZZA DSA Signature with SHA1 Digest",
875 CSSM_ALGID_SHA1WithDSA, INVALID_CERT_EXTENSION ),
876
877 /* verisign oids */
878 OD( verisignUserNotices, SEC_OID_VERISIGN_USER_NOTICES,
879 "Verisign User Notices",
880 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
881
882 /* pkix oids */
883 OD( pkixCPSPointerQualifier, SEC_OID_PKIX_CPS_POINTER_QUALIFIER,
884 "PKIX CPS Pointer Qualifier",
885 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
886 OD( pkixUserNoticeQualifier, SEC_OID_PKIX_USER_NOTICE_QUALIFIER,
887 "PKIX User Notice Qualifier",
888 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
889
890 OD( pkixOCSP, SEC_OID_PKIX_OCSP,
891 "PKIX Online Certificate Status Protocol",
892 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
893 OD( pkixOCSPBasicResponse, SEC_OID_PKIX_OCSP_BASIC_RESPONSE,
894 "OCSP Basic Response", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
895 OD( pkixOCSPNonce, SEC_OID_PKIX_OCSP_NONCE,
896 "OCSP Nonce Extension", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
897 OD( pkixOCSPCRL, SEC_OID_PKIX_OCSP_CRL,
898 "OCSP CRL Reference Extension",
899 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
900 OD( pkixOCSPResponse, SEC_OID_PKIX_OCSP_RESPONSE,
901 "OCSP Response Types Extension",
902 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
903 OD( pkixOCSPNoCheck, SEC_OID_PKIX_OCSP_NO_CHECK,
904 "OCSP No Check Extension",
905 CSSM_ALGID_NONE, SUPPORTED_CERT_EXTENSION ),
906 OD( pkixOCSPArchiveCutoff, SEC_OID_PKIX_OCSP_ARCHIVE_CUTOFF,
907 "OCSP Archive Cutoff Extension",
908 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
909 OD( pkixOCSPServiceLocator, SEC_OID_PKIX_OCSP_SERVICE_LOCATOR,
910 "OCSP Service Locator Extension",
911 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
912
913 OD( pkixRegCtrlRegToken, SEC_OID_PKIX_REGCTRL_REGTOKEN,
914 "PKIX CRMF Registration Control, Registration Token",
915 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
916 OD( pkixRegCtrlAuthenticator, SEC_OID_PKIX_REGCTRL_AUTHENTICATOR,
917 "PKIX CRMF Registration Control, Registration Authenticator",
918 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
919 OD( pkixRegCtrlPKIPubInfo, SEC_OID_PKIX_REGCTRL_PKIPUBINFO,
920 "PKIX CRMF Registration Control, PKI Publication Info",
921 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION),
922 OD( pkixRegCtrlPKIArchOptions,
923 SEC_OID_PKIX_REGCTRL_PKI_ARCH_OPTIONS,
924 "PKIX CRMF Registration Control, PKI Archive Options",
925 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION),
926 OD( pkixRegCtrlOldCertID, SEC_OID_PKIX_REGCTRL_OLD_CERT_ID,
927 "PKIX CRMF Registration Control, Old Certificate ID",
928 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION),
929 OD( pkixRegCtrlProtEncKey, SEC_OID_PKIX_REGCTRL_PROTOCOL_ENC_KEY,
930 "PKIX CRMF Registration Control, Protocol Encryption Key",
931 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION),
932 OD( pkixRegInfoUTF8Pairs, SEC_OID_PKIX_REGINFO_UTF8_PAIRS,
933 "PKIX CRMF Registration Info, UTF8 Pairs",
934 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION),
935 OD( pkixRegInfoCertReq, SEC_OID_PKIX_REGINFO_CERT_REQUEST,
936 "PKIX CRMF Registration Info, Certificate Request",
937 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION),
938 OD( pkixExtendedKeyUsageServerAuth,
939 SEC_OID_EXT_KEY_USAGE_SERVER_AUTH,
940 "TLS Web Server Authentication Certificate",
941 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION),
942 OD( pkixExtendedKeyUsageClientAuth,
943 SEC_OID_EXT_KEY_USAGE_CLIENT_AUTH,
944 "TLS Web Client Authentication Certificate",
945 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION),
946 OD( pkixExtendedKeyUsageCodeSign, SEC_OID_EXT_KEY_USAGE_CODE_SIGN,
947 "Code Signing Certificate",
948 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION),
949 OD( pkixExtendedKeyUsageEMailProtect,
950 SEC_OID_EXT_KEY_USAGE_EMAIL_PROTECT,
951 "E-Mail Protection Certificate",
952 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION),
953 OD( pkixExtendedKeyUsageTimeStamp,
954 SEC_OID_EXT_KEY_USAGE_TIME_STAMP,
955 "Time Stamping Certifcate",
956 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION),
957 OD( pkixOCSPResponderExtendedKeyUsage, SEC_OID_OCSP_RESPONDER,
958 "OCSP Responder Certificate",
959 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION),
960
961 /* Netscape Algorithm OIDs */
962
963 OD( netscapeSMimeKEA, SEC_OID_NETSCAPE_SMIME_KEA,
964 "Netscape S/MIME KEA", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
965 /* Skipjack OID -- ### mwelch temporary */
966 OD( skipjackCBC, SEC_OID_FORTEZZA_SKIPJACK,
967 "Skipjack CBC64", CSSM_ALGID_SKIPJACK, INVALID_CERT_EXTENSION ),
968 /* pkcs12 v2 oids */
969 OD( pkcs12V2PBEWithSha1And128BitRC4,
970 SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_128_BIT_RC4,
971 "PKCS12 V2 PBE With SHA1 And 128 Bit RC4",
972 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
973 OD( pkcs12V2PBEWithSha1And40BitRC4,
974 SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_40_BIT_RC4,
975 "PKCS12 V2 PBE With SHA1 And 40 Bit RC4",
976 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
977 OD( pkcs12V2PBEWithSha1And3KeyTripleDEScbc,
978 SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_3KEY_TRIPLE_DES_CBC,
979 "PKCS12 V2 PBE With SHA1 And 3KEY Triple DES-cbc",
980 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
981 OD( pkcs12V2PBEWithSha1And2KeyTripleDEScbc,
982 SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_2KEY_TRIPLE_DES_CBC,
983 "PKCS12 V2 PBE With SHA1 And 2KEY Triple DES-cbc",
984 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
985 OD( pkcs12V2PBEWithSha1And128BitRC2cbc,
986 SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_128_BIT_RC2_CBC,
987 "PKCS12 V2 PBE With SHA1 And 128 Bit RC2 CBC",
988 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
989 OD( pkcs12V2PBEWithSha1And40BitRC2cbc,
990 SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_40_BIT_RC2_CBC,
991 "PKCS12 V2 PBE With SHA1 And 40 Bit RC2 CBC",
992 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
993 OD( pkcs12SafeContentsID, SEC_OID_PKCS12_SAFE_CONTENTS_ID,
994 "PKCS #12 Safe Contents ID",
995 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
996 OD( pkcs12PKCS8ShroudedKeyBagID,
997 SEC_OID_PKCS12_PKCS8_SHROUDED_KEY_BAG_ID,
998 "PKCS #12 Safe Contents ID",
999 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
1000 OD( pkcs12V1KeyBag, SEC_OID_PKCS12_V1_KEY_BAG_ID,
1001 "PKCS #12 V1 Key Bag",
1002 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
1003 OD( pkcs12V1PKCS8ShroudedKeyBag,
1004 SEC_OID_PKCS12_V1_PKCS8_SHROUDED_KEY_BAG_ID,
1005 "PKCS #12 V1 PKCS8 Shrouded Key Bag",
1006 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
1007 OD( pkcs12V1CertBag, SEC_OID_PKCS12_V1_CERT_BAG_ID,
1008 "PKCS #12 V1 Cert Bag",
1009 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
1010 OD( pkcs12V1CRLBag, SEC_OID_PKCS12_V1_CRL_BAG_ID,
1011 "PKCS #12 V1 CRL Bag",
1012 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
1013 OD( pkcs12V1SecretBag, SEC_OID_PKCS12_V1_SECRET_BAG_ID,
1014 "PKCS #12 V1 Secret Bag",
1015 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
1016 OD( pkcs12V1SafeContentsBag, SEC_OID_PKCS12_V1_SAFE_CONTENTS_BAG_ID,
1017 "PKCS #12 V1 Safe Contents Bag",
1018 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
1019
1020 OD( pkcs9X509Certificate, SEC_OID_PKCS9_X509_CERT,
1021 "PKCS #9 X509 Certificate",
1022 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
1023 OD( pkcs9SDSICertificate, SEC_OID_PKCS9_SDSI_CERT,
1024 "PKCS #9 SDSI Certificate",
1025 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
1026 OD( pkcs9X509CRL, SEC_OID_PKCS9_X509_CRL,
1027 "PKCS #9 X509 CRL", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
1028 OD( pkcs9FriendlyName, SEC_OID_PKCS9_FRIENDLY_NAME,
1029 "PKCS #9 Friendly Name",
1030 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
1031 OD( pkcs9LocalKeyID, SEC_OID_PKCS9_LOCAL_KEY_ID,
1032 "PKCS #9 Local Key ID",
1033 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
1034 OD( pkcs12KeyUsageAttr, SEC_OID_PKCS12_KEY_USAGE,
1035 "PKCS 12 Key Usage", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
1036 OD( dhPublicKey, SEC_OID_X942_DIFFIE_HELMAN_KEY,
1037 "Diffie-Helman Public Key", CSSM_ALGID_DH,
1038 INVALID_CERT_EXTENSION ),
1039 OD( netscapeNickname, SEC_OID_NETSCAPE_NICKNAME,
1040 "Netscape Nickname", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
1041
1042 /* Cert Server specific OIDs */
1043 OD( netscapeRecoveryRequest, SEC_OID_NETSCAPE_RECOVERY_REQUEST,
1044 "Recovery Request OID",
1045 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
1046
1047 OD( nsExtAIACertRenewal, SEC_OID_CERT_RENEWAL_LOCATOR,
1048 "Certificate Renewal Locator OID", CSSM_ALGID_NONE,
1049 INVALID_CERT_EXTENSION ),
1050
1051 OD( nsExtCertScopeOfUse, SEC_OID_NS_CERT_EXT_SCOPE_OF_USE,
1052 "Certificate Scope-of-Use Extension", CSSM_ALGID_NONE,
1053 SUPPORTED_CERT_EXTENSION ),
1054
1055 /* CMS stuff */
1056 OD( cmsESDH, SEC_OID_CMS_EPHEMERAL_STATIC_DIFFIE_HELLMAN,
1057 "Ephemeral-Static Diffie-Hellman", CSSM_ALGID_NONE /* XXX */,
1058 INVALID_CERT_EXTENSION ),
1059 OD( cms3DESwrap, SEC_OID_CMS_3DES_KEY_WRAP,
1060 "CMS 3DES Key Wrap", CSSM_ALGID_NONE /* XXX */,
1061 INVALID_CERT_EXTENSION ),
1062 OD( cmsRC2wrap, SEC_OID_CMS_RC2_KEY_WRAP,
1063 "CMS RC2 Key Wrap", CSSM_ALGID_NONE /* XXX */,
1064 INVALID_CERT_EXTENSION ),
1065 OD( smimeEncryptionKeyPreference, SEC_OID_SMIME_ENCRYPTION_KEY_PREFERENCE,
1066 "S/MIME Encryption Key Preference",
1067 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
1068
1069 /* AES algorithm OIDs */
1070 OD( aes128_ECB, SEC_OID_AES_128_ECB,
1071 "AES-128-ECB", CSSM_ALGID_AES, INVALID_CERT_EXTENSION ),
1072 OD( aes128_CBC, SEC_OID_AES_128_CBC,
1073 "AES-128-CBC", CSSM_ALGID_AES, INVALID_CERT_EXTENSION ),
1074 OD( aes192_ECB, SEC_OID_AES_192_ECB,
1075 "AES-192-ECB", CSSM_ALGID_AES, INVALID_CERT_EXTENSION ),
1076 OD( aes192_CBC, SEC_OID_AES_192_CBC,
1077 "AES-192-CBC", CSSM_ALGID_AES, INVALID_CERT_EXTENSION ),
1078 OD( aes256_ECB, SEC_OID_AES_256_ECB,
1079 "AES-256-ECB", CSSM_ALGID_AES, INVALID_CERT_EXTENSION ),
1080 OD( aes256_CBC, SEC_OID_AES_256_CBC,
1081 "AES-256-CBC", CSSM_ALGID_AES, INVALID_CERT_EXTENSION ),
1082
1083 /* More bogus DSA OIDs */
1084 OD( sdn702DSASignature, SEC_OID_SDN702_DSA_SIGNATURE,
1085 "SDN.702 DSA Signature", CSSM_ALGID_SHA1WithDSA, INVALID_CERT_EXTENSION ),
1086
1087 OD( ms_smimeEncryptionKeyPreference,
1088 SEC_OID_MS_SMIME_ENCRYPTION_KEY_PREFERENCE,
1089 "Microsoft S/MIME Encryption Key Preference",
1090 CSSM_ALGID_NONE, INVALID_CERT_EXTENSION ),
1091
1092 OD( sha224, SEC_OID_SHA224, "SHA-224", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION),
1093 OD( sha256, SEC_OID_SHA256, "SHA-256", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION),
1094 OD( sha384, SEC_OID_SHA384, "SHA-384", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION),
1095 OD( sha512, SEC_OID_SHA512, "SHA-512", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION),
1096
1097 OD( pkcs1SHA256WithRSAEncryption, SEC_OID_PKCS1_SHA256_WITH_RSA_ENCRYPTION,
1098 "PKCS #1 SHA-256 With RSA Encryption", CSSM_ALGID_NONE,
1099 INVALID_CERT_EXTENSION ),
1100 OD( pkcs1SHA384WithRSAEncryption, SEC_OID_PKCS1_SHA384_WITH_RSA_ENCRYPTION,
1101 "PKCS #1 SHA-384 With RSA Encryption", CSSM_ALGID_NONE,
1102 INVALID_CERT_EXTENSION ),
1103 OD( pkcs1SHA512WithRSAEncryption, SEC_OID_PKCS1_SHA512_WITH_RSA_ENCRYPTION,
1104 "PKCS #1 SHA-512 With RSA Encryption", CSSM_ALGID_NONE,
1105 INVALID_CERT_EXTENSION ),
1106
1107 OD( aes128_KEY_WRAP, SEC_OID_AES_128_KEY_WRAP,
1108 "AES-128 Key Wrap", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION),
1109 OD( aes192_KEY_WRAP, SEC_OID_AES_192_KEY_WRAP,
1110 "AES-192 Key Wrap", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION),
1111 OD( aes256_KEY_WRAP, SEC_OID_AES_256_KEY_WRAP,
1112 "AES-256 Key Wrap", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION),
1113
1114 /* caller-specified OID for eContentType */
1115 OD( noOid, SEC_OID_OTHER,
1116 "Caller-specified eContentType", CSSM_ALGID_NONE, INVALID_CERT_EXTENSION),
1117
1118 OD( ecPublicKey, SEC_OID_EC_PUBLIC_KEY,
1119 "ECDSA Public Key", CSSM_ALGID_NONE,
1120 INVALID_CERT_EXTENSION ),
1121 OD( ecdsaWithSHA1, SEC_OID_ECDSA_WithSHA1,
1122 "SHA-1 With ECDSA", CSSM_ALGID_NONE,
1123 INVALID_CERT_EXTENSION ),
1124 OD( dhSinglePassStdDHsha1kdf, SEC_OID_DH_SINGLE_STD_SHA1KDF,
1125 "ECDH With SHA1 KDF", CSSM_ALGID_NONE,
1126 INVALID_CERT_EXTENSION ),
1127 OD( secp256r1, SEC_OID_SECP_256_R1,
1128 "secp256r1", CSSM_ALGID_NONE,
1129 INVALID_CERT_EXTENSION ),
1130 OD( secp384r1, SEC_OID_SECP_384_R1,
1131 "secp384r1", CSSM_ALGID_NONE,
1132 INVALID_CERT_EXTENSION ),
1133 OD( secp521r1, SEC_OID_SECP_521_R1,
1134 "secp521r1", CSSM_ALGID_NONE,
1135 INVALID_CERT_EXTENSION ),
1136
1137 OD( smimeTimeStampTokenInfo, SEC_OID_PKCS9_ID_CT_TSTInfo,
1138 "id-ct-TSTInfo", CSSM_ALGID_NONE,
1139 INVALID_CERT_EXTENSION ),
1140
1141 OD( smimeTimeStampToken, SEC_OID_PKCS9_TIMESTAMP_TOKEN,
1142 "id-aa-timeStampToken", CSSM_ALGID_NONE,
1143 INVALID_CERT_EXTENSION ),
1144
1145 OD( smimeSigningCertificate, SEC_OID_PKCS9_SIGNING_CERTIFICATE,
1146 "id-aa-signing-certificate", CSSM_ALGID_NONE,
1147 INVALID_CERT_EXTENSION ),
1148
1149 /* ECDSA with SHA2 */
1150 OD( ecdsaWithSHA256, SEC_OID_ECDSA_WITH_SHA256,
1151 "ECDSA With SHA-256", CSSM_ALGID_SHA256WithECDSA,
1152 INVALID_CERT_EXTENSION ),
1153 OD( ecdsaWithSHA384, SEC_OID_ECDSA_WITH_SHA384,
1154 "ECDSA With SHA-384", CSSM_ALGID_SHA384WithECDSA,
1155 INVALID_CERT_EXTENSION ),
1156 OD( ecdsaWithSHA512, SEC_OID_ECDSA_WITH_SHA512,
1157 "ECDSA With SHA-512", CSSM_ALGID_SHA512WithECDSA,
1158 INVALID_CERT_EXTENSION ),
1159
1160 /* Apple Hash Agility */
1161 OD( appleHashAgility, SEC_OID_APPLE_HASH_AGILITY,
1162 "appleCodesigningHashAgilityAttribute", CSSM_ALGID_NONE,
1163 INVALID_CERT_EXTENSION),
1164
1165 };
1166
1167 /*
1168 * now the dynamic table. The dynamic table gets build at init time.
1169 * and gets modified if the user loads new crypto modules.
1170 */
1171
1172 #if 0 /* disabled since its not used (the only function that could "add" items was disabled before */
1173
1174 // TODO: protect this: used multi-threaded
1175 static PLHashTable *oid_d_hash = 0;
1176 static SECOidData **secoidDynamicTable = NULL;
1177 static int secoidDynamicTableSize = 0;
1178 static int secoidLastDynamicEntry = 0;
1179 static int secoidLastHashEntry = 0;
1180
1181 static SECStatus
1182 secoid_DynamicRehash(void)
1183 {
1184 SECOidData *oid;
1185 PLHashEntry *entry;
1186 int i;
1187 int last = secoidLastDynamicEntry;
1188
1189 if (!oid_d_hash) {
1190 oid_d_hash = PL_NewHashTable(0, SECITEM_Hash, SECITEM_HashCompare,
1191 PL_CompareValues, NULL, NULL);
1192 }
1193
1194
1195 if ( !oid_d_hash ) {
1196 PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
1197 return(SECFailure);
1198 }
1199
1200 for ( i = secoidLastHashEntry; i < last; i++ ) {
1201 oid = secoidDynamicTable[i];
1202
1203 entry = PL_HashTableAdd( oid_d_hash, &oid->oid, oid );
1204 if ( entry == NULL ) {
1205 return(SECFailure);
1206 }
1207 }
1208 secoidLastHashEntry = last;
1209 return(SECSuccess);
1210 }
1211
1212
1213
1214 /*
1215 * Lookup a Dynamic OID. Dynamic OID's still change slowly, so it's
1216 * cheaper to rehash the table when it changes than it is to do the loop
1217 * each time. Worry: what about thread safety here? Global Static data with
1218 * no locks.... (sigh).
1219 */
1220 static SECOidData *
1221 secoid_FindDynamic(const SecAsn1Item *key) {
1222 SECOidData *ret = NULL;
1223 if (secoidDynamicTable == NULL) {
1224 /* PORT_SetError! */
1225 return NULL;
1226 }
1227 if (secoidLastHashEntry != secoidLastDynamicEntry) {
1228 SECStatus rv = secoid_DynamicRehash();
1229 if ( rv != SECSuccess ) {
1230 return NULL;
1231 }
1232 }
1233 ret = (SECOidData *)PL_HashTableLookup (oid_d_hash, key);
1234 return ret;
1235
1236 }
1237
1238 static SECOidData *
1239 secoid_FindDynamicByTag(SECOidTag tagnum)
1240 {
1241 int tagNumDiff;
1242
1243 if (secoidDynamicTable == NULL) {
1244 return NULL;
1245 }
1246
1247 if (tagnum < SEC_OID_TOTAL) {
1248 return NULL;
1249 }
1250
1251 tagNumDiff = tagnum - SEC_OID_TOTAL;
1252 if (tagNumDiff >= secoidLastDynamicEntry) {
1253 return NULL;
1254 }
1255
1256 return(secoidDynamicTable[tagNumDiff]);
1257 }
1258
1259 /*
1260 * this routine is definately not thread safe. It is only called out
1261 * of the UI, or at init time. If we want to call it any other time,
1262 * we need to make it thread safe.
1263 */
1264 SECStatus
1265 SECOID_AddEntry(SecAsn1Item *oid, char *description, SecAsn1AlgId cssmAlgorithm) {
1266 SECOidData *oiddp = (SECOidData *)PORT_Alloc(sizeof(SECOidData));
1267 int last = secoidLastDynamicEntry;
1268 int tableSize = secoidDynamicTableSize;
1269 int next = last++;
1270 SECOidData **newTable = secoidDynamicTable;
1271 SECOidData **oldTable = NULL;
1272
1273 if (oid == NULL) {
1274 return SECFailure;
1275 }
1276
1277 /* fill in oid structure */
1278 if (SECITEM_CopyItem(NULL,&oiddp->oid,oid) != SECSuccess) {
1279 PORT_Free(oiddp);
1280 return SECFailure;
1281 }
1282 oiddp->offset = (SECOidTag)(next + SEC_OID_TOTAL);
1283 /* may we should just reference the copy passed to us? */
1284 oiddp->desc = PORT_Strdup(description);
1285 oiddp->cssmAlgorithm = cssmAlgorithm;
1286
1287
1288 if (last > tableSize) {
1289 int oldTableSize = tableSize;
1290 tableSize += 10;
1291 oldTable = newTable;
1292 newTable = (SECOidData **)PORT_ZAlloc(sizeof(SECOidData *)*tableSize);
1293 if (newTable == NULL) {
1294 PORT_Free(oiddp->oid.Data);
1295 PORT_Free(oiddp);
1296 return SECFailure;
1297 }
1298 PORT_Memcpy(newTable,oldTable,sizeof(SECOidData *)*oldTableSize);
1299 PORT_Free(oldTable);
1300 }
1301
1302 newTable[next] = oiddp;
1303 secoidDynamicTable = newTable;
1304 secoidDynamicTableSize = tableSize;
1305 secoidLastDynamicEntry= last;
1306 return SECSuccess;
1307 }
1308 #endif
1309
1310 /* normal static table processing */
1311
1312 /* TODO: MORE GLOBAL DATA */
1313 static pthread_once_t hash_once = PTHREAD_ONCE_INIT;
1314 static PLHashTable *oidhash = NULL;
1315 static PLHashTable *oidmechhash = NULL;
1316
1317 static PLHashNumber
1318 secoid_HashNumber(const void *key)
1319 {
1320 /* This truncate the hash to the lower 32 bits -- probably safe right ??? */
1321 return (PLHashNumber)(PRUword)key;
1322 }
1323
1324
1325 static SECStatus
1326 InitOIDHash(void)
1327 {
1328 PLHashEntry *entry;
1329 const SECOidData *oid;
1330 size_t ix;
1331
1332 oidhash = PL_NewHashTable(0, SECITEM_Hash, SECITEM_HashCompare,
1333 PL_CompareValues, NULL, NULL);
1334 oidmechhash = PL_NewHashTable(0, secoid_HashNumber, PL_CompareValues,
1335 PL_CompareValues, NULL, NULL);
1336
1337 if ( !oidhash || !oidmechhash) {
1338 PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
1339 PORT_Assert(0); /*This function should never fail. */
1340 return(SECFailure);
1341 }
1342
1343 for ( ix = 0; ix < ( sizeof(oids) / sizeof(SECOidData) ); ix++ ) {
1344 oid = &oids[ix];
1345
1346 PORT_Assert ( oid->offset == ix );
1347
1348 entry = PL_HashTableAdd( oidhash, &oid->oid, (void *)oid );
1349 if ( entry == NULL ) {
1350 PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
1351 PORT_Assert(0); /*This function should never fail. */
1352 return(SECFailure);
1353 }
1354
1355 #if USE_CDSA_CRYPTO
1356 if ( oid->cssmAlgorithm.algorithm.Length /*CSSM_ALGID_NONE*/ ) {
1357 entry = PL_HashTableAdd( oidmechhash,
1358 (void *)&(oid->cssmAlgorithm), (void *)oid );
1359 if ( entry == NULL ) {
1360 PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
1361 PORT_Assert(0); /* This function should never fail. */
1362 return(SECFailure);
1363 }
1364 }
1365 #endif
1366 }
1367
1368 PORT_Assert (ix == SEC_OID_TOTAL);
1369
1370 return(SECSuccess);
1371 }
1372
1373 static void InitOIDHashOnce()
1374 {
1375 if (SECSuccess != InitOIDHash())
1376 abort();
1377 }
1378
1379 /* TODO: appears to be the public entry point */
1380 SECOidData *
1381 SECOID_FindOIDByCssmAlgorithm(SecAsn1AlgId cssmAlgorithm)
1382 {
1383 SECOidData *ret;
1384
1385 pthread_once(&hash_once, InitOIDHashOnce);
1386
1387 ret = PL_HashTableLookupConst ( oidmechhash, (void *)&cssmAlgorithm);
1388 if ( ret == NULL ) {
1389 PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
1390 }
1391
1392 return (ret);
1393 }
1394
1395 /* TODO: appears to be the public entry point */
1396 SECOidData *
1397 SECOID_FindOID(const SecAsn1Item *oid)
1398 {
1399 SECOidData *ret;
1400
1401 pthread_once(&hash_once, InitOIDHashOnce);
1402
1403 ret = PL_HashTableLookupConst ( oidhash, oid );
1404 if ( ret == NULL ) {
1405 #if 0
1406 ret = secoid_FindDynamic(oid);
1407 #endif
1408 if (ret == NULL) {
1409 PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
1410 }
1411 }
1412
1413 return(ret);
1414 }
1415
1416 SECOidTag
1417 SECOID_FindOIDTag(const SecAsn1Item *oid)
1418 {
1419 SECOidData *oiddata;
1420
1421 oiddata = SECOID_FindOID (oid);
1422 if (oiddata == NULL)
1423 return SEC_OID_UNKNOWN;
1424
1425 return oiddata->offset;
1426 }
1427
1428 /* This really should return const. */
1429 SECOidData *
1430 SECOID_FindOIDByTag(SECOidTag tagnum)
1431 {
1432 pthread_once(&hash_once, InitOIDHashOnce);
1433
1434 #if 0
1435 if (tagnum >= SEC_OID_TOTAL) {
1436 return secoid_FindDynamicByTag(tagnum);
1437 }
1438 #else
1439 if (tagnum >= SEC_OID_TOTAL)
1440 return NULL;
1441 #endif
1442
1443 PORT_Assert((unsigned int)tagnum < (sizeof(oids) / sizeof(SECOidData)));
1444 return (SECOidData *)(&oids[tagnum]);
1445 }
1446
1447 Boolean SECOID_KnownCertExtenOID (const SecAsn1Item *extenOid)
1448 {
1449 SECOidData * oidData;
1450
1451 oidData = SECOID_FindOID (extenOid);
1452 if (oidData == (SECOidData *)NULL)
1453 return (PR_FALSE);
1454 return ((oidData->supportedExtension == SUPPORTED_CERT_EXTENSION) ?
1455 PR_TRUE : PR_FALSE);
1456 }
1457
1458
1459 const char *
1460 SECOID_FindOIDTagDescription(SECOidTag tagnum)
1461 {
1462 const SECOidData *oidData = SECOID_FindOIDByTag(tagnum);
1463 return oidData ? oidData->desc : 0;
1464 }
1465
1466 #if 0
1467 /*
1468 * free up the oid tables.
1469 */
1470 SECStatus
1471 SECOID_Shutdown(void)
1472 {
1473 int i;
1474
1475 if (oidhash) {
1476 PL_HashTableDestroy(oidhash);
1477 oidhash = NULL;
1478 }
1479 if (oidmechhash) {
1480 PL_HashTableDestroy(oidmechhash);
1481 oidmechhash = NULL;
1482 }
1483 if (oid_d_hash) {
1484 PL_HashTableDestroy(oid_d_hash);
1485 oid_d_hash = NULL;
1486 }
1487 if (secoidDynamicTable) {
1488 for (i=0; i < secoidLastDynamicEntry; i++) {
1489 PORT_Free(secoidDynamicTable[i]);
1490 }
1491 PORT_Free(secoidDynamicTable);
1492 secoidDynamicTable = NULL;
1493 secoidDynamicTableSize = 0;
1494 secoidLastDynamicEntry = 0;
1495 secoidLastHashEntry = 0;
1496 }
1497 return SECSuccess;
1498 }
1499 #endif