BIO_printf(bio_err, "Warning, input file %s ignored\n", infile);
}
- ctx = EVP_PKEY_CTX_new_from_name(NULL, alg, NULL);
+ ctx = EVP_PKEY_CTX_new_from_name(app_get0_libctx(), alg, app_get0_propq());
if (ctx == NULL) {
BIO_printf(bio_err,
"Error, %s param generation context allocation failed\n",
EVP_PKEY_print_params(out, pkey, 4, NULL);
if (check) {
- ctx = EVP_PKEY_CTX_new_from_pkey(NULL, pkey, NULL);
+ ctx = EVP_PKEY_CTX_new_from_pkey(app_get0_libctx(), pkey, app_get0_propq());
if (ctx == NULL) {
BIO_printf(bio_err, "Error, failed to check DH parameters\n");
goto end;
goto err;
}
- ctx = EVP_PKEY_CTX_new_from_name(NULL, "DHX", NULL);
+ ctx = EVP_PKEY_CTX_new_from_name(app_get0_libctx(), "DHX", app_get0_propq());
if (ctx == NULL
|| EVP_PKEY_fromdata_init(ctx) <= 0
|| EVP_PKEY_fromdata(ctx, &pkey, EVP_PKEY_KEY_PARAMETERS, params) <= 0) {
use strict;
use warnings;
-use OpenSSL::Test qw(:DEFAULT data_file);
+use OpenSSL::Test qw(:DEFAULT data_file srctop_file);
use OpenSSL::Test::Utils;
#Tests for the dhparam CLI application
plan skip_all => "DH is not supported in this build"
if disabled("dh");
-plan tests => 17;
+plan tests => 21;
+
+my $fipsconf = srctop_file("test", "fips-and-base.cnf");
sub checkdhparams {
my $file = shift; #Filename containing params
checkdhparams("gen-x942-0-512.der", "X9.42", 0, "DER", 512);
};
}
+SKIP: {
+ skip "Skipping tests that are only supported in a fips build with security ".
+ "checks", 4 if (disabled("fips") || disabled("fips-securitychecks"));
+
+ $ENV{OPENSSL_CONF} = $fipsconf;
+
+ ok(!run(app(['openssl', 'dhparam', '-check', '512'])),
+ "Generating 512 bit DH params should fail in FIPS mode");
+
+ ok(run(app(['openssl', 'dhparam', '-provider', 'default', '-propquery',
+ '?fips!=yes', '-check', '512'])),
+ "Generating 512 bit DH params should succeed in FIPS mode using".
+ " non-FIPS property query");
+
+ SKIP: {
+ skip "Skipping tests that require DSA", 2 if disabled("dsa");
+
+ ok(!run(app(['openssl', 'dhparam', '-dsaparam', '-check', '512'])),
+ "Generating 512 bit DSA-style DH params should fail in FIPS mode");
+
+ ok(run(app(['openssl', 'dhparam', '-provider', 'default', '-propquery',
+ '?fips!=yes', '-dsaparam', '-check', '512'])),
+ "Generating 512 bit DSA-style DH params should succeed in FIPS".
+ " mode using non-FIPS property query");
+ }
+
+ delete $ENV{OPENSSL_CONF};
+}
ok(run(app(["openssl", "dhparam", "-noout", "-text"],
stdin => data_file("pkcs3-2-1024.pem"))),