Add some dummy BIGNUM calls from inside the FIPS provider
authorMatt Caswell <matt@openssl.org>
Tue, 11 Jun 2019 11:06:27 +0000 (12:06 +0100)
committerMatt Caswell <matt@openssl.org>
Wed, 12 Jun 2019 08:16:43 +0000 (09:16 +0100)
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/9130)

providers/fips/fipsprov.c

index ab37d98d6cf61b55b711df660c699b2c47375e09..bec305b5e7e91cb8d18c115c4ec7f3a3578ad0b9 100644 (file)
@@ -50,6 +50,8 @@ static int dummy_evp_call(OPENSSL_CTX *libctx)
     unsigned int dgstlen = 0;
     unsigned char dgst[SHA256_DIGEST_LENGTH];
     int ret = 0;
+    BN_CTX *bnctx = NULL;
+    BIGNUM *a = NULL, *b = NULL;
 
     if (ctx == NULL || sha256 == NULL)
         goto err;
@@ -63,8 +65,25 @@ static int dummy_evp_call(OPENSSL_CTX *libctx)
     if (dgstlen != sizeof(exptd) || memcmp(dgst, exptd, sizeof(exptd)) != 0)
         goto err;
 
+    bnctx = BN_CTX_new_ex(libctx);
+    if (bnctx == NULL)
+        goto err;
+    BN_CTX_start(bnctx);
+    a = BN_CTX_get(bnctx);
+    b = BN_CTX_get(bnctx);
+    if (b == NULL)
+        goto err;
+    BN_zero(a);
+    if (!BN_one(b)
+        || !BN_add(a, a, b)
+        || BN_cmp(a, b) != 0)
+        goto err;
+    
     ret = 1;
  err:
+    BN_CTX_end(bnctx);
+    BN_CTX_free(bnctx);
+    
     EVP_MD_CTX_free(ctx);
     EVP_MD_meth_free(sha256);
     return ret;