diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/dsa/dsa.h | 4 | ||||
| -rw-r--r-- | src/lib/libcrypto/dsa/dsa_ameth.c | 18 | ||||
| -rw-r--r-- | src/lib/libcrypto/dsa/dsa_gen.c | 14 | ||||
| -rw-r--r-- | src/lib/libcrypto/dsa/dsa_key.c | 5 | ||||
| -rw-r--r-- | src/lib/libcrypto/dsa/dsa_lib.c | 26 | ||||
| -rw-r--r-- | src/lib/libcrypto/dsa/dsa_ossl.c | 23 | ||||
| -rw-r--r-- | src/lib/libcrypto/dsa/dsa_sign.c | 8 |
7 files changed, 36 insertions, 62 deletions
diff --git a/src/lib/libcrypto/dsa/dsa.h b/src/lib/libcrypto/dsa/dsa.h index c1264ac325..bd7b26070d 100644 --- a/src/lib/libcrypto/dsa/dsa.h +++ b/src/lib/libcrypto/dsa/dsa.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: dsa.h,v 1.17 2014/06/12 15:49:28 deraadt Exp $ */ | 1 | /* $OpenBSD: dsa.h,v 1.18 2014/07/12 16:03:37 miod 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 | * |
| @@ -206,7 +206,7 @@ int DSA_set_method(DSA *dsa, const DSA_METHOD *); | |||
| 206 | 206 | ||
| 207 | DSA * DSA_new(void); | 207 | DSA * DSA_new(void); |
| 208 | DSA * DSA_new_method(ENGINE *engine); | 208 | DSA * DSA_new_method(ENGINE *engine); |
| 209 | void DSA_free (DSA *r); | 209 | void DSA_free(DSA *r); |
| 210 | /* "up" the DSA object's reference count */ | 210 | /* "up" the DSA object's reference count */ |
| 211 | int DSA_up_ref(DSA *r); | 211 | int DSA_up_ref(DSA *r); |
| 212 | int DSA_size(const DSA *); | 212 | int DSA_size(const DSA *); |
diff --git a/src/lib/libcrypto/dsa/dsa_ameth.c b/src/lib/libcrypto/dsa/dsa_ameth.c index 73c58ec94c..7da4ac5695 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.12 2014/07/11 08:44:48 jsing Exp $ */ | 1 | /* $OpenBSD: dsa_ameth.c,v 1.13 2014/07/12 16:03:37 miod 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 | */ |
| @@ -125,8 +125,7 @@ dsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey) | |||
| 125 | err: | 125 | err: |
| 126 | if (public_key) | 126 | if (public_key) |
| 127 | ASN1_INTEGER_free(public_key); | 127 | ASN1_INTEGER_free(public_key); |
| 128 | if (dsa) | 128 | DSA_free(dsa); |
| 129 | DSA_free(dsa); | ||
| 130 | return 0; | 129 | return 0; |
| 131 | } | 130 | } |
| 132 | 131 | ||
| @@ -264,7 +263,7 @@ dsa_priv_decode(EVP_PKEY *pkey, PKCS8_PRIV_KEY_INFO *p8) | |||
| 264 | } | 263 | } |
| 265 | 264 | ||
| 266 | EVP_PKEY_assign_DSA(pkey, dsa); | 265 | EVP_PKEY_assign_DSA(pkey, dsa); |
| 267 | BN_CTX_free (ctx); | 266 | BN_CTX_free(ctx); |
| 268 | if (ndsa) | 267 | if (ndsa) |
| 269 | sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free); | 268 | sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free); |
| 270 | else | 269 | else |
| @@ -275,7 +274,7 @@ dsa_priv_decode(EVP_PKEY *pkey, PKCS8_PRIV_KEY_INFO *p8) | |||
| 275 | decerr: | 274 | decerr: |
| 276 | DSAerr(DSA_F_DSA_PRIV_DECODE, EVP_R_DECODE_ERROR); | 275 | DSAerr(DSA_F_DSA_PRIV_DECODE, EVP_R_DECODE_ERROR); |
| 277 | dsaerr: | 276 | dsaerr: |
| 278 | BN_CTX_free (ctx); | 277 | BN_CTX_free(ctx); |
| 279 | if (privkey) | 278 | if (privkey) |
| 280 | ASN1_INTEGER_free(privkey); | 279 | ASN1_INTEGER_free(privkey); |
| 281 | sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free); | 280 | sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free); |
| @@ -358,20 +357,17 @@ dsa_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from) | |||
| 358 | 357 | ||
| 359 | if ((a = BN_dup(from->pkey.dsa->p)) == NULL) | 358 | if ((a = BN_dup(from->pkey.dsa->p)) == NULL) |
| 360 | return 0; | 359 | return 0; |
| 361 | if (to->pkey.dsa->p != NULL) | 360 | BN_free(to->pkey.dsa->p); |
| 362 | BN_free(to->pkey.dsa->p); | ||
| 363 | to->pkey.dsa->p = a; | 361 | to->pkey.dsa->p = a; |
| 364 | 362 | ||
| 365 | if ((a = BN_dup(from->pkey.dsa->q)) == NULL) | 363 | if ((a = BN_dup(from->pkey.dsa->q)) == NULL) |
| 366 | return 0; | 364 | return 0; |
| 367 | if (to->pkey.dsa->q != NULL) | 365 | BN_free(to->pkey.dsa->q); |
| 368 | BN_free(to->pkey.dsa->q); | ||
| 369 | to->pkey.dsa->q = a; | 366 | to->pkey.dsa->q = a; |
| 370 | 367 | ||
| 371 | if ((a = BN_dup(from->pkey.dsa->g)) == NULL) | 368 | if ((a = BN_dup(from->pkey.dsa->g)) == NULL) |
| 372 | return 0; | 369 | return 0; |
| 373 | if (to->pkey.dsa->g != NULL) | 370 | BN_free(to->pkey.dsa->g); |
| 374 | BN_free(to->pkey.dsa->g); | ||
| 375 | to->pkey.dsa->g = a; | 371 | to->pkey.dsa->g = a; |
| 376 | return 1; | 372 | return 1; |
| 377 | } | 373 | } |
diff --git a/src/lib/libcrypto/dsa/dsa_gen.c b/src/lib/libcrypto/dsa/dsa_gen.c index d41e7562e1..a3d07b901a 100644 --- a/src/lib/libcrypto/dsa/dsa_gen.c +++ b/src/lib/libcrypto/dsa/dsa_gen.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: dsa_gen.c,v 1.15 2014/07/11 08:44:48 jsing Exp $ */ | 1 | /* $OpenBSD: dsa_gen.c,v 1.16 2014/07/12 16:03:37 miod 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 | * |
| @@ -322,12 +322,9 @@ end: | |||
| 322 | ok = 1; | 322 | ok = 1; |
| 323 | err: | 323 | err: |
| 324 | if (ok) { | 324 | if (ok) { |
| 325 | if (ret->p) | 325 | BN_free(ret->p); |
| 326 | BN_free(ret->p); | 326 | BN_free(ret->q); |
| 327 | if (ret->q) | 327 | BN_free(ret->g); |
| 328 | BN_free(ret->q); | ||
| 329 | if (ret->g) | ||
| 330 | BN_free(ret->g); | ||
| 331 | ret->p = BN_dup(p); | 328 | ret->p = BN_dup(p); |
| 332 | ret->q = BN_dup(q); | 329 | ret->q = BN_dup(q); |
| 333 | ret->g = BN_dup(g); | 330 | ret->g = BN_dup(g); |
| @@ -346,8 +343,7 @@ err: | |||
| 346 | BN_CTX_end(ctx); | 343 | BN_CTX_end(ctx); |
| 347 | BN_CTX_free(ctx); | 344 | BN_CTX_free(ctx); |
| 348 | } | 345 | } |
| 349 | if (mont != NULL) | 346 | BN_MONT_CTX_free(mont); |
| 350 | BN_MONT_CTX_free(mont); | ||
| 351 | return ok; | 347 | return ok; |
| 352 | } | 348 | } |
| 353 | #endif | 349 | #endif |
diff --git a/src/lib/libcrypto/dsa/dsa_key.c b/src/lib/libcrypto/dsa/dsa_key.c index 4573ecbcce..4dc28dbb90 100644 --- a/src/lib/libcrypto/dsa/dsa_key.c +++ b/src/lib/libcrypto/dsa/dsa_key.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: dsa_key.c,v 1.18 2014/07/11 08:44:48 jsing Exp $ */ | 1 | /* $OpenBSD: dsa_key.c,v 1.19 2014/07/12 16:03:37 miod 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 | * |
| @@ -128,8 +128,7 @@ err: | |||
| 128 | BN_free(pub_key); | 128 | BN_free(pub_key); |
| 129 | if (priv_key != NULL && dsa->priv_key == NULL) | 129 | if (priv_key != NULL && dsa->priv_key == NULL) |
| 130 | BN_free(priv_key); | 130 | BN_free(priv_key); |
| 131 | if (ctx != NULL) | 131 | BN_CTX_free(ctx); |
| 132 | BN_CTX_free(ctx); | ||
| 133 | return ok; | 132 | return ok; |
| 134 | } | 133 | } |
| 135 | #endif | 134 | #endif |
diff --git a/src/lib/libcrypto/dsa/dsa_lib.c b/src/lib/libcrypto/dsa/dsa_lib.c index 97307134cd..1cfd6ce6b8 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.20 2014/07/11 08:44:48 jsing Exp $ */ | 1 | /* $OpenBSD: dsa_lib.c,v 1.21 2014/07/12 16:03:37 miod 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 | * |
| @@ -201,20 +201,13 @@ DSA_free(DSA *r) | |||
| 201 | 201 | ||
| 202 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, r, &r->ex_data); | 202 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, r, &r->ex_data); |
| 203 | 203 | ||
| 204 | if (r->p != NULL) | 204 | BN_clear_free(r->p); |
| 205 | BN_clear_free(r->p); | 205 | BN_clear_free(r->q); |
| 206 | if (r->q != NULL) | 206 | BN_clear_free(r->g); |
| 207 | BN_clear_free(r->q); | 207 | BN_clear_free(r->pub_key); |
| 208 | if (r->g != NULL) | 208 | BN_clear_free(r->priv_key); |
| 209 | BN_clear_free(r->g); | 209 | BN_clear_free(r->kinv); |
| 210 | if (r->pub_key != NULL) | 210 | BN_clear_free(r->r); |
| 211 | BN_clear_free(r->pub_key); | ||
| 212 | if (r->priv_key != NULL) | ||
| 213 | BN_clear_free(r->priv_key); | ||
| 214 | if (r->kinv != NULL) | ||
| 215 | BN_clear_free(r->kinv); | ||
| 216 | if (r->r != NULL) | ||
| 217 | BN_clear_free(r->r); | ||
| 218 | free(r); | 211 | free(r); |
| 219 | } | 212 | } |
| 220 | 213 | ||
| @@ -305,8 +298,7 @@ DSA_dup_DH(const DSA *r) | |||
| 305 | return ret; | 298 | return ret; |
| 306 | 299 | ||
| 307 | err: | 300 | err: |
| 308 | if (ret != NULL) | 301 | DH_free(ret); |
| 309 | DH_free(ret); | ||
| 310 | return NULL; | 302 | return NULL; |
| 311 | } | 303 | } |
| 312 | #endif | 304 | #endif |
diff --git a/src/lib/libcrypto/dsa/dsa_ossl.c b/src/lib/libcrypto/dsa/dsa_ossl.c index 5bff836c50..e372853063 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.20 2014/07/11 08:44:48 jsing Exp $ */ | 1 | /* $OpenBSD: dsa_ossl.c,v 1.21 2014/07/12 16:03:37 miod 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 | * |
| @@ -212,12 +212,10 @@ err: | |||
| 212 | BN_free(r); | 212 | BN_free(r); |
| 213 | BN_free(s); | 213 | BN_free(s); |
| 214 | } | 214 | } |
| 215 | if (ctx != NULL) | 215 | BN_CTX_free(ctx); |
| 216 | BN_CTX_free(ctx); | ||
| 217 | BN_clear_free(&m); | 216 | BN_clear_free(&m); |
| 218 | BN_clear_free(&xr); | 217 | BN_clear_free(&xr); |
| 219 | if (kinv != NULL) /* dsa->kinv is NULL now if we used it */ | 218 | BN_clear_free(kinv); |
| 220 | BN_clear_free(kinv); | ||
| 221 | return ret; | 219 | return ret; |
| 222 | } | 220 | } |
| 223 | 221 | ||
| @@ -295,19 +293,16 @@ dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) | |||
| 295 | if ((kinv = BN_mod_inverse(NULL, &k, dsa->q, ctx)) == NULL) | 293 | if ((kinv = BN_mod_inverse(NULL, &k, dsa->q, ctx)) == NULL) |
| 296 | goto err; | 294 | goto err; |
| 297 | 295 | ||
| 298 | if (*kinvp != NULL) | 296 | BN_clear_free(*kinvp); |
| 299 | BN_clear_free(*kinvp); | ||
| 300 | *kinvp = kinv; | 297 | *kinvp = kinv; |
| 301 | kinv = NULL; | 298 | kinv = NULL; |
| 302 | if (*rp != NULL) | 299 | BN_clear_free(*rp); |
| 303 | BN_clear_free(*rp); | ||
| 304 | *rp = r; | 300 | *rp = r; |
| 305 | ret = 1; | 301 | ret = 1; |
| 306 | err: | 302 | err: |
| 307 | if (!ret) { | 303 | if (!ret) { |
| 308 | DSAerr(DSA_F_DSA_SIGN_SETUP, ERR_R_BN_LIB); | 304 | DSAerr(DSA_F_DSA_SIGN_SETUP, ERR_R_BN_LIB); |
| 309 | if (r != NULL) | 305 | BN_clear_free(r); |
| 310 | BN_clear_free(r); | ||
| 311 | } | 306 | } |
| 312 | if (ctx_in == NULL) | 307 | if (ctx_in == NULL) |
| 313 | BN_CTX_free(ctx); | 308 | BN_CTX_free(ctx); |
| @@ -406,8 +401,7 @@ err: | |||
| 406 | there is no error in BN. Test should be ret == -1 (Ben) */ | 401 | there is no error in BN. Test should be ret == -1 (Ben) */ |
| 407 | if (ret != 1) | 402 | if (ret != 1) |
| 408 | DSAerr(DSA_F_DSA_DO_VERIFY, ERR_R_BN_LIB); | 403 | DSAerr(DSA_F_DSA_DO_VERIFY, ERR_R_BN_LIB); |
| 409 | if (ctx != NULL) | 404 | BN_CTX_free(ctx); |
| 410 | BN_CTX_free(ctx); | ||
| 411 | BN_free(&u1); | 405 | BN_free(&u1); |
| 412 | BN_free(&u2); | 406 | BN_free(&u2); |
| 413 | BN_free(&t1); | 407 | BN_free(&t1); |
| @@ -424,8 +418,7 @@ dsa_init(DSA *dsa) | |||
| 424 | static int | 418 | static int |
| 425 | dsa_finish(DSA *dsa) | 419 | dsa_finish(DSA *dsa) |
| 426 | { | 420 | { |
| 427 | if (dsa->method_mont_p) | 421 | BN_MONT_CTX_free(dsa->method_mont_p); |
| 428 | BN_MONT_CTX_free(dsa->method_mont_p); | ||
| 429 | return 1; | 422 | return 1; |
| 430 | } | 423 | } |
| 431 | 424 | ||
diff --git a/src/lib/libcrypto/dsa/dsa_sign.c b/src/lib/libcrypto/dsa/dsa_sign.c index efeb35477c..80e002c4a7 100644 --- a/src/lib/libcrypto/dsa/dsa_sign.c +++ b/src/lib/libcrypto/dsa/dsa_sign.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: dsa_sign.c,v 1.17 2014/07/11 08:44:48 jsing Exp $ */ | 1 | /* $OpenBSD: dsa_sign.c,v 1.18 2014/07/12 16:03:37 miod 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 | * |
| @@ -91,10 +91,8 @@ void | |||
| 91 | DSA_SIG_free(DSA_SIG *sig) | 91 | DSA_SIG_free(DSA_SIG *sig) |
| 92 | { | 92 | { |
| 93 | if (sig) { | 93 | if (sig) { |
| 94 | if (sig->r) | 94 | BN_free(sig->r); |
| 95 | BN_free(sig->r); | 95 | BN_free(sig->s); |
| 96 | if (sig->s) | ||
| 97 | BN_free(sig->s); | ||
| 98 | free(sig); | 96 | free(sig); |
| 99 | } | 97 | } |
| 100 | } | 98 | } |
