|
|
@ -169,6 +169,23 @@ BORINGSSL_bcm_power_on_self_test(void) { |
|
|
|
#if !defined(OPENSSL_ASAN) |
|
|
|
#if !defined(OPENSSL_ASAN) |
|
|
|
// Integrity tests cannot run under ASAN because it involves reading the full
|
|
|
|
// Integrity tests cannot run under ASAN because it involves reading the full
|
|
|
|
// .text section, which triggers the global-buffer overflow detection.
|
|
|
|
// .text section, which triggers the global-buffer overflow detection.
|
|
|
|
|
|
|
|
if (!BORINGSSL_integrity_test()) { |
|
|
|
|
|
|
|
goto err; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif // OPENSSL_ASAN
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!boringssl_self_test_startup()) { |
|
|
|
|
|
|
|
goto err; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
err: |
|
|
|
|
|
|
|
BORINGSSL_FIPS_abort(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if !defined(OPENSSL_ASAN) |
|
|
|
|
|
|
|
int BORINGSSL_integrity_test(void) { |
|
|
|
const uint8_t *const start = BORINGSSL_bcm_text_start; |
|
|
|
const uint8_t *const start = BORINGSSL_bcm_text_start; |
|
|
|
const uint8_t *const end = BORINGSSL_bcm_text_end; |
|
|
|
const uint8_t *const end = BORINGSSL_bcm_text_end; |
|
|
|
|
|
|
|
|
|
|
@ -198,14 +215,14 @@ BORINGSSL_bcm_power_on_self_test(void) { |
|
|
|
const EVP_MD *const kHashFunction = EVP_sha256(); |
|
|
|
const EVP_MD *const kHashFunction = EVP_sha256(); |
|
|
|
if (!boringssl_self_test_sha256() || |
|
|
|
if (!boringssl_self_test_sha256() || |
|
|
|
!boringssl_self_test_hmac_sha256()) { |
|
|
|
!boringssl_self_test_hmac_sha256()) { |
|
|
|
goto err; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
#else |
|
|
|
#else |
|
|
|
uint8_t result[SHA512_DIGEST_LENGTH]; |
|
|
|
uint8_t result[SHA512_DIGEST_LENGTH]; |
|
|
|
const EVP_MD *const kHashFunction = EVP_sha512(); |
|
|
|
const EVP_MD *const kHashFunction = EVP_sha512(); |
|
|
|
if (!boringssl_self_test_sha512() || |
|
|
|
if (!boringssl_self_test_sha512() || |
|
|
|
!boringssl_self_test_hmac_sha256()) { |
|
|
|
!boringssl_self_test_hmac_sha256()) { |
|
|
|
goto err; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
@ -216,7 +233,7 @@ BORINGSSL_bcm_power_on_self_test(void) { |
|
|
|
if (!HMAC_Init_ex(&hmac_ctx, kHMACKey, sizeof(kHMACKey), kHashFunction, |
|
|
|
if (!HMAC_Init_ex(&hmac_ctx, kHMACKey, sizeof(kHMACKey), kHashFunction, |
|
|
|
NULL /* no ENGINE */)) { |
|
|
|
NULL /* no ENGINE */)) { |
|
|
|
fprintf(stderr, "HMAC_Init_ex failed.\n"); |
|
|
|
fprintf(stderr, "HMAC_Init_ex failed.\n"); |
|
|
|
goto err; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
BORINGSSL_maybe_set_module_text_permissions(PROT_READ | PROT_EXEC); |
|
|
|
BORINGSSL_maybe_set_module_text_permissions(PROT_READ | PROT_EXEC); |
|
|
@ -236,7 +253,7 @@ BORINGSSL_bcm_power_on_self_test(void) { |
|
|
|
if (!HMAC_Final(&hmac_ctx, result, &result_len) || |
|
|
|
if (!HMAC_Final(&hmac_ctx, result, &result_len) || |
|
|
|
result_len != sizeof(result)) { |
|
|
|
result_len != sizeof(result)) { |
|
|
|
fprintf(stderr, "HMAC failed.\n"); |
|
|
|
fprintf(stderr, "HMAC failed.\n"); |
|
|
|
goto err; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
HMAC_CTX_cleanse(&hmac_ctx); // FIPS 140-3, AS05.10.
|
|
|
|
HMAC_CTX_cleanse(&hmac_ctx); // FIPS 140-3, AS05.10.
|
|
|
|
|
|
|
|
|
|
|
@ -244,22 +261,14 @@ BORINGSSL_bcm_power_on_self_test(void) { |
|
|
|
|
|
|
|
|
|
|
|
if (!check_test(expected, result, sizeof(result), "FIPS integrity test")) { |
|
|
|
if (!check_test(expected, result, sizeof(result), "FIPS integrity test")) { |
|
|
|
#if !defined(BORINGSSL_FIPS_BREAK_TESTS) |
|
|
|
#if !defined(BORINGSSL_FIPS_BREAK_TESTS) |
|
|
|
goto err; |
|
|
|
return 0; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
OPENSSL_cleanse(result, sizeof(result)); // FIPS 140-3, AS05.10.
|
|
|
|
OPENSSL_cleanse(result, sizeof(result)); // FIPS 140-3, AS05.10.
|
|
|
|
#endif // OPENSSL_ASAN
|
|
|
|
return 1; |
|
|
|
|
|
|
|
|
|
|
|
if (!boringssl_self_test_startup()) { |
|
|
|
|
|
|
|
goto err; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
err: |
|
|
|
|
|
|
|
BORINGSSL_FIPS_abort(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif // OPENSSL_ASAN
|
|
|
|
|
|
|
|
|
|
|
|
void BORINGSSL_FIPS_abort(void) { |
|
|
|
void BORINGSSL_FIPS_abort(void) { |
|
|
|
for (;;) { |
|
|
|
for (;;) { |
|
|
|