summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2018-02-20 17:48:35 +0000
committertb <>2018-02-20 17:48:35 +0000
commitd5b2f67cbed2fbcdcb6e7429f71fd4a875ad9361 (patch)
tree0b7135337ad574a607f3dd748bfe269074e8623e
parent90a2cac2c9296c6001b956f786252ce7b31af437 (diff)
downloadopenbsd-d5b2f67cbed2fbcdcb6e7429f71fd4a875ad9361.tar.gz
openbsd-d5b2f67cbed2fbcdcb6e7429f71fd4a875ad9361.tar.bz2
openbsd-d5b2f67cbed2fbcdcb6e7429f71fd4a875ad9361.zip
Provide DSA_SIG_{g,s}et0()
ok jsing
-rw-r--r--src/lib/libcrypto/Symbols.list2
-rw-r--r--src/lib/libcrypto/dsa/dsa.h4
-rw-r--r--src/lib/libcrypto/dsa/dsa_asn1.c25
3 files changed, 29 insertions, 2 deletions
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
798DSAPublicKey_it 798DSAPublicKey_it
799DSA_OpenSSL 799DSA_OpenSSL
800DSA_SIG_free 800DSA_SIG_free
801DSA_SIG_get0
801DSA_SIG_it 802DSA_SIG_it
802DSA_SIG_new 803DSA_SIG_new
804DSA_SIG_set0
803DSA_clear_flags 805DSA_clear_flags
804DSA_do_sign 806DSA_do_sign
805DSA_do_verify 807DSA_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 @@
1/* $OpenBSD: dsa.h,v 1.27 2018/02/20 17:45:44 tb Exp $ */ 1/* $OpenBSD: dsa.h,v 1.28 2018/02/20 17:48:35 tb 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 *
@@ -183,6 +183,8 @@ DSA_SIG * DSA_SIG_new(void);
183void DSA_SIG_free(DSA_SIG *a); 183void DSA_SIG_free(DSA_SIG *a);
184int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp); 184int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp);
185DSA_SIG * d2i_DSA_SIG(DSA_SIG **v, const unsigned char **pp, long length); 185DSA_SIG * d2i_DSA_SIG(DSA_SIG **v, const unsigned char **pp, long length);
186void DSA_SIG_get0(const DSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps);
187int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s);
186 188
187DSA_SIG * DSA_do_sign(const unsigned char *dgst,int dlen,DSA *dsa); 189DSA_SIG * DSA_do_sign(const unsigned char *dgst,int dlen,DSA *dsa);
188int DSA_do_verify(const unsigned char *dgst,int dgst_len, 190int 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 @@
1/* $OpenBSD: dsa_asn1.c,v 1.20 2017/05/02 03:59:44 deraadt Exp $ */ 1/* $OpenBSD: dsa_asn1.c,v 1.21 2018/02/20 17:48:35 tb 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 2000. 3 * project 2000.
4 */ 4 */
@@ -133,6 +133,29 @@ i2d_DSA_SIG(const DSA_SIG *a, unsigned char **out)
133 return ASN1_item_i2d((ASN1_VALUE *)a, out, &DSA_SIG_it); 133 return ASN1_item_i2d((ASN1_VALUE *)a, out, &DSA_SIG_it);
134} 134}
135 135
136void
137DSA_SIG_get0(const DSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps)
138{
139 if (pr != NULL)
140 *pr = sig->r;
141 if (ps != NULL)
142 *ps = sig->s;
143}
144
145int
146DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s)
147{
148 if (r == NULL || s == NULL)
149 return 0;
150
151 BN_clear_free(sig->r);
152 sig->r = r;
153 BN_clear_free(sig->s);
154 sig->s = s;
155
156 return 1;
157}
158
136/* Override the default free and new methods */ 159/* Override the default free and new methods */
137static int 160static int
138dsa_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) 161dsa_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg)