From: Matt Caswell Date: Fri, 18 Mar 2016 17:43:58 +0000 (+0000) Subject: Fix no-dsa X-Git-Tag: OpenSSL_1_1_0-pre5~269 X-Git-Url: https://git.openssl.org/?p=openssl.git;a=commitdiff_plain;h=83ae8124de62f5f6d07dd4b0e6043c8a196b789e Fix no-dsa Misc fixes for no-dsa. Reviewed-by: Richard Levitte --- diff --git a/apps/dhparam.c b/apps/dhparam.c index f7fd8c0c35..58baff822a 100644 --- a/apps/dhparam.c +++ b/apps/dhparam.c @@ -171,7 +171,10 @@ int dhparam_main(int argc, char **argv) BIO *in = NULL, *out = NULL; DH *dh = NULL; char *infile = NULL, *outfile = NULL, *prog, *inrand = NULL; - int dsaparam = 0, i, text = 0, C = 0, ret = 1, num = 0, g = 0; +#ifndef OPENSSL_NO_DSA + int dsaparam = 0; +#endif + int i, text = 0, C = 0, ret = 1, num = 0, g = 0; int informat = FORMAT_PEM, outformat = FORMAT_PEM, check = 0, noout = 0; OPTION_CHOICE o; @@ -211,7 +214,9 @@ int dhparam_main(int argc, char **argv) text = 1; break; case OPT_DSAPARAM: +#ifndef OPENSSL_NO_DSA dsaparam = 1; +#endif break; case OPT_C: C = 1; diff --git a/apps/rsa.c b/apps/rsa.c index 5320f38455..38cedf7b77 100644 --- a/apps/rsa.c +++ b/apps/rsa.c @@ -167,7 +167,10 @@ int rsa_main(int argc, char **argv) char *passin = NULL, *passout = NULL, *passinarg = NULL, *passoutarg = NULL; int i, private = 0; int informat = FORMAT_PEM, outformat = FORMAT_PEM, text = 0, check = 0; - int noout = 0, modulus = 0, pubin = 0, pubout = 0, pvk_encr = 2, ret = 1; + int noout = 0, modulus = 0, pubin = 0, pubout = 0, ret = 1; +# if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_RC4) + int pvk_encr = 2; +#endif OPTION_CHOICE o; prog = opt_init(argc, argv, rsa_options); @@ -217,7 +220,7 @@ int rsa_main(int argc, char **argv) case OPT_RSAPUBKEY_OUT: pubout = 2; break; -#ifndef OPENSSL_NO_RC4 +# if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_RC4) case OPT_PVK_STRONG: pvk_encr = 2; break; diff --git a/apps/speed.c b/apps/speed.c index 260b55fccc..409f3a98e2 100644 --- a/apps/speed.c +++ b/apps/speed.c @@ -547,15 +547,17 @@ static OPT_PAIR doit_choices[] = { {NULL} }; -#define R_DSA_512 0 -#define R_DSA_1024 1 -#define R_DSA_2048 2 +#ifndef OPENSSL_NO_DSA +# define R_DSA_512 0 +# define R_DSA_1024 1 +# define R_DSA_2048 2 static OPT_PAIR dsa_choices[] = { {"dsa512", R_DSA_512}, {"dsa1024", R_DSA_1024}, {"dsa2048", R_DSA_2048}, {NULL}, }; +#endif #define R_RSA_512 0 #define R_RSA_1024 1 @@ -1247,7 +1249,10 @@ int speed_main(int argc, char **argv) double d = 0.0; OPTION_CHOICE o; int multiblock = 0, doit[ALGOR_NUM], pr_header = 0; - int dsa_doit[DSA_NUM], rsa_doit[RSA_NUM]; +#ifndef OPENSSL_NO_DSA + int dsa_doit[DSA_NUM]; +#endif + int rsa_doit[RSA_NUM]; int ret = 1, i, k, misalign = 0; long c[ALGOR_NUM][SIZE_NUM], count = 0, save_count = 0; #ifndef NO_FORK @@ -1395,8 +1400,10 @@ int speed_main(int argc, char **argv) doit[i] = 0; for (i = 0; i < RSA_NUM; i++) rsa_doit[i] = 0; +#ifndef OPENSSL_NO_DSA for (i = 0; i < DSA_NUM; i++) dsa_doit[i] = 0; +#endif #ifndef OPENSSL_NO_EC for (i = 0; i < EC_NUM; i++) ecdsa_doit[i] = 0; @@ -1612,8 +1619,10 @@ int speed_main(int argc, char **argv) doit[i] = 1; for (i = 0; i < RSA_NUM; i++) rsa_doit[i] = 1; +#ifndef OPENSSL_NO_DSA for (i = 0; i < DSA_NUM; i++) dsa_doit[i] = 1; +#endif #ifndef OPENSSL_NO_EC for (i = 0; i < EC_NUM; i++) ecdsa_doit[i] = 1; diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c index 34193f38ad..e5df8e7fe0 100644 --- a/crypto/engine/eng_cryptodev.c +++ b/crypto/engine/eng_cryptodev.c @@ -115,6 +115,7 @@ static int cryptodev_rsa_nocrt_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx); static int cryptodev_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx); +#ifndef OPENSSL_NO_DSA static int cryptodev_dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); @@ -126,6 +127,7 @@ static DSA_SIG *cryptodev_dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa); static int cryptodev_dsa_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, DSA *dsa); +#endif #ifndef OPENSSL_NO_DH static int cryptodev_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, @@ -1384,6 +1386,7 @@ static RSA_METHOD cryptodev_rsa = { NULL /* rsa_verify */ }; +#ifndef OPENSSL_NO_DSA static int cryptodev_dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx) @@ -1526,6 +1529,7 @@ static DSA_METHOD cryptodev_dsa = { 0, /* flags */ NULL /* app_data */ }; +#endif #ifndef OPENSSL_NO_DH static int @@ -1665,6 +1669,7 @@ void engine_load_cryptodev_internal(void) } } +#ifndef OPENSSL_NO_DSA if (ENGINE_set_DSA(engine, &cryptodev_dsa)) { const DSA_METHOD *meth = DSA_OpenSSL(); @@ -1678,6 +1683,7 @@ void engine_load_cryptodev_internal(void) if (cryptodev_asymfeat & CRF_DSA_VERIFY) cryptodev_dsa.dsa_do_verify = cryptodev_dsa_verify; } +#endif #ifndef OPENSSL_NO_DH if (ENGINE_set_DH(engine, &cryptodev_dh)) { diff --git a/test/recipes/80-test_cms.t b/test/recipes/80-test_cms.t index 8dc6e9039a..21926d430e 100644 --- a/test/recipes/80-test_cms.t +++ b/test/recipes/80-test_cms.t @@ -13,8 +13,8 @@ setup("test_cms"); my $smdir = srctop_dir("test", "smime-certs"); my $smcont = srctop_file("test", "smcont.txt"); -my ($no_des, $no_dh, $no_ec, $no_ec2m, $no_rc2, $no_zlib) - = disabled qw/des dh ec ec2m rc2 zlib/; +my ($no_des, $no_dh, $no_dsa, $no_ec, $no_ec2m, $no_rc2, $no_zlib) + = disabled qw/des dh dsa ec ec2m rc2 zlib/; plan tests => 4; @@ -59,7 +59,7 @@ my @smime_pkcs7_tests = ( "-content", $smcont ] ], - [ "signed detached content DER format, add RSA signer", + [ "signed detached content DER format, add RSA signer (with DSA existing)", [ "-resign", "-inform", "DER", "-in", "test.cms", "-outform", "DER", "-signer", catfile($smdir, "smrsa1.pem"), "-out", "test2.cms" ], [ "-verify", "-in", "test2.cms", "-inform", "DER", @@ -477,6 +477,8 @@ sub check_availability { if ($no_rc2 && $tnam =~ /RC2/); return "$tnam: skipped, DES disabled\n" if ($no_des && $tnam =~ /DES/); + return "$tnam: skipped, DSA disabled\n" + if ($no_dsa && $tnam =~ / DSA/); return ""; }