gcm128.c: make it work with no-sse2.
[openssl.git] / crypto / x509v3 / v3_purp.c
index a5d9805ce466bdad1c54c8cb280b3f41fabe22a2..e7cf7011604af0ea94ecbfa96686d4d19f94ac53 100644 (file)
@@ -1,5 +1,5 @@
 /* v3_purp.c */
-/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
+/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
  * project 2001.
  */
 /* ====================================================================
@@ -272,8 +272,8 @@ static int nid_cmp(const int *a, const int *b)
        return *a - *b;
        }
 
-DECLARE_OBJ_BSEARCH_CMP_FN(int, int, nid_cmp);
-IMPLEMENT_OBJ_BSEARCH_CMP_FN(int, int, nid_cmp);
+DECLARE_OBJ_BSEARCH_CMP_FN(int, int, nid);
+IMPLEMENT_OBJ_BSEARCH_CMP_FN(int, int, nid);
 
 int X509_supported_extension(X509_EXTENSION *ex)
        {
@@ -303,13 +303,13 @@ int X509_supported_extension(X509_EXTENSION *ex)
                NID_inhibit_any_policy  /* 748 */
        };
 
-       const int ex_nid = OBJ_obj2nid(X509_EXTENSION_get_object(ex));
+       int ex_nid = OBJ_obj2nid(X509_EXTENSION_get_object(ex));
 
        if (ex_nid == NID_undef) 
                return 0;
 
-       if (OBJ_bsearch(int, &ex_nid, int, supported_nids,
-                       sizeof(supported_nids)/sizeof(int), nid_cmp))
+       if (OBJ_bsearch_nid(&ex_nid, supported_nids,
+                       sizeof(supported_nids)/sizeof(int)))
                return 1;
        return 0;
        }
@@ -368,9 +368,6 @@ static void x509v3_cache_extensions(X509 *x)
 #ifndef OPENSSL_NO_SHA
        X509_digest(x, EVP_sha1(), x->sha1_hash, NULL);
 #endif
-       /* Does subject name match issuer ? */
-       if(!X509_NAME_cmp(X509_get_subject_name(x), X509_get_issuer_name(x)))
-                        x->ex_flags |= EXFLAG_SI;
        /* V1 should mean no extensions ... */
        if(!X509_get_version(x)) x->ex_flags |= EXFLAG_V1;
        /* Handle basic constraints */
@@ -447,6 +444,10 @@ static void x509v3_cache_extensions(X509 *x)
                                case NID_dvcs:
                                x->ex_xkusage |= XKU_DVCS;
                                break;
+
+                               case NID_anyExtendedKeyUsage:
+                               x->ex_xkusage |= XKU_ANYEKU;
+                               break;
                        }
                }
                sk_ASN1_OBJECT_pop_free(extusage, ASN1_OBJECT_free);
@@ -460,6 +461,14 @@ static void x509v3_cache_extensions(X509 *x)
        }
        x->skid =X509_get_ext_d2i(x, NID_subject_key_identifier, NULL, NULL);
        x->akid =X509_get_ext_d2i(x, NID_authority_key_identifier, NULL, NULL);
+       /* Does subject name match issuer ? */
+       if(!X509_NAME_cmp(X509_get_subject_name(x), X509_get_issuer_name(x)))
+                       {
+                       x->ex_flags |= EXFLAG_SI;
+                       /* If SKID matches AKID also indicate self signed */
+                       if (X509_check_akid(x, x->akid) == X509_V_OK)
+                               x->ex_flags |= EXFLAG_SS;
+                       }
        x->altname = X509_get_ext_d2i(x, NID_subject_alt_name, NULL, NULL);
        x->nc = X509_get_ext_d2i(x, NID_name_constraints, &i, NULL);
        if (!x->nc && (i != -1))