From d5b2f67cbed2fbcdcb6e7429f71fd4a875ad9361 Mon Sep 17 00:00:00 2001
From: tb <>
Date: Tue, 20 Feb 2018 17:48:35 +0000
Subject: Provide DSA_SIG_{g,s}et0()

ok jsing
---
 src/lib/libcrypto/Symbols.list   |  2 ++
 src/lib/libcrypto/dsa/dsa.h      |  4 +++-
 src/lib/libcrypto/dsa/dsa_asn1.c | 25 ++++++++++++++++++++++++-
 3 files changed, 29 insertions(+), 2 deletions(-)

(limited to 'src')

diff --git a/src/lib/libcrypto/Symbols.list b/src/lib/libcrypto/Symbols.list
index 0cb1c38106..7e5b59f019 100644
--- a/src/lib/libcrypto/Symbols.list
+++ b/src/lib/libcrypto/Symbols.list
@@ -798,8 +798,10 @@ DSAPrivateKey_it
 DSAPublicKey_it
 DSA_OpenSSL
 DSA_SIG_free
+DSA_SIG_get0
 DSA_SIG_it
 DSA_SIG_new
+DSA_SIG_set0
 DSA_clear_flags
 DSA_do_sign
 DSA_do_verify
diff --git a/src/lib/libcrypto/dsa/dsa.h b/src/lib/libcrypto/dsa/dsa.h
index 6d618113fd..7e73b205b0 100644
--- a/src/lib/libcrypto/dsa/dsa.h
+++ b/src/lib/libcrypto/dsa/dsa.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dsa.h,v 1.27 2018/02/20 17:45:44 tb Exp $ */
+/* $OpenBSD: dsa.h,v 1.28 2018/02/20 17:48:35 tb Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -183,6 +183,8 @@ DSA_SIG * DSA_SIG_new(void);
 void	DSA_SIG_free(DSA_SIG *a);
 int	i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp);
 DSA_SIG * d2i_DSA_SIG(DSA_SIG **v, const unsigned char **pp, long length);
+void	DSA_SIG_get0(const DSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps);
+int	DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s);
 
 DSA_SIG * DSA_do_sign(const unsigned char *dgst,int dlen,DSA *dsa);
 int	DSA_do_verify(const unsigned char *dgst,int dgst_len,
diff --git a/src/lib/libcrypto/dsa/dsa_asn1.c b/src/lib/libcrypto/dsa/dsa_asn1.c
index f7dfaf1d9c..aac67dbd03 100644
--- a/src/lib/libcrypto/dsa/dsa_asn1.c
+++ b/src/lib/libcrypto/dsa/dsa_asn1.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dsa_asn1.c,v 1.20 2017/05/02 03:59:44 deraadt Exp $ */
+/* $OpenBSD: dsa_asn1.c,v 1.21 2018/02/20 17:48:35 tb Exp $ */
 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
  * project 2000.
  */
@@ -133,6 +133,29 @@ i2d_DSA_SIG(const DSA_SIG *a, unsigned char **out)
 	return ASN1_item_i2d((ASN1_VALUE *)a, out, &DSA_SIG_it);
 }
 
+void
+DSA_SIG_get0(const DSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps)
+{
+	if (pr != NULL)
+		*pr = sig->r;
+	if (ps != NULL)
+		*ps = sig->s;
+}
+
+int
+DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s)
+{
+	if (r == NULL || s == NULL)
+		return 0;
+
+	BN_clear_free(sig->r);
+	sig->r = r;
+	BN_clear_free(sig->s);
+	sig->s = s;
+
+	return 1;
+}
+
 /* Override the default free and new methods */
 static int
 dsa_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg)
-- 
cgit v1.2.3-55-g6feb