Source-Changes-HG archive

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

[src/trunk]: src/crypto/dist/openssl/crypto/rsa enable RSA blinding by defual...



details:   https://anonhg.NetBSD.org/src/rev/62d9ac947fa1
branches:  trunk
changeset: 544339:62d9ac947fa1
user:      itojun <itojun%NetBSD.org@localhost>
date:      Mon Mar 17 14:33:50 2003 +0000

description:
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 67c909a98736 -r 62d9ac947fa1 crypto/dist/openssl/crypto/rsa/rsa_eay.c
--- a/crypto/dist/openssl/crypto/rsa/rsa_eay.c  Mon Mar 17 12:29:09 2003 +0000
+++ b/crypto/dist/openssl/crypto/rsa/rsa_eay.c  Mon Mar 17 14:33:50 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 67c909a98736 -r 62d9ac947fa1 crypto/dist/openssl/crypto/rsa/rsa_lib.c
--- a/crypto/dist/openssl/crypto/rsa/rsa_lib.c  Mon Mar 17 12:29:09 2003 +0000
+++ b/crypto/dist/openssl/crypto/rsa/rsa_lib.c  Mon Mar 17 14:33:50 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