Revert "Move unit tests out of bcm/fipsmodule"

This reverts commit e09fcf8302f75dc50afcfe40f0d59a92b40a3c2e.

Change-Id: Ib15912481ac25fd60e7e4806d9b6bd5be8e62db8
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/68809
Auto-Submit: Bob Beck <bbe@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Bob Beck <bbe@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
diff --git a/build.json b/build.json
index c6d3bf6..28b2111 100644
--- a/build.json
+++ b/build.json
@@ -789,18 +789,11 @@
             "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",
@@ -809,21 +802,30 @@
             "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",
@@ -838,10 +840,8 @@
             "crypto/pkcs8/pkcs12_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/rand_extra/getentropy_test.cc",
             "crypto/refcount_test.cc",
             "crypto/rsa_extra/rsa_test.cc",
             "crypto/self_test.cc",
@@ -863,7 +863,6 @@
             "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",
@@ -874,16 +873,17 @@
             "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/rand_extra/urandom_test.cc"
+            "crypto/fipsmodule/rand/urandom_test.cc"
         ]
     },
     "pki_test": {
diff --git a/crypto/cipher_extra/aes_test.cc b/crypto/fipsmodule/aes/aes_test.cc
similarity index 98%
rename from crypto/cipher_extra/aes_test.cc
rename to crypto/fipsmodule/aes/aes_test.cc
index 47e5666..d4a458b 100644
--- a/crypto/cipher_extra/aes_test.cc
+++ b/crypto/fipsmodule/aes/aes_test.cc
@@ -25,11 +25,12 @@
 #include <openssl/aes.h>
 #include <openssl/rand.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"
+#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"
 
 
 static void TestRaw(FileTest *t) {
diff --git a/crypto/bn_extra/bn_test.cc b/crypto/fipsmodule/bn/bn_test.cc
similarity index 99%
rename from crypto/bn_extra/bn_test.cc
rename to crypto/fipsmodule/bn/bn_test.cc
index 47af50d..710b60f 100644
--- a/crypto/bn_extra/bn_test.cc
+++ b/crypto/fipsmodule/bn/bn_test.cc
@@ -87,12 +87,13 @@
 #include <openssl/mem.h>
 #include <openssl/rand.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"
+#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"
 
 
 static int HexToBIGNUM(bssl::UniquePtr<BIGNUM> *out, const char *in) {
diff --git a/crypto/cipher_extra/cmac_test.cc b/crypto/fipsmodule/cmac/cmac_test.cc
similarity index 98%
rename from crypto/cipher_extra/cmac_test.cc
rename to crypto/fipsmodule/cmac/cmac_test.cc
index f6da0eb..9e3744e 100644
--- a/crypto/cipher_extra/cmac_test.cc
+++ b/crypto/fipsmodule/cmac/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/ec_extra/ec_test.cc b/crypto/fipsmodule/ec/ec_test.cc
similarity index 99%
rename from crypto/ec_extra/ec_test.cc
rename to crypto/fipsmodule/ec/ec_test.cc
index a9e8ffe..b9bc1a2 100644
--- a/crypto/ec_extra/ec_test.cc
+++ b/crypto/fipsmodule/ec/ec_test.cc
@@ -30,9 +30,11 @@
 #include <openssl/obj.h>
 #include <openssl/span.h>
 
-#include "./internal.h"
-#include "../test/file_test.h"
-#include "../test/test_util.h"
+#include "../../ec_extra/internal.h"
+#include "../../test/file_test.h"
+#include "../../test/test_util.h"
+#include "../bn/internal.h"
+#include "internal.h"
 
 
 // kECKeyWithoutPublic is an ECPrivateKey with the optional publicKey field
diff --git a/crypto/ec_extra/p256-nistz_test.cc b/crypto/fipsmodule/ec/p256-nistz_test.cc
similarity index 98%
rename from crypto/ec_extra/p256-nistz_test.cc
rename to crypto/fipsmodule/ec/p256-nistz_test.cc
index 11d99a4..263db50 100644
--- a/crypto/ec_extra/p256-nistz_test.cc
+++ b/crypto/fipsmodule/ec/p256-nistz_test.cc
@@ -25,11 +25,12 @@
 #include <openssl/nid.h>
 
 #include "internal.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"
+#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"
 
 
 // Disable tests if BORINGSSL_SHARED_LIBRARY is defined. These tests need access
@@ -486,7 +487,7 @@
 }
 
 TEST(P256_NistzTest, TestVectors) {
-  return FileTestGTest("crypto/ec_extra/p256-nistz_tests.txt",
+  return FileTestGTest("crypto/fipsmodule/ec/p256-nistz_tests.txt",
                        [](FileTest *t) {
     if (t->GetParameter() == "Negate") {
       TestNegate(t);
diff --git a/crypto/ec_extra/p256-nistz_tests.txt b/crypto/fipsmodule/ec/p256-nistz_tests.txt
similarity index 100%
rename from crypto/ec_extra/p256-nistz_tests.txt
rename to crypto/fipsmodule/ec/p256-nistz_tests.txt
diff --git a/crypto/ec_extra/p256_test.cc b/crypto/fipsmodule/ec/p256_test.cc
similarity index 93%
rename from crypto/ec_extra/p256_test.cc
rename to crypto/fipsmodule/ec/p256_test.cc
index 7fc1c80..2af9319 100644
--- a/crypto/ec_extra/p256_test.cc
+++ b/crypto/fipsmodule/ec/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/ecdsa_extra/ecdsa_test.cc b/crypto/fipsmodule/ecdsa/ecdsa_test.cc
similarity index 99%
rename from crypto/ecdsa_extra/ecdsa_test.cc
rename to crypto/fipsmodule/ecdsa/ecdsa_test.cc
index 53d7bc2..5876935 100644
--- a/crypto/ecdsa_extra/ecdsa_test.cc
+++ b/crypto/fipsmodule/ecdsa/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/cipher_extra/hkdf_test.cc b/crypto/fipsmodule/hkdf/hkdf_test.cc
similarity index 98%
rename from crypto/cipher_extra/hkdf_test.cc
rename to crypto/fipsmodule/hkdf/hkdf_test.cc
index 8aad6c8..dd7dd58 100644
--- a/crypto/cipher_extra/hkdf_test.cc
+++ b/crypto/fipsmodule/hkdf/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/cipher_extra/md5_test.cc b/crypto/fipsmodule/md5/md5_test.cc
similarity index 95%
rename from crypto/cipher_extra/md5_test.cc
rename to crypto/fipsmodule/md5/md5_test.cc
index 4ad6b8c..7df5bb2 100644
--- a/crypto/cipher_extra/md5_test.cc
+++ b/crypto/fipsmodule/md5/md5_test.cc
@@ -16,7 +16,8 @@
 
 #include <gtest/gtest.h>
 
-#include "../test/abi_test.h"
+#include "internal.h"
+#include "../../test/abi_test.h"
 
 
 #if defined(MD5_ASM) && defined(SUPPORTS_ABI_TEST)
diff --git a/crypto/cipher_extra/gcm_test.cc b/crypto/fipsmodule/modes/gcm_test.cc
similarity index 97%
rename from crypto/cipher_extra/gcm_test.cc
rename to crypto/fipsmodule/modes/gcm_test.cc
index 456ce99..b4f9b90 100644
--- a/crypto/cipher_extra/gcm_test.cc
+++ b/crypto/fipsmodule/modes/gcm_test.cc
@@ -55,11 +55,12 @@
 
 #include <openssl/aes.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"
+#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"
 
 
 TEST(GCMTest, TestVectors) {
diff --git a/crypto/rand_extra/ctrdrbg_test.cc b/crypto/fipsmodule/rand/ctrdrbg_test.cc
similarity index 96%
rename from crypto/rand_extra/ctrdrbg_test.cc
rename to crypto/fipsmodule/rand/ctrdrbg_test.cc
index 6950bb3..deed19f 100644
--- a/crypto/rand_extra/ctrdrbg_test.cc
+++ b/crypto/fipsmodule/rand/ctrdrbg_test.cc
@@ -17,9 +17,9 @@
 #include <openssl/ctrdrbg.h>
 #include <openssl/sha.h>
 
-#include "../fipsmodule/rand/internal.h"
-#include "../test/file_test.h"
-#include "../test/test_util.h"
+#include "internal.h"
+#include "../../test/file_test.h"
+#include "../../test/test_util.h"
 
 
 TEST(CTRDRBGTest, Basic) {
@@ -94,7 +94,7 @@
 }
 
 TEST(CTRDRBGTest, TestVectors) {
-  FileTestGTest("crypto/rand_extra/ctrdrbg_vectors.txt", [](FileTest *t) {
+  FileTestGTest("crypto/fipsmodule/rand/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/rand_extra/ctrdrbg_vectors.txt b/crypto/fipsmodule/rand/ctrdrbg_vectors.txt
similarity index 100%
rename from crypto/rand_extra/ctrdrbg_vectors.txt
rename to crypto/fipsmodule/rand/ctrdrbg_vectors.txt
diff --git a/crypto/rand_extra/fork_detect_test.cc b/crypto/fipsmodule/rand/fork_detect_test.cc
similarity index 98%
rename from crypto/rand_extra/fork_detect_test.cc
rename to crypto/fipsmodule/rand/fork_detect_test.cc
index bea1ec6..f9cde28 100644
--- a/crypto/rand_extra/fork_detect_test.cc
+++ b/crypto/fipsmodule/rand/fork_detect_test.cc
@@ -14,7 +14,7 @@
 
 #include <openssl/base.h>
 
-#include "../fipsmodule/rand/fork_detect.h"
+#include "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/rand_extra/urandom_test.cc b/crypto/fipsmodule/rand/urandom_test.cc
similarity index 99%
rename from crypto/rand_extra/urandom_test.cc
rename to crypto/fipsmodule/rand/urandom_test.cc
index 909d193..08e4183 100644
--- a/crypto/rand_extra/urandom_test.cc
+++ b/crypto/fipsmodule/rand/urandom_test.cc
@@ -19,7 +19,8 @@
 #include <openssl/ctrdrbg.h>
 #include <openssl/rand.h>
 
-#include "../fipsmodule/rand/getrandom_fillin.h"
+#include "getrandom_fillin.h"
+#include "internal.h"
 
 #if (defined(OPENSSL_X86_64) || defined(OPENSSL_AARCH64)) &&               \
     !defined(BORINGSSL_SHARED_LIBRARY) && defined(OPENSSL_RAND_URANDOM) && \
diff --git a/crypto/cipher_extra/sha_test.cc b/crypto/fipsmodule/sha/sha_test.cc
similarity index 97%
rename from crypto/cipher_extra/sha_test.cc
rename to crypto/fipsmodule/sha/sha_test.cc
index e6a0488..5624288 100644
--- a/crypto/cipher_extra/sha_test.cc
+++ b/crypto/fipsmodule/sha/sha_test.cc
@@ -18,9 +18,9 @@
 
 #include <gtest/gtest.h>
 
-#include "../fipsmodule/sha/internal.h"
-#include "../test/abi_test.h"
-#include "../test/test_util.h"
+#include "internal.h"
+#include "../../test/abi_test.h"
+#include "../../test/test_util.h"
 
 
 TEST(SHATest, FIPS1862PRF) {
diff --git a/gen/sources.bzl b/gen/sources.bzl
index f0896a0..26f9e91 100644
--- a/gen/sources.bzl
+++ b/gen/sources.bzl
@@ -683,18 +683,11 @@
   "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",
@@ -707,17 +700,26 @@
   "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",
@@ -732,8 +734,6 @@
   "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,7 +787,6 @@
   "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",
@@ -808,9 +807,11 @@
   "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",
@@ -830,7 +831,6 @@
   "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/rand_extra/urandom_test.cc",
+  "crypto/fipsmodule/rand/urandom_test.cc",
 ]
diff --git a/gen/sources.cmake b/gen/sources.cmake
index 390cc6e..11d97be 100644
--- a/gen/sources.cmake
+++ b/gen/sources.cmake
@@ -707,18 +707,11 @@
   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
@@ -731,17 +724,26 @@
   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
@@ -756,8 +758,6 @@
   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,7 +813,6 @@
   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
@@ -834,9 +833,11 @@
   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
@@ -856,7 +857,6 @@
   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/rand_extra/urandom_test.cc
+  crypto/fipsmodule/rand/urandom_test.cc
 )
diff --git a/gen/sources.json b/gen/sources.json
index f673138..3bb5ea5 100644
--- a/gen/sources.json
+++ b/gen/sources.json
@@ -664,18 +664,11 @@
       "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",
@@ -688,17 +681,26 @@
       "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",
@@ -713,8 +715,6 @@
       "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,7 +767,6 @@
       "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",
@@ -788,9 +787,11 @@
       "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",
@@ -810,7 +811,6 @@
       "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/rand_extra/urandom_test.cc"
+      "crypto/fipsmodule/rand/urandom_test.cc"
     ]
   }
 }
\ No newline at end of file