Move fips_fragments into bcm.internal_hdrs in build.json

This is sliiiightly weird because we can't quite decide whether these
are headers with the wrong extension or standalone C files. But since
most of our build does the former, I've done this for now. I expect
we'll need to iterate on this one a bit.

Bug: 542
Change-Id: Ib50332c0804efb5a1aa37fe445f129156260835a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/67300
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
diff --git a/build.json b/build.json
index 2808cf1..bc994b6 100644
--- a/build.json
+++ b/build.json
@@ -15,6 +15,84 @@
         "srcs": [
             "crypto/fipsmodule/bcm.c"
         ],
+        "internal_hdrs": [
+            "crypto/fipsmodule/aes/aes.c",
+            "crypto/fipsmodule/aes/aes_nohw.c",
+            "crypto/fipsmodule/aes/key_wrap.c",
+            "crypto/fipsmodule/aes/mode_wrappers.c",
+            "crypto/fipsmodule/bn/add.c",
+            "crypto/fipsmodule/bn/asm/x86_64-gcc.c",
+            "crypto/fipsmodule/bn/bn.c",
+            "crypto/fipsmodule/bn/bytes.c",
+            "crypto/fipsmodule/bn/cmp.c",
+            "crypto/fipsmodule/bn/ctx.c",
+            "crypto/fipsmodule/bn/div.c",
+            "crypto/fipsmodule/bn/div_extra.c",
+            "crypto/fipsmodule/bn/exponentiation.c",
+            "crypto/fipsmodule/bn/gcd.c",
+            "crypto/fipsmodule/bn/gcd_extra.c",
+            "crypto/fipsmodule/bn/generic.c",
+            "crypto/fipsmodule/bn/jacobi.c",
+            "crypto/fipsmodule/bn/montgomery.c",
+            "crypto/fipsmodule/bn/montgomery_inv.c",
+            "crypto/fipsmodule/bn/mul.c",
+            "crypto/fipsmodule/bn/prime.c",
+            "crypto/fipsmodule/bn/random.c",
+            "crypto/fipsmodule/bn/rsaz_exp.c",
+            "crypto/fipsmodule/bn/shift.c",
+            "crypto/fipsmodule/bn/sqrt.c",
+            "crypto/fipsmodule/cipher/aead.c",
+            "crypto/fipsmodule/cipher/cipher.c",
+            "crypto/fipsmodule/cipher/e_aes.c",
+            "crypto/fipsmodule/cipher/e_aesccm.c",
+            "crypto/fipsmodule/cmac/cmac.c",
+            "crypto/fipsmodule/dh/check.c",
+            "crypto/fipsmodule/dh/dh.c",
+            "crypto/fipsmodule/digest/digest.c",
+            "crypto/fipsmodule/digest/digests.c",
+            "crypto/fipsmodule/digestsign/digestsign.c",
+            "crypto/fipsmodule/ec/ec.c",
+            "crypto/fipsmodule/ec/ec_key.c",
+            "crypto/fipsmodule/ec/ec_montgomery.c",
+            "crypto/fipsmodule/ec/felem.c",
+            "crypto/fipsmodule/ec/oct.c",
+            "crypto/fipsmodule/ec/p224-64.c",
+            "crypto/fipsmodule/ec/p256-nistz.c",
+            "crypto/fipsmodule/ec/p256.c",
+            "crypto/fipsmodule/ec/scalar.c",
+            "crypto/fipsmodule/ec/simple.c",
+            "crypto/fipsmodule/ec/simple_mul.c",
+            "crypto/fipsmodule/ec/util.c",
+            "crypto/fipsmodule/ec/wnaf.c",
+            "crypto/fipsmodule/ecdh/ecdh.c",
+            "crypto/fipsmodule/ecdsa/ecdsa.c",
+            "crypto/fipsmodule/hkdf/hkdf.c",
+            "crypto/fipsmodule/hmac/hmac.c",
+            "crypto/fipsmodule/md4/md4.c",
+            "crypto/fipsmodule/md5/md5.c",
+            "crypto/fipsmodule/modes/cbc.c",
+            "crypto/fipsmodule/modes/cfb.c",
+            "crypto/fipsmodule/modes/ctr.c",
+            "crypto/fipsmodule/modes/gcm.c",
+            "crypto/fipsmodule/modes/gcm_nohw.c",
+            "crypto/fipsmodule/modes/ofb.c",
+            "crypto/fipsmodule/modes/polyval.c",
+            "crypto/fipsmodule/rand/ctrdrbg.c",
+            "crypto/fipsmodule/rand/fork_detect.c",
+            "crypto/fipsmodule/rand/rand.c",
+            "crypto/fipsmodule/rand/urandom.c",
+            "crypto/fipsmodule/rsa/blinding.c",
+            "crypto/fipsmodule/rsa/padding.c",
+            "crypto/fipsmodule/rsa/rsa.c",
+            "crypto/fipsmodule/rsa/rsa_impl.c",
+            "crypto/fipsmodule/self_check/fips.c",
+            "crypto/fipsmodule/self_check/self_check.c",
+            "crypto/fipsmodule/service_indicator/service_indicator.c",
+            "crypto/fipsmodule/sha/sha1.c",
+            "crypto/fipsmodule/sha/sha256.c",
+            "crypto/fipsmodule/sha/sha512.c",
+            "crypto/fipsmodule/tls/kdf.c"
+        ],
         "perlasm_aarch64": [
             {"src": "crypto/fipsmodule/aes/asm/aesv8-armx.pl", "dst": "aesv8-armv8"},
             {"src": "crypto/fipsmodule/modes/asm/aesv8-gcm-armv8.pl"},
diff --git a/gen/sources.cmake b/gen/sources.cmake
index 2de79b5..7c468ba 100644
--- a/gen/sources.cmake
+++ b/gen/sources.cmake
@@ -21,6 +21,87 @@
 )
 
 set(
+  BCM_INTERNAL_HEADERS
+
+  crypto/fipsmodule/aes/aes.c
+  crypto/fipsmodule/aes/aes_nohw.c
+  crypto/fipsmodule/aes/key_wrap.c
+  crypto/fipsmodule/aes/mode_wrappers.c
+  crypto/fipsmodule/bn/add.c
+  crypto/fipsmodule/bn/asm/x86_64-gcc.c
+  crypto/fipsmodule/bn/bn.c
+  crypto/fipsmodule/bn/bytes.c
+  crypto/fipsmodule/bn/cmp.c
+  crypto/fipsmodule/bn/ctx.c
+  crypto/fipsmodule/bn/div.c
+  crypto/fipsmodule/bn/div_extra.c
+  crypto/fipsmodule/bn/exponentiation.c
+  crypto/fipsmodule/bn/gcd.c
+  crypto/fipsmodule/bn/gcd_extra.c
+  crypto/fipsmodule/bn/generic.c
+  crypto/fipsmodule/bn/jacobi.c
+  crypto/fipsmodule/bn/montgomery.c
+  crypto/fipsmodule/bn/montgomery_inv.c
+  crypto/fipsmodule/bn/mul.c
+  crypto/fipsmodule/bn/prime.c
+  crypto/fipsmodule/bn/random.c
+  crypto/fipsmodule/bn/rsaz_exp.c
+  crypto/fipsmodule/bn/shift.c
+  crypto/fipsmodule/bn/sqrt.c
+  crypto/fipsmodule/cipher/aead.c
+  crypto/fipsmodule/cipher/cipher.c
+  crypto/fipsmodule/cipher/e_aes.c
+  crypto/fipsmodule/cipher/e_aesccm.c
+  crypto/fipsmodule/cmac/cmac.c
+  crypto/fipsmodule/dh/check.c
+  crypto/fipsmodule/dh/dh.c
+  crypto/fipsmodule/digest/digest.c
+  crypto/fipsmodule/digest/digests.c
+  crypto/fipsmodule/digestsign/digestsign.c
+  crypto/fipsmodule/ec/ec.c
+  crypto/fipsmodule/ec/ec_key.c
+  crypto/fipsmodule/ec/ec_montgomery.c
+  crypto/fipsmodule/ec/felem.c
+  crypto/fipsmodule/ec/oct.c
+  crypto/fipsmodule/ec/p224-64.c
+  crypto/fipsmodule/ec/p256-nistz.c
+  crypto/fipsmodule/ec/p256.c
+  crypto/fipsmodule/ec/scalar.c
+  crypto/fipsmodule/ec/simple.c
+  crypto/fipsmodule/ec/simple_mul.c
+  crypto/fipsmodule/ec/util.c
+  crypto/fipsmodule/ec/wnaf.c
+  crypto/fipsmodule/ecdh/ecdh.c
+  crypto/fipsmodule/ecdsa/ecdsa.c
+  crypto/fipsmodule/hkdf/hkdf.c
+  crypto/fipsmodule/hmac/hmac.c
+  crypto/fipsmodule/md4/md4.c
+  crypto/fipsmodule/md5/md5.c
+  crypto/fipsmodule/modes/cbc.c
+  crypto/fipsmodule/modes/cfb.c
+  crypto/fipsmodule/modes/ctr.c
+  crypto/fipsmodule/modes/gcm.c
+  crypto/fipsmodule/modes/gcm_nohw.c
+  crypto/fipsmodule/modes/ofb.c
+  crypto/fipsmodule/modes/polyval.c
+  crypto/fipsmodule/rand/ctrdrbg.c
+  crypto/fipsmodule/rand/fork_detect.c
+  crypto/fipsmodule/rand/rand.c
+  crypto/fipsmodule/rand/urandom.c
+  crypto/fipsmodule/rsa/blinding.c
+  crypto/fipsmodule/rsa/padding.c
+  crypto/fipsmodule/rsa/rsa.c
+  crypto/fipsmodule/rsa/rsa_impl.c
+  crypto/fipsmodule/self_check/fips.c
+  crypto/fipsmodule/self_check/self_check.c
+  crypto/fipsmodule/service_indicator/service_indicator.c
+  crypto/fipsmodule/sha/sha1.c
+  crypto/fipsmodule/sha/sha256.c
+  crypto/fipsmodule/sha/sha512.c
+  crypto/fipsmodule/tls/kdf.c
+)
+
+set(
   BCM_SOURCES_ASM
 
   gen/bcm/aesni-gcm-x86_64-apple.S
diff --git a/gen/sources.json b/gen/sources.json
index f3dd301..0568057 100644
--- a/gen/sources.json
+++ b/gen/sources.json
@@ -3,6 +3,84 @@
     "srcs": [
       "crypto/fipsmodule/bcm.c"
     ],
+    "internal_hdrs": [
+      "crypto/fipsmodule/aes/aes.c",
+      "crypto/fipsmodule/aes/aes_nohw.c",
+      "crypto/fipsmodule/aes/key_wrap.c",
+      "crypto/fipsmodule/aes/mode_wrappers.c",
+      "crypto/fipsmodule/bn/add.c",
+      "crypto/fipsmodule/bn/asm/x86_64-gcc.c",
+      "crypto/fipsmodule/bn/bn.c",
+      "crypto/fipsmodule/bn/bytes.c",
+      "crypto/fipsmodule/bn/cmp.c",
+      "crypto/fipsmodule/bn/ctx.c",
+      "crypto/fipsmodule/bn/div.c",
+      "crypto/fipsmodule/bn/div_extra.c",
+      "crypto/fipsmodule/bn/exponentiation.c",
+      "crypto/fipsmodule/bn/gcd.c",
+      "crypto/fipsmodule/bn/gcd_extra.c",
+      "crypto/fipsmodule/bn/generic.c",
+      "crypto/fipsmodule/bn/jacobi.c",
+      "crypto/fipsmodule/bn/montgomery.c",
+      "crypto/fipsmodule/bn/montgomery_inv.c",
+      "crypto/fipsmodule/bn/mul.c",
+      "crypto/fipsmodule/bn/prime.c",
+      "crypto/fipsmodule/bn/random.c",
+      "crypto/fipsmodule/bn/rsaz_exp.c",
+      "crypto/fipsmodule/bn/shift.c",
+      "crypto/fipsmodule/bn/sqrt.c",
+      "crypto/fipsmodule/cipher/aead.c",
+      "crypto/fipsmodule/cipher/cipher.c",
+      "crypto/fipsmodule/cipher/e_aes.c",
+      "crypto/fipsmodule/cipher/e_aesccm.c",
+      "crypto/fipsmodule/cmac/cmac.c",
+      "crypto/fipsmodule/dh/check.c",
+      "crypto/fipsmodule/dh/dh.c",
+      "crypto/fipsmodule/digest/digest.c",
+      "crypto/fipsmodule/digest/digests.c",
+      "crypto/fipsmodule/digestsign/digestsign.c",
+      "crypto/fipsmodule/ec/ec.c",
+      "crypto/fipsmodule/ec/ec_key.c",
+      "crypto/fipsmodule/ec/ec_montgomery.c",
+      "crypto/fipsmodule/ec/felem.c",
+      "crypto/fipsmodule/ec/oct.c",
+      "crypto/fipsmodule/ec/p224-64.c",
+      "crypto/fipsmodule/ec/p256-nistz.c",
+      "crypto/fipsmodule/ec/p256.c",
+      "crypto/fipsmodule/ec/scalar.c",
+      "crypto/fipsmodule/ec/simple.c",
+      "crypto/fipsmodule/ec/simple_mul.c",
+      "crypto/fipsmodule/ec/util.c",
+      "crypto/fipsmodule/ec/wnaf.c",
+      "crypto/fipsmodule/ecdh/ecdh.c",
+      "crypto/fipsmodule/ecdsa/ecdsa.c",
+      "crypto/fipsmodule/hkdf/hkdf.c",
+      "crypto/fipsmodule/hmac/hmac.c",
+      "crypto/fipsmodule/md4/md4.c",
+      "crypto/fipsmodule/md5/md5.c",
+      "crypto/fipsmodule/modes/cbc.c",
+      "crypto/fipsmodule/modes/cfb.c",
+      "crypto/fipsmodule/modes/ctr.c",
+      "crypto/fipsmodule/modes/gcm.c",
+      "crypto/fipsmodule/modes/gcm_nohw.c",
+      "crypto/fipsmodule/modes/ofb.c",
+      "crypto/fipsmodule/modes/polyval.c",
+      "crypto/fipsmodule/rand/ctrdrbg.c",
+      "crypto/fipsmodule/rand/fork_detect.c",
+      "crypto/fipsmodule/rand/rand.c",
+      "crypto/fipsmodule/rand/urandom.c",
+      "crypto/fipsmodule/rsa/blinding.c",
+      "crypto/fipsmodule/rsa/padding.c",
+      "crypto/fipsmodule/rsa/rsa.c",
+      "crypto/fipsmodule/rsa/rsa_impl.c",
+      "crypto/fipsmodule/self_check/fips.c",
+      "crypto/fipsmodule/self_check/self_check.c",
+      "crypto/fipsmodule/service_indicator/service_indicator.c",
+      "crypto/fipsmodule/sha/sha1.c",
+      "crypto/fipsmodule/sha/sha256.c",
+      "crypto/fipsmodule/sha/sha512.c",
+      "crypto/fipsmodule/tls/kdf.c"
+    ],
     "asm": [
       "gen/bcm/aesni-gcm-x86_64-apple.S",
       "gen/bcm/aesni-gcm-x86_64-linux.S",
diff --git a/util/generate_build_files.py b/util/generate_build_files.py
index 264ae9d..31b39f4 100644
--- a/util/generate_build_files.py
+++ b/util/generate_build_files.py
@@ -533,11 +533,6 @@
     with open('sources.json', 'w+') as f:
       json.dump(files, f, sort_keys=True, indent=2)
 
-def OnlyFIPSFragments(path, dent, is_dir):
-  return is_dir or (path.startswith(
-      os.path.join('src', 'crypto', 'fipsmodule', '')) and
-      NoTests(path, dent, is_dir))
-
 def NoTestsNorFIPSFragments(path, dent, is_dir):
   return (NoTests(path, dent, is_dir) and
       (is_dir or not OnlyFIPSFragments(path, dent, is_dir)))
@@ -628,7 +623,6 @@
   with open(os.path.join('src', 'gen', 'sources.json')) as f:
     sources = json.load(f)
 
-  fips_fragments = FindCFiles(os.path.join('src', 'crypto', 'fipsmodule'), OnlyFIPSFragments)
   bssl_sys_files = FindRustFiles(os.path.join('src', 'rust', 'bssl-sys', 'src'))
   bssl_crypto_files = FindRustFiles(os.path.join('src', 'rust', 'bssl-crypto', 'src'))
 
@@ -653,7 +647,7 @@
           PrefixWithSrc(sources['crypto']['internal_hdrs']),
       'crypto_test': PrefixWithSrc(sources['crypto_test']['srcs']),
       'crypto_test_data': PrefixWithSrc(sources['crypto_test']['data']),
-      'fips_fragments': fips_fragments,
+      'fips_fragments': PrefixWithSrc(sources['bcm']['internal_hdrs']),
       'fuzz': fuzz_c_files,
       'pki': PrefixWithSrc(sources['pki']['srcs']),
       'pki_headers': PrefixWithSrc(sources['pki']['hdrs']),