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
2 changes: 1 addition & 1 deletion src/fips.c
Original file line number Diff line number Diff line change
Expand Up @@ -1373,7 +1373,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 };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding SHA1 here causes it to no longer be included in the mechanism list (ica_get_functionlist()), but it does not hinder anyone from using the ica_sha1() function.....

I checked how this is done for e.g. DES, and there the ica_des_xxx() functions have

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

at the top of the function body. So this block the function when fips is active.

Note that ica_sha1() has the following there:

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

This blocks the function only if the fips selftests have failed (note (fips) vs (fips >> 1)).

const size_t FIPS_BLACKLIST_LEN
= sizeof(FIPS_BLACKLIST) / sizeof(FIPS_BLACKLIST[0]);

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