From 191fb070e1f9eb8a131ccf6b93f502087099ab53 Mon Sep 17 00:00:00 2001 From: tb Date: Tue, 20 Feb 2018 17:48:35 +0000 Subject: [PATCH] Provide DSA_SIG_{g,s}et0() ok jsing --- lib/libcrypto/Symbols.list | 2 ++ lib/libcrypto/dsa/dsa.h | 4 +++- lib/libcrypto/dsa/dsa_asn1.c | 25 ++++++++++++++++++++++++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/lib/libcrypto/Symbols.list b/lib/libcrypto/Symbols.list index 0cb1c381065..7e5b59f0190 100644 --- a/lib/libcrypto/Symbols.list +++ b/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/lib/libcrypto/dsa/dsa.h b/lib/libcrypto/dsa/dsa.h index 6d618113fdb..7e73b205b09 100644 --- a/lib/libcrypto/dsa/dsa.h +++ b/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/lib/libcrypto/dsa/dsa_asn1.c b/lib/libcrypto/dsa/dsa_asn1.c index f7dfaf1d9c4..aac67dbd034 100644 --- a/lib/libcrypto/dsa/dsa_asn1.c +++ b/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) -- 2.20.1