Move unit tests out of bcm/fipsmodule

Strictly speaking this does not change any of the bcm/fipsmodule
code, it moves the tests out into libcrypto so that once we move
to an api boundary where bcm does not call libcrypto functions
directly, these tests still can do so.

Bug: 722

Change-Id: I9defc70a9e523e52dda2d53ab4bd155a4b44fc02
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/68787
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Bob Beck <bbe@google.com>
diff --git a/build.json b/build.json
index 28b2111..c6d3bf6 100644
--- a/build.json
+++ b/build.json
@@ -789,11 +789,18 @@
             "crypto/base64/base64_test.cc",
             "crypto/bio/bio_test.cc",
             "crypto/blake2/blake2_test.cc",
+            "crypto/bn_extra/bn_test.cc",
             "crypto/buf/buf_test.cc",
             "crypto/bytestring/bytestring_test.cc",
             "crypto/chacha/chacha_test.cc",
             "crypto/cipher_extra/aead_test.cc",
+            "crypto/cipher_extra/aes_test.cc",
             "crypto/cipher_extra/cipher_test.cc",
+            "crypto/cipher_extra/cmac_test.cc",
+            "crypto/cipher_extra/gcm_test.cc",
+            "crypto/cipher_extra/hkdf_test.cc",
+            "crypto/cipher_extra/md5_test.cc",
+            "crypto/cipher_extra/sha_test.cc",
             "crypto/compiler_test.cc",
             "crypto/conf/conf_test.cc",
             "crypto/constant_time_test.cc",
@@ -802,30 +809,21 @@
             "crypto/curve25519/ed25519_test.cc",
             "crypto/curve25519/spake25519_test.cc",
             "crypto/curve25519/x25519_test.cc",
-            "crypto/ecdh_extra/ecdh_test.cc",
             "crypto/dh_extra/dh_test.cc",
             "crypto/digest_extra/digest_test.cc",
             "crypto/dilithium/dilithium_test.cc",
             "crypto/dsa/dsa_test.cc",
+            "crypto/ec_extra/ec_test.cc",
+            "crypto/ec_extra/p256_test.cc",
+            "crypto/ec_extra/p256-nistz_test.cc",
+            "crypto/ecdh_extra/ecdh_test.cc",
+            "crypto/ecdsa_extra/ecdsa_test.cc",
             "crypto/err/err_test.cc",
             "crypto/evp/evp_extra_test.cc",
             "crypto/evp/evp_test.cc",
             "crypto/evp/pbkdf_test.cc",
             "crypto/evp/scrypt_test.cc",
-            "crypto/fipsmodule/aes/aes_test.cc",
-            "crypto/fipsmodule/bn/bn_test.cc",
-            "crypto/fipsmodule/cmac/cmac_test.cc",
-            "crypto/fipsmodule/ec/ec_test.cc",
-            "crypto/fipsmodule/ec/p256-nistz_test.cc",
-            "crypto/fipsmodule/ec/p256_test.cc",
-            "crypto/fipsmodule/ecdsa/ecdsa_test.cc",
-            "crypto/fipsmodule/hkdf/hkdf_test.cc",
-            "crypto/fipsmodule/md5/md5_test.cc",
-            "crypto/fipsmodule/modes/gcm_test.cc",
-            "crypto/fipsmodule/rand/ctrdrbg_test.cc",
-            "crypto/fipsmodule/rand/fork_detect_test.cc",
             "crypto/fipsmodule/service_indicator/service_indicator_test.cc",
-            "crypto/fipsmodule/sha/sha_test.cc",
             "crypto/hpke/hpke_test.cc",
             "crypto/hmac_extra/hmac_test.cc",
             "crypto/hrss/hrss_test.cc",
@@ -840,8 +838,10 @@
             "crypto/pkcs8/pkcs12_test.cc",
             "crypto/poly1305/poly1305_test.cc",
             "crypto/pool/pool_test.cc",
-            "crypto/rand_extra/rand_test.cc",
+            "crypto/rand_extra/ctrdrbg_test.cc",
+            "crypto/rand_extra/fork_detect_test.cc",
             "crypto/rand_extra/getentropy_test.cc",
+            "crypto/rand_extra/rand_test.cc",
             "crypto/refcount_test.cc",
             "crypto/rsa_extra/rsa_test.cc",
             "crypto/self_test.cc",
@@ -863,6 +863,7 @@
             "crypto/dilithium/dilithium_tests.txt",
             "crypto/dilithium/edge_cases_draft_dilithium3_sign.txt",
             "crypto/dilithium/edge_cases_draft_dilithium3_verify.txt",
+            "crypto/ec_extra/p256-nistz_tests.txt",
             "crypto/ecdh_extra/ecdh_tests.txt",
             "crypto/evp/evp_tests.txt",
             "crypto/evp/scrypt_tests.txt",
@@ -873,17 +874,16 @@
             "crypto/fipsmodule/cmac/cavp_aes192_cmac_tests.txt",
             "crypto/fipsmodule/cmac/cavp_aes256_cmac_tests.txt",
             "crypto/fipsmodule/ec/ec_scalar_base_mult_tests.txt",
-            "crypto/fipsmodule/ec/p256-nistz_tests.txt",
             "crypto/fipsmodule/ecdsa/ecdsa_sign_tests.txt",
             "crypto/fipsmodule/ecdsa/ecdsa_verify_tests.txt",
             "crypto/fipsmodule/modes/gcm_tests.txt",
-            "crypto/fipsmodule/rand/ctrdrbg_vectors.txt",
             "crypto/hmac_extra/hmac_tests.txt",
             "crypto/hpke/hpke_test_vectors.txt",
             "crypto/keccak/keccak_tests.txt",
             "crypto/kyber/kyber_tests.txt",
             "crypto/pkcs8/test/*.p12",
             "crypto/poly1305/poly1305_tests.txt",
+            "crypto/rand_extra/ctrdrbg_vectors.txt",
             "crypto/siphash/siphash_tests.txt",
             "crypto/spx/spx_tests.txt",
             "crypto/spx/spx_tests_deterministic.txt",
@@ -893,7 +893,7 @@
     },
     "urandom_test": {
         "srcs": [
-            "crypto/fipsmodule/rand/urandom_test.cc"
+            "crypto/rand_extra/urandom_test.cc"
         ]
     },
     "pki_test": {
diff --git a/crypto/fipsmodule/bn/bn_test.cc b/crypto/bn_extra/bn_test.cc
similarity index 99%
rename from crypto/fipsmodule/bn/bn_test.cc
rename to crypto/bn_extra/bn_test.cc
index 710b60f..47af50d 100644
--- a/crypto/fipsmodule/bn/bn_test.cc
+++ b/crypto/bn_extra/bn_test.cc
@@ -87,13 +87,12 @@
 #include <openssl/mem.h>
 #include <openssl/rand.h>
 
-#include "./internal.h"
-#include "./rsaz_exp.h"
-#include "../../internal.h"
-#include "../../test/abi_test.h"
-#include "../../test/file_test.h"
-#include "../../test/test_util.h"
-#include "../../test/wycheproof_util.h"
+#include "../fipsmodule/bn/internal.h"
+#include "../internal.h"
+#include "../test/abi_test.h"
+#include "../test/file_test.h"
+#include "../test/test_util.h"
+#include "../test/wycheproof_util.h"
 
 
 static int HexToBIGNUM(bssl::UniquePtr<BIGNUM> *out, const char *in) {
diff --git a/crypto/fipsmodule/aes/aes_test.cc b/crypto/cipher_extra/aes_test.cc
similarity index 98%
rename from crypto/fipsmodule/aes/aes_test.cc
rename to crypto/cipher_extra/aes_test.cc
index d4a458b..47e5666 100644
--- a/crypto/fipsmodule/aes/aes_test.cc
+++ b/crypto/cipher_extra/aes_test.cc
@@ -25,12 +25,11 @@
 #include <openssl/aes.h>
 #include <openssl/rand.h>
 
-#include "internal.h"
-#include "../../internal.h"
-#include "../../test/abi_test.h"
-#include "../../test/file_test.h"
-#include "../../test/test_util.h"
-#include "../../test/wycheproof_util.h"
+#include "../fipsmodule/aes/internal.h"
+#include "../test/abi_test.h"
+#include "../test/file_test.h"
+#include "../test/test_util.h"
+#include "../test/wycheproof_util.h"
 
 
 static void TestRaw(FileTest *t) {
diff --git a/crypto/fipsmodule/cmac/cmac_test.cc b/crypto/cipher_extra/cmac_test.cc
similarity index 98%
rename from crypto/fipsmodule/cmac/cmac_test.cc
rename to crypto/cipher_extra/cmac_test.cc
index 9e3744e..f6da0eb 100644
--- a/crypto/fipsmodule/cmac/cmac_test.cc
+++ b/crypto/cipher_extra/cmac_test.cc
@@ -23,9 +23,9 @@
 #include <openssl/cmac.h>
 #include <openssl/mem.h>
 
-#include "../../test/file_test.h"
-#include "../../test/test_util.h"
-#include "../../test/wycheproof_util.h"
+#include "../test/file_test.h"
+#include "../test/test_util.h"
+#include "../test/wycheproof_util.h"
 
 
 static void test(const char *name, const uint8_t *key, size_t key_len,
diff --git a/crypto/fipsmodule/modes/gcm_test.cc b/crypto/cipher_extra/gcm_test.cc
similarity index 97%
rename from crypto/fipsmodule/modes/gcm_test.cc
rename to crypto/cipher_extra/gcm_test.cc
index b4f9b90..456ce99 100644
--- a/crypto/fipsmodule/modes/gcm_test.cc
+++ b/crypto/cipher_extra/gcm_test.cc
@@ -55,12 +55,11 @@
 
 #include <openssl/aes.h>
 
-#include "../../internal.h"
-#include "../../test/abi_test.h"
-#include "../../test/file_test.h"
-#include "../../test/test_util.h"
-#include "../aes/internal.h"
-#include "internal.h"
+#include "../test/abi_test.h"
+#include "../test/file_test.h"
+#include "../test/test_util.h"
+#include "../fipsmodule/aes/internal.h"
+#include "../fipsmodule/modes/internal.h"
 
 
 TEST(GCMTest, TestVectors) {
diff --git a/crypto/fipsmodule/hkdf/hkdf_test.cc b/crypto/cipher_extra/hkdf_test.cc
similarity index 98%
rename from crypto/fipsmodule/hkdf/hkdf_test.cc
rename to crypto/cipher_extra/hkdf_test.cc
index dd7dd58..8aad6c8 100644
--- a/crypto/fipsmodule/hkdf/hkdf_test.cc
+++ b/crypto/cipher_extra/hkdf_test.cc
@@ -20,9 +20,9 @@
 
 #include <gtest/gtest.h>
 
-#include "../../test/file_test.h"
-#include "../../test/test_util.h"
-#include "../../test/wycheproof_util.h"
+#include "../test/file_test.h"
+#include "../test/test_util.h"
+#include "../test/wycheproof_util.h"
 
 
 struct HKDFTestVector {
diff --git a/crypto/fipsmodule/md5/md5_test.cc b/crypto/cipher_extra/md5_test.cc
similarity index 95%
rename from crypto/fipsmodule/md5/md5_test.cc
rename to crypto/cipher_extra/md5_test.cc
index 7df5bb2..4ad6b8c 100644
--- a/crypto/fipsmodule/md5/md5_test.cc
+++ b/crypto/cipher_extra/md5_test.cc
@@ -16,8 +16,7 @@
 
 #include <gtest/gtest.h>
 
-#include "internal.h"
-#include "../../test/abi_test.h"
+#include "../test/abi_test.h"
 
 
 #if defined(MD5_ASM) && defined(SUPPORTS_ABI_TEST)
diff --git a/crypto/fipsmodule/sha/sha_test.cc b/crypto/cipher_extra/sha_test.cc
similarity index 97%
rename from crypto/fipsmodule/sha/sha_test.cc
rename to crypto/cipher_extra/sha_test.cc
index 5624288..e6a0488 100644
--- a/crypto/fipsmodule/sha/sha_test.cc
+++ b/crypto/cipher_extra/sha_test.cc
@@ -18,9 +18,9 @@
 
 #include <gtest/gtest.h>
 
-#include "internal.h"
-#include "../../test/abi_test.h"
-#include "../../test/test_util.h"
+#include "../fipsmodule/sha/internal.h"
+#include "../test/abi_test.h"
+#include "../test/test_util.h"
 
 
 TEST(SHATest, FIPS1862PRF) {
diff --git a/crypto/fipsmodule/ec/ec_test.cc b/crypto/ec_extra/ec_test.cc
similarity index 99%
rename from crypto/fipsmodule/ec/ec_test.cc
rename to crypto/ec_extra/ec_test.cc
index b9bc1a2..a9e8ffe 100644
--- a/crypto/fipsmodule/ec/ec_test.cc
+++ b/crypto/ec_extra/ec_test.cc
@@ -30,11 +30,9 @@
 #include <openssl/obj.h>
 #include <openssl/span.h>
 
-#include "../../ec_extra/internal.h"
-#include "../../test/file_test.h"
-#include "../../test/test_util.h"
-#include "../bn/internal.h"
-#include "internal.h"
+#include "./internal.h"
+#include "../test/file_test.h"
+#include "../test/test_util.h"
 
 
 // kECKeyWithoutPublic is an ECPrivateKey with the optional publicKey field
diff --git a/crypto/fipsmodule/ec/p256-nistz_test.cc b/crypto/ec_extra/p256-nistz_test.cc
similarity index 98%
rename from crypto/fipsmodule/ec/p256-nistz_test.cc
rename to crypto/ec_extra/p256-nistz_test.cc
index 263db50..11d99a4 100644
--- a/crypto/fipsmodule/ec/p256-nistz_test.cc
+++ b/crypto/ec_extra/p256-nistz_test.cc
@@ -25,12 +25,11 @@
 #include <openssl/nid.h>
 
 #include "internal.h"
-#include "../bn/internal.h"
-#include "../../internal.h"
-#include "../../test/abi_test.h"
-#include "../../test/file_test.h"
-#include "../../test/test_util.h"
-#include "p256-nistz.h"
+#include "../internal.h"
+#include "../test/abi_test.h"
+#include "../test/file_test.h"
+#include "../test/test_util.h"
+#include "../fipsmodule/ec/p256-nistz.h"
 
 
 // Disable tests if BORINGSSL_SHARED_LIBRARY is defined. These tests need access
@@ -487,7 +486,7 @@
 }
 
 TEST(P256_NistzTest, TestVectors) {
-  return FileTestGTest("crypto/fipsmodule/ec/p256-nistz_tests.txt",
+  return FileTestGTest("crypto/ec_extra/p256-nistz_tests.txt",
                        [](FileTest *t) {
     if (t->GetParameter() == "Negate") {
       TestNegate(t);
diff --git a/crypto/fipsmodule/ec/p256-nistz_tests.txt b/crypto/ec_extra/p256-nistz_tests.txt
similarity index 100%
rename from crypto/fipsmodule/ec/p256-nistz_tests.txt
rename to crypto/ec_extra/p256-nistz_tests.txt
diff --git a/crypto/fipsmodule/ec/p256_test.cc b/crypto/ec_extra/p256_test.cc
similarity index 93%
rename from crypto/fipsmodule/ec/p256_test.cc
rename to crypto/ec_extra/p256_test.cc
index 2af9319..7fc1c80 100644
--- a/crypto/fipsmodule/ec/p256_test.cc
+++ b/crypto/ec_extra/p256_test.cc
@@ -13,13 +13,13 @@
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
 
 #include <gtest/gtest.h>
-#include "../../internal.h"
-#include "../../test/abi_test.h"
+#include "../internal.h"
+#include "../test/abi_test.h"
 
 #if !defined(OPENSSL_NO_ASM) && defined(__GNUC__) && defined(__x86_64__) && \
     defined(SUPPORTS_ABI_TEST)
 extern "C" {
-#include "../../../third_party/fiat/p256_64.h"
+#include "../../third_party/fiat/p256_64.h"
 }
 
 TEST(P256Test, AdxMulABI) {
diff --git a/crypto/fipsmodule/ecdsa/ecdsa_test.cc b/crypto/ecdsa_extra/ecdsa_test.cc
similarity index 99%
rename from crypto/fipsmodule/ecdsa/ecdsa_test.cc
rename to crypto/ecdsa_extra/ecdsa_test.cc
index 5876935..53d7bc2 100644
--- a/crypto/fipsmodule/ecdsa/ecdsa_test.cc
+++ b/crypto/ecdsa_extra/ecdsa_test.cc
@@ -64,9 +64,9 @@
 #include <openssl/nid.h>
 #include <openssl/rand.h>
 
-#include "../ec/internal.h"
-#include "../../test/file_test.h"
-#include "../../test/test_util.h"
+//#include "../ec/internal.h"
+#include "../test/file_test.h"
+#include "../test/test_util.h"
 
 
 static bssl::UniquePtr<BIGNUM> HexToBIGNUM(const char *hex) {
diff --git a/crypto/fipsmodule/rand/ctrdrbg_test.cc b/crypto/rand_extra/ctrdrbg_test.cc
similarity index 96%
rename from crypto/fipsmodule/rand/ctrdrbg_test.cc
rename to crypto/rand_extra/ctrdrbg_test.cc
index deed19f..6950bb3 100644
--- a/crypto/fipsmodule/rand/ctrdrbg_test.cc
+++ b/crypto/rand_extra/ctrdrbg_test.cc
@@ -17,9 +17,9 @@
 #include <openssl/ctrdrbg.h>
 #include <openssl/sha.h>
 
-#include "internal.h"
-#include "../../test/file_test.h"
-#include "../../test/test_util.h"
+#include "../fipsmodule/rand/internal.h"
+#include "../test/file_test.h"
+#include "../test/test_util.h"
 
 
 TEST(CTRDRBGTest, Basic) {
@@ -94,7 +94,7 @@
 }
 
 TEST(CTRDRBGTest, TestVectors) {
-  FileTestGTest("crypto/fipsmodule/rand/ctrdrbg_vectors.txt", [](FileTest *t) {
+  FileTestGTest("crypto/rand_extra/ctrdrbg_vectors.txt", [](FileTest *t) {
     std::vector<uint8_t> seed, personalisation, reseed, ai_reseed, ai1, ai2,
         expected;
     ASSERT_TRUE(t->GetBytes(&seed, "EntropyInput"));
diff --git a/crypto/fipsmodule/rand/ctrdrbg_vectors.txt b/crypto/rand_extra/ctrdrbg_vectors.txt
similarity index 100%
rename from crypto/fipsmodule/rand/ctrdrbg_vectors.txt
rename to crypto/rand_extra/ctrdrbg_vectors.txt
diff --git a/crypto/fipsmodule/rand/fork_detect_test.cc b/crypto/rand_extra/fork_detect_test.cc
similarity index 98%
rename from crypto/fipsmodule/rand/fork_detect_test.cc
rename to crypto/rand_extra/fork_detect_test.cc
index f9cde28..bea1ec6 100644
--- a/crypto/fipsmodule/rand/fork_detect_test.cc
+++ b/crypto/rand_extra/fork_detect_test.cc
@@ -14,7 +14,7 @@
 
 #include <openssl/base.h>
 
-#include "fork_detect.h"
+#include "../fipsmodule/rand/fork_detect.h"
 
 // TSAN cannot cope with this test and complains that "starting new threads
 // after multi-threaded fork is not supported".
diff --git a/crypto/fipsmodule/rand/urandom_test.cc b/crypto/rand_extra/urandom_test.cc
similarity index 99%
rename from crypto/fipsmodule/rand/urandom_test.cc
rename to crypto/rand_extra/urandom_test.cc
index 08e4183..909d193 100644
--- a/crypto/fipsmodule/rand/urandom_test.cc
+++ b/crypto/rand_extra/urandom_test.cc
@@ -19,8 +19,7 @@
 #include <openssl/ctrdrbg.h>
 #include <openssl/rand.h>
 
-#include "getrandom_fillin.h"
-#include "internal.h"
+#include "../fipsmodule/rand/getrandom_fillin.h"
 
 #if (defined(OPENSSL_X86_64) || defined(OPENSSL_AARCH64)) &&               \
     !defined(BORINGSSL_SHARED_LIBRARY) && defined(OPENSSL_RAND_URANDOM) && \
diff --git a/gen/sources.bzl b/gen/sources.bzl
index 26f9e91..f0896a0 100644
--- a/gen/sources.bzl
+++ b/gen/sources.bzl
@@ -683,11 +683,18 @@
   "crypto/base64/base64_test.cc",
   "crypto/bio/bio_test.cc",
   "crypto/blake2/blake2_test.cc",
+  "crypto/bn_extra/bn_test.cc",
   "crypto/buf/buf_test.cc",
   "crypto/bytestring/bytestring_test.cc",
   "crypto/chacha/chacha_test.cc",
   "crypto/cipher_extra/aead_test.cc",
+  "crypto/cipher_extra/aes_test.cc",
   "crypto/cipher_extra/cipher_test.cc",
+  "crypto/cipher_extra/cmac_test.cc",
+  "crypto/cipher_extra/gcm_test.cc",
+  "crypto/cipher_extra/hkdf_test.cc",
+  "crypto/cipher_extra/md5_test.cc",
+  "crypto/cipher_extra/sha_test.cc",
   "crypto/compiler_test.cc",
   "crypto/conf/conf_test.cc",
   "crypto/constant_time_test.cc",
@@ -700,26 +707,17 @@
   "crypto/digest_extra/digest_test.cc",
   "crypto/dilithium/dilithium_test.cc",
   "crypto/dsa/dsa_test.cc",
+  "crypto/ec_extra/ec_test.cc",
+  "crypto/ec_extra/p256-nistz_test.cc",
+  "crypto/ec_extra/p256_test.cc",
   "crypto/ecdh_extra/ecdh_test.cc",
+  "crypto/ecdsa_extra/ecdsa_test.cc",
   "crypto/err/err_test.cc",
   "crypto/evp/evp_extra_test.cc",
   "crypto/evp/evp_test.cc",
   "crypto/evp/pbkdf_test.cc",
   "crypto/evp/scrypt_test.cc",
-  "crypto/fipsmodule/aes/aes_test.cc",
-  "crypto/fipsmodule/bn/bn_test.cc",
-  "crypto/fipsmodule/cmac/cmac_test.cc",
-  "crypto/fipsmodule/ec/ec_test.cc",
-  "crypto/fipsmodule/ec/p256-nistz_test.cc",
-  "crypto/fipsmodule/ec/p256_test.cc",
-  "crypto/fipsmodule/ecdsa/ecdsa_test.cc",
-  "crypto/fipsmodule/hkdf/hkdf_test.cc",
-  "crypto/fipsmodule/md5/md5_test.cc",
-  "crypto/fipsmodule/modes/gcm_test.cc",
-  "crypto/fipsmodule/rand/ctrdrbg_test.cc",
-  "crypto/fipsmodule/rand/fork_detect_test.cc",
   "crypto/fipsmodule/service_indicator/service_indicator_test.cc",
-  "crypto/fipsmodule/sha/sha_test.cc",
   "crypto/hmac_extra/hmac_test.cc",
   "crypto/hpke/hpke_test.cc",
   "crypto/hrss/hrss_test.cc",
@@ -734,6 +732,8 @@
   "crypto/pkcs8/pkcs8_test.cc",
   "crypto/poly1305/poly1305_test.cc",
   "crypto/pool/pool_test.cc",
+  "crypto/rand_extra/ctrdrbg_test.cc",
+  "crypto/rand_extra/fork_detect_test.cc",
   "crypto/rand_extra/getentropy_test.cc",
   "crypto/rand_extra/rand_test.cc",
   "crypto/refcount_test.cc",
@@ -787,6 +787,7 @@
   "crypto/dilithium/dilithium_tests.txt",
   "crypto/dilithium/edge_cases_draft_dilithium3_sign.txt",
   "crypto/dilithium/edge_cases_draft_dilithium3_verify.txt",
+  "crypto/ec_extra/p256-nistz_tests.txt",
   "crypto/ecdh_extra/ecdh_tests.txt",
   "crypto/evp/evp_tests.txt",
   "crypto/evp/scrypt_tests.txt",
@@ -807,11 +808,9 @@
   "crypto/fipsmodule/cmac/cavp_aes192_cmac_tests.txt",
   "crypto/fipsmodule/cmac/cavp_aes256_cmac_tests.txt",
   "crypto/fipsmodule/ec/ec_scalar_base_mult_tests.txt",
-  "crypto/fipsmodule/ec/p256-nistz_tests.txt",
   "crypto/fipsmodule/ecdsa/ecdsa_sign_tests.txt",
   "crypto/fipsmodule/ecdsa/ecdsa_verify_tests.txt",
   "crypto/fipsmodule/modes/gcm_tests.txt",
-  "crypto/fipsmodule/rand/ctrdrbg_vectors.txt",
   "crypto/hmac_extra/hmac_tests.txt",
   "crypto/hpke/hpke_test_vectors.txt",
   "crypto/keccak/keccak_tests.txt",
@@ -831,6 +830,7 @@
   "crypto/pkcs8/test/unicode_password.p12",
   "crypto/pkcs8/test/windows.p12",
   "crypto/poly1305/poly1305_tests.txt",
+  "crypto/rand_extra/ctrdrbg_vectors.txt",
   "crypto/siphash/siphash_tests.txt",
   "crypto/spx/spx_tests.txt",
   "crypto/spx/spx_tests_deterministic.txt",
@@ -2681,5 +2681,5 @@
 ]
 
 urandom_test_sources = [
-  "crypto/fipsmodule/rand/urandom_test.cc",
+  "crypto/rand_extra/urandom_test.cc",
 ]
diff --git a/gen/sources.cmake b/gen/sources.cmake
index 11d97be..390cc6e 100644
--- a/gen/sources.cmake
+++ b/gen/sources.cmake
@@ -707,11 +707,18 @@
   crypto/base64/base64_test.cc
   crypto/bio/bio_test.cc
   crypto/blake2/blake2_test.cc
+  crypto/bn_extra/bn_test.cc
   crypto/buf/buf_test.cc
   crypto/bytestring/bytestring_test.cc
   crypto/chacha/chacha_test.cc
   crypto/cipher_extra/aead_test.cc
+  crypto/cipher_extra/aes_test.cc
   crypto/cipher_extra/cipher_test.cc
+  crypto/cipher_extra/cmac_test.cc
+  crypto/cipher_extra/gcm_test.cc
+  crypto/cipher_extra/hkdf_test.cc
+  crypto/cipher_extra/md5_test.cc
+  crypto/cipher_extra/sha_test.cc
   crypto/compiler_test.cc
   crypto/conf/conf_test.cc
   crypto/constant_time_test.cc
@@ -724,26 +731,17 @@
   crypto/digest_extra/digest_test.cc
   crypto/dilithium/dilithium_test.cc
   crypto/dsa/dsa_test.cc
+  crypto/ec_extra/ec_test.cc
+  crypto/ec_extra/p256-nistz_test.cc
+  crypto/ec_extra/p256_test.cc
   crypto/ecdh_extra/ecdh_test.cc
+  crypto/ecdsa_extra/ecdsa_test.cc
   crypto/err/err_test.cc
   crypto/evp/evp_extra_test.cc
   crypto/evp/evp_test.cc
   crypto/evp/pbkdf_test.cc
   crypto/evp/scrypt_test.cc
-  crypto/fipsmodule/aes/aes_test.cc
-  crypto/fipsmodule/bn/bn_test.cc
-  crypto/fipsmodule/cmac/cmac_test.cc
-  crypto/fipsmodule/ec/ec_test.cc
-  crypto/fipsmodule/ec/p256-nistz_test.cc
-  crypto/fipsmodule/ec/p256_test.cc
-  crypto/fipsmodule/ecdsa/ecdsa_test.cc
-  crypto/fipsmodule/hkdf/hkdf_test.cc
-  crypto/fipsmodule/md5/md5_test.cc
-  crypto/fipsmodule/modes/gcm_test.cc
-  crypto/fipsmodule/rand/ctrdrbg_test.cc
-  crypto/fipsmodule/rand/fork_detect_test.cc
   crypto/fipsmodule/service_indicator/service_indicator_test.cc
-  crypto/fipsmodule/sha/sha_test.cc
   crypto/hmac_extra/hmac_test.cc
   crypto/hpke/hpke_test.cc
   crypto/hrss/hrss_test.cc
@@ -758,6 +756,8 @@
   crypto/pkcs8/pkcs8_test.cc
   crypto/poly1305/poly1305_test.cc
   crypto/pool/pool_test.cc
+  crypto/rand_extra/ctrdrbg_test.cc
+  crypto/rand_extra/fork_detect_test.cc
   crypto/rand_extra/getentropy_test.cc
   crypto/rand_extra/rand_test.cc
   crypto/refcount_test.cc
@@ -813,6 +813,7 @@
   crypto/dilithium/dilithium_tests.txt
   crypto/dilithium/edge_cases_draft_dilithium3_sign.txt
   crypto/dilithium/edge_cases_draft_dilithium3_verify.txt
+  crypto/ec_extra/p256-nistz_tests.txt
   crypto/ecdh_extra/ecdh_tests.txt
   crypto/evp/evp_tests.txt
   crypto/evp/scrypt_tests.txt
@@ -833,11 +834,9 @@
   crypto/fipsmodule/cmac/cavp_aes192_cmac_tests.txt
   crypto/fipsmodule/cmac/cavp_aes256_cmac_tests.txt
   crypto/fipsmodule/ec/ec_scalar_base_mult_tests.txt
-  crypto/fipsmodule/ec/p256-nistz_tests.txt
   crypto/fipsmodule/ecdsa/ecdsa_sign_tests.txt
   crypto/fipsmodule/ecdsa/ecdsa_verify_tests.txt
   crypto/fipsmodule/modes/gcm_tests.txt
-  crypto/fipsmodule/rand/ctrdrbg_vectors.txt
   crypto/hmac_extra/hmac_tests.txt
   crypto/hpke/hpke_test_vectors.txt
   crypto/keccak/keccak_tests.txt
@@ -857,6 +856,7 @@
   crypto/pkcs8/test/unicode_password.p12
   crypto/pkcs8/test/windows.p12
   crypto/poly1305/poly1305_tests.txt
+  crypto/rand_extra/ctrdrbg_vectors.txt
   crypto/siphash/siphash_tests.txt
   crypto/spx/spx_tests.txt
   crypto/spx/spx_tests_deterministic.txt
@@ -2741,5 +2741,5 @@
 set(
   URANDOM_TEST_SOURCES
 
-  crypto/fipsmodule/rand/urandom_test.cc
+  crypto/rand_extra/urandom_test.cc
 )
diff --git a/gen/sources.json b/gen/sources.json
index 3bb5ea5..f673138 100644
--- a/gen/sources.json
+++ b/gen/sources.json
@@ -664,11 +664,18 @@
       "crypto/base64/base64_test.cc",
       "crypto/bio/bio_test.cc",
       "crypto/blake2/blake2_test.cc",
+      "crypto/bn_extra/bn_test.cc",
       "crypto/buf/buf_test.cc",
       "crypto/bytestring/bytestring_test.cc",
       "crypto/chacha/chacha_test.cc",
       "crypto/cipher_extra/aead_test.cc",
+      "crypto/cipher_extra/aes_test.cc",
       "crypto/cipher_extra/cipher_test.cc",
+      "crypto/cipher_extra/cmac_test.cc",
+      "crypto/cipher_extra/gcm_test.cc",
+      "crypto/cipher_extra/hkdf_test.cc",
+      "crypto/cipher_extra/md5_test.cc",
+      "crypto/cipher_extra/sha_test.cc",
       "crypto/compiler_test.cc",
       "crypto/conf/conf_test.cc",
       "crypto/constant_time_test.cc",
@@ -681,26 +688,17 @@
       "crypto/digest_extra/digest_test.cc",
       "crypto/dilithium/dilithium_test.cc",
       "crypto/dsa/dsa_test.cc",
+      "crypto/ec_extra/ec_test.cc",
+      "crypto/ec_extra/p256-nistz_test.cc",
+      "crypto/ec_extra/p256_test.cc",
       "crypto/ecdh_extra/ecdh_test.cc",
+      "crypto/ecdsa_extra/ecdsa_test.cc",
       "crypto/err/err_test.cc",
       "crypto/evp/evp_extra_test.cc",
       "crypto/evp/evp_test.cc",
       "crypto/evp/pbkdf_test.cc",
       "crypto/evp/scrypt_test.cc",
-      "crypto/fipsmodule/aes/aes_test.cc",
-      "crypto/fipsmodule/bn/bn_test.cc",
-      "crypto/fipsmodule/cmac/cmac_test.cc",
-      "crypto/fipsmodule/ec/ec_test.cc",
-      "crypto/fipsmodule/ec/p256-nistz_test.cc",
-      "crypto/fipsmodule/ec/p256_test.cc",
-      "crypto/fipsmodule/ecdsa/ecdsa_test.cc",
-      "crypto/fipsmodule/hkdf/hkdf_test.cc",
-      "crypto/fipsmodule/md5/md5_test.cc",
-      "crypto/fipsmodule/modes/gcm_test.cc",
-      "crypto/fipsmodule/rand/ctrdrbg_test.cc",
-      "crypto/fipsmodule/rand/fork_detect_test.cc",
       "crypto/fipsmodule/service_indicator/service_indicator_test.cc",
-      "crypto/fipsmodule/sha/sha_test.cc",
       "crypto/hmac_extra/hmac_test.cc",
       "crypto/hpke/hpke_test.cc",
       "crypto/hrss/hrss_test.cc",
@@ -715,6 +713,8 @@
       "crypto/pkcs8/pkcs8_test.cc",
       "crypto/poly1305/poly1305_test.cc",
       "crypto/pool/pool_test.cc",
+      "crypto/rand_extra/ctrdrbg_test.cc",
+      "crypto/rand_extra/fork_detect_test.cc",
       "crypto/rand_extra/getentropy_test.cc",
       "crypto/rand_extra/rand_test.cc",
       "crypto/refcount_test.cc",
@@ -767,6 +767,7 @@
       "crypto/dilithium/dilithium_tests.txt",
       "crypto/dilithium/edge_cases_draft_dilithium3_sign.txt",
       "crypto/dilithium/edge_cases_draft_dilithium3_verify.txt",
+      "crypto/ec_extra/p256-nistz_tests.txt",
       "crypto/ecdh_extra/ecdh_tests.txt",
       "crypto/evp/evp_tests.txt",
       "crypto/evp/scrypt_tests.txt",
@@ -787,11 +788,9 @@
       "crypto/fipsmodule/cmac/cavp_aes192_cmac_tests.txt",
       "crypto/fipsmodule/cmac/cavp_aes256_cmac_tests.txt",
       "crypto/fipsmodule/ec/ec_scalar_base_mult_tests.txt",
-      "crypto/fipsmodule/ec/p256-nistz_tests.txt",
       "crypto/fipsmodule/ecdsa/ecdsa_sign_tests.txt",
       "crypto/fipsmodule/ecdsa/ecdsa_verify_tests.txt",
       "crypto/fipsmodule/modes/gcm_tests.txt",
-      "crypto/fipsmodule/rand/ctrdrbg_vectors.txt",
       "crypto/hmac_extra/hmac_tests.txt",
       "crypto/hpke/hpke_test_vectors.txt",
       "crypto/keccak/keccak_tests.txt",
@@ -811,6 +810,7 @@
       "crypto/pkcs8/test/unicode_password.p12",
       "crypto/pkcs8/test/windows.p12",
       "crypto/poly1305/poly1305_tests.txt",
+      "crypto/rand_extra/ctrdrbg_vectors.txt",
       "crypto/siphash/siphash_tests.txt",
       "crypto/spx/spx_tests.txt",
       "crypto/spx/spx_tests_deterministic.txt",
@@ -2660,7 +2660,7 @@
   },
   "urandom_test": {
     "srcs": [
-      "crypto/fipsmodule/rand/urandom_test.cc"
+      "crypto/rand_extra/urandom_test.cc"
     ]
   }
 }
\ No newline at end of file