OPT_PROV_NAME, OPT_SECTION_NAME, OPT_MAC_NAME, OPT_MACOPT, OPT_VERIFY,
OPT_NO_LOG, OPT_CORRUPT_DESC, OPT_CORRUPT_TYPE, OPT_QUIET, OPT_CONFIG,
OPT_NO_CONDITIONAL_ERRORS,
- OPT_NO_SECURITY_CHECKS
+ OPT_NO_SECURITY_CHECKS,
+ OPT_SELF_TEST_ONLOAD
} OPTION_CHOICE;
const OPTIONS fipsinstall_options[] = {
" any conditional self tests fail"},
{"no_security_checks", OPT_NO_SECURITY_CHECKS, '-',
"Disable the run-time FIPS security checks in the module"},
+ {"self_test_onload", OPT_SELF_TEST_ONLOAD, '-',
+ "Forces self tests to always run on module load"},
OPT_SECTION("Input"),
{"in", OPT_IN, '<', "Input config file, used when verifying"},
module_mac_len))
goto end;
- if (install_mac != NULL) {
+ if (install_mac != NULL && install_mac_len > 0) {
if (!print_mac(out, OSSL_PROV_FIPS_PARAM_INSTALL_MAC, install_mac,
install_mac_len)
|| BIO_printf(out, "%s = %s\n", OSSL_PROV_FIPS_PARAM_INSTALL_STATUS,
BIO_printf(bio_err, "version not found\n");
goto end;
}
- s = NCONF_get_string(conf, section, OSSL_PROV_FIPS_PARAM_INSTALL_STATUS);
- if (s == NULL || strcmp(s, INSTALL_STATUS_VAL) != 0) {
- BIO_printf(bio_err, "install status not found\n");
- goto end;
- }
s = NCONF_get_string(conf, section, OSSL_PROV_FIPS_PARAM_MODULE_MAC);
if (s == NULL) {
BIO_printf(bio_err, "Module integrity MAC not found\n");
BIO_printf(bio_err, "Module integrity mismatch\n");
goto end;
}
- s = NCONF_get_string(conf, section, OSSL_PROV_FIPS_PARAM_INSTALL_MAC);
- if (s == NULL) {
- BIO_printf(bio_err, "Install indicator MAC not found\n");
- goto end;
- }
- buf2 = OPENSSL_hexstr2buf(s, &len);
- if (buf2 == NULL
- || (size_t)len != install_mac_len
- || memcmp(install_mac, buf2, install_mac_len) != 0) {
- BIO_printf(bio_err, "Install indicator status mismatch\n");
- goto end;
+ if (install_mac != NULL && install_mac_len > 0) {
+ s = NCONF_get_string(conf, section, OSSL_PROV_FIPS_PARAM_INSTALL_STATUS);
+ if (s == NULL || strcmp(s, INSTALL_STATUS_VAL) != 0) {
+ BIO_printf(bio_err, "install status not found\n");
+ goto end;
+ }
+ s = NCONF_get_string(conf, section, OSSL_PROV_FIPS_PARAM_INSTALL_MAC);
+ if (s == NULL) {
+ BIO_printf(bio_err, "Install indicator MAC not found\n");
+ goto end;
+ }
+ buf2 = OPENSSL_hexstr2buf(s, &len);
+ if (buf2 == NULL
+ || (size_t)len != install_mac_len
+ || memcmp(install_mac, buf2, install_mac_len) != 0) {
+ BIO_printf(bio_err, "Install indicator status mismatch\n");
+ goto end;
+ }
}
ret = 1;
end:
int fipsinstall_main(int argc, char **argv)
{
- int ret = 1, verify = 0, gotkey = 0, gotdigest = 0;
+ int ret = 1, verify = 0, gotkey = 0, gotdigest = 0, self_test_onload = 0;
int enable_conditional_errors = 1, enable_security_checks = 1;
const char *section_name = "fips_sect";
const char *mac_name = "HMAC";
case OPT_VERIFY:
verify = 1;
break;
+ case OPT_SELF_TEST_ONLOAD:
+ self_test_onload = 1;
+ break;
}
}
if (!do_mac(ctx, read_buffer, module_bio, module_mac, &module_mac_len))
goto end;
- mem_bio = BIO_new_mem_buf((const void *)INSTALL_STATUS_VAL,
- strlen(INSTALL_STATUS_VAL));
- if (mem_bio == NULL) {
- BIO_printf(bio_err, "Unable to create memory BIO\n");
- goto end;
+ if (self_test_onload == 0) {
+ mem_bio = BIO_new_mem_buf((const void *)INSTALL_STATUS_VAL,
+ strlen(INSTALL_STATUS_VAL));
+ if (mem_bio == NULL) {
+ BIO_printf(bio_err, "Unable to create memory BIO\n");
+ goto end;
+ }
+ if (!do_mac(ctx2, read_buffer, mem_bio, install_mac, &install_mac_len))
+ goto end;
+ } else {
+ install_mac_len = 0;
}
- if (!do_mac(ctx2, read_buffer, mem_bio, install_mac, &install_mac_len))
- goto end;
if (verify) {
if (!verify_config(in_fname, section_name, module_mac, module_mac_len,
[B<-quiet>]
[B<-no_conditional_errors>]
[B<-no_security_checks>]
+[B<-self_test_onload>]
[B<-corrupt_desc> I<selftest_description>]
[B<-corrupt_type> I<selftest_type>]
[B<-config> I<parent_config>]
This command is used to generate a FIPS module configuration file.
This configuration file can be used each time a FIPS module is loaded
in order to pass data to the FIPS module self tests. The FIPS module always
-verifies its MAC, but only needs to run the KAT's once,
+verifies its MAC, but optionally only needs to run the KAT's once,
at installation.
The generated configuration file consists of:
Configure the module to not perform run-time security checks as described above.
+=item B<-self_test_onload>
+
+Do not write the two fields related to the "test status indicator" and
+"MAC status indicator" to the output configuration file. Without these fields
+the self tests KATS will run each time the module is loaded. This option could be
+used for cross compiling, since the self tests need to run at least once on each
+target machine. Once the self tests have run on the target machine the user
+could possibly then add the 2 fields into the configuration using some other
+mechanism.
+
=item B<-quiet>
Do not output pass/fail messages. Implies B<-noout>.
plan skip_all => "Test only supported in a fips build" if disabled("fips");
-plan tests => 26;
+plan tests => 29;
my $infile = bldtop_file('providers', platform->dso('fips'));
my $fipskey = $ENV{FIPSKEY} // '00';
&& !run(app(['openssl', 'fipsinstall',
'-config', 'fips_parent_bad_module_mac.cnf'])),
"verify load config fail bad module mac");
+
+
+my $stconf = "fipsmodule_selftest.cnf";
+
+ok(run(app(['openssl', 'fipsinstall', '-out', $stconf,
+ '-module', $infile, '-self_test_onload'])),
+ "fipsinstall config saved without self test indicator");
+
+ok(!run(app(['openssl', 'fipsinstall', '-in', $stconf,
+ '-module', $infile, '-verify'])),
+ "fipsinstall config verify fails without self test indicator");
+
+ok(run(app(['openssl', 'fipsinstall', '-in', $stconf,
+ '-module', $infile, '-self_test_onload', '-verify'])),
+ "fipsinstall config verify passes when self test indicator is not present");