Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-6]: src/crypto/dist/openssl/crypto/rsa Pull up revision 1.2 (re...



details:   https://anonhg.NetBSD.org/src/rev/fff29b9fe05f
branches:  netbsd-1-6
changeset: 530181:fff29b9fe05f
user:      tron <tron%NetBSD.org@localhost>
date:      Thu Mar 20 09:47:01 2003 +0000

description:
Pull up revision 1.2 (requested by itojun in ticket #1221):
enable RSA blinding by defualt.  from bugtraq posting <3E758B85.6090300%algroup.co.uk@localhost>

diffstat:

 crypto/dist/openssl/crypto/rsa/rsa_eay.c |  27 +++++++++++++++++++++++----
 crypto/dist/openssl/crypto/rsa/rsa_lib.c |   8 +++++++-
 2 files changed, 30 insertions(+), 5 deletions(-)

diffs (69 lines):

diff -r 61a14b3bc423 -r fff29b9fe05f crypto/dist/openssl/crypto/rsa/rsa_eay.c
--- a/crypto/dist/openssl/crypto/rsa/rsa_eay.c  Sat Mar 08 00:12:21 2003 +0000
+++ b/crypto/dist/openssl/crypto/rsa/rsa_eay.c  Thu Mar 20 09:47:01 2003 +0000
@@ -190,6 +190,25 @@
        return(r);
        }
 
+static int rsa_eay_blinding(RSA *rsa, BN_CTX *ctx)
+       {
+       int ret = 1;
+       CRYPTO_w_lock(CRYPTO_LOCK_RSA);
+       /* Check again inside the lock - the macro's check is racey */
+       if(rsa->blinding == NULL)
+               ret = RSA_blinding_on(rsa, ctx);
+       CRYPTO_w_unlock(CRYPTO_LOCK_RSA);
+       return ret;
+       }
+
+#define BLINDING_HELPER(rsa, ctx, err_instr) \
+       do { \
+               if(((rsa)->flags & RSA_FLAG_BLINDING) && \
+                               ((rsa)->blinding == NULL) && \
+                               !rsa_eay_blinding(rsa, ctx)) \
+                       err_instr \
+       } while(0)
+
 /* signing */
 static int RSA_eay_private_encrypt(int flen, unsigned char *from,
             unsigned char *to, RSA *rsa, int padding)
@@ -234,8 +253,8 @@
                goto err;
                }
 
-       if ((rsa->flags & RSA_FLAG_BLINDING) && (rsa->blinding == NULL))
-               RSA_blinding_on(rsa,ctx);
+       BLINDING_HELPER(rsa, ctx, goto err;);
+
        if (rsa->flags & RSA_FLAG_BLINDING)
                if (!BN_BLINDING_convert(&f,rsa->blinding,ctx)) goto err;
 
@@ -313,8 +332,8 @@
                goto err;
                }
 
-       if ((rsa->flags & RSA_FLAG_BLINDING) && (rsa->blinding == NULL))
-               RSA_blinding_on(rsa,ctx);
+       BLINDING_HELPER(rsa, ctx, goto err;);
+
        if (rsa->flags & RSA_FLAG_BLINDING)
                if (!BN_BLINDING_convert(&f,rsa->blinding,ctx)) goto err;
 
diff -r 61a14b3bc423 -r fff29b9fe05f crypto/dist/openssl/crypto/rsa/rsa_lib.c
--- a/crypto/dist/openssl/crypto/rsa/rsa_lib.c  Sat Mar 08 00:12:21 2003 +0000
+++ b/crypto/dist/openssl/crypto/rsa/rsa_lib.c  Thu Mar 20 09:47:01 2003 +0000
@@ -71,7 +71,13 @@
 
 RSA *RSA_new(void)
        {
-       return(RSA_new_method(NULL));
+       RSA *r=RSA_new_method(NULL);
+
+#ifndef OPENSSL_NO_FORCE_RSA_BLINDING
+       r->flags|=RSA_FLAG_BLINDING;
+#endif
+
+       return r;
        }
 
 void RSA_set_default_method(RSA_METHOD *meth)



Home | Main Index | Thread Index | Old Index