]> git.saurik.com Git - apple/security.git/blob - cdsa/cssm/oidsalg.c
Security-179.tar.gz
[apple/security.git] / cdsa / cssm / oidsalg.c
1 /*
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
3 *
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
8 * using this file.
9 *
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
16 */
17
18
19 /*
20 * oidsalg.c - OIDs defining crypto algorithms
21 */
22
23 #include <Security/oidsbase.h>
24 #include <Security/cssmtype.h>
25 #include <Security/cssmapple.h>
26 #include <string.h>
27
28 static const uint8
29 OID_MD2[] = { OID_RSA_HASH, 2 },
30 OID_MD4[] = { OID_RSA_HASH, 4 },
31 OID_MD5[] = { OID_RSA_HASH, 5 },
32 OID_RSAEncryption[] = { OID_PKCS_1, 1 },
33 OID_MD2WithRSA[] = { OID_PKCS_1, 2 },
34 OID_MD4WithRSA[] = { OID_PKCS_1, 3 },
35 OID_MD5WithRSA[] = { OID_PKCS_1, 4 },
36 OID_SHA1WithRSA[] = { OID_PKCS_1, 5 },
37 OID_PKCS_3_ARC[] = { OID_PKCS_3 },
38 OID_DHKeyAgreement[] = { OID_PKCS_3, 1 },
39 /* BSAFE-specific DSA */
40 OID_OIW_DSA[] = { OID_OIW_ALGORITHM, 12 },
41 OID_OIW_DSAWithSHA1[] = { OID_OIW_ALGORITHM, 27 },
42 /* DSA from CMS */
43 OID_CMS_DSA[] = { 0x2A, 0x86, 0x48, 0xCE, 0x38, 4, 1 },
44 OID_CMS_DSAWithSHA1[] = { 0x2A, 0x86, 0x48, 0xCE, 0x38, 4, 3 },
45 /* DSA from JDK 1.1 */
46 OID_JDK_DSA[] = { 0x2B, 0x0E, 0x03, 0x02, 0x0c },
47 OID_JDK_DSAWithSHA1[] = { 0x2B, 0x0E, 0x03, 0x02, 0x0D },
48
49 OID_OIW_SHA1[] = { OID_OIW_ALGORITHM, 26 },
50 OID_OIW_RSAWithSHA1[] = { OID_OIW_ALGORITHM, 29 },
51
52 /* ANSI X9.42 */
53 OID_ANSI_DH_PUB_NUMBER[]= { OID_ANSI_X9_42, 1 },
54 OID_ANSI_DH_STATIC[] = { OID_ANSI_X9_42_SCHEME, 1 },
55 OID_ANSI_DH_EPHEM[] = { OID_ANSI_X9_42_SCHEME, 2 },
56 OID_ANSI_DH_ONE_FLOW[] = { OID_ANSI_X9_42_SCHEME, 3 },
57 OID_ANSI_DH_HYBRID1[] = { OID_ANSI_X9_42_SCHEME, 4 },
58 OID_ANSI_DH_HYBRID2[] = { OID_ANSI_X9_42_SCHEME, 5 },
59 OID_ANSI_DH_HYBRID_ONEFLOW[] = { OID_ANSI_X9_42_SCHEME, 6 },
60 /* sic - enumerated in reverse order in the spec */
61 OID_ANSI_MQV1[] = { OID_ANSI_X9_42_SCHEME, 8 },
62 OID_ANSI_MQV2[] = { OID_ANSI_X9_42_SCHEME, 7 },
63
64 OID_ANSI_DH_STATIC_SHA1[] = { OID_ANSI_X9_42_NAMED_SCHEME, 1 },
65 OID_ANSI_DH_EPHEM_SHA1[] = { OID_ANSI_X9_42_NAMED_SCHEME, 2 },
66 OID_ANSI_DH_ONE_FLOW_SHA1[] = { OID_ANSI_X9_42_NAMED_SCHEME, 3 },
67 OID_ANSI_DH_HYBRID1_SHA1[] = { OID_ANSI_X9_42_NAMED_SCHEME, 4 },
68 OID_ANSI_DH_HYBRID2_SHA1[] = { OID_ANSI_X9_42_NAMED_SCHEME, 5 },
69 OID_ANSI_DH_HYBRID_ONEFLOW_SHA1[] = { OID_ANSI_X9_42_NAMED_SCHEME, 6 },
70 /* sic - enumerated in reverse order in the spec */
71 OID_ANSI_MQV1_SHA1[] = { OID_ANSI_X9_42_NAMED_SCHEME, 8 },
72 OID_ANSI_MQV2_SHA1[] = { OID_ANSI_X9_42_NAMED_SCHEME, 7 };
73
74 const CSSM_OID
75 CSSMOID_MD2 = {OID_RSA_HASH_LENGTH+1, (uint8 *)OID_MD2},
76 CSSMOID_MD4 = {OID_RSA_HASH_LENGTH+1, (uint8 *)OID_MD4},
77 CSSMOID_MD5 = {OID_RSA_HASH_LENGTH+1, (uint8 *)OID_MD5},
78 CSSMOID_RSA = {OID_PKCS_1_LENGTH+1, (uint8 *)OID_RSAEncryption},
79 CSSMOID_MD2WithRSA = {OID_PKCS_1_LENGTH+1, (uint8 *)OID_MD2WithRSA},
80 CSSMOID_MD4WithRSA = {OID_PKCS_1_LENGTH+1, (uint8 *)OID_MD4WithRSA},
81 CSSMOID_MD5WithRSA = {OID_PKCS_1_LENGTH+1, (uint8 *)OID_MD5WithRSA},
82 CSSMOID_SHA1WithRSA = {OID_PKCS_1_LENGTH+1, (uint8 *)OID_SHA1WithRSA},
83 CSSMOID_PKCS3 = {OID_PKCS_3_LENGTH, (uint8 *)OID_PKCS_3_ARC},
84 CSSMOID_DH = {OID_PKCS_3_LENGTH+1, (uint8 *)OID_DHKeyAgreement},
85 CSSMOID_DSA = {OID_OIW_ALGORITHM_LENGTH+1, (uint8 *)OID_OIW_DSA},
86 CSSMOID_DSA_CMS = { 7, (uint8 *)OID_CMS_DSA},
87 CSSMOID_DSA_JDK = { 5, (uint8 *)OID_JDK_DSA},
88 CSSMOID_SHA1WithDSA = {OID_OIW_ALGORITHM_LENGTH+1, (uint8 *)OID_OIW_DSAWithSHA1},
89 CSSMOID_SHA1WithDSA_CMS = { 7, (uint8 *)OID_CMS_DSAWithSHA1},
90 CSSMOID_SHA1WithDSA_JDK = { 5, (uint8 *)OID_JDK_DSAWithSHA1},
91 CSSMOID_SHA1 = {OID_OIW_ALGORITHM_LENGTH+1, (uint8 *)OID_OIW_SHA1},
92 CSSMOID_SHA1WithRSA_OIW = {OID_OIW_ALGORITHM_LENGTH+1, (uint8 *)OID_OIW_RSAWithSHA1},
93 CSSMOID_ANSI_DH_PUB_NUMBER = {OID_ANSI_X9_42_LEN + 1, (uint8 *)OID_ANSI_DH_PUB_NUMBER},
94 CSSMOID_ANSI_DH_STATIC = {OID_ANSI_X9_42_SCHEME_LEN + 1, (uint8 *)OID_ANSI_DH_STATIC},
95 CSSMOID_ANSI_DH_ONE_FLOW = {OID_ANSI_X9_42_SCHEME_LEN + 1, (uint8 *)OID_ANSI_DH_ONE_FLOW},
96 CSSMOID_ANSI_DH_EPHEM = {OID_ANSI_X9_42_SCHEME_LEN + 1, (uint8 *)OID_ANSI_DH_EPHEM},
97 CSSMOID_ANSI_DH_HYBRID1 = {OID_ANSI_X9_42_SCHEME_LEN + 1, (uint8 *)OID_ANSI_DH_HYBRID1},
98 CSSMOID_ANSI_DH_HYBRID2 = {OID_ANSI_X9_42_SCHEME_LEN + 1, (uint8 *)OID_ANSI_DH_HYBRID2},
99 CSSMOID_ANSI_DH_HYBRID_ONEFLOW = {OID_ANSI_X9_42_SCHEME_LEN + 1,
100 (uint8 *)OID_ANSI_DH_HYBRID_ONEFLOW},
101 CSSMOID_ANSI_DH_MQV1 = {OID_ANSI_X9_42_SCHEME_LEN + 1, (uint8 *)OID_ANSI_MQV1},
102 CSSMOID_ANSI_DH_MQV2 = {OID_ANSI_X9_42_SCHEME_LEN + 1, (uint8 *)OID_ANSI_MQV2},
103 CSSMOID_ANSI_DH_STATIC_SHA1 = {OID_ANSI_X9_42_NAMED_SCHEME_LEN + 1,
104 (uint8 *)OID_ANSI_DH_STATIC_SHA1},
105 CSSMOID_ANSI_DH_ONE_FLOW_SHA1 = {OID_ANSI_X9_42_NAMED_SCHEME_LEN + 1,
106 (uint8 *)OID_ANSI_DH_ONE_FLOW_SHA1},
107 CSSMOID_ANSI_DH_EPHEM_SHA1 = {OID_ANSI_X9_42_NAMED_SCHEME_LEN + 1,
108 (uint8 *)OID_ANSI_DH_EPHEM_SHA1},
109 CSSMOID_ANSI_DH_HYBRID1_SHA1 = {OID_ANSI_X9_42_NAMED_SCHEME_LEN + 1,
110 (uint8 *)OID_ANSI_DH_HYBRID1_SHA1},
111 CSSMOID_ANSI_DH_HYBRID2_SHA1 = {OID_ANSI_X9_42_NAMED_SCHEME_LEN + 1,
112 (uint8 *)OID_ANSI_DH_HYBRID2_SHA1},
113 CSSMOID_ANSI_DH_HYBRID_ONEFLOW_SHA1 = {OID_ANSI_X9_42_NAMED_SCHEME_LEN + 1,
114 (uint8 *)OID_ANSI_DH_HYBRID_ONEFLOW_SHA1},
115 CSSMOID_ANSI_MQV1_SHA1 = {OID_ANSI_X9_42_NAMED_SCHEME_LEN + 1,
116 (uint8 *)OID_ANSI_MQV1_SHA1},
117 CSSMOID_ANSI_MQV2_SHA1 = {OID_ANSI_X9_42_NAMED_SCHEME_LEN + 1,
118 (uint8 *)OID_ANSI_MQV2_SHA1};
119
120
121 /* iSignTP OBJECT IDENTIFIER ::=
122 * { appleTrustPolicy 1 }
123 * { 1 2 840 113635 100 1 1 }
124 *
125 * BER = 06 09 2A 86 48 86 F7 63 64 01 01
126 */
127 static const uint8
128 APPLE_TP_ISIGN[] = {APPLE_TP_OID, 1},
129
130 /* AppleX509Basic OBJECT IDENTIFIER ::=
131 * { appleTrustPolicy 2 }
132 * { 1 2 840 113635 100 1 2 }
133 *
134 * BER = 06 09 2A 86 48 86 F7 63 64 01 01
135 */
136 APPLE_TP_X509_BASIC[] = {APPLE_TP_OID, 2},
137
138 /* AppleSSLPolicy := {appleTrustPolicy 3 } */
139 APPLE_TP_SSL[] = {APPLE_TP_OID, 3},
140
141 /* AppleLocalCertGenPolicy := {appleTrustPolicy 4 } */
142 APPLE_TP_LOCAL_CERT_GEN[] = {APPLE_TP_OID, 4},
143
144 /* AppleCSRGenPolicy := {appleTrustPolicy 5 } */
145 APPLE_TP_CSR_GEN[] = {APPLE_TP_OID, 5},
146
147 /* Apple CRL-based revocation policy := {appleTrustPolicy 6 } */
148 APPLE_TP_REVOCATION_CRL[] = {APPLE_TP_OID, 6},
149
150 /* Apple OCSP-based revocation policy := {appleTrustPolicy 7 } */
151 APPLE_TP_REVOCATION_OCSP[] = {APPLE_TP_OID, 7},
152
153 /* Apple S/MIME trust policy := {appleTrustPolicy 8 } */
154 APPLE_TP_SMIME[] = {APPLE_TP_OID, 8},
155
156 /* Apple EAP trust policy := {appleTrustPolicy 9 } */
157 APPLE_TP_EAP[] = {APPLE_TP_OID, 9},
158
159 /*
160 * fee OBJECT IDENTIFIER ::=
161 * { appleSecurityAlgorithm 1 }
162 * { 1 2 840 113635 100 2 1 }
163 *
164 * BER = 06 09 2A 86 48 86 F7 63 64 02 01
165 */
166 APPLE_FEE[] = {APPLE_ALG_OID, 1},
167
168 /*
169 * asc OBJECT IDENTIFIER ::=
170 * { appleSecurityAlgorithm 2 }
171 * { 1 2 840 113635 100 2 2 }
172 *
173 * BER = 06 09 2A 86 48 86 F7 63 64 02 02
174 */
175 APPLE_ASC[] = {APPLE_ALG_OID, 2},
176
177 /*
178 * fee_MD5 OBJECT IDENTIFIER ::=
179 * { appleSecurityAlgorithm 3 }
180 * { 1 2 840 113635 100 2 3 }
181 *
182 * BER = 06 09 2A 86 48 86 F7 63 64 02 03
183 */
184 APPLE_FEE_MD5[] = {APPLE_ALG_OID, 3},
185
186 /*
187 * fee_SHA1 OBJECT IDENTIFIER ::=
188 * { appleSecurityAlgorithm 4 }
189 * { 1 2 840 113635 100 2 4 }
190 *
191 * BER = 06 09 2A 86 48 86 F7 63 64 02 04
192 */
193 APPLE_FEE_SHA1[] = {APPLE_ALG_OID, 4},
194
195 /*
196 * feed OBJECT IDENTIFIER ::=
197 * { appleSecurityAlgorithm 5 }
198 * { 1 2 840 113635 100 2 5 }
199 *
200 * BER = 06 09 2A 86 48 86 F7 63 64 02 05
201 */
202 APPLE_FEED[] = {APPLE_ALG_OID, 5},
203
204 /*
205 * feedExp OBJECT IDENTIFIER ::=
206 * { appleSecurityAlgorithm 6 }
207 * { 1 2 840 113635 100 2 6 }
208 *
209 * BER = 06 09 2A 86 48 86 F7 63 64 02 06
210 */
211 APPLE_FEEDEXP[] = {APPLE_ALG_OID, 6},
212
213 /*
214 * AppleECDSA OBJECT IDENTIFIER ::=
215 * { appleSecurityAlgorithm 7 }
216 * { 1 2 840 113635 100 2 7 }
217 *
218 * BER = 06 09 2A 86 48 86 F7 63 64 02 07
219 */
220 APPLE_ECDSA[] = {APPLE_ALG_OID, 7};
221
222 const CSSM_OID
223
224 CSSMOID_APPLE_ISIGN = {APPLE_TP_OID_LENGTH+1, (uint8 *)APPLE_TP_ISIGN},
225 CSSMOID_APPLE_X509_BASIC = {APPLE_TP_OID_LENGTH+1, (uint8 *)APPLE_TP_X509_BASIC},
226 CSSMOID_APPLE_TP_SSL = {APPLE_TP_OID_LENGTH+1, (uint8 *)APPLE_TP_SSL},
227 CSSMOID_APPLE_TP_LOCAL_CERT_GEN =
228 {APPLE_TP_OID_LENGTH+1, (uint8 *)APPLE_TP_LOCAL_CERT_GEN},
229 CSSMOID_APPLE_TP_CSR_GEN = {APPLE_TP_OID_LENGTH+1, (uint8 *)APPLE_TP_CSR_GEN},
230 CSSMOID_APPLE_TP_REVOCATION_CRL =
231 {APPLE_TP_OID_LENGTH+1, (uint8 *)APPLE_TP_REVOCATION_CRL},
232 CSSMOID_APPLE_TP_REVOCATION_OCSP =
233 {APPLE_TP_OID_LENGTH+1, (uint8 *)APPLE_TP_REVOCATION_OCSP},
234 CSSMOID_APPLE_TP_SMIME = {APPLE_TP_OID_LENGTH+1, (uint8 *)APPLE_TP_SMIME},
235 CSSMOID_APPLE_TP_EAP = {APPLE_TP_OID_LENGTH+1, (uint8 *)APPLE_TP_EAP},
236 CSSMOID_APPLE_FEE = {APPLE_ALG_OID_LENGTH+1, (uint8 *)APPLE_FEE},
237 CSSMOID_APPLE_ASC = {APPLE_ALG_OID_LENGTH+1, (uint8 *)APPLE_ASC},
238 CSSMOID_APPLE_FEE_MD5 = {APPLE_ALG_OID_LENGTH+1, (uint8 *)APPLE_FEE_MD5},
239 CSSMOID_APPLE_FEE_SHA1 = {APPLE_ALG_OID_LENGTH+1, (uint8 *)APPLE_FEE_SHA1},
240 CSSMOID_APPLE_FEED = {APPLE_ALG_OID_LENGTH+1, (uint8 *)APPLE_FEED},
241 CSSMOID_APPLE_FEEDEXP = {APPLE_ALG_OID_LENGTH+1, (uint8 *)APPLE_FEEDEXP},
242 CSSMOID_APPLE_ECDSA = {APPLE_ALG_OID_LENGTH+1, (uint8 *)APPLE_ECDSA};
243
244 /* PKCS12 algorithms */
245 #define OID_PKCS12_PbeIds OID_PKCS_12,1
246 #define OID_PKCS12_PbeIds_Length OID_PKCS_12_LENGTH+1
247
248 static const uint8
249 OID_PKCS12_pbeWithSHAAnd128BitRC4[] = { OID_PKCS12_PbeIds, 1 },
250 OID_PKCS12_pbeWithSHAAnd40BitRC4[] = { OID_PKCS12_PbeIds, 2 },
251 OID_PKCS12_pbeWithSHAAnd3Key3DESCBC[] = { OID_PKCS12_PbeIds, 3 },
252 OID_PKCS12_pbeWithSHAAnd2Key3DESCBC[] = { OID_PKCS12_PbeIds, 4 },
253 OID_PKCS12_pbeWithSHAAnd128BitRC2CBC[] ={ OID_PKCS12_PbeIds, 5 },
254 OID_PKCS12_pbewithSHAAnd40BitRC2CBC[] = { OID_PKCS12_PbeIds, 6 };
255
256
257 const CSSM_OID
258 CSSMOID_PKCS12_pbeWithSHAAnd128BitRC4 = {OID_PKCS12_PbeIds_Length + 1,
259 (uint8 *)OID_PKCS12_pbeWithSHAAnd128BitRC4 },
260 CSSMOID_PKCS12_pbeWithSHAAnd40BitRC4 = {OID_PKCS12_PbeIds_Length + 1,
261 (uint8 *)OID_PKCS12_pbeWithSHAAnd40BitRC4 },
262 CSSMOID_PKCS12_pbeWithSHAAnd3Key3DESCBC = {OID_PKCS12_PbeIds_Length + 1,
263 (uint8 *)OID_PKCS12_pbeWithSHAAnd3Key3DESCBC },
264 CSSMOID_PKCS12_pbeWithSHAAnd2Key3DESCBC = {OID_PKCS12_PbeIds_Length + 1,
265 (uint8 *)OID_PKCS12_pbeWithSHAAnd2Key3DESCBC },
266 CSSMOID_PKCS12_pbeWithSHAAnd128BitRC2CBC = {OID_PKCS12_PbeIds_Length + 1,
267 (uint8 *)OID_PKCS12_pbeWithSHAAnd128BitRC2CBC },
268 CSSMOID_PKCS12_pbewithSHAAnd40BitRC2CBC = {OID_PKCS12_PbeIds_Length + 1,
269 (uint8 *)OID_PKCS12_pbewithSHAAnd40BitRC2CBC };
270
271
272 #pragma mark ----- CSSM_OID <--> CSSM_ALGORITHMS -----
273
274 typedef struct {
275 const CSSM_OID *oid;
276 CSSM_ALGORITHMS alg;
277 } OidToAlgEnt;
278
279 static const OidToAlgEnt oidToAlgMap[] =
280 {
281 {&CSSMOID_RSA, CSSM_ALGID_RSA },
282 {&CSSMOID_MD2WithRSA, CSSM_ALGID_MD2WithRSA },
283 {&CSSMOID_MD5WithRSA, CSSM_ALGID_MD5WithRSA },
284 {&CSSMOID_SHA1WithRSA, CSSM_ALGID_SHA1WithRSA },
285 {&CSSMOID_SHA1WithRSA_OIW, CSSM_ALGID_SHA1WithRSA },
286 {&CSSMOID_SHA1, CSSM_ALGID_SHA1},
287 {&CSSMOID_MD5, CSSM_ALGID_MD5 },
288 /*
289 * These OIDs have three variants - one for BSAFE, CMS, and JDK 1.1.
290 * On the oid-to-alg map, we'll handle either one, mapping to
291 * the same CSSM alg. When we map from alg to OID, we'll use
292 * the CMS variant (being first in the list).
293 */
294 {&CSSMOID_DSA_CMS, CSSM_ALGID_DSA },
295 {&CSSMOID_DSA, CSSM_ALGID_DSA },
296 {&CSSMOID_DSA_JDK, CSSM_ALGID_DSA },
297 {&CSSMOID_SHA1WithDSA_CMS, CSSM_ALGID_SHA1WithDSA },
298 {&CSSMOID_SHA1WithDSA, CSSM_ALGID_SHA1WithDSA },
299 {&CSSMOID_SHA1WithDSA_JDK, CSSM_ALGID_SHA1WithDSA },
300 /*
301 * Multiple entries for Diffie-Hellman. We favor the PKCS3 version for
302 * mapping alg to OID.
303 */
304 {&CSSMOID_DH, CSSM_ALGID_DH},
305 {&CSSMOID_ANSI_DH_PUB_NUMBER, CSSM_ALGID_DH},
306 {&CSSMOID_ANSI_DH_STATIC, CSSM_ALGID_DH},
307 {&CSSMOID_ANSI_DH_ONE_FLOW, CSSM_ALGID_DH},
308 {&CSSMOID_ANSI_DH_EPHEM, CSSM_ALGID_DH},
309 {&CSSMOID_ANSI_DH_HYBRID1, CSSM_ALGID_DH},
310 {&CSSMOID_ANSI_DH_HYBRID2, CSSM_ALGID_DH},
311 {&CSSMOID_ANSI_DH_HYBRID_ONEFLOW, CSSM_ALGID_DH},
312 {&CSSMOID_APPLE_FEE, CSSM_ALGID_FEE },
313 {&CSSMOID_APPLE_ASC, CSSM_ALGID_ASC },
314 {&CSSMOID_APPLE_FEE_MD5, CSSM_ALGID_FEE_MD5 },
315 {&CSSMOID_APPLE_FEE_SHA1, CSSM_ALGID_FEE_SHA1 },
316 {&CSSMOID_APPLE_FEED, CSSM_ALGID_FEED },
317 {&CSSMOID_APPLE_FEEDEXP, CSSM_ALGID_FEEDEXP },
318 {&CSSMOID_APPLE_ECDSA, CSSM_ALGID_SHA1WithECDSA },
319 {NULL, 0}
320 };
321
322 #define NUM_OID_TO_ALGS (sizeof(oidToAlgMap) / sizeof(oidToAlgMap[0]))
323
324 /*
325 * Compare two CSSM_DATAs (or two CSSM_OIDs), return true if identical.
326 */
327 static bool compareCssmData(
328 const CSSM_DATA *data1,
329 const CSSM_DATA *data2)
330 {
331 if((data1 == NULL) || (data1->Data == NULL) ||
332 (data2 == NULL) || (data2->Data == NULL) ||
333 (data1->Length != data2->Length)) {
334 return false;
335 }
336 if(data1->Length != data2->Length) {
337 return false;
338 }
339 if(memcmp(data1->Data, data2->Data, data1->Length) == 0) {
340 return true;
341 }
342 else {
343 return false;
344 }
345 }
346
347 bool cssmOidToAlg(
348 const CSSM_OID *oid,
349 CSSM_ALGORITHMS *alg) // RETURNED
350 {
351 const OidToAlgEnt *ent;
352
353 for(ent=oidToAlgMap; ent->oid; ent++) {
354 if(compareCssmData(ent->oid, oid)) {
355 *alg = ent->alg;
356 return true;
357 }
358 }
359 return false;
360 }
361
362 const CSSM_OID *cssmAlgToOid(
363 CSSM_ALGORITHMS algId)
364 {
365 const OidToAlgEnt *ent;
366
367 for(ent=oidToAlgMap; ent->oid; ent++) {
368 if(ent->alg == algId) {
369 return ent->oid;
370 }
371 }
372 return NULL;
373 }
374
375