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