From: tb Date: Sun, 18 Feb 2018 12:50:58 +0000 (+0000) Subject: Provide DSA_set0_pqg. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5c89949f5999a0ed6c32dad6950b30638a969537;p=openbsd Provide DSA_set0_pqg. ok jsing --- diff --git a/lib/libcrypto/Symbols.list b/lib/libcrypto/Symbols.list index aeafb88492e..79b2e946dc0 100644 --- a/lib/libcrypto/Symbols.list +++ b/lib/libcrypto/Symbols.list @@ -795,6 +795,7 @@ DSA_new DSA_new_method DSA_print DSA_print_fp +DSA_set0_pqg DSA_set_default_method DSA_set_ex_data DSA_set_method diff --git a/lib/libcrypto/dsa/dsa.h b/lib/libcrypto/dsa/dsa.h index 608c15df6b2..21e5baa235e 100644 --- a/lib/libcrypto/dsa/dsa.h +++ b/lib/libcrypto/dsa/dsa.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa.h,v 1.24 2018/02/17 14:35:40 jsing Exp $ */ +/* $OpenBSD: dsa.h,v 1.25 2018/02/18 12:50:58 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -259,6 +259,7 @@ DH *DSA_dup_DH(const DSA *r); void DSA_get0_pqg(const DSA *d, const BIGNUM **p, const BIGNUM **q, const BIGNUM **g); +int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g); void DSA_get0_key(const DSA *d, const BIGNUM **pub_key, const BIGNUM **priv_key); #define EVP_PKEY_CTX_set_dsa_paramgen_bits(ctx, nbits) \ diff --git a/lib/libcrypto/dsa/dsa_lib.c b/lib/libcrypto/dsa/dsa_lib.c index ae9155c9f8c..2dec8567f5d 100644 --- a/lib/libcrypto/dsa/dsa_lib.c +++ b/lib/libcrypto/dsa/dsa_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_lib.c,v 1.24 2018/02/17 13:47:36 tb Exp $ */ +/* $OpenBSD: dsa_lib.c,v 1.25 2018/02/18 12:50:58 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -315,6 +315,29 @@ DSA_get0_pqg(const DSA *d, const BIGNUM **p, const BIGNUM **q, const BIGNUM **g) *g = d->g; } +int +DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g) +{ + if ((d->p == NULL && p == NULL) || (d->q == NULL && q == NULL) || + (d->g == NULL && g == NULL)) + return 0; + + if (p != NULL) { + BN_free(d->p); + d->p = p; + } + if (q != NULL) { + BN_free(d->q); + d->q = q; + } + if (g != NULL) { + BN_free(d->g); + d->g = g; + } + + return 1; +} + void DSA_get0_key(const DSA *d, const BIGNUM **pub_key, const BIGNUM **priv_key) {