Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/fips.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ static int sha##_sha_##_kat(void) { \
} \
return 0; \
}
SHA_KAT(1, );
SHA_KAT(224, 256);
SHA_KAT(256, 256);
SHA_KAT(384, 512);
Expand All @@ -180,7 +179,6 @@ static int sha##_sha_##_kat(void) { \
} \
return 0; \
}
SHA_KAT(1, );
SHA_KAT(224, 256);
SHA_KAT(256, 256);
SHA_KAT(384, 512);
Expand Down Expand Up @@ -596,7 +594,7 @@ fips_powerup_tests(void)
{
typedef int (*kat_func)(void);
kat_func kats[] = {
drbg_kat, sha1_kat, sha224_kat, sha256_kat, sha384_kat, sha512_kat,
drbg_kat, sha224_kat, sha256_kat, sha384_kat, sha512_kat,
sha3_224_kat, sha3_256_kat, sha3_384_kat, sha3_512_kat, aes_ecb_kat,
aes_cbc_kat, aes_cbc_cs_kat, aes_cfb_kat, aes_ctr_kat, aes_ofb_kat,
aes_ccm_kat, aes_gcm_kat, aes_xts_kat, aes_cmac_kat, rsa_kat,
Expand Down Expand Up @@ -1373,7 +1371,7 @@ int FIPS_BLACKLIST[] = {DES_ECB, DES_CBC, DES_CBC_CS, DES_OFB,
DES3_CBC, DES3_CBC_CS, DES3_OFB, DES3_CFB, DES3_CTR, DES3_CTRLST,
DES3_CBC_MAC, DES3_CMAC, ED25519_KEYGEN, ED25519_SIGN, ED25519_VERIFY,
ED448_KEYGEN, ED448_SIGN, ED448_VERIFY, X25519_KEYGEN, X25519_DERIVE,
X448_KEYGEN, X448_DERIVE, RSA_ME, RSA_CRT, SHA512_DRNG, -1, -1 };
X448_KEYGEN, X448_DERIVE, RSA_ME, RSA_CRT, SHA512_DRNG, SHA1, -1, -1 };
Comment thread
vkanjur marked this conversation as resolved.
const size_t FIPS_BLACKLIST_LEN
= sizeof(FIPS_BLACKLIST) / sizeof(FIPS_BLACKLIST[0]);

Expand Down
2 changes: 1 addition & 1 deletion src/ica_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ unsigned int ica_sha1(unsigned int message_part,
int rc;

#ifdef ICA_FIPS
if (fips >> 1)
if (fips)
return EACCES;
#endif /* ICA_FIPS */

Expand Down
7 changes: 7 additions & 0 deletions src/s390_ecc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2828,6 +2828,13 @@ static void ecdsa_test(void)
for (i = 0; i < ECDSA_TV_LEN; i++) {
switch (t->hash) {
case SHA1:
#ifdef ICA_FIPS
if (fips & ICA_FIPS_MODE) {
printf("Skipping ECDSA test vector %lu (SHA-1 not FIPS approved)\n", i);
t++;
continue;
}
#endif /* ICA_FIPS */
rc = ica_sha1(SHA_MSG_PART_ONLY, t->msglen, t->msg,
&sha_ctx, hash);
hashlen = SHA1_HASH_LENGTH;
Expand Down
26 changes: 17 additions & 9 deletions test/icastats_test.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -692,16 +692,24 @@ static int sha_tests()
shake_256_context_t shake_256_context;

/* Test SHA-1 */
rc = system("@builddir@icastats -r");
if (rc == -1)
return handle_ica_error(rc, "system");
#ifdef ICA_FIPS
if (ica_fips_status() & ICA_FIPS_MODE) {
V_(printf("icastats SHA-1 test skipped. (SHA-1 not FIPS 140-3 approved)\n"));
} else {
#endif /* ICA_FIPS */
rc = system("@builddir@icastats -r");
if (rc == -1)
return handle_ica_error(rc, "system");

rc = ica_sha1(SHA_MSG_PART_ONLY, DATA_LENGTH, plain_data, &sha_context0, hash);
if (rc)
return handle_ica_error(rc, "ica_sha1");
rc = check_icastats(SHA1, "SHA-1");
if (rc != 0)
return rc;
rc = ica_sha1(SHA_MSG_PART_ONLY, DATA_LENGTH, plain_data, &sha_context0, hash);
if (rc)
return handle_ica_error(rc, "ica_sha1");
rc = check_icastats(SHA1, "SHA-1");
if (rc != 0)
return rc;
#ifdef ICA_FIPS
}
#endif /* ICA_FIPS */

/* Test SHA-224 */
rc = system("@builddir@icastats -r");
Expand Down
8 changes: 8 additions & 0 deletions test/sha1_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ int main(int argc, char **argv)

set_verbosity(argc, argv);

#ifdef ICA_FIPS
if (ica_fips_status() & ICA_FIPS_MODE) {
printf("All SHA-1 tests skipped."
" (SHA-1 not FIPS approved)\n");
return TEST_SKIP;
}
#endif /* ICA_FIPS */

rc = new_api_sha_test();
if (rc) {
printf("new_api_sha_test failed with rc = %i\n", rc);
Expand Down
9 changes: 9 additions & 0 deletions test/sha_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ int main(int argc, char *argv[])
switch (curr_test->type) {
case SHA1:
V_(printf("SHA1 ...\n"));
#ifdef ICA_FIPS
if (ica_fips_status() & ICA_FIPS_MODE) {
V_(printf("SHA1 test skipped (SHA-1 not FIPS approved)\n"));
rc = TEST_SKIP;
} else
#endif /* ICA_FIPS */
rc = sha1_new_api_test(curr_test);
break;
case SHA224:
Expand Down Expand Up @@ -202,6 +208,9 @@ int main(int argc, char *argv[])
V_(printf("... Passed.\n"));
queue.passed++;
}
else if (rc == TEST_SKIP) {
V_(printf("... Skipped.\n"));
}
else {
V_(printf("error: (%x).\n", rc));
queue.failed++;
Expand Down