summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/dsa
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/dsa')
-rw-r--r--src/lib/libcrypto/dsa/dsa_ameth.c46
-rw-r--r--src/lib/libcrypto/dsa/dsa_asn1.c4
-rw-r--r--src/lib/libcrypto/dsa/dsa_err.c35
-rw-r--r--src/lib/libcrypto/dsa/dsa_lib.c8
-rw-r--r--src/lib/libcrypto/dsa/dsa_ossl.c16
-rw-r--r--src/lib/libcrypto/dsa/dsa_pmeth.c11
-rw-r--r--src/lib/libcrypto/dsa/dsa_prn.c6
7 files changed, 50 insertions, 76 deletions
diff --git a/src/lib/libcrypto/dsa/dsa_ameth.c b/src/lib/libcrypto/dsa/dsa_ameth.c
index b589d39892..92f543de9e 100644
--- a/src/lib/libcrypto/dsa/dsa_ameth.c
+++ b/src/lib/libcrypto/dsa/dsa_ameth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dsa_ameth.c,v 1.22 2017/01/21 10:38:29 beck Exp $ */ 1/* $OpenBSD: dsa_ameth.c,v 1.23 2017/01/29 17:49:22 beck Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -92,26 +92,26 @@ dsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey)
92 pmlen = pstr->length; 92 pmlen = pstr->length;
93 93
94 if (!(dsa = d2i_DSAparams(NULL, &pm, pmlen))) { 94 if (!(dsa = d2i_DSAparams(NULL, &pm, pmlen))) {
95 DSAerr(DSA_F_DSA_PUB_DECODE, DSA_R_DECODE_ERROR); 95 DSAerror(DSA_R_DECODE_ERROR);
96 goto err; 96 goto err;
97 } 97 }
98 } else if (ptype == V_ASN1_NULL || ptype == V_ASN1_UNDEF) { 98 } else if (ptype == V_ASN1_NULL || ptype == V_ASN1_UNDEF) {
99 if (!(dsa = DSA_new())) { 99 if (!(dsa = DSA_new())) {
100 DSAerr(DSA_F_DSA_PUB_DECODE, ERR_R_MALLOC_FAILURE); 100 DSAerror(ERR_R_MALLOC_FAILURE);
101 goto err; 101 goto err;
102 } 102 }
103 } else { 103 } else {
104 DSAerr(DSA_F_DSA_PUB_DECODE, DSA_R_PARAMETER_ENCODING_ERROR); 104 DSAerror(DSA_R_PARAMETER_ENCODING_ERROR);
105 goto err; 105 goto err;
106 } 106 }
107 107
108 if (!(public_key=d2i_ASN1_INTEGER(NULL, &p, pklen))) { 108 if (!(public_key=d2i_ASN1_INTEGER(NULL, &p, pklen))) {
109 DSAerr(DSA_F_DSA_PUB_DECODE, DSA_R_DECODE_ERROR); 109 DSAerror(DSA_R_DECODE_ERROR);
110 goto err; 110 goto err;
111 } 111 }
112 112
113 if (!(dsa->pub_key = ASN1_INTEGER_to_BN(public_key, NULL))) { 113 if (!(dsa->pub_key = ASN1_INTEGER_to_BN(public_key, NULL))) {
114 DSAerr(DSA_F_DSA_PUB_DECODE, DSA_R_BN_DECODE_ERROR); 114 DSAerror(DSA_R_BN_DECODE_ERROR);
115 goto err; 115 goto err;
116 } 116 }
117 117
@@ -141,12 +141,12 @@ dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
141 141
142 str = ASN1_STRING_new(); 142 str = ASN1_STRING_new();
143 if (str == NULL) { 143 if (str == NULL) {
144 DSAerr(DSA_F_DSA_PUB_ENCODE, ERR_R_MALLOC_FAILURE); 144 DSAerror(ERR_R_MALLOC_FAILURE);
145 goto err; 145 goto err;
146 } 146 }
147 str->length = i2d_DSAparams(dsa, &str->data); 147 str->length = i2d_DSAparams(dsa, &str->data);
148 if (str->length <= 0) { 148 if (str->length <= 0) {
149 DSAerr(DSA_F_DSA_PUB_ENCODE, ERR_R_MALLOC_FAILURE); 149 DSAerror(ERR_R_MALLOC_FAILURE);
150 ASN1_STRING_free(str); 150 ASN1_STRING_free(str);
151 goto err; 151 goto err;
152 } 152 }
@@ -160,7 +160,7 @@ dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
160 penclen = i2d_DSAPublicKey(dsa, &penc); 160 penclen = i2d_DSAPublicKey(dsa, &penc);
161 161
162 if (penclen <= 0) { 162 if (penclen <= 0) {
163 DSAerr(DSA_F_DSA_PUB_ENCODE, ERR_R_MALLOC_FAILURE); 163 DSAerror(ERR_R_MALLOC_FAILURE);
164 goto err; 164 goto err;
165 } 165 }
166 166
@@ -211,21 +211,21 @@ dsa_priv_decode(EVP_PKEY *pkey, PKCS8_PRIV_KEY_INFO *p8)
211 goto decerr; 211 goto decerr;
212 /* We have parameters now set private key */ 212 /* We have parameters now set private key */
213 if (!(dsa->priv_key = ASN1_INTEGER_to_BN(privkey, NULL))) { 213 if (!(dsa->priv_key = ASN1_INTEGER_to_BN(privkey, NULL))) {
214 DSAerr(DSA_F_DSA_PRIV_DECODE,DSA_R_BN_ERROR); 214 DSAerror(DSA_R_BN_ERROR);
215 goto dsaerr; 215 goto dsaerr;
216 } 216 }
217 /* Calculate public key */ 217 /* Calculate public key */
218 if (!(dsa->pub_key = BN_new())) { 218 if (!(dsa->pub_key = BN_new())) {
219 DSAerr(DSA_F_DSA_PRIV_DECODE, ERR_R_MALLOC_FAILURE); 219 DSAerror(ERR_R_MALLOC_FAILURE);
220 goto dsaerr; 220 goto dsaerr;
221 } 221 }
222 if (!(ctx = BN_CTX_new())) { 222 if (!(ctx = BN_CTX_new())) {
223 DSAerr(DSA_F_DSA_PRIV_DECODE, ERR_R_MALLOC_FAILURE); 223 DSAerror(ERR_R_MALLOC_FAILURE);
224 goto dsaerr; 224 goto dsaerr;
225 } 225 }
226 226
227 if (!BN_mod_exp_ct(dsa->pub_key, dsa->g, dsa->priv_key, dsa->p, ctx)) { 227 if (!BN_mod_exp_ct(dsa->pub_key, dsa->g, dsa->priv_key, dsa->p, ctx)) {
228 DSAerr(DSA_F_DSA_PRIV_DECODE,DSA_R_BN_ERROR); 228 DSAerror(DSA_R_BN_ERROR);
229 goto dsaerr; 229 goto dsaerr;
230 } 230 }
231 231
@@ -236,7 +236,7 @@ dsa_priv_decode(EVP_PKEY *pkey, PKCS8_PRIV_KEY_INFO *p8)
236 goto done; 236 goto done;
237 237
238decerr: 238decerr:
239 DSAerr(DSA_F_DSA_PRIV_DECODE, DSA_R_DECODE_ERROR); 239 DSAerror(DSA_R_DECODE_ERROR);
240dsaerr: 240dsaerr:
241 DSA_free(dsa); 241 DSA_free(dsa);
242done: 242done:
@@ -255,13 +255,13 @@ dsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey)
255 255
256 params = ASN1_STRING_new(); 256 params = ASN1_STRING_new();
257 if (!params) { 257 if (!params) {
258 DSAerr(DSA_F_DSA_PRIV_ENCODE, ERR_R_MALLOC_FAILURE); 258 DSAerror(ERR_R_MALLOC_FAILURE);
259 goto err; 259 goto err;
260 } 260 }
261 261
262 params->length = i2d_DSAparams(pkey->pkey.dsa, &params->data); 262 params->length = i2d_DSAparams(pkey->pkey.dsa, &params->data);
263 if (params->length <= 0) { 263 if (params->length <= 0) {
264 DSAerr(DSA_F_DSA_PRIV_ENCODE, ERR_R_MALLOC_FAILURE); 264 DSAerror(ERR_R_MALLOC_FAILURE);
265 goto err; 265 goto err;
266 } 266 }
267 params->type = V_ASN1_SEQUENCE; 267 params->type = V_ASN1_SEQUENCE;
@@ -269,7 +269,7 @@ dsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey)
269 /* Get private key into integer */ 269 /* Get private key into integer */
270 prkey = BN_to_ASN1_INTEGER(pkey->pkey.dsa->priv_key, NULL); 270 prkey = BN_to_ASN1_INTEGER(pkey->pkey.dsa->priv_key, NULL);
271 if (!prkey) { 271 if (!prkey) {
272 DSAerr(DSA_F_DSA_PRIV_ENCODE, DSA_R_BN_ERROR); 272 DSAerror(DSA_R_BN_ERROR);
273 goto err; 273 goto err;
274 } 274 }
275 275
@@ -407,7 +407,7 @@ do_dsa_print(BIO *bp, const DSA *x, int off, int ptype)
407 407
408 m = malloc(buf_len + 10); 408 m = malloc(buf_len + 10);
409 if (m == NULL) { 409 if (m == NULL) {
410 DSAerr(DSA_F_DO_DSA_PRINT, ERR_R_MALLOC_FAILURE); 410 DSAerror(ERR_R_MALLOC_FAILURE);
411 goto err; 411 goto err;
412 } 412 }
413 413
@@ -441,7 +441,7 @@ dsa_param_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen)
441 DSA *dsa; 441 DSA *dsa;
442 442
443 if (!(dsa = d2i_DSAparams(NULL, pder, derlen))) { 443 if (!(dsa = d2i_DSAparams(NULL, pder, derlen))) {
444 DSAerr(DSA_F_DSA_PARAM_DECODE, ERR_R_DSA_LIB); 444 DSAerror(ERR_R_DSA_LIB);
445 return 0; 445 return 0;
446 } 446 }
447 EVP_PKEY_assign_DSA(pkey, dsa); 447 EVP_PKEY_assign_DSA(pkey, dsa);
@@ -480,7 +480,7 @@ old_dsa_priv_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen)
480 BIGNUM *j, *p1, *newp1; 480 BIGNUM *j, *p1, *newp1;
481 481
482 if (!(dsa = d2i_DSAPrivateKey(NULL, pder, derlen))) { 482 if (!(dsa = d2i_DSAPrivateKey(NULL, pder, derlen))) {
483 DSAerr(DSA_F_OLD_DSA_PRIV_DECODE, ERR_R_DSA_LIB); 483 DSAerror(ERR_R_DSA_LIB);
484 return 0; 484 return 0;
485 } 485 }
486 486
@@ -507,7 +507,7 @@ old_dsa_priv_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen)
507 if (BN_mul(newp1, dsa->q, j, ctx) == 0) 507 if (BN_mul(newp1, dsa->q, j, ctx) == 0)
508 goto err; 508 goto err;
509 if (BN_cmp(newp1, p1) != 0) { 509 if (BN_cmp(newp1, p1) != 0) {
510 DSAerr(DSA_F_DSA_PARAM_DECODE, DSA_R_BAD_Q_VALUE); 510 DSAerror(DSA_R_BAD_Q_VALUE);
511 goto err; 511 goto err;
512 } 512 }
513 513
@@ -516,7 +516,7 @@ old_dsa_priv_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen)
516 */ 516 */
517 517
518 if (BN_is_prime_ex(dsa->q, BN_prime_checks, ctx, NULL) == 0) { 518 if (BN_is_prime_ex(dsa->q, BN_prime_checks, ctx, NULL) == 0) {
519 DSAerr(DSA_F_DSA_PARAM_DECODE, DSA_R_BAD_Q_VALUE); 519 DSAerror(DSA_R_BAD_Q_VALUE);
520 goto err; 520 goto err;
521 } 521 }
522 522
@@ -561,7 +561,7 @@ dsa_sig_print(BIO *bp, const X509_ALGOR *sigalg, const ASN1_STRING *sig,
561 update_buflen(dsa_sig->s, &buf_len); 561 update_buflen(dsa_sig->s, &buf_len);
562 m = malloc(buf_len + 10); 562 m = malloc(buf_len + 10);
563 if (m == NULL) { 563 if (m == NULL) {
564 DSAerr(DSA_F_DSA_SIG_PRINT, ERR_R_MALLOC_FAILURE); 564 DSAerror(ERR_R_MALLOC_FAILURE);
565 goto err; 565 goto err;
566 } 566 }
567 567
diff --git a/src/lib/libcrypto/dsa/dsa_asn1.c b/src/lib/libcrypto/dsa/dsa_asn1.c
index 5a1c7ceb71..d7b77470bd 100644
--- a/src/lib/libcrypto/dsa/dsa_asn1.c
+++ b/src/lib/libcrypto/dsa/dsa_asn1.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dsa_asn1.c,v 1.18 2016/12/30 15:28:42 jsing Exp $ */ 1/* $OpenBSD: dsa_asn1.c,v 1.19 2017/01/29 17:49:22 beck Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -73,7 +73,7 @@ sig_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg)
73 73
74 sig = malloc(sizeof(DSA_SIG)); 74 sig = malloc(sizeof(DSA_SIG));
75 if (!sig) { 75 if (!sig) {
76 DSAerr(DSA_F_SIG_CB, ERR_R_MALLOC_FAILURE); 76 DSAerror(ERR_R_MALLOC_FAILURE);
77 return 0; 77 return 0;
78 } 78 }
79 sig->r = NULL; 79 sig->r = NULL;
diff --git a/src/lib/libcrypto/dsa/dsa_err.c b/src/lib/libcrypto/dsa/dsa_err.c
index b116b643c3..2dcddcbf77 100644
--- a/src/lib/libcrypto/dsa/dsa_err.c
+++ b/src/lib/libcrypto/dsa/dsa_err.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dsa_err.c,v 1.14 2014/07/10 22:45:56 jsing Exp $ */ 1/* $OpenBSD: dsa_err.c,v 1.15 2017/01/29 17:49:22 beck Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -71,35 +71,10 @@
71#define ERR_FUNC(func) ERR_PACK(ERR_LIB_DSA,func,0) 71#define ERR_FUNC(func) ERR_PACK(ERR_LIB_DSA,func,0)
72#define ERR_REASON(reason) ERR_PACK(ERR_LIB_DSA,0,reason) 72#define ERR_REASON(reason) ERR_PACK(ERR_LIB_DSA,0,reason)
73 73
74static ERR_STRING_DATA DSA_str_functs[]= 74static ERR_STRING_DATA DSA_str_functs[]= {
75 { 75 {ERR_FUNC(0xfff), "CRYPTO_internal"},
76{ERR_FUNC(DSA_F_D2I_DSA_SIG), "d2i_DSA_SIG"}, 76 {0, NULL}
77{ERR_FUNC(DSA_F_DO_DSA_PRINT), "DO_DSA_PRINT"}, 77};
78{ERR_FUNC(DSA_F_DSAPARAMS_PRINT), "DSAparams_print"},
79{ERR_FUNC(DSA_F_DSAPARAMS_PRINT_FP), "DSAparams_print_fp"},
80{ERR_FUNC(DSA_F_DSA_DO_SIGN), "DSA_do_sign"},
81{ERR_FUNC(DSA_F_DSA_DO_VERIFY), "DSA_do_verify"},
82{ERR_FUNC(DSA_F_DSA_GENERATE_KEY), "DSA_generate_key"},
83{ERR_FUNC(DSA_F_DSA_GENERATE_PARAMETERS_EX), "DSA_generate_parameters_ex"},
84{ERR_FUNC(DSA_F_DSA_NEW_METHOD), "DSA_new_method"},
85{ERR_FUNC(DSA_F_DSA_PARAM_DECODE), "DSA_PARAM_DECODE"},
86{ERR_FUNC(DSA_F_DSA_PRINT_FP), "DSA_print_fp"},
87{ERR_FUNC(DSA_F_DSA_PRIV_DECODE), "DSA_PRIV_DECODE"},
88{ERR_FUNC(DSA_F_DSA_PRIV_ENCODE), "DSA_PRIV_ENCODE"},
89{ERR_FUNC(DSA_F_DSA_PUB_DECODE), "DSA_PUB_DECODE"},
90{ERR_FUNC(DSA_F_DSA_PUB_ENCODE), "DSA_PUB_ENCODE"},
91{ERR_FUNC(DSA_F_DSA_SIGN), "DSA_sign"},
92{ERR_FUNC(DSA_F_DSA_SIGN_SETUP), "DSA_sign_setup"},
93{ERR_FUNC(DSA_F_DSA_SIG_NEW), "DSA_SIG_new"},
94{ERR_FUNC(DSA_F_DSA_SIG_PRINT), "DSA_SIG_PRINT"},
95{ERR_FUNC(DSA_F_DSA_VERIFY), "DSA_verify"},
96{ERR_FUNC(DSA_F_I2D_DSA_SIG), "i2d_DSA_SIG"},
97{ERR_FUNC(DSA_F_OLD_DSA_PRIV_DECODE), "OLD_DSA_PRIV_DECODE"},
98{ERR_FUNC(DSA_F_PKEY_DSA_CTRL), "PKEY_DSA_CTRL"},
99{ERR_FUNC(DSA_F_PKEY_DSA_KEYGEN), "PKEY_DSA_KEYGEN"},
100{ERR_FUNC(DSA_F_SIG_CB), "SIG_CB"},
101{0,NULL}
102 };
103 78
104static ERR_STRING_DATA DSA_str_reasons[]= 79static ERR_STRING_DATA DSA_str_reasons[]=
105 { 80 {
diff --git a/src/lib/libcrypto/dsa/dsa_lib.c b/src/lib/libcrypto/dsa/dsa_lib.c
index 8016f2f7cb..58af74889c 100644
--- a/src/lib/libcrypto/dsa/dsa_lib.c
+++ b/src/lib/libcrypto/dsa/dsa_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dsa_lib.c,v 1.22 2015/02/11 03:19:37 doug Exp $ */ 1/* $OpenBSD: dsa_lib.c,v 1.23 2017/01/29 17:49:22 beck Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -126,14 +126,14 @@ DSA_new_method(ENGINE *engine)
126 126
127 ret = malloc(sizeof(DSA)); 127 ret = malloc(sizeof(DSA));
128 if (ret == NULL) { 128 if (ret == NULL) {
129 DSAerr(DSA_F_DSA_NEW_METHOD, ERR_R_MALLOC_FAILURE); 129 DSAerror(ERR_R_MALLOC_FAILURE);
130 return NULL; 130 return NULL;
131 } 131 }
132 ret->meth = DSA_get_default_method(); 132 ret->meth = DSA_get_default_method();
133#ifndef OPENSSL_NO_ENGINE 133#ifndef OPENSSL_NO_ENGINE
134 if (engine) { 134 if (engine) {
135 if (!ENGINE_init(engine)) { 135 if (!ENGINE_init(engine)) {
136 DSAerr(DSA_F_DSA_NEW_METHOD, ERR_R_ENGINE_LIB); 136 DSAerror(ERR_R_ENGINE_LIB);
137 free(ret); 137 free(ret);
138 return NULL; 138 return NULL;
139 } 139 }
@@ -143,7 +143,7 @@ DSA_new_method(ENGINE *engine)
143 if (ret->engine) { 143 if (ret->engine) {
144 ret->meth = ENGINE_get_DSA(ret->engine); 144 ret->meth = ENGINE_get_DSA(ret->engine);
145 if (!ret->meth) { 145 if (!ret->meth) {
146 DSAerr(DSA_F_DSA_NEW_METHOD, ERR_R_ENGINE_LIB); 146 DSAerror(ERR_R_ENGINE_LIB);
147 ENGINE_finish(ret->engine); 147 ENGINE_finish(ret->engine);
148 free(ret); 148 free(ret);
149 return NULL; 149 return NULL;
diff --git a/src/lib/libcrypto/dsa/dsa_ossl.c b/src/lib/libcrypto/dsa/dsa_ossl.c
index f806cd645a..f1013fe547 100644
--- a/src/lib/libcrypto/dsa/dsa_ossl.c
+++ b/src/lib/libcrypto/dsa/dsa_ossl.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dsa_ossl.c,v 1.29 2017/01/21 11:00:46 beck Exp $ */ 1/* $OpenBSD: dsa_ossl.c,v 1.30 2017/01/29 17:49:22 beck Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -169,7 +169,7 @@ redo:
169 169
170err: 170err:
171 if (!ret) { 171 if (!ret) {
172 DSAerr(DSA_F_DSA_DO_SIGN, reason); 172 DSAerror(reason);
173 BN_free(r); 173 BN_free(r);
174 BN_free(s); 174 BN_free(s);
175 } 175 }
@@ -188,7 +188,7 @@ dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp)
188 int ret = 0; 188 int ret = 0;
189 189
190 if (!dsa->p || !dsa->q || !dsa->g) { 190 if (!dsa->p || !dsa->q || !dsa->g) {
191 DSAerr(DSA_F_DSA_SIGN_SETUP, DSA_R_MISSING_PARAMETERS); 191 DSAerror(DSA_R_MISSING_PARAMETERS);
192 return 0; 192 return 0;
193 } 193 }
194 194
@@ -259,7 +259,7 @@ dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp)
259 ret = 1; 259 ret = 1;
260err: 260err:
261 if (!ret) { 261 if (!ret) {
262 DSAerr(DSA_F_DSA_SIGN_SETUP, ERR_R_BN_LIB); 262 DSAerror(ERR_R_BN_LIB);
263 BN_clear_free(r); 263 BN_clear_free(r);
264 } 264 }
265 if (ctx_in == NULL) 265 if (ctx_in == NULL)
@@ -277,19 +277,19 @@ dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, DSA *dsa)
277 int ret = -1, i; 277 int ret = -1, i;
278 278
279 if (!dsa->p || !dsa->q || !dsa->g) { 279 if (!dsa->p || !dsa->q || !dsa->g) {
280 DSAerr(DSA_F_DSA_DO_VERIFY, DSA_R_MISSING_PARAMETERS); 280 DSAerror(DSA_R_MISSING_PARAMETERS);
281 return -1; 281 return -1;
282 } 282 }
283 283
284 i = BN_num_bits(dsa->q); 284 i = BN_num_bits(dsa->q);
285 /* fips 186-3 allows only different sizes for q */ 285 /* fips 186-3 allows only different sizes for q */
286 if (i != 160 && i != 224 && i != 256) { 286 if (i != 160 && i != 224 && i != 256) {
287 DSAerr(DSA_F_DSA_DO_VERIFY, DSA_R_BAD_Q_VALUE); 287 DSAerror(DSA_R_BAD_Q_VALUE);
288 return -1; 288 return -1;
289 } 289 }
290 290
291 if (BN_num_bits(dsa->p) > OPENSSL_DSA_MAX_MODULUS_BITS) { 291 if (BN_num_bits(dsa->p) > OPENSSL_DSA_MAX_MODULUS_BITS) {
292 DSAerr(DSA_F_DSA_DO_VERIFY, DSA_R_MODULUS_TOO_LARGE); 292 DSAerror(DSA_R_MODULUS_TOO_LARGE);
293 return -1; 293 return -1;
294 } 294 }
295 BN_init(&u1); 295 BN_init(&u1);
@@ -363,7 +363,7 @@ dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, DSA *dsa)
363 363
364err: 364err:
365 if (ret < 0) 365 if (ret < 0)
366 DSAerr(DSA_F_DSA_DO_VERIFY, ERR_R_BN_LIB); 366 DSAerror(ERR_R_BN_LIB);
367 BN_CTX_free(ctx); 367 BN_CTX_free(ctx);
368 BN_free(&u1); 368 BN_free(&u1);
369 BN_free(&u2); 369 BN_free(&u2);
diff --git a/src/lib/libcrypto/dsa/dsa_pmeth.c b/src/lib/libcrypto/dsa/dsa_pmeth.c
index c7a2edfc94..780b070a72 100644
--- a/src/lib/libcrypto/dsa/dsa_pmeth.c
+++ b/src/lib/libcrypto/dsa/dsa_pmeth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dsa_pmeth.c,v 1.10 2014/07/11 08:44:48 jsing Exp $ */ 1/* $OpenBSD: dsa_pmeth.c,v 1.11 2017/01/29 17:49:22 beck Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -191,7 +191,7 @@ pkey_dsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
191 case NID_sha256: 191 case NID_sha256:
192 break; 192 break;
193 default: 193 default:
194 DSAerr(DSA_F_PKEY_DSA_CTRL, DSA_R_INVALID_DIGEST_TYPE); 194 DSAerror(DSA_R_INVALID_DIGEST_TYPE);
195 return 0; 195 return 0;
196 } 196 }
197 dctx->md = p2; 197 dctx->md = p2;
@@ -208,7 +208,7 @@ pkey_dsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
208 case NID_sha512: 208 case NID_sha512:
209 break; 209 break;
210 default: 210 default:
211 DSAerr(DSA_F_PKEY_DSA_CTRL, DSA_R_INVALID_DIGEST_TYPE); 211 DSAerror(DSA_R_INVALID_DIGEST_TYPE);
212 return 0; 212 return 0;
213 } 213 }
214 dctx->md = p2; 214 dctx->md = p2;
@@ -220,8 +220,7 @@ pkey_dsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
220 return 1; 220 return 1;
221 221
222 case EVP_PKEY_CTRL_PEER_KEY: 222 case EVP_PKEY_CTRL_PEER_KEY:
223 DSAerr(DSA_F_PKEY_DSA_CTRL, 223 DSAerror(EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
224 EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
225 return -2; 224 return -2;
226 default: 225 default:
227 return -2; 226 return -2;
@@ -303,7 +302,7 @@ pkey_dsa_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
303 DSA *dsa = NULL; 302 DSA *dsa = NULL;
304 303
305 if (ctx->pkey == NULL) { 304 if (ctx->pkey == NULL) {
306 DSAerr(DSA_F_PKEY_DSA_KEYGEN, DSA_R_NO_PARAMETERS_SET); 305 DSAerror(DSA_R_NO_PARAMETERS_SET);
307 return 0; 306 return 0;
308 } 307 }
309 dsa = DSA_new(); 308 dsa = DSA_new();
diff --git a/src/lib/libcrypto/dsa/dsa_prn.c b/src/lib/libcrypto/dsa/dsa_prn.c
index 60f4e6c760..fb5e35f909 100644
--- a/src/lib/libcrypto/dsa/dsa_prn.c
+++ b/src/lib/libcrypto/dsa/dsa_prn.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dsa_prn.c,v 1.5 2014/07/11 08:44:48 jsing Exp $ */ 1/* $OpenBSD: dsa_prn.c,v 1.6 2017/01/29 17:49:22 beck Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -69,7 +69,7 @@ DSA_print_fp(FILE *fp, const DSA *x, int off)
69 int ret; 69 int ret;
70 70
71 if ((b = BIO_new(BIO_s_file())) == NULL) { 71 if ((b = BIO_new(BIO_s_file())) == NULL) {
72 DSAerr(DSA_F_DSA_PRINT_FP, ERR_R_BUF_LIB); 72 DSAerror(ERR_R_BUF_LIB);
73 return 0; 73 return 0;
74 } 74 }
75 BIO_set_fp(b, fp, BIO_NOCLOSE); 75 BIO_set_fp(b, fp, BIO_NOCLOSE);
@@ -85,7 +85,7 @@ DSAparams_print_fp(FILE *fp, const DSA *x)
85 int ret; 85 int ret;
86 86
87 if ((b = BIO_new(BIO_s_file())) == NULL) { 87 if ((b = BIO_new(BIO_s_file())) == NULL) {
88 DSAerr(DSA_F_DSAPARAMS_PRINT_FP, ERR_R_BUF_LIB); 88 DSAerror(ERR_R_BUF_LIB);
89 return 0; 89 return 0;
90 } 90 }
91 BIO_set_fp(b, fp, BIO_NOCLOSE); 91 BIO_set_fp(b, fp, BIO_NOCLOSE);