Fix use of -no-proxy option of CMP app
[openssl.git] / test / drbg_cavs_test.c
index 5e0b202680f2bc78f6f425c75ffc00d7a4ddebbd..2873417ff057d98ed32fb52505f55958c3abef87 100644 (file)
@@ -1,7 +1,7 @@
 /*
- * Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
  *
- * Licensed under the OpenSSL license (the "License").  You may not use
+ * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
  * in the file LICENSE in the source distribution or at
  * https://www.openssl.org/source/license.html
@@ -15,7 +15,7 @@
 #include <openssl/obj_mac.h>
 #include <openssl/evp.h>
 #include <openssl/aes.h>
-#include "../crypto/rand/rand_lcl.h"
+#include "../crypto/rand/rand_local.h"
 
 #include "testutil.h"
 #include "drbg_cavs_data.h"
@@ -106,12 +106,9 @@ static int single_kat_no_reseed(const struct drbg_kat *td)
         failures++;
 
 err:
-    if (buff != NULL)
-        OPENSSL_free(buff);
-    if (drbg != NULL) {
-        RAND_DRBG_uninstantiate(drbg);
-        RAND_DRBG_free(drbg);
-    }
+    OPENSSL_free(buff);
+    RAND_DRBG_uninstantiate(drbg);
+    RAND_DRBG_free(drbg);
     return failures == 0;
 }
 
@@ -176,12 +173,9 @@ static int single_kat_pr_false(const struct drbg_kat *td)
         failures++;
 
 err:
-    if (buff != NULL)
-        OPENSSL_free(buff);
-    if (drbg != NULL) {
-        RAND_DRBG_uninstantiate(drbg);
-        RAND_DRBG_free(drbg);
-    }
+    OPENSSL_free(buff);
+    RAND_DRBG_uninstantiate(drbg);
+    RAND_DRBG_free(drbg);
     return failures == 0;
 }
 
@@ -249,12 +243,9 @@ static int single_kat_pr_true(const struct drbg_kat *td)
         failures++;
 
 err:
-    if (buff != NULL)
-        OPENSSL_free(buff);
-    if (drbg != NULL) {
-        RAND_DRBG_uninstantiate(drbg);
-        RAND_DRBG_free(drbg);
-    }
+    OPENSSL_free(buff);
+    RAND_DRBG_uninstantiate(drbg);
+    RAND_DRBG_free(drbg);
     return failures == 0;
 }
 
@@ -263,6 +254,12 @@ static int test_cavs_kats(const struct drbg_kat *test[], int i)
     const struct drbg_kat *td = test[i];
     int rv = 0;
 
+#ifdef FIPS_MODULE
+    /* FIPS mode doesn't support instantiating without a derivation function */
+    if ((td->flags & USE_DF) == 0)
+        return TEST_skip("instantiating without derivation function "
+                         "is not supported in FIPS mode");
+#endif
     switch (td->type) {
     case NO_RESEED:
         if (!single_kat_no_reseed(td))
@@ -276,7 +273,7 @@ static int test_cavs_kats(const struct drbg_kat *test[], int i)
         if (!single_kat_pr_true(td))
             goto err;
         break;
-    default:   /* cant happen */
+    default:    /* cant happen */
         goto err;
     }
     rv = 1;