summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2018-02-18 12:50:59 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2018-02-18 12:50:59 +0000
commit6b393a4ed1a430fda3ff7f3b54a6005532878d8b (patch)
tree1d8f4f31db7d45e182a51dc8131bceeb3536d75a /lib
parenta3da3261ad36fb98f48dd47768dd7dd1f1f8c121 (diff)
Provide DSA_set0_pqg.
ok jsing
Diffstat (limited to 'lib')
-rw-r--r--lib/libcrypto/Symbols.list1
-rw-r--r--lib/libcrypto/dsa/dsa.h3
-rw-r--r--lib/libcrypto/dsa/dsa_lib.c25
3 files changed, 27 insertions, 2 deletions
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)
{