X509_CRL_digest() - ensure precomputed sha1 hash before returning it
authorRichard Levitte <levitte@openssl.org>
Sat, 28 Jan 2017 16:43:17 +0000 (17:43 +0100)
committerRichard Levitte <levitte@openssl.org>
Sat, 28 Jan 2017 19:07:04 +0000 (20:07 +0100)
X509_CRL_digest() didn't check if the precomputed sha1 hash was actually
present.  This also makes sure there's an appropriate flag to check.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2314)

crypto/x509/x_all.c
crypto/x509/x_crl.c

index 59f96a52d127768848d1d39deb14aa127d2f4f50..124dd2d2f8dc8c8ae288db8532f2231a43819cd1 100644 (file)
@@ -377,7 +377,7 @@ int X509_digest(const X509 *data, const EVP_MD *type, unsigned char *md,
 int X509_CRL_digest(const X509_CRL *data, const EVP_MD *type,
                     unsigned char *md, unsigned int *len)
 {
-    if (type == EVP_sha1()) {
+    if (type == EVP_sha1() && (data->flags & EXFLAG_SET) != 0) {
         /* Asking for SHA1; always computed in CRL d2i. */
         if (len != NULL)
             *len = sizeof(data->sha1_hash);
index da9c6b61577ebbe855c94ee4299f3ebfe9957b2a..dbed850b37ff5784fedee0ae02d15e65a1f6691d 100644 (file)
@@ -226,6 +226,8 @@ static int crl_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
             if (crl->meth->crl_init(crl) == 0)
                 return 0;
         }
+
+        crl->flags |= EXFLAG_SET;
         break;
 
     case ASN1_OP_FREE_POST: