Merge in recent changes from 0.9.6-stable
authorRichard Levitte <levitte@openssl.org>
Thu, 29 Mar 2001 22:15:23 +0000 (22:15 +0000)
committerRichard Levitte <levitte@openssl.org>
Thu, 29 Mar 2001 22:15:23 +0000 (22:15 +0000)
19 files changed:
CHANGES
NEWS
crypto/des/cbc_cksm.c
crypto/des/cfb64enc.c
crypto/des/cfb_enc.c
crypto/des/des.h
crypto/des/des_enc.c
crypto/des/des_opts.c
crypto/des/ecb_enc.c
crypto/des/ede_cbcm_enc.c
crypto/des/ncbc_enc.c
crypto/des/ofb64enc.c
crypto/des/ofb_enc.c
crypto/des/pcbc_enc.c
crypto/des/speed.c
crypto/des/xcbc_enc.c
crypto/mdc2/mdc2dgst.c
crypto/rsa/rsa_eay.c
util/libeay.num

diff --git a/CHANGES b/CHANGES
index 663fc5b9ffbf62aa79cde9ab1abdb6626c86c12e..96fbadd4d8a0417bba3b6ef389732b698aaf80f4 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -4,6 +4,20 @@
 
  Changes between 0.9.6 and 0.9.6a  [xx XXX 2001]
 
+  *) Rename 'des_encrypt' to 'des_encrypt1'.  This avoids the clashes
+     with des_encrypt() defined on some operating systems, like Solaris
+     and UnixWare.
+     [Richard Levitte]
+
+  *) Check the result of RSA-CRT (see D. Boneh, R. DeMillo, R. Lipton:
+     On the Importance of Eliminating Errors in Cryptographic
+     Computations, J. Cryptology 14 (2001) 2, 101-119,
+     http://theory.stanford.edu/~dabo/papers/faults.ps.gz).
+     [Ulf Moeller]
+  
+  *) MIPS assembler BIGNUM division bug fix. 
+     [Andy Polyakov]
+
   *) Fix PKCS#7 decode routines so they correctly update the length
      after reading an EOC for the EXPLICIT tag.
      [Steve Henson]
diff --git a/NEWS b/NEWS
index 7cf95cfb0bf95f3669ba58aff7d6addc1e0e5916..794f90382218a99060284a57c6e68b1b9fce41e4 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,30 @@
   This file gives a brief overview of the major changes between each OpenSSL
   release. For more details please read the CHANGES file.
 
+  Major changes between OpenSSL 0.9.6 and OpenSSL 0.9.6a:
+
+      o Security fix: change behavior of OpenSSL to avoid using
+        environment variables when running as root.
+      o Security fix: check the result of RSA-CRT to reduce the
+        possibility of deducing the private key from an incorrectly
+        calculated signature.
+      o Security fix: prevent Bleichenbacher's DSA attack.
+      o Security fix: Zero the premaster secret after deriving the
+        master secret in DH ciphersuites.
+      o Compatibility fix: the function des_encrypt() renamed to
+        des_encrypt1() to avoid clashes with some Unixen libc.
+      o Bug fixes for Win32, HP/UX and Irix.
+      o Bug fixes in BIGNUM, SSL, PKCS#7, PKCS#12, X.509, CONF and
+        memory checking routines.
+      o Bug fixes for RSA operations in threaded enviroments.
+      o Bug fixes in misc. openssl applications.
+      o Remove a few potential memory leaks.
+      o Add tighter checks of BIGNUM routines.
+      o Shared library support has been reworked for generality.
+      o More documentation.
+      o New function BN_rand_range()
+      o Add "-rand" option to openssl s_client and s_server.
+
   Major changes between OpenSSL 0.9.5a and OpenSSL 0.9.6:
 
       o Some documentation for BIO and SSL libraries.
index 1e543cb2a19db7919bb495ccea4d81a744d4ca75..b857df09852a8260e7be1b8411b8cbabdb4de87e 100644 (file)
@@ -82,7 +82,7 @@ DES_LONG des_cbc_cksum(const unsigned char *in, des_cblock *output,
                        
                tin0^=tout0; tin[0]=tin0;
                tin1^=tout1; tin[1]=tin1;
-               des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT);
+               des_encrypt1((DES_LONG *)tin,schedule,DES_ENCRYPT);
                /* fix 15/10/91 eay - thanks to keithr@sco.COM */
                tout0=tin[0];
                tout1=tin[1];
index 389a232cb36b026db38c193d79ada8d4b6f5297b..105530dfa3bae2061e16fbb1a9905b7362665158 100644 (file)
@@ -82,7 +82,7 @@ void des_cfb64_encrypt(const unsigned char *in, unsigned char *out,
                                {
                                c2l(iv,v0); ti[0]=v0;
                                c2l(iv,v1); ti[1]=v1;
-                               des_encrypt(ti,schedule,DES_ENCRYPT);
+                               des_encrypt1(ti,schedule,DES_ENCRYPT);
                                iv = &(*ivec)[0];
                                v0=ti[0]; l2c(v0,iv);
                                v0=ti[1]; l2c(v0,iv);
@@ -102,7 +102,7 @@ void des_cfb64_encrypt(const unsigned char *in, unsigned char *out,
                                {
                                c2l(iv,v0); ti[0]=v0;
                                c2l(iv,v1); ti[1]=v1;
-                               des_encrypt(ti,schedule,DES_ENCRYPT);
+                               des_encrypt1(ti,schedule,DES_ENCRYPT);
                                iv = &(*ivec)[0];
                                v0=ti[0]; l2c(v0,iv);
                                v0=ti[1]; l2c(v0,iv);
index cca34dd7c5ecd4caa3df8de16fe7a8cd9a18cca7..ec4fd4ea67bafe04741b7db77f01390347b962db 100644 (file)
@@ -100,7 +100,7 @@ void des_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
                        l-=n;
                        ti[0]=v0;
                        ti[1]=v1;
-                       des_encrypt((DES_LONG *)ti,schedule,DES_ENCRYPT);
+                       des_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT);
                        c2ln(in,d0,d1,n);
                        in+=n;
                        d0=(d0^ti[0])&mask0;
@@ -132,7 +132,7 @@ void des_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
                        l-=n;
                        ti[0]=v0;
                        ti[1]=v1;
-                       des_encrypt((DES_LONG *)ti,schedule,DES_ENCRYPT);
+                       des_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT);
                        c2ln(in,d0,d1,n);
                        in+=n;
                        /* 30-08-94 - eay - changed because l>>32 and
index 2db9748cb410fc5c4b4ca3ba906b8df753104580..6b8a7ee11b1d875dbb48341d370d295db3d4be68 100644 (file)
@@ -147,14 +147,14 @@ void des_ecb_encrypt(const_des_cblock *input,des_cblock *output,
        Data is a pointer to 2 unsigned long's and ks is the
        des_key_schedule to use.  enc, is non zero specifies encryption,
        zero if decryption. */
-void des_encrypt(DES_LONG *data,des_key_schedule ks, int enc);
+void des_encrypt1(DES_LONG *data,des_key_schedule ks, int enc);
 
-/*     This functions is the same as des_encrypt() except that the DES
+/*     This functions is the same as des_encrypt1() except that the DES
        initial permutation (IP) and final permutation (FP) have been left
-       out.  As for des_encrypt(), you should not use this function.
+       out.  As for des_encrypt1(), you should not use this function.
        It is used by the routines in the library that implement triple DES.
        IP() des_encrypt2() des_encrypt2() des_encrypt2() FP() is the same
-       as des_encrypt() des_encrypt() des_encrypt() except faster :-). */
+       as des_encrypt1() des_encrypt1() des_encrypt1() except faster :-). */
 void des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc);
 
 void des_encrypt3(DES_LONG *data, des_key_schedule ks1,
index 8311e106281c29dc599112f78da1147098cf1f91..0bd9fa39bcd49d94d07883225fad07a4f6f2f3d7 100644 (file)
@@ -58,7 +58,7 @@
 
 #include "des_locl.h"
 
-void des_encrypt(DES_LONG *data, des_key_schedule ks, int enc)
+void des_encrypt1(DES_LONG *data, des_key_schedule ks, int enc)
        {
        register DES_LONG l,r,t,u;
 #ifdef DES_PTR
index b2ca7ac31d6c08d3176c05724bfe7c1740851394..82b3f29b9b75e2b7587a0af37d0a5ae7c89ef865 100644 (file)
@@ -453,7 +453,7 @@ int main(int argc, char **argv)
                count*=2;
                Time_F(START);
                for (i=count; i; i--)
-                       des_encrypt(data,&(sch[0]),DES_ENCRYPT);
+                       des_encrypt1(data,&(sch[0]),DES_ENCRYPT);
                d=Time_F(STOP);
                } while (d < 3.0);
        ca=count;
index b261a8aad9408b27d0e8cef87ac6202421e61d6b..d481327ef3b38a279d92c512b6d2c5c8a56e3c3f 100644 (file)
@@ -114,7 +114,7 @@ void des_ecb_encrypt(const_des_cblock *input, des_cblock *output,
 
        c2l(in,l); ll[0]=l;
        c2l(in,l); ll[1]=l;
-       des_encrypt(ll,ks,enc);
+       des_encrypt1(ll,ks,enc);
        l=ll[0]; l2c(l,out);
        l=ll[1]; l2c(l,out);
        l=ll[0]=ll[1]=0;
index c53062481ddd5441080f7d5589209b89024b872f..b98f7e17af1d640d67d3f7dddeeb676f8b755a08 100644 (file)
@@ -95,7 +95,7 @@ void des_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out,
            {
            tin[0]=m0;
            tin[1]=m1;
-           des_encrypt(tin,ks3,1);
+           des_encrypt1(tin,ks3,1);
            m0=tin[0];
            m1=tin[1];
 
@@ -113,13 +113,13 @@ void des_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out,
 
            tin[0]=tin0;
            tin[1]=tin1;
-           des_encrypt(tin,ks1,1);
+           des_encrypt1(tin,ks1,1);
            tin[0]^=m0;
            tin[1]^=m1;
-           des_encrypt(tin,ks2,0);
+           des_encrypt1(tin,ks2,0);
            tin[0]^=m0;
            tin[1]^=m1;
-           des_encrypt(tin,ks1,1);
+           des_encrypt1(tin,ks1,1);
            tout0=tin[0];
            tout1=tin[1];
 
@@ -146,7 +146,7 @@ void des_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out,
            {
            tin[0]=m0;
            tin[1]=m1;
-           des_encrypt(tin,ks3,1);
+           des_encrypt1(tin,ks3,1);
            m0=tin[0];
            m1=tin[1];
 
@@ -158,13 +158,13 @@ void des_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out,
 
            tin[0]=tin0;
            tin[1]=tin1;
-           des_encrypt(tin,ks1,0);
+           des_encrypt1(tin,ks1,0);
            tin[0]^=m0;
            tin[1]^=m1;
-           des_encrypt(tin,ks2,1);
+           des_encrypt1(tin,ks2,1);
            tin[0]^=m0;
            tin[1]^=m1;
-           des_encrypt(tin,ks1,0);
+           des_encrypt1(tin,ks1,0);
            tout0=tin[0];
            tout1=tin[1];
 
index 3b681691a9b797399e8a85128b7616031833ca5a..b8db07b199d6017933e8506ec4a56b7fd38c1a21 100644 (file)
@@ -89,7 +89,7 @@ void des_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length,
                        c2l(in,tin1);
                        tin0^=tout0; tin[0]=tin0;
                        tin1^=tout1; tin[1]=tin1;
-                       des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT);
+                       des_encrypt1((DES_LONG *)tin,schedule,DES_ENCRYPT);
                        tout0=tin[0]; l2c(tout0,out);
                        tout1=tin[1]; l2c(tout1,out);
                        }
@@ -98,7 +98,7 @@ void des_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length,
                        c2ln(in,tin0,tin1,l+8);
                        tin0^=tout0; tin[0]=tin0;
                        tin1^=tout1; tin[1]=tin1;
-                       des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT);
+                       des_encrypt1((DES_LONG *)tin,schedule,DES_ENCRYPT);
                        tout0=tin[0]; l2c(tout0,out);
                        tout1=tin[1]; l2c(tout1,out);
                        }
@@ -116,7 +116,7 @@ void des_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length,
                        {
                        c2l(in,tin0); tin[0]=tin0;
                        c2l(in,tin1); tin[1]=tin1;
-                       des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT);
+                       des_encrypt1((DES_LONG *)tin,schedule,DES_DECRYPT);
                        tout0=tin[0]^xor0;
                        tout1=tin[1]^xor1;
                        l2c(tout0,out);
@@ -128,7 +128,7 @@ void des_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length,
                        {
                        c2l(in,tin0); tin[0]=tin0;
                        c2l(in,tin1); tin[1]=tin1;
-                       des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT);
+                       des_encrypt1((DES_LONG *)tin,schedule,DES_DECRYPT);
                        tout0=tin[0]^xor0;
                        tout1=tin[1]^xor1;
                        l2cn(tout0,tout1,out,l+8);
index 64953959cab0dc87305a562d83ab0e0680f16755..1a1d1f1ac47076eb7947c2dc32e2f3cccf48a594 100644 (file)
@@ -87,7 +87,7 @@ void des_ofb64_encrypt(register const unsigned char *in,
                {
                if (n == 0)
                        {
-                       des_encrypt(ti,schedule,DES_ENCRYPT);
+                       des_encrypt1(ti,schedule,DES_ENCRYPT);
                        dp=d;
                        t=ti[0]; l2c(t,dp);
                        t=ti[1]; l2c(t,dp);
index a8f425a575a13bc2ff1cbd8a1f02da213d479359..70493e632ccf91b22b91ae30a5bb0537c000a73e 100644 (file)
@@ -101,7 +101,7 @@ void des_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
                {
                ti[0]=v0;
                ti[1]=v1;
-               des_encrypt((DES_LONG *)ti,schedule,DES_ENCRYPT);
+               des_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT);
                vv0=ti[0];
                vv1=ti[1];
                c2ln(in,d0,d1,n);
index dd69a26d4aabb111fe560b5738f59d226d97ef63..5b987f074d316d6ef871df87b2f4bafe48e74bea 100644 (file)
@@ -85,7 +85,7 @@ void des_pcbc_encrypt(const unsigned char *input, unsigned char *output,
                                c2ln(in,sin0,sin1,length);
                        tin[0]=sin0^xor0;
                        tin[1]=sin1^xor1;
-                       des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT);
+                       des_encrypt1((DES_LONG *)tin,schedule,DES_ENCRYPT);
                        tout0=tin[0];
                        tout1=tin[1];
                        xor0=sin0^tout0;
@@ -103,7 +103,7 @@ void des_pcbc_encrypt(const unsigned char *input, unsigned char *output,
                        c2l(in,sin1);
                        tin[0]=sin0;
                        tin[1]=sin1;
-                       des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT);
+                       des_encrypt1((DES_LONG *)tin,schedule,DES_DECRYPT);
                        tout0=tin[0]^xor0;
                        tout1=tin[1]^xor1;
                        if (length >= 8)
index 814b86f4aee517cb4177bdce8d350f050d5d0d38..1223edf2907973dbc3e19ca83fea39665e16c0c5 100644 (file)
@@ -204,7 +204,7 @@ int main(int argc, char **argv)
                count*=2;
                Time_F(START);
                for (i=count; i; i--)
-                       des_encrypt(data,&(sch[0]),DES_ENCRYPT);
+                       des_encrypt1(data,&(sch[0]),DES_ENCRYPT);
                d=Time_F(STOP);
                } while (d < 3.0);
        ca=count;
@@ -241,7 +241,7 @@ int main(int argc, char **argv)
                {
                DES_LONG data[2];
 
-               des_encrypt(data,&(sch[0]),DES_ENCRYPT);
+               des_encrypt1(data,&(sch[0]),DES_ENCRYPT);
                }
        d=Time_F(STOP);
        printf("%ld des_encrypt's in %.2f second\n",count,d);
index 51e17e6b8a64c38ac8471f73bcf367ec91cd603f..ccfede13aca6e1725786e516bd701943a2aad5b4 100644 (file)
@@ -138,7 +138,7 @@ void des_xcbc_encrypt(const unsigned char *in, unsigned char *out,
                        c2l(in,tin1);
                        tin0^=tout0^inW0; tin[0]=tin0;
                        tin1^=tout1^inW1; tin[1]=tin1;
-                       des_encrypt(tin,schedule,DES_ENCRYPT);
+                       des_encrypt1(tin,schedule,DES_ENCRYPT);
                        tout0=tin[0]^outW0; l2c(tout0,out);
                        tout1=tin[1]^outW1; l2c(tout1,out);
                        }
@@ -147,7 +147,7 @@ void des_xcbc_encrypt(const unsigned char *in, unsigned char *out,
                        c2ln(in,tin0,tin1,l+8);
                        tin0^=tout0^inW0; tin[0]=tin0;
                        tin1^=tout1^inW1; tin[1]=tin1;
-                       des_encrypt(tin,schedule,DES_ENCRYPT);
+                       des_encrypt1(tin,schedule,DES_ENCRYPT);
                        tout0=tin[0]^outW0; l2c(tout0,out);
                        tout1=tin[1]^outW1; l2c(tout1,out);
                        }
@@ -163,7 +163,7 @@ void des_xcbc_encrypt(const unsigned char *in, unsigned char *out,
                        {
                        c2l(in,tin0); tin[0]=tin0^outW0;
                        c2l(in,tin1); tin[1]=tin1^outW1;
-                       des_encrypt(tin,schedule,DES_DECRYPT);
+                       des_encrypt1(tin,schedule,DES_DECRYPT);
                        tout0=tin[0]^xor0^inW0;
                        tout1=tin[1]^xor1^inW1;
                        l2c(tout0,out);
@@ -175,7 +175,7 @@ void des_xcbc_encrypt(const unsigned char *in, unsigned char *out,
                        {
                        c2l(in,tin0); tin[0]=tin0^outW0;
                        c2l(in,tin1); tin[1]=tin1^outW1;
-                       des_encrypt(tin,schedule,DES_DECRYPT);
+                       des_encrypt1(tin,schedule,DES_DECRYPT);
                        tout0=tin[0]^xor0^inW0;
                        tout1=tin[1]^xor1^inW1;
                        l2cn(tout0,tout1,out,l+8);
index c630a24c2eed2491a1dcad76cdde860967a41848..84c6c4551a16a3ae35f72ed6c25c70c67ddd0fed 100644 (file)
@@ -136,11 +136,11 @@ static void mdc2_body(MDC2_CTX *c, const unsigned char *in, unsigned int len)
 
                des_set_odd_parity(&c->h);
                des_set_key_unchecked(&c->h,k);
-               des_encrypt(d,k,1);
+               des_encrypt1(d,k,1);
 
                des_set_odd_parity(&c->hh);
                des_set_key_unchecked(&c->hh,k);
-               des_encrypt(dd,k,1);
+               des_encrypt1(dd,k,1);
 
                ttin0=tin0^dd[0];
                ttin1=tin1^dd[1];
index b31486869196d40e990dbd10f90ae02a9ac6adb0..cde5ca27d5082034f6193eaed5a6a9715229d28f 100644 (file)
@@ -453,7 +453,7 @@ err:
 static int RSA_eay_mod_exp(BIGNUM *r0, BIGNUM *I, RSA *rsa)
        {
        const RSA_METHOD *meth;
-       BIGNUM r1,m1;
+       BIGNUM r1,m1,vrfy;
        int ret=0;
        BN_CTX *ctx;
 
@@ -461,6 +461,7 @@ static int RSA_eay_mod_exp(BIGNUM *r0, BIGNUM *I, RSA *rsa)
        if ((ctx=BN_CTX_new()) == NULL) goto err;
        BN_init(&m1);
        BN_init(&r1);
+       BN_init(&vrfy);
 
        if (rsa->flags & RSA_FLAG_CACHE_PRIVATE)
                {
@@ -541,10 +542,19 @@ static int RSA_eay_mod_exp(BIGNUM *r0, BIGNUM *I, RSA *rsa)
        if (!BN_mul(&r1,r0,rsa->q,ctx)) goto err;
        if (!BN_add(r0,&r1,&m1)) goto err;
 
+       if (rsa->e && rsa->n)
+               {
+               if (!meth->bn_mod_exp(&vrfy,r0,rsa->e,rsa->n,ctx,NULL)) goto err;
+               if (BN_cmp(I, &vrfy) != 0)
+                       {
+                       if (!meth->bn_mod_exp(r0,I,rsa->d,rsa->n,ctx,NULL)) goto err;
+                       }
+               }
        ret=1;
 err:
        BN_clear_free(&m1);
        BN_clear_free(&r1);
+       BN_clear_free(&vrfy);
        BN_CTX_free(ctx);
        return(ret);
        }
index 5e5b96c8980f953f8cdf8a468dfb82ad1b9913aa..84ae840804a11bbbb16639252acab42007d9832f 100755 (executable)
@@ -779,7 +779,7 @@ des_ede3_cfb64_encrypt                  786 EXIST::FUNCTION:DES
 des_ede3_ofb64_encrypt                  787    EXIST::FUNCTION:DES
 des_enc_read                            788    EXIST::FUNCTION:DES
 des_enc_write                           789    EXIST::FUNCTION:DES
-des_encrypt                             790    EXIST::FUNCTION:DES
+des_encrypt1                            790    EXIST::FUNCTION:DES
 des_encrypt2                            791    EXIST::FUNCTION:DES
 des_encrypt3                            792    EXIST::FUNCTION:DES
 des_fcrypt                              793    EXIST::FUNCTION:DES