[prev in list] [next in list] [prev in thread] [next in thread]
List: openssl-cvs
Subject: [CVS] OpenSSL: openssl/crypto/bn/ bn_blind.c bn_gcd.c bn_lcl.h
From: "Dr. Stephen Henson" <steve () openssl ! org>
Date: 2011-01-26 16:59:47
Message-ID: 20110126165947.C06771EAE993 () master ! openssl ! org
[Download RAW message or body]
OpenSSL CVS Repository
http://cvs.openssl.org/
____________________________________________________________________________
Server: cvs.openssl.org Name: Dr. Stephen Henson
Root: /v/openssl/cvs Email: steve@openssl.org
Module: openssl Date: 26-Jan-2011 17:59:47
Branch: HEAD Handle: 2011012616594700
Modified files:
openssl/crypto/bn bn_blind.c bn_gcd.c bn_lcl.h
Log:
Internal version of BN_mod_inverse allowing checking of no-inverse without
need to inspect error queue.
Summary:
Revision Changes Path
1.16 +3 -4 openssl/crypto/bn/bn_blind.c
1.24 +17 -1 openssl/crypto/bn/bn_gcd.c
1.41 +3 -0 openssl/crypto/bn/bn_lcl.h
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: openssl/crypto/bn/bn_blind.c
============================================================================
$ cvs diff -u -r1.15 -r1.16 bn_blind.c
--- openssl/crypto/bn/bn_blind.c 6 Aug 2008 15:54:10 -0000 1.15
+++ openssl/crypto/bn/bn_blind.c 26 Jan 2011 16:59:47 -0000 1.16
@@ -331,12 +331,12 @@
ret->m_ctx = m_ctx;
do {
+ int rv;
if (!BN_rand_range(ret->A, ret->mod)) goto err;
- if (BN_mod_inverse(ret->Ai, ret->A, ret->mod, ctx) == NULL)
+ if (!int_bn_mod_inverse(ret->Ai, ret->A, ret->mod, ctx, &rv))
{
/* this should almost never happen for good RSA keys */
- unsigned long error = ERR_peek_last_error();
- if (ERR_GET_REASON(error) == BN_R_NO_INVERSE)
+ if (rv)
{
if (retry_counter-- == 0)
{
@@ -344,7 +344,6 @@
BN_R_TOO_MANY_ITERATIONS);
goto err;
}
- ERR_clear_error();
}
else
goto err;
@@ .
patch -p0 <<'@@ .'
Index: openssl/crypto/bn/bn_gcd.c
============================================================================
$ cvs diff -u -r1.23 -r1.24 bn_gcd.c
--- openssl/crypto/bn/bn_gcd.c 11 Jun 2007 16:33:02 -0000 1.23
+++ openssl/crypto/bn/bn_gcd.c 26 Jan 2011 16:59:47 -0000 1.24
@@ -205,13 +205,28 @@
/* solves ax == 1 (mod n) */
static BIGNUM *BN_mod_inverse_no_branch(BIGNUM *in,
const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx);
+
BIGNUM *BN_mod_inverse(BIGNUM *in,
const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx)
{
+ BIGNUM *rv;
+ int noinv;
+ rv = int_bn_mod_inverse(in, a, n, ctx, &noinv);
+ if (noinv)
+ BNerr(BN_F_BN_MOD_INVERSE,BN_R_NO_INVERSE);
+ return rv;
+ }
+
+BIGNUM *int_bn_mod_inverse(BIGNUM *in,
+ const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx, int *pnoinv)
+ {
BIGNUM *A,*B,*X,*Y,*M,*D,*T,*R=NULL;
BIGNUM *ret=NULL;
int sign;
+ if (pnoinv)
+ *pnoinv = 0;
+
if ((BN_get_flags(a, BN_FLG_CONSTTIME) != 0) || (BN_get_flags(n, \
BN_FLG_CONSTTIME) != 0)) {
return BN_mod_inverse_no_branch(in, a, n, ctx);
@@ -488,7 +503,8 @@
}
else
{
- BNerr(BN_F_BN_MOD_INVERSE,BN_R_NO_INVERSE);
+ if (pnoinv)
+ *pnoinv = 1;
goto err;
}
ret=R;
@@ .
patch -p0 <<'@@ .'
Index: openssl/crypto/bn/bn_lcl.h
============================================================================
$ cvs diff -u -r1.40 -r1.41 bn_lcl.h
--- openssl/crypto/bn/bn_lcl.h 17 Jan 2010 12:08:24 -0000 1.40
+++ openssl/crypto/bn/bn_lcl.h 26 Jan 2011 16:59:47 -0000 1.41
@@ -497,6 +497,9 @@
int cl, int dl);
int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const \
BN_ULONG *np,const BN_ULONG *n0, int num);
+BIGNUM *int_bn_mod_inverse(BIGNUM *in,
+ const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx, int *noinv);
+
#ifdef __cplusplus
}
#endif
@@ .
______________________________________________________________________
OpenSSL Project http://www.openssl.org
CVS Repository Commit List openssl-cvs@openssl.org
Automated List Manager majordomo@openssl.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic