diff options
author | 2012-10-13 21:25:05 +0000 | |
---|---|---|
committer | 2012-10-13 21:25:05 +0000 | |
commit | 5cdd308e23c573f20580c33373ebbd6aaf46ca93 (patch) | |
tree | 8c9c6577606b3e2a4f852b80db635caddf559533 /lib/libcrypto/dsa/dsa_ossl.c | |
parent | import OpenSSL-1.0.1c (diff) | |
download | wireguard-openbsd-5cdd308e23c573f20580c33373ebbd6aaf46ca93.tar.xz wireguard-openbsd-5cdd308e23c573f20580c33373ebbd6aaf46ca93.zip |
resolve conflicts
Diffstat (limited to 'lib/libcrypto/dsa/dsa_ossl.c')
-rw-r--r-- | lib/libcrypto/dsa/dsa_ossl.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/libcrypto/dsa/dsa_ossl.c b/lib/libcrypto/dsa/dsa_ossl.c index a3ddd7d2816..b3d78e524cf 100644 --- a/lib/libcrypto/dsa/dsa_ossl.c +++ b/lib/libcrypto/dsa/dsa_ossl.c @@ -136,6 +136,7 @@ static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) BN_CTX *ctx=NULL; int reason=ERR_R_BN_LIB; DSA_SIG *ret=NULL; + int noredo = 0; BN_init(&m); BN_init(&xr); @@ -150,7 +151,7 @@ static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) if (s == NULL) goto err; ctx=BN_CTX_new(); if (ctx == NULL) goto err; - +redo: if ((dsa->kinv == NULL) || (dsa->r == NULL)) { if (!DSA_sign_setup(dsa,ctx,&kinv,&r)) goto err; @@ -161,6 +162,7 @@ static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) dsa->kinv=NULL; r=dsa->r; dsa->r=NULL; + noredo = 1; } @@ -181,6 +183,18 @@ static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) ret=DSA_SIG_new(); if (ret == NULL) goto err; + /* Redo if r or s is zero as required by FIPS 186-3: this is + * very unlikely. + */ + if (BN_is_zero(r) || BN_is_zero(s)) + { + if (noredo) + { + reason = DSA_R_NEED_NEW_SETUP_VALUES; + goto err; + } + goto redo; + } ret->r = r; ret->s = s; |