]> git.saurik.com Git - apple/security.git/blobdiff - libsecurity_smime/lib/secoid.c
Security-58286.41.2.tar.gz
[apple/security.git] / libsecurity_smime / lib / secoid.c
index 2f0f62a99b6fdb7d1a14b456120b8b65ceb8ce59..af40f9ca15c3813937df14f4c4a071b92944aa26 100644 (file)
 #include <security_asn1/secerr.h>
 #include <security_asn1/secport.h>
 
+#if USE_CDSA_CRYPTO
+#include <Security/cssmapple.h>
+#else
 #include <Security/oidsalg.h>
 #include <CommonCrypto/CommonCryptor.h>
-
+#endif
 #include <pthread.h>
 
 /* MISSI Mosaic Object ID space */
@@ -484,7 +487,11 @@ CONST_OID noOid[]                          = { 0 };
 
 #define OI(x) { sizeof x, (uint8_t *)x }
 #ifndef SECOID_NO_STRINGS
+#if USE_CDSA_CRYPTO
+#define OD(oid,tag,desc,mech,ext) { OI(oid), tag, desc, mech, ext }
+#else
 #define OD(oid,tag,desc,mech,ext) { OI(oid), tag, desc, ext }
+#endif
 #else
 #define OD(oid,tag,desc,mech,ext) { OI(oid), tag, 0, mech, ext }
 #endif
@@ -1334,16 +1341,28 @@ InitOIDHash(void)
     }
 
     for ( ix = 0; ix < ( sizeof(oids) / sizeof(SECOidData) ); ix++ ) {
-        oid = &oids[ix];
+       oid = &oids[ix];
+
+       PORT_Assert ( oid->offset == ix );
 
-        PORT_Assert ( oid->offset == ix );
+       entry = PL_HashTableAdd( oidhash, &oid->oid, (void *)oid );
+       if ( entry == NULL ) {
+           PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
+            PORT_Assert(0); /*This function should never fail. */
+           return(SECFailure);
+       }
 
-        entry = PL_HashTableAdd( oidhash, &oid->oid, (void *)oid );
-        if ( entry == NULL ) {
-            PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
-                PORT_Assert(0); /*This function should never fail. */
-            return(SECFailure);
-        }
+#if USE_CDSA_CRYPTO
+       if ( oid->cssmAlgorithm.algorithm.Length /*CSSM_ALGID_NONE*/ ) {
+           entry = PL_HashTableAdd( oidmechhash, 
+                                       (void *)&(oid->cssmAlgorithm), (void *)oid );
+           if ( entry == NULL ) {
+               PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
+                PORT_Assert(0); /* This function should never fail. */
+               return(SECFailure);
+           }
+       }
+#endif
     }
 
     PORT_Assert (ix == SEC_OID_TOTAL);