1/*
2 * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
3 * Use is subject to license terms.
4 */
5/*
6 * Copyright(c) 1995-2000 Intel Corporation. All rights reserved.
7 */
8
9#include <kmfapi.h>
10
11/* From X.520 */
12static uint8_t
13OID_ObjectClass[] = { OID_ATTR_TYPE, 0 },
14OID_AliasedEntryName[] = { OID_ATTR_TYPE, 1 },
15OID_KnowledgeInformation[] = { OID_ATTR_TYPE, 2 },
16OID_CommonName[] = { OID_ATTR_TYPE, 3 },
17OID_Surname[] = { OID_ATTR_TYPE, 4 },
18OID_SerialNumber[] = { OID_ATTR_TYPE, 5 },
19OID_CountryName[] = { OID_ATTR_TYPE, 6 },
20OID_LocalityName[] = { OID_ATTR_TYPE, 7 },
21OID_StateProvinceName[] = { OID_ATTR_TYPE, 8 },
22OID_CollectiveStateProvinceName[] = { OID_ATTR_TYPE, 8, 1 },
23OID_StreetAddress[] = { OID_ATTR_TYPE, 9 },
24OID_CollectiveStreetAddress[] = { OID_ATTR_TYPE, 9, 1 },
25OID_OrganizationName[] = { OID_ATTR_TYPE, 10 },
26OID_CollectiveOrganizationName[] = { OID_ATTR_TYPE, 10, 1 },
27OID_OrganizationalUnitName[] = { OID_ATTR_TYPE, 11 },
28OID_CollectiveOrganizationalUnitName[] = { OID_ATTR_TYPE, 11, 1 },
29OID_Title[] = { OID_ATTR_TYPE, 12 },
30OID_Description[] = { OID_ATTR_TYPE, 13 },
31OID_SearchGuide[] = { OID_ATTR_TYPE, 14 },
32OID_BusinessCategory[] = { OID_ATTR_TYPE, 15 },
33OID_PostalAddress[] = { OID_ATTR_TYPE, 16 },
34OID_CollectivePostalAddress[] = { OID_ATTR_TYPE, 16, 1 },
35OID_PostalCode[] = { OID_ATTR_TYPE, 17 },
36OID_CollectivePostalCode[] = { OID_ATTR_TYPE, 17, 1 },
37OID_PostOfficeBox[] = { OID_ATTR_TYPE, 18 },
38OID_CollectivePostOfficeBox[] = { OID_ATTR_TYPE, 18, 1 },
39OID_PhysicalDeliveryOfficeName[] = { OID_ATTR_TYPE, 19 },
40OID_CollectivePhysicalDeliveryOfficeName[] = { OID_ATTR_TYPE, 19, 1 },
41OID_TelephoneNumber[] = { OID_ATTR_TYPE, 20 },
42OID_CollectiveTelephoneNumber[] = { OID_ATTR_TYPE, 20, 1 },
43OID_TelexNumber[] = { OID_ATTR_TYPE, 21 },
44OID_CollectiveTelexNumber[] = { OID_ATTR_TYPE, 21, 1 },
45OID_TelexTerminalIdentifier[] = { OID_ATTR_TYPE, 22 },
46OID_CollectiveTelexTerminalIdentifier[] = { OID_ATTR_TYPE, 22, 1 },
47OID_FacsimileTelephoneNumber[] = { OID_ATTR_TYPE, 23 },
48OID_CollectiveFacsimileTelephoneNumber[] = { OID_ATTR_TYPE, 23, 1 },
49OID_X_121Address[] = { OID_ATTR_TYPE, 24 },
50OID_InternationalISDNNumber[] = { OID_ATTR_TYPE, 25 },
51OID_CollectiveInternationalISDNNumber[] = { OID_ATTR_TYPE, 25, 1 },
52OID_RegisteredAddress[] = { OID_ATTR_TYPE, 26 },
53OID_DestinationIndicator[] = { OID_ATTR_TYPE, 27 },
54OID_PreferredDeliveryMethod[] = { OID_ATTR_TYPE, 28 },
55OID_PresentationAddress[] = { OID_ATTR_TYPE, 29 },
56OID_SupportedApplicationContext[] = { OID_ATTR_TYPE, 30 },
57OID_Member[] = { OID_ATTR_TYPE, 31 },
58OID_Owner[] = { OID_ATTR_TYPE, 32 },
59OID_RoleOccupant[] = { OID_ATTR_TYPE, 33 },
60OID_SeeAlso[] = { OID_ATTR_TYPE, 34 },
61OID_UserPassword[] = { OID_ATTR_TYPE, 35 },
62OID_UserCertificate[] = { OID_ATTR_TYPE, 36 },
63OID_CACertificate[] = { OID_ATTR_TYPE, 37 },
64OID_AuthorityRevocationList[] = { OID_ATTR_TYPE, 38 },
65OID_CertificateRevocationList[] = { OID_ATTR_TYPE, 39 },
66OID_CrossCertificatePair[] = { OID_ATTR_TYPE, 40 },
67OID_Name[] = { OID_ATTR_TYPE, 41 },
68OID_GivenName[] = { OID_ATTR_TYPE, 42 },
69OID_Initials[] = { OID_ATTR_TYPE, 43 },
70OID_GenerationQualifier[] = { OID_ATTR_TYPE, 44 },
71OID_UniqueIdentifier[] = { OID_ATTR_TYPE, 45 },
72OID_DNQualifier[] = { OID_ATTR_TYPE, 46 },
73OID_EnhancedSearchGuide[] = { OID_ATTR_TYPE, 47 },
74OID_ProtocolInformation[] = { OID_ATTR_TYPE, 48 },
75OID_DistinguishedName[] = { OID_ATTR_TYPE, 49 },
76OID_UniqueMember[] = { OID_ATTR_TYPE, 50 },
77OID_HouseIdentifier[] = { OID_ATTR_TYPE, 51 }
78/* OID_SupportedAlgorithms[] = { OID_ATTR_TYPE, 52 }, */
79/* OID_DeltaRevocationList[] = { OID_ATTR_TYPE, 53 }, */
80/* OID_AttributeCertificate[] = { OID_ATTR_TYPE, 58 } */
81;
82
83/* From PKCS 9 */
84static uint8_t
85OID_EmailAddress[] = { OID_PKCS_9, 1 },
86OID_UnstructuredName[] = { OID_PKCS_9, 2 },
87OID_ContentType[] = { OID_PKCS_9, 3 },
88OID_MessageDigest[] = { OID_PKCS_9, 4 },
89OID_SigningTime[] = { OID_PKCS_9, 5 },
90OID_CounterSignature[] = { OID_PKCS_9, 6 },
91OID_ChallengePassword[] = { OID_PKCS_9, 7 },
92OID_UnstructuredAddress[] = { OID_PKCS_9, 8 },
93OID_ExtendedCertificateAttributes[] = { OID_PKCS_9, 9 },
94OID_ExtensionRequest[] = { OID_PKCS_9, 14 };
95
96/* From PKIX 1 */
97/* Standard Extensions */
98static uint8_t
99OID_SubjectDirectoryAttributes[] = { OID_EXTENSION, 9 },
100OID_SubjectKeyIdentifier[] = { OID_EXTENSION, 14 },
101OID_KeyUsage[] = { OID_EXTENSION, 15 },
102OID_PrivateKeyUsagePeriod[] = { OID_EXTENSION, 16 },
103OID_SubjectAltName[] = { OID_EXTENSION, 17 },
104OID_IssuerAltName[] = { OID_EXTENSION, 18 },
105OID_BasicConstraints[] = { OID_EXTENSION, 19 },
106OID_CrlNumber[] = { OID_EXTENSION, 20 },
107OID_CrlReason[] = { OID_EXTENSION, 21 },
108OID_HoldInstructionCode[] = { OID_EXTENSION, 23 },
109OID_InvalidityDate[] = { OID_EXTENSION, 24 },
110OID_DeltaCrlIndicator[] = { OID_EXTENSION, 27 },
111OID_IssuingDistributionPoints[] = { OID_EXTENSION, 28 },
112
113/* OID_CertificateIssuer[] = { OID_EXTENSION, 29 }, */
114OID_NameConstraints[] = { OID_EXTENSION, 30 },
115OID_CrlDistributionPoints[] = { OID_EXTENSION, 31 },
116OID_CertificatePolicies[] = { OID_EXTENSION, 32 },
117OID_PolicyMappings[] = { OID_EXTENSION, 33 },
118/* 34 deprecated */
119OID_AuthorityKeyIdentifier[] = { OID_EXTENSION, 35 },
120OID_PolicyConstraints[] = { OID_EXTENSION, 36 },
121OID_ExtKeyUsage[] = { OID_EXTENSION, 37 }
122;
123
124/* PKIX-defined extended key purpose OIDs */
125static uint8_t
126OID_QT_CPSuri[]		 = { OID_PKIX_QT_CPS },
127OID_QT_Unotice[]	 = { OID_PKIX_QT_UNOTICE },
128
129OID_KP_ServerAuth[]	 = { OID_PKIX_KP, 1 },
130OID_KP_ClientAuth[] = { OID_PKIX_KP, 2 },
131OID_KP_CodeSigning[] = { OID_PKIX_KP, 3 },
132OID_KP_EmailProtection[] = { OID_PKIX_KP, 4 },
133OID_KP_IPSecEndSystem[] = { OID_PKIX_KP, 5 },
134OID_KP_IPSecTunnel[] = { OID_PKIX_KP, 6 },
135OID_KP_IPSecUser[] = { OID_PKIX_KP, 7 },
136OID_KP_TimeStamping[] = { OID_PKIX_KP, 8 },
137OID_KP_OCSPSigning[] = { OID_PKIX_KP, 9 }
138;
139
140/* From PKIX 1 */
141static uint8_t
142OID_AuthorityInfoAccess[] = { OID_PKIX_PE, 1};
143
144const KMF_OID
145KMFOID_AuthorityInfoAccess = {OID_PKIX_LENGTH + 2, OID_AuthorityInfoAccess};
146
147static uint8_t
148OID_PkixAdOcsp[] = {OID_PKIX_AD, 1};
149
150const KMF_OID
151KMFOID_PkixAdOcsp = {OID_PKIX_AD_LENGTH + 1, OID_PkixAdOcsp};
152
153static uint8_t
154OID_PkixAdCaIssuers[] = {OID_PKIX_AD, 2};
155
156const KMF_OID
157KMFOID_PkixAdCaIssuers = {OID_PKIX_AD_LENGTH + 1, OID_PkixAdCaIssuers};
158
159/*
160 * From RFC 1274
161 */
162static uint8_t
163OID_userid[] =		{OID_PILOT, 1},
164OID_RFC822mailbox[] =	{OID_PILOT, 3},
165OID_domainComponent[] =	{OID_PILOT, 25};
166
167const KMF_OID
168KMFOID_userid		= {OID_PILOT_LENGTH + 1, OID_userid},
169KMFOID_RFC822mailbox	= {OID_PILOT_LENGTH + 1, OID_RFC822mailbox},
170KMFOID_domainComponent	= {OID_PILOT_LENGTH + 1, OID_domainComponent},
171KMFOID_ObjectClass = {OID_ATTR_TYPE_LENGTH+1, OID_ObjectClass},
172KMFOID_AliasedEntryName = {OID_ATTR_TYPE_LENGTH+1, OID_AliasedEntryName},
173KMFOID_KnowledgeInformation = {OID_ATTR_TYPE_LENGTH+1,
174	OID_KnowledgeInformation},
175KMFOID_CommonName = {OID_ATTR_TYPE_LENGTH+1, OID_CommonName},
176KMFOID_Surname = {OID_ATTR_TYPE_LENGTH+1, OID_Surname},
177KMFOID_SerialNumber = {OID_ATTR_TYPE_LENGTH+1, OID_SerialNumber},
178KMFOID_CountryName = {OID_ATTR_TYPE_LENGTH+1, OID_CountryName},
179KMFOID_LocalityName = {OID_ATTR_TYPE_LENGTH+1, OID_LocalityName},
180KMFOID_StateProvinceName = {OID_ATTR_TYPE_LENGTH+1, OID_StateProvinceName},
181KMFOID_CollectiveStateProvinceName = {OID_ATTR_TYPE_LENGTH+2,
182	OID_CollectiveStateProvinceName},
183KMFOID_StreetAddress = {OID_ATTR_TYPE_LENGTH+1, OID_StreetAddress},
184KMFOID_CollectiveStreetAddress = {OID_ATTR_TYPE_LENGTH+2,
185	OID_CollectiveStreetAddress},
186KMFOID_OrganizationName = {OID_ATTR_TYPE_LENGTH+1, OID_OrganizationName},
187KMFOID_CollectiveOrganizationName = {OID_ATTR_TYPE_LENGTH+2,
188	OID_CollectiveOrganizationName},
189KMFOID_OrganizationalUnitName = {OID_ATTR_TYPE_LENGTH+1,
190	OID_OrganizationalUnitName},
191KMFOID_CollectiveOrganizationalUnitName = {OID_ATTR_TYPE_LENGTH+2,
192	OID_CollectiveOrganizationalUnitName},
193KMFOID_Title = {OID_ATTR_TYPE_LENGTH+1, OID_Title},
194KMFOID_Description = {OID_ATTR_TYPE_LENGTH+1, OID_Description},
195KMFOID_SearchGuide = {OID_ATTR_TYPE_LENGTH+1, OID_SearchGuide},
196KMFOID_BusinessCategory = {OID_ATTR_TYPE_LENGTH+1, OID_BusinessCategory},
197KMFOID_PostalAddress = {OID_ATTR_TYPE_LENGTH+1, OID_PostalAddress},
198KMFOID_CollectivePostalAddress = {OID_ATTR_TYPE_LENGTH+2,
199	OID_CollectivePostalAddress},
200KMFOID_PostalCode = {OID_ATTR_TYPE_LENGTH+1, OID_PostalCode},
201KMFOID_CollectivePostalCode = {OID_ATTR_TYPE_LENGTH+2,
202	OID_CollectivePostalCode},
203KMFOID_PostOfficeBox = {OID_ATTR_TYPE_LENGTH+1, OID_PostOfficeBox},
204KMFOID_CollectivePostOfficeBox = {OID_ATTR_TYPE_LENGTH+2,
205	OID_CollectivePostOfficeBox},
206KMFOID_PhysicalDeliveryOfficeName = {OID_ATTR_TYPE_LENGTH+1,
207	OID_PhysicalDeliveryOfficeName},
208KMFOID_CollectivePhysicalDeliveryOfficeName = {OID_ATTR_TYPE_LENGTH+2,
209	OID_CollectivePhysicalDeliveryOfficeName},
210KMFOID_TelephoneNumber = {OID_ATTR_TYPE_LENGTH+1, OID_TelephoneNumber},
211KMFOID_CollectiveTelephoneNumber = {OID_ATTR_TYPE_LENGTH+2,
212	OID_CollectiveTelephoneNumber},
213KMFOID_TelexNumber = {OID_ATTR_TYPE_LENGTH+1, OID_TelexNumber},
214KMFOID_CollectiveTelexNumber = {OID_ATTR_TYPE_LENGTH+2,
215	OID_CollectiveTelexNumber},
216KMFOID_TelexTerminalIdentifier = {OID_ATTR_TYPE_LENGTH+1,
217	OID_TelexTerminalIdentifier},
218KMFOID_CollectiveTelexTerminalIdentifier = {OID_ATTR_TYPE_LENGTH+2,
219	OID_CollectiveTelexTerminalIdentifier},
220KMFOID_FacsimileTelephoneNumber = {OID_ATTR_TYPE_LENGTH+1,
221	OID_FacsimileTelephoneNumber},
222KMFOID_CollectiveFacsimileTelephoneNumber = {OID_ATTR_TYPE_LENGTH+2,
223	OID_CollectiveFacsimileTelephoneNumber},
224KMFOID_X_121Address = {OID_ATTR_TYPE_LENGTH+1, OID_X_121Address},
225KMFOID_InternationalISDNNumber = {OID_ATTR_TYPE_LENGTH+1,
226	OID_InternationalISDNNumber},
227KMFOID_CollectiveInternationalISDNNumber = {OID_ATTR_TYPE_LENGTH+2,
228	OID_CollectiveInternationalISDNNumber},
229KMFOID_RegisteredAddress = {OID_ATTR_TYPE_LENGTH+1, OID_RegisteredAddress},
230KMFOID_DestinationIndicator = {OID_ATTR_TYPE_LENGTH+1,
231	OID_DestinationIndicator},
232KMFOID_PreferredDeliveryMethod = {OID_ATTR_TYPE_LENGTH+1,
233	OID_PreferredDeliveryMethod},
234KMFOID_PresentationAddress = {OID_ATTR_TYPE_LENGTH+1,
235	OID_PresentationAddress},
236KMFOID_SupportedApplicationContext = {OID_ATTR_TYPE_LENGTH+1,
237	OID_SupportedApplicationContext},
238KMFOID_Member = {OID_ATTR_TYPE_LENGTH+1, OID_Member},
239KMFOID_Owner = {OID_ATTR_TYPE_LENGTH+1, OID_Owner},
240KMFOID_RoleOccupant = {OID_ATTR_TYPE_LENGTH+1, OID_RoleOccupant},
241KMFOID_SeeAlso = {OID_ATTR_TYPE_LENGTH+1, OID_SeeAlso},
242KMFOID_UserPassword = {OID_ATTR_TYPE_LENGTH+1, OID_UserPassword},
243KMFOID_UserCertificate = {OID_ATTR_TYPE_LENGTH+1, OID_UserCertificate},
244KMFOID_CACertificate = {OID_ATTR_TYPE_LENGTH+1, OID_CACertificate},
245KMFOID_AuthorityRevocationList = {OID_ATTR_TYPE_LENGTH+1,
246	OID_AuthorityRevocationList},
247KMFOID_CertificateRevocationList = {OID_ATTR_TYPE_LENGTH+1,
248	OID_CertificateRevocationList},
249KMFOID_CrossCertificatePair = {OID_ATTR_TYPE_LENGTH+1,
250	OID_CrossCertificatePair},
251KMFOID_Name = {OID_ATTR_TYPE_LENGTH+1, OID_Name},
252KMFOID_GivenName = {OID_ATTR_TYPE_LENGTH+1, OID_GivenName},
253KMFOID_Initials = {OID_ATTR_TYPE_LENGTH+1, OID_Initials},
254KMFOID_GenerationQualifier = {OID_ATTR_TYPE_LENGTH+1, OID_GenerationQualifier},
255KMFOID_UniqueIdentifier = {OID_ATTR_TYPE_LENGTH+1, OID_UniqueIdentifier},
256KMFOID_DNQualifier = {OID_ATTR_TYPE_LENGTH+1, OID_DNQualifier},
257KMFOID_EnhancedSearchGuide = {OID_ATTR_TYPE_LENGTH+1, OID_EnhancedSearchGuide},
258KMFOID_ProtocolInformation = {OID_ATTR_TYPE_LENGTH+1, OID_ProtocolInformation},
259KMFOID_DistinguishedName = {OID_ATTR_TYPE_LENGTH+1, OID_DistinguishedName},
260KMFOID_UniqueMember = {OID_ATTR_TYPE_LENGTH+1, OID_UniqueMember},
261KMFOID_HouseIdentifier = {OID_ATTR_TYPE_LENGTH+1, OID_HouseIdentifier},
262KMFOID_EmailAddress = {OID_PKCS_9_LENGTH+1, OID_EmailAddress},
263KMFOID_UnstructuredName = {OID_PKCS_9_LENGTH+1, OID_UnstructuredName},
264KMFOID_ContentType = {OID_PKCS_9_LENGTH+1, OID_ContentType},
265KMFOID_MessageDigest = {OID_PKCS_9_LENGTH+1, OID_MessageDigest},
266KMFOID_SigningTime = {OID_PKCS_9_LENGTH+1, OID_SigningTime},
267KMFOID_CounterSignature = {OID_PKCS_9_LENGTH+1, OID_CounterSignature},
268KMFOID_ChallengePassword = {OID_PKCS_9_LENGTH+1, OID_ChallengePassword},
269KMFOID_UnstructuredAddress = {OID_PKCS_9_LENGTH+1, OID_UnstructuredAddress},
270KMFOID_ExtendedCertificateAttributes = {OID_PKCS_9_LENGTH+1,
271	OID_ExtendedCertificateAttributes},
272KMFOID_ExtensionRequest = {OID_PKCS_9_LENGTH + 1, OID_ExtensionRequest};
273
274static uint8_t
275OID_AuthorityKeyID[] = { OID_EXTENSION, 1 },
276OID_VerisignCertificatePolicy[] = { OID_EXTENSION, 3 },
277OID_KeyUsageRestriction[] = { OID_EXTENSION, 4 };
278
279const KMF_OID
280KMFOID_AuthorityKeyID		 = {OID_EXTENSION_LENGTH+1, OID_AuthorityKeyID},
281
282KMFOID_VerisignCertificatePolicy = {OID_EXTENSION_LENGTH+1,
283	OID_VerisignCertificatePolicy},
284
285KMFOID_KeyUsageRestriction	 = {OID_EXTENSION_LENGTH+1,
286	OID_KeyUsageRestriction},
287
288KMFOID_SubjectDirectoryAttributes = {OID_EXTENSION_LENGTH+1,
289	OID_SubjectDirectoryAttributes},
290
291KMFOID_SubjectKeyIdentifier	 = {OID_EXTENSION_LENGTH+1,
292	OID_SubjectKeyIdentifier },
293KMFOID_KeyUsage		 = {OID_EXTENSION_LENGTH+1, OID_KeyUsage },
294
295KMFOID_PrivateKeyUsagePeriod	 = {OID_EXTENSION_LENGTH+1,
296	OID_PrivateKeyUsagePeriod},
297KMFOID_SubjectAltName	 = {OID_EXTENSION_LENGTH+1, OID_SubjectAltName },
298KMFOID_IssuerAltName	 = {OID_EXTENSION_LENGTH+1, OID_IssuerAltName },
299KMFOID_BasicConstraints	 = {OID_EXTENSION_LENGTH+1, OID_BasicConstraints },
300
301KMFOID_CrlNumber	 = {OID_EXTENSION_LENGTH+1, OID_CrlNumber},
302
303KMFOID_CrlReason	 = {OID_EXTENSION_LENGTH+1, OID_CrlReason},
304
305KMFOID_HoldInstructionCode = {OID_EXTENSION_LENGTH+1, OID_HoldInstructionCode},
306
307KMFOID_InvalidityDate	 = {OID_EXTENSION_LENGTH+1, OID_InvalidityDate},
308
309KMFOID_DeltaCrlIndicator = {OID_EXTENSION_LENGTH+1, OID_DeltaCrlIndicator},
310
311KMFOID_IssuingDistributionPoints = {OID_EXTENSION_LENGTH+1,
312	OID_IssuingDistributionPoints},
313
314KMFOID_NameConstraints	 = {OID_EXTENSION_LENGTH+1,
315	OID_NameConstraints},
316
317KMFOID_CrlDistributionPoints = {OID_EXTENSION_LENGTH+1,
318	OID_CrlDistributionPoints},
319
320KMFOID_CertificatePolicies = {OID_EXTENSION_LENGTH+1,
321	OID_CertificatePolicies},
322
323KMFOID_PolicyMappings	 = {OID_EXTENSION_LENGTH+1, OID_PolicyMappings},
324
325KMFOID_PolicyConstraints = {OID_EXTENSION_LENGTH+1, OID_PolicyConstraints},
326
327KMFOID_AuthorityKeyIdentifier = {OID_EXTENSION_LENGTH+1,
328	OID_AuthorityKeyIdentifier},
329
330KMFOID_ExtendedKeyUsage	 = {OID_EXTENSION_LENGTH+1, OID_ExtKeyUsage},
331
332KMFOID_PKIX_PQ_CPSuri	 = {OID_PKIX_QT_CPS_LENGTH, 	OID_QT_CPSuri},
333
334KMFOID_PKIX_PQ_Unotice	 = {OID_PKIX_QT_UNOTICE_LENGTH,	OID_QT_Unotice},
335
336/* Extended Key Usage OIDs */
337KMFOID_PKIX_KP_ServerAuth = {OID_PKIX_KP_LENGTH + 1, OID_KP_ServerAuth},
338
339KMFOID_PKIX_KP_ClientAuth = {OID_PKIX_KP_LENGTH + 1, OID_KP_ClientAuth},
340
341KMFOID_PKIX_KP_CodeSigning = {OID_PKIX_KP_LENGTH + 1, OID_KP_CodeSigning},
342
343KMFOID_PKIX_KP_EmailProtection	 = {OID_PKIX_KP_LENGTH + 1,
344	OID_KP_EmailProtection},
345
346KMFOID_PKIX_KP_IPSecEndSystem = {OID_PKIX_KP_LENGTH + 1, OID_KP_IPSecEndSystem},
347
348KMFOID_PKIX_KP_IPSecTunnel = {OID_PKIX_KP_LENGTH + 1, OID_KP_IPSecTunnel},
349
350KMFOID_PKIX_KP_IPSecUser = {OID_PKIX_KP_LENGTH + 1, OID_KP_IPSecUser},
351
352KMFOID_PKIX_KP_TimeStamping = {OID_PKIX_KP_LENGTH + 1, OID_KP_TimeStamping},
353
354KMFOID_PKIX_KP_OCSPSigning = {OID_PKIX_KP_LENGTH + 1, OID_KP_OCSPSigning};
355
356static uint8_t
357OID_OIW_SHA1[] = { OID_OIW_ALGORITHM, 26},
358OID_OIW_DSA[] = { OID_OIW_ALGORITHM, 12  },
359OID_OIW_DSAWithSHA1[] = { OID_OIW_ALGORITHM, 13 },
360OID_RSAEncryption[] = { OID_PKCS_1, 1 },
361OID_MD2WithRSA[]   = { OID_PKCS_1, 2 },
362OID_MD5WithRSA[]   = { OID_PKCS_1, 4 },
363OID_SHA1WithRSA[]  = { OID_PKCS_1, 5 },
364OID_SHA256WithRSA[]  = { OID_PKCS_1, 11 },
365OID_SHA384WithRSA[]  = { OID_PKCS_1, 12 },
366OID_SHA512WithRSA[]  = { OID_PKCS_1, 13 },
367OID_X9CM_DSA[] = { OID_X9CM_X9ALGORITHM, 1 },
368OID_X9CM_DSAWithSHA1[] = { OID_X9CM_X9ALGORITHM, 3};
369
370const KMF_OID
371KMFOID_SHA1 = {OID_OIW_ALGORITHM_LENGTH+1, OID_OIW_SHA1},
372KMFOID_RSA = {OID_PKCS_1_LENGTH+1, OID_RSAEncryption},
373KMFOID_DSA = {OID_OIW_ALGORITHM_LENGTH+1, OID_OIW_DSA},
374KMFOID_MD5WithRSA = {OID_PKCS_1_LENGTH+1, OID_MD5WithRSA},
375KMFOID_MD2WithRSA = {OID_PKCS_1_LENGTH+1, OID_MD2WithRSA},
376KMFOID_SHA1WithRSA = {OID_PKCS_1_LENGTH+1, OID_SHA1WithRSA},
377KMFOID_SHA256WithRSA = {OID_PKCS_1_LENGTH+1, OID_SHA256WithRSA},
378KMFOID_SHA384WithRSA = {OID_PKCS_1_LENGTH+1, OID_SHA384WithRSA},
379KMFOID_SHA512WithRSA = {OID_PKCS_1_LENGTH+1, OID_SHA512WithRSA},
380KMFOID_SHA1WithDSA  = {OID_OIW_ALGORITHM_LENGTH+1, OID_OIW_DSAWithSHA1},
381KMFOID_X9CM_DSA = {OID_X9CM_X9ALGORITHM_LENGTH+1, OID_X9CM_DSA},
382KMFOID_X9CM_DSAWithSHA1 = {OID_X9CM_X9ALGORITHM_LENGTH+1,
383		OID_X9CM_DSAWithSHA1};
384
385/*
386 * New for PKINIT support.
387 */
388static uint8_t
389OID_pkinit_san[] = { OID_KRB5_SAN },
390OID_pkinit_san_upn[] = { OID_MS_KP_SC_LOGON_UPN },
391OID_pkinit_kp_clientauth[] = { OID_KRB5_PKINIT_KPCLIENTAUTH },
392OID_pkinit_kp_kdc[] = { OID_KRB5_PKINIT_KPKDC },
393OID_pkinit_kp_sc_logon[] = { OID_MS_KP_SC_LOGON };
394
395const KMF_OID
396KMFOID_PKINIT_san = {OID_KRB5_SAN_LENGTH, OID_pkinit_san },
397KMFOID_PKINIT_ClientAuth = {OID_KRB5_PKINIT_KPCLIENTAUTH_LENGTH,
398    OID_pkinit_kp_clientauth},
399KMFOID_PKINIT_Kdc = {OID_KRB5_PKINIT_KPKDC_LENGTH,
400    OID_pkinit_kp_kdc},
401KMFOID_MS_KP_SCLogon = {OID_MS_KP_SC_LOGON_LENGTH,
402    OID_pkinit_kp_sc_logon},
403KMFOID_MS_KP_SCLogon_UPN = {OID_MS_KP_SC_LOGON_UPN_LENGTH,
404    OID_pkinit_san_upn};
405
406/*
407 * MD5
408 * iso(1) member-body(2) us(840) rsadsi(113549)
409 * digestAlgorithm(2) 5
410 */
411#define	RSADSI 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d
412#define	OID_id_md5	RSADSI, 0x02, 0x05
413
414/*
415 * SHA2 OIDs
416 */
417#define	NIST_ALG 96, 134, 72, 1, 101, 3, 4
418#define	NIST_HASH NIST_ALG, 2
419#define	OID_id_sha256 NIST_HASH, 1
420#define	OID_id_sha384 NIST_HASH, 2
421#define	OID_id_sha512 NIST_HASH, 3
422#define	OID_id_sha224 NIST_HASH, 4
423
424#define	OID_id_dsa_with_sha224	NIST_ALG, 3, 1
425#define	OID_id_dsa_with_sha256	NIST_ALG, 3, 2
426
427/*
428 * For ECC support.
429 */
430#define	CERTICOM_OID	0x2b, 0x81, 0x04
431#define	SECG_OID	CERTICOM_OID, 0x00
432
433#define	ANSI_X962_OID		0x2a, 0x86, 0x48, 0xce, 0x3d
434#define	ANSI_X962_CURVE_OID	ANSI_X962_OID, 0x03
435#define	ANSI_X962_GF2m_OID	ANSI_X962_CURVE_OID, 0x00
436#define	ANSI_X962_GFp_OID	ANSI_X962_CURVE_OID, 0x01
437
438#define	ANSI_X962_SIG_OID	ANSI_X962_OID, 0x04
439#define	OID_ecdsa_with_sha224	ANSI_X962_SIG_OID, 3, 1
440#define	OID_ecdsa_with_sha256	ANSI_X962_SIG_OID, 3, 2
441#define	OID_ecdsa_with_sha384	ANSI_X962_SIG_OID, 3, 3
442#define	OID_ecdsa_with_sha512	ANSI_X962_SIG_OID, 3, 4
443
444static uint8_t
445OID_secp112r1[] = { 0x6, 0x5, SECG_OID, 0x06 },
446OID_secp112r2[] = { 0x6, 0x5, SECG_OID, 0x07 },
447OID_secp128r1[] = { 0x6, 0x5, SECG_OID, 0x1c },
448OID_secp128r2[] = { 0x6, 0x5, SECG_OID, 0x1d },
449OID_secp160k1[] = { 0x6, 0x5, SECG_OID, 0x09 },
450OID_secp160r1[] = { 0x6, 0x5, SECG_OID, 0x08 },
451OID_secp160r2[] = { 0x6, 0x5, SECG_OID, 0x1e },
452OID_secp192k1[] = { 0x6, 0x5, SECG_OID, 0x1f },
453OID_secp224k1[] = { 0x6, 0x5, SECG_OID, 0x20 },
454OID_secp224r1[] = { 0x6, 0x5, SECG_OID, 0x21 },
455OID_secp256k1[] = { 0x6, 0x5, SECG_OID, 0x0a },
456OID_secp384r1[] = { 0x6, 0x5, SECG_OID, 0x22 },
457OID_secp521r1[] = { 0x6, 0x5, SECG_OID, 0x23 },
458OID_sect113r1[] = { 0x6, 0x5, SECG_OID, 0x04 },
459OID_sect113r2[] = { 0x6, 0x5, SECG_OID, 0x05 },
460OID_sect131r1[] = { 0x6, 0x5, SECG_OID, 0x16 },
461OID_sect131r2[] = { 0x6, 0x5, SECG_OID, 0x17 },
462OID_sect163k1[] = { 0x6, 0x5, SECG_OID, 0x01 },
463OID_sect163r1[] = { 0x6, 0x5, SECG_OID, 0x02 },
464OID_sect163r2[] = { 0x6, 0x5, SECG_OID, 0x0f },
465OID_sect193r1[] = { 0x6, 0x5, SECG_OID, 0x18 },
466OID_sect193r2[] = { 0x6, 0x5, SECG_OID, 0x19 },
467OID_sect233k1[] = { 0x6, 0x5, SECG_OID, 0x1a },
468OID_sect233r1[] = { 0x6, 0x5, SECG_OID, 0x1b },
469OID_sect239k1[] = { 0x6, 0x5, SECG_OID, 0x03 },
470OID_sect283k1[] = { 0x6, 0x5, SECG_OID, 0x10 },
471OID_sect283r1[] = { 0x6, 0x5, SECG_OID, 0x11 },
472OID_sect409k1[] = { 0x6, 0x5, SECG_OID, 0x24 },
473OID_sect409r1[] = { 0x6, 0x5, SECG_OID, 0x25 },
474OID_sect571k1[] = { 0x6, 0x5, SECG_OID, 0x26 },
475OID_sect571r1[] = { 0x6, 0x5, SECG_OID, 0x27 },
476OID_c2pnb163v1[] = { 0x6, 0x8, ANSI_X962_GF2m_OID, 0x01 },
477OID_c2pnb163v2[] = { 0x6, 0x8, ANSI_X962_GF2m_OID, 0x02 },
478OID_c2pnb163v3[] = { 0x6, 0x8, ANSI_X962_GF2m_OID, 0x03 },
479OID_c2pnb176v1[] = { 0x6, 0x8, ANSI_X962_GF2m_OID, 0x04 },
480OID_c2tnb191v1[] = { 0x6, 0x8, ANSI_X962_GF2m_OID, 0x05 },
481OID_c2tnb191v2[] = { 0x6, 0x8, ANSI_X962_GF2m_OID, 0x06 },
482OID_c2tnb191v3[] = { 0x6, 0x8, ANSI_X962_GF2m_OID, 0x07 },
483OID_c2pnb208w1[] = { 0x6, 0x8, ANSI_X962_GF2m_OID, 0x0a },
484OID_c2tnb239v1[] = { 0x6, 0x8, ANSI_X962_GF2m_OID, 0x0b },
485OID_c2tnb239v2[] = { 0x6, 0x8, ANSI_X962_GF2m_OID, 0x0c },
486OID_c2tnb239v3[] = { 0x6, 0x8, ANSI_X962_GF2m_OID, 0x0d },
487OID_c2pnb272w1[] = { 0x6, 0x8, ANSI_X962_GF2m_OID, 0x10 },
488OID_c2pnb304w1[] = { 0x6, 0x8, ANSI_X962_GF2m_OID, 0x11 },
489OID_c2tnb359v1[] = { 0x6, 0x8, ANSI_X962_GF2m_OID, 0x12 },
490OID_c2pnb368w1[] = { 0x6, 0x8, ANSI_X962_GF2m_OID, 0x13 },
491OID_c2tnb431r1[] = { 0x6, 0x8, ANSI_X962_GF2m_OID, 0x14 },
492
493OID_prime192v2[] = { 0x6, 0x8, ANSI_X962_GFp_OID, 0x02 },
494OID_prime192v3[] = { 0x6, 0x8, ANSI_X962_GFp_OID, 0x03 },
495
496OID_secp192r1[] = { 0x6, 0x8, ANSI_X962_GFp_OID, 0x01 },
497OID_secp256r1[] = { 0x6, 0x8, ANSI_X962_GFp_OID, 0x07 };
498
499const KMF_OID
500KMFOID_ECC_secp112r1 = {sizeof (OID_secp112r1), OID_secp112r1},
501KMFOID_ECC_secp112r2 = {sizeof (OID_secp112r2), OID_secp112r2},
502KMFOID_ECC_secp128r1 = {sizeof (OID_secp128r1), OID_secp128r1},
503KMFOID_ECC_secp128r2 = {sizeof (OID_secp128r2), OID_secp128r2},
504KMFOID_ECC_secp160k1 = {sizeof (OID_secp160k1), OID_secp160k1},
505KMFOID_ECC_secp160r1 = {sizeof (OID_secp160r1), OID_secp160r1},
506KMFOID_ECC_secp160r2 = {sizeof (OID_secp160r2), OID_secp160r2},
507KMFOID_ECC_secp192k1 = {sizeof (OID_secp192k1), OID_secp192k1},
508KMFOID_ECC_secp224k1 = {sizeof (OID_secp224k1), OID_secp224k1},
509KMFOID_ECC_secp224r1 = {sizeof (OID_secp224r1), OID_secp224r1},
510KMFOID_ECC_secp256k1 = {sizeof (OID_secp256k1), OID_secp256k1},
511KMFOID_ECC_secp384r1 = {sizeof (OID_secp384r1), OID_secp384r1},
512KMFOID_ECC_secp521r1 = {sizeof (OID_secp521r1), OID_secp521r1},
513KMFOID_ECC_sect113r1 = {sizeof (OID_sect113r1), OID_sect113r1},
514KMFOID_ECC_sect113r2 = {sizeof (OID_sect113r2), OID_sect113r2},
515KMFOID_ECC_sect131r1 = {sizeof (OID_sect131r1), OID_sect131r1},
516KMFOID_ECC_sect131r2 = {sizeof (OID_sect131r2), OID_sect131r2},
517KMFOID_ECC_sect163k1 = {sizeof (OID_sect163k1), OID_sect163k1},
518KMFOID_ECC_sect163r1 = {sizeof (OID_sect163r1), OID_sect163r1},
519KMFOID_ECC_sect163r2 = {sizeof (OID_sect163r2), OID_sect163r2},
520KMFOID_ECC_sect193r1 = {sizeof (OID_sect193r1), OID_sect193r1},
521KMFOID_ECC_sect193r2 = {sizeof (OID_sect193r2), OID_sect193r2},
522KMFOID_ECC_sect233k1 = {sizeof (OID_sect233k1), OID_sect233k1},
523KMFOID_ECC_sect233r1 = {sizeof (OID_sect233r1), OID_sect233r1},
524KMFOID_ECC_sect239k1 = {sizeof (OID_sect239k1), OID_sect239k1},
525KMFOID_ECC_sect283k1 = {sizeof (OID_sect283k1), OID_sect283k1},
526KMFOID_ECC_sect283r1 = {sizeof (OID_sect283r1), OID_sect283r1},
527KMFOID_ECC_sect409k1 = {sizeof (OID_sect409k1), OID_sect409k1},
528KMFOID_ECC_sect409r1 = {sizeof (OID_sect409r1), OID_sect409r1},
529KMFOID_ECC_sect571k1 = {sizeof (OID_sect571k1), OID_sect571k1},
530KMFOID_ECC_sect571r1 = {sizeof (OID_sect571r1), OID_sect571r1},
531KMFOID_ECC_c2pnb163v1 = {sizeof (OID_c2pnb163v1), OID_c2pnb163v1},
532KMFOID_ECC_c2pnb163v2 = {sizeof (OID_c2pnb163v2), OID_c2pnb163v2},
533KMFOID_ECC_c2pnb163v3 = {sizeof (OID_c2pnb163v3), OID_c2pnb163v3},
534KMFOID_ECC_c2pnb176v1 = {sizeof (OID_c2pnb176v1), OID_c2pnb176v1},
535KMFOID_ECC_c2tnb191v1 = {sizeof (OID_c2tnb191v1), OID_c2tnb191v1},
536KMFOID_ECC_c2tnb191v2 = {sizeof (OID_c2tnb191v2), OID_c2tnb191v2},
537KMFOID_ECC_c2tnb191v3 = {sizeof (OID_c2tnb191v3), OID_c2tnb191v3},
538KMFOID_ECC_c2pnb208w1 = {sizeof (OID_c2pnb208w1), OID_c2pnb208w1},
539KMFOID_ECC_c2tnb239v1 = {sizeof (OID_c2tnb239v1), OID_c2tnb239v1},
540KMFOID_ECC_c2tnb239v2 = {sizeof (OID_c2tnb239v2), OID_c2tnb239v2},
541KMFOID_ECC_c2tnb239v3 = {sizeof (OID_c2tnb239v3), OID_c2tnb239v3},
542KMFOID_ECC_c2pnb272w1 = {sizeof (OID_c2pnb272w1), OID_c2pnb272w1},
543KMFOID_ECC_c2pnb304w1 = {sizeof (OID_c2pnb304w1), OID_c2pnb304w1},
544KMFOID_ECC_c2tnb359v1 = {sizeof (OID_c2tnb359v1), OID_c2tnb359v1},
545KMFOID_ECC_c2pnb368w1 = {sizeof (OID_c2pnb368w1), OID_c2pnb368w1},
546KMFOID_ECC_c2tnb431r1 = {sizeof (OID_c2tnb431r1), OID_c2tnb431r1},
547KMFOID_ECC_prime192v2 = {sizeof (OID_prime192v2), OID_prime192v2},
548KMFOID_ECC_prime192v3 = {sizeof (OID_prime192v3), OID_prime192v3},
549KMFOID_ECC_secp192r1 = {sizeof (OID_secp192r1), OID_secp192r1},
550KMFOID_ECC_secp256r1 = {sizeof (OID_secp256r1), OID_secp256r1};
551
552static uint8_t
553OID_EC_PUBLIC_KEY[] = {ANSI_X962_OID, 0x02, 0x01},
554OID_ECDSA_SHA1[] = {ANSI_X962_OID, 0x04, 0x01},
555OID_ECDSA_SHA224[] = {ANSI_X962_OID, 0x04, 0x03, 0x01},
556OID_ECDSA_SHA256[] = {ANSI_X962_OID, 0x04, 0x03, 0x02},
557OID_ECDSA_SHA384[] = {ANSI_X962_OID, 0x04, 0x03, 0x03},
558OID_ECDSA_SHA512[] = {ANSI_X962_OID, 0x04, 0x03, 0x04},
559OID_DSA_SHA224[] = {OID_id_dsa_with_sha224},
560OID_DSA_SHA256[] = {OID_id_dsa_with_sha256},
561OID_SHA224[] = {OID_id_sha224},
562OID_SHA256[] = {OID_id_sha256},
563OID_SHA384[] = {OID_id_sha384},
564OID_SHA512[] = {OID_id_sha512},
565OID_MD5[] = {OID_id_md5};
566
567const KMF_OID
568KMFOID_EC_PUBLIC_KEY = { sizeof (OID_EC_PUBLIC_KEY), OID_EC_PUBLIC_KEY},
569KMFOID_SHA1WithECDSA = { sizeof (OID_ECDSA_SHA1), OID_ECDSA_SHA1},
570KMFOID_SHA224WithECDSA = { sizeof (OID_ECDSA_SHA224), OID_ECDSA_SHA224},
571KMFOID_SHA256WithECDSA = { sizeof (OID_ECDSA_SHA256), OID_ECDSA_SHA256},
572KMFOID_SHA384WithECDSA = { sizeof (OID_ECDSA_SHA384), OID_ECDSA_SHA384},
573KMFOID_SHA512WithECDSA = { sizeof (OID_ECDSA_SHA512), OID_ECDSA_SHA512},
574KMFOID_SHA224WithDSA = { sizeof (OID_DSA_SHA224), OID_DSA_SHA224},
575KMFOID_SHA256WithDSA = { sizeof (OID_DSA_SHA256), OID_DSA_SHA256},
576KMFOID_SHA224 = { sizeof (OID_SHA224), OID_SHA224},
577KMFOID_SHA256 = { sizeof (OID_SHA256), OID_SHA256},
578KMFOID_SHA384 = { sizeof (OID_SHA384), OID_SHA384},
579KMFOID_SHA512 = { sizeof (OID_SHA512), OID_SHA512},
580KMFOID_MD5 = { sizeof (OID_MD5), OID_MD5};
581