Remove BSAES code entirely if BSAES is not compiled in.

Removes the need to conditionally mark BSAES function extern "C" (which
would break redefine_extname on them).

Bug: 42220000
Change-Id: I865329dec170b1bd012050a3c3b1e02b6a6a6964
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/87250
Auto-Submit: Rudolf Polzer <rpolzer@google.com>
Commit-Queue: Rudolf Polzer <rpolzer@google.com>
Reviewed-by: Xiangfei Ding <xfding@google.com>
diff --git a/crypto/fipsmodule/aes/aes_test.cc b/crypto/fipsmodule/aes/aes_test.cc
index c9d8b52..d0c168d 100644
--- a/crypto/fipsmodule/aes/aes_test.cc
+++ b/crypto/fipsmodule/aes/aes_test.cc
@@ -293,6 +293,7 @@
       block_counts = {0, 1, 8};
     }
 
+#if defined(BSAES)
     if (bsaes_capable()) {
       ASSERT_EQ(vpaes_set_encrypt_key(kKey, bits, &key), 0);
       CHECK_ABI(vpaes_encrypt_key_to_bsaes, &key, &key);
@@ -311,6 +312,7 @@
                   block, AES_DECRYPT);
       }
     }
+#endif
 
     if (vpaes_capable()) {
       ASSERT_EQ(CHECK_ABI(vpaes_set_encrypt_key, kKey, bits, &key), 0);
@@ -332,7 +334,7 @@
         CHECK_ABI(vpaes_cbc_encrypt, buf, buf, AES_BLOCK_SIZE * blocks, &key,
                   block, AES_DECRYPT);
       }
-#endif  // VPAES_CBC
+#endif
     }
 
     if (hwaes_capable()) {
diff --git a/crypto/fipsmodule/aes/internal.h b/crypto/fipsmodule/aes/internal.h
index a83864e..9b42a6a 100644
--- a/crypto/fipsmodule/aes/internal.h
+++ b/crypto/fipsmodule/aes/internal.h
@@ -192,31 +192,6 @@
 void vpaes_ctr32_encrypt_blocks_with_bsaes(const uint8_t *in, uint8_t *out,
                                            size_t blocks, const AES_KEY *key,
                                            const uint8_t ivec[16]);
-#else
-inline int bsaes_capable() { return 0; }
-
-// On other platforms, bsaes_capable() will always return false and so the
-// following will never be called.
-inline void bsaes_cbc_encrypt(const uint8_t *in, uint8_t *out, size_t length,
-                              const AES_KEY *key, uint8_t ivec[16], int enc) {
-  abort();
-}
-
-inline void bsaes_ctr32_encrypt_blocks(const uint8_t *in, uint8_t *out,
-                                       size_t len, const AES_KEY *key,
-                                       const uint8_t ivec[16]) {
-  abort();
-}
-
-inline void vpaes_encrypt_key_to_bsaes(AES_KEY *out_bsaes,
-                                       const AES_KEY *vpaes) {
-  abort();
-}
-
-inline void vpaes_decrypt_key_to_bsaes(AES_KEY *out_bsaes,
-                                       const AES_KEY *vpaes) {
-  abort();
-}
 #endif  // !BSAES
 
 
diff --git a/crypto/fipsmodule/cipher/e_aes.cc.inc b/crypto/fipsmodule/cipher/e_aes.cc.inc
index 43f75b7..02648da 100644
--- a/crypto/fipsmodule/cipher/e_aes.cc.inc
+++ b/crypto/fipsmodule/cipher/e_aes.cc.inc
@@ -86,6 +86,7 @@
       if (mode == EVP_CIPH_CBC_MODE) {
         dat->stream.cbc = aes_hw_cbc_encrypt;
       }
+#if defined(BSAES)
     } else if (bsaes_capable() && mode == EVP_CIPH_CBC_MODE) {
       assert(vpaes_capable());
       ret = vpaes_set_decrypt_key(key, ctx->key_len * 8, &dat->ks.ks);
@@ -95,6 +96,7 @@
       // If |dat->stream.cbc| is provided, |dat->block| is never used.
       dat->block = nullptr;
       dat->stream.cbc = bsaes_cbc_encrypt;
+#endif
     } else if (vpaes_capable()) {
       ret = vpaes_set_decrypt_key(key, ctx->key_len * 8, &dat->ks.ks);
       dat->block = vpaes_decrypt;