Recent changes from 0.9.6-stable.
authorRichard Levitte <levitte@openssl.org>
Mon, 2 Dec 2002 03:01:52 +0000 (03:01 +0000)
committerRichard Levitte <levitte@openssl.org>
Mon, 2 Dec 2002 03:01:52 +0000 (03:01 +0000)
32 files changed:
crypto/bf/bftest.c
crypto/bn/bn_lib.c
crypto/bn/bn_rand.c
crypto/bn/bntest.c
crypto/bn/exptest.c
crypto/cast/casttest.c
crypto/dh/dhtest.c
crypto/dsa/dsatest.c
crypto/hmac/hmactest.c
crypto/idea/ideatest.c
crypto/md2/md2_dgst.c
crypto/md2/md2_one.c
crypto/md2/md2test.c
crypto/md4/md4_one.c
crypto/md4/md4test.c
crypto/md5/md5_one.c
crypto/md5/md5test.c
crypto/mdc2/mdc2_one.c
crypto/mdc2/mdc2test.c
crypto/pem/pem_lib.c
crypto/rand/randtest.c
crypto/rc2/rc2test.c
crypto/rc4/rc4test.c
crypto/rc5/rc5test.c
crypto/ripemd/rmdtest.c
crypto/sha/sha1test.c
crypto/sha/shatest.c
doc/crypto/RSA_print.pod
e_os.h
ssl/s3_srvr.c
ssl/ssltest.c
test/methtest.c

index cf67cadefd4204eebf52aec518e0b144a3c2e3bb..212edfaf622e0395a29d44fc4e9bcd5f117d3b9b 100644 (file)
@@ -63,6 +63,8 @@
 #include <string.h>
 #include <stdlib.h>
 
+#include "../e_os.h"
+
 #ifdef NO_BF
 int main(int argc, char *argv[])
 {
@@ -275,7 +277,7 @@ int main(int argc, char *argv[])
        else
                ret=test();
 
-       exit(ret);
+       EXIT(ret);
        return(0);
        }
 
index 7767d6517022eb2062a7bffed6c1e4791e7793cc..5f121dea1e49007118e3b1c097b4587175a855a5 100644 (file)
@@ -263,12 +263,12 @@ void BN_clear_free(BIGNUM *a)
        if (a == NULL) return;
        if (a->d != NULL)
                {
-               memset(a->d,0,a->dmax*sizeof(a->d[0]));
+               OPENSSL_cleanse(a->d,a->dmax*sizeof(a->d[0]));
                if (!(BN_get_flags(a,BN_FLG_STATIC_DATA)))
                        OPENSSL_free(a->d);
                }
        i=BN_get_flags(a,BN_FLG_MALLOCED);
-       memset(a,0,sizeof(BIGNUM));
+       OPENSSL_cleanse(a,sizeof(BIGNUM));
        if (i)
                OPENSSL_free(a);
        }
index 4944ffbf232f3b432312f0aba1fedb3237fe1d32..eb65c28cbb413be0b936cebac6f4386b08fff7c0 100644 (file)
@@ -201,7 +201,7 @@ static int bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom)
 err:
        if (buf != NULL)
                {
-               memset(buf,0,bytes);
+               OPENSSL_cleanse(buf,bytes);
                OPENSSL_free(buf);
                }
        return(ret);
index af0c2629e87eb65d6be79639ca635a6af502e5e5..6ae2b4aff08cc92fca8ceeb5532f3d3d5bfab5a1 100644 (file)
@@ -139,10 +139,10 @@ int main(int argc, char *argv[])
 
 
        ctx=BN_CTX_new();
-       if (ctx == NULL) exit(1);
+       if (ctx == NULL) EXIT(1);
 
        out=BIO_new(BIO_s_file());
-       if (out == NULL) exit(1);
+       if (out == NULL) EXIT(1);
        if (outfile == NULL)
                {
                BIO_set_fp(out,stdout,BIO_NOCLOSE);
@@ -152,7 +152,7 @@ int main(int argc, char *argv[])
                if (!BIO_write_filename(out,outfile))
                        {
                        perror(outfile);
-                       exit(1);
+                       EXIT(1);
                        }
                }
 
@@ -228,14 +228,14 @@ int main(int argc, char *argv[])
        BIO_free(out);
 
 /**/
-       exit(0);
+       EXIT(0);
 err:
        BIO_puts(out,"1\n"); /* make sure the Perl script fed by bc notices
                              * the failure, see test_bn in test/Makefile.ssl*/
        BIO_flush(out);
        ERR_load_crypto_strings();
        ERR_print_errors_fp(stderr);
-       exit(1);
+       EXIT(1);
        return(1);
        }
 
@@ -746,7 +746,7 @@ int test_mod_mul(BIO *bp, BN_CTX *ctx)
                        while ((l=ERR_get_error()))
                                fprintf(stderr,"ERROR:%s\n",
                                        ERR_error_string(l,NULL));
-                       exit(1);
+                       EXIT(1);
                        }
                if (bp != NULL)
                        {
index 3e86f2ea0e0b3897a24e437b38a73824e1993110..b3b807af387cb918363613d861b8317e22726b8e 100644 (file)
@@ -59,6 +59,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+
+#include "../e_os.h"
+
 #include <openssl/bio.h>
 #include <openssl/bn.h>
 #include <openssl/rand.h>
@@ -86,7 +89,7 @@ int main(int argc, char *argv[])
        ERR_load_BN_strings();
 
        ctx=BN_CTX_new();
-       if (ctx == NULL) exit(1);
+       if (ctx == NULL) EXIT(1);
        r_mont=BN_new();
        r_recp=BN_new();
        r_simple=BN_new();
@@ -99,7 +102,7 @@ int main(int argc, char *argv[])
 
        out=BIO_new(BIO_s_file());
 
-       if (out == NULL) exit(1);
+       if (out == NULL) EXIT(1);
        BIO_set_fp(out,stdout,BIO_NOCLOSE);
 
        for (i=0; i<200; i++)
@@ -124,7 +127,7 @@ int main(int argc, char *argv[])
                        {
                        printf("BN_mod_exp_mont() problems\n");
                        ERR_print_errors(out);
-                       exit(1);
+                       EXIT(1);
                        }
 
                ret=BN_mod_exp_recp(r_recp,a,b,m,ctx);
@@ -132,7 +135,7 @@ int main(int argc, char *argv[])
                        {
                        printf("BN_mod_exp_recp() problems\n");
                        ERR_print_errors(out);
-                       exit(1);
+                       EXIT(1);
                        }
 
                ret=BN_mod_exp_simple(r_simple,a,b,m,ctx);
@@ -140,7 +143,7 @@ int main(int argc, char *argv[])
                        {
                        printf("BN_mod_exp_simple() problems\n");
                        ERR_print_errors(out);
-                       exit(1);
+                       EXIT(1);
                        }
 
                if (BN_cmp(r_simple, r_mont) == 0
@@ -163,7 +166,7 @@ int main(int argc, char *argv[])
                        printf("\nrecp     ="); BN_print(out,r_recp);
                        printf("\nmont     ="); BN_print(out,r_mont);
                        printf("\n");
-                       exit(1);
+                       EXIT(1);
                        }
                }
        BN_free(r_mont);
@@ -177,11 +180,11 @@ int main(int argc, char *argv[])
        CRYPTO_mem_leaks(out);
        BIO_free(out);
        printf(" done\n");
-       exit(0);
+       EXIT(0);
 err:
        ERR_load_crypto_strings();
        ERR_print_errors(out);
-       exit(1);
+       EXIT(1);
        return(1);
        }
 
index ab2aeac606eae5be5f3119f16537dc0a2b9cca07..0e1034da45bc2668b660dfed52bb9e39a1517b3c 100644 (file)
@@ -60,6 +60,8 @@
 #include <string.h>
 #include <stdlib.h>
 
+#include "../e_os.h"
+
 #ifdef NO_CAST
 int main(int argc, char *argv[])
 {
@@ -224,7 +226,7 @@ int main(int argc, char *argv[])
       }
 #endif
 
-    exit(err);
+    EXIT(err);
     return(err);
     }
 #endif
index a38465da130e9fa117829869ce7110712514c0b1..c57cac099d49cda7704e2701d10a878df605eb92 100644 (file)
@@ -59,6 +59,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+
+#include "../e_os.h"
+
 #ifdef WINDOWS
 #include "../bio/bss_file.c" 
 #endif
@@ -107,7 +110,7 @@ int main(int argc, char *argv[])
        RAND_seed(rnd_seed, sizeof rnd_seed);
 
        out=BIO_new(BIO_s_file());
-       if (out == NULL) exit(1);
+       if (out == NULL) EXIT(1);
        BIO_set_fp(out,stdout,BIO_NOCLOSE);
 
        a=DH_generate_parameters(64,DH_GENERATOR_5,cb,out);
@@ -188,7 +191,7 @@ err:
        if(b != NULL) DH_free(b);
        if(a != NULL) DH_free(a);
        BIO_free(out);
-       exit(ret);
+       EXIT(ret);
        return(ret);
        }
 
index 309a7cda899230af018dc67944d533aa0fc107d4..2361ad61cbb81c10027471053bac1fb531041458 100644 (file)
@@ -61,6 +61,9 @@
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+
+#include "../e_os.h"
+
 #include <openssl/crypto.h>
 #include <openssl/rand.h>
 #include <openssl/bio.h>
@@ -207,10 +210,15 @@ end:
                BIO_free(bio_err);
                bio_err = NULL;
                }
-       exit(!ret);
+       EXIT(!ret);
        return(0);
        }
 
+static int cb_exit(int ec)
+       {
+       EXIT(ec);
+       }
+
 static void MS_CALLBACK dsa_cb(int p, int n, void *arg)
        {
        char c='*';
@@ -226,7 +234,7 @@ static void MS_CALLBACK dsa_cb(int p, int n, void *arg)
        if (!ok && (p == 0) && (num > 1))
                {
                BIO_printf((BIO *)arg,"error in dsatest\n");
-               exit(1);
+               cb_exit(1);
                }
        }
 #endif
index 4b56b8ee135564499bb701dab5fce1af7704dfb8..3bc476b9c770b98aa2b18b8bd35a6383c0122330 100644 (file)
@@ -60,6 +60,8 @@
 #include <string.h>
 #include <stdlib.h>
 
+#include "../e_os.h"
+
 #ifdef NO_HMAC
 int main(int argc, char *argv[])
 {
@@ -143,7 +145,7 @@ int main(int argc, char *argv[])
                else
                        printf("test %d ok\n",i);
                }
-       exit(err);
+       EXIT(err);
        return(0);
        }
 
index 64b9353e414f4557858f3aa4401b44995f1bc12c..01d43adb19dad56673ca11591c501b82cbb5c336 100644 (file)
@@ -60,6 +60,8 @@
 #include <string.h>
 #include <stdlib.h>
 
+#include "../e_os.h"
+
 #ifdef NO_IDEA
 int main(int argc, char *argv[])
 {
@@ -167,7 +169,7 @@ int main(int argc, char *argv[])
        else
                printf("ok\n");
 
-       exit(err);
+       EXIT(err);
        return(err);
        }
 
index 608baefa8f34d44da25c3a30b4f78c70c9600c81..458a3fad7fb854c4eec1ed203cf92489e293c3cf 100644 (file)
@@ -194,7 +194,7 @@ static void md2_block(MD2_CTX *c, const unsigned char *d)
                t=(t+i)&0xff;
                }
        memcpy(sp1,state,16*sizeof(MD2_INT));
-       memset(state,0,48*sizeof(MD2_INT));
+       OPENSSL_cleanse(state,48*sizeof(MD2_INT));
        }
 
 void MD2_Final(unsigned char *md, MD2_CTX *c)
index b12c37ce4def4e1a538b7bca74ef7cac8ce7b8e3..835160ef56d1bcf4470bd3f79633d4a137c63f79 100644 (file)
@@ -88,6 +88,6 @@ unsigned char *MD2(const unsigned char *d, unsigned long n, unsigned char *md)
        }
 #endif
        MD2_Final(md,&c);
-       memset(&c,0,sizeof(c)); /* Security consideration */
+       OPENSSL_cleanse(&c,sizeof(c));  /* Security consideration */
        return(md);
        }
index e3f4fb4c341af264b2d2de675822d63860d266a6..4d7231753bedc6365bbef3a3578d6ca381843947 100644 (file)
@@ -60,6 +60,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "../e_os.h"
+
 #ifdef NO_MD2
 int main(int argc, char *argv[])
 {
@@ -119,7 +121,7 @@ int main(int argc, char *argv[])
                R++;
                P++;
                }
-       exit(err);
+       EXIT(err);
        return(0);
        }
 
index 87a995d38d434f68ff3bb6056d887abe6f03880b..53efd430ec01640c9ee76d3ce90f9bd8ee3433fc 100644 (file)
@@ -89,7 +89,7 @@ unsigned char *MD4(const unsigned char *d, unsigned long n, unsigned char *md)
        }
 #endif
        MD4_Final(md,&c);
-       memset(&c,0,sizeof(c)); /* security consideration */
+       OPENSSL_cleanse(&c,sizeof(c)); /* security consideration */
        return(md);
        }
 
index 97e6e21efd1576c0126ae5b1e9e1000ae2e93478..faa9e84a9a3de91346e6452e394a005ea40cd8ac 100644 (file)
@@ -60,6 +60,8 @@
 #include <string.h>
 #include <stdlib.h>
 
+#include "../e_os.h"
+
 #ifdef NO_MD4
 int main(int argc, char *argv[])
 {
@@ -115,7 +117,7 @@ int main(int argc, char *argv[])
                R++;
                P++;
                }
-       exit(err);
+       EXIT(err);
        return(0);
        }
 
index b89dec850d2d5b20ed511227cac38a986b2380cd..c67eb795ca76398aa8c58ab03575c6960d743c41 100644 (file)
@@ -89,7 +89,7 @@ unsigned char *MD5(const unsigned char *d, unsigned long n, unsigned char *md)
        }
 #endif
        MD5_Final(md,&c);
-       memset(&c,0,sizeof(c)); /* security consideration */
+       OPENSSL_cleanse(&c,sizeof(c)); /* security consideration */
        return(md);
        }
 
index 6bd86563020e1b871b286355b8a6c40866b76d99..e3258cc0bf103f82028970a9b23e7988b96155bc 100644 (file)
@@ -60,6 +60,8 @@
 #include <string.h>
 #include <stdlib.h>
 
+#include "../e_os.h"
+
 #ifdef NO_MD5
 int main(int argc, char *argv[])
 {
@@ -115,7 +117,7 @@ int main(int argc, char *argv[])
                R++;
                P++;
                }
-       exit(err);
+       EXIT(err);
        return(0);
        }
 
index 6cd141b4d621b64bd9d062280fde4e7061e71dbb..37f06c8d77cfee5ee5194449e302b7390a025dc0 100644 (file)
@@ -69,7 +69,7 @@ unsigned char *MDC2(const unsigned char *d, unsigned long n, unsigned char *md)
        MDC2_Init(&c);
        MDC2_Update(&c,d,n);
         MDC2_Final(md,&c);
-       memset(&c,0,sizeof(c)); /* security consideration */
+       OPENSSL_cleanse(&c,sizeof(c)); /* security consideration */
        return(md);
        }
 
index 46c25aeff4c6cdcf9cdb4f21a2c566141927e14b..bad02979ee0e3e4bf520a95b33784061a2dfa4cd 100644 (file)
@@ -60,6 +60,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "../e_os.h"
+
 #if defined(NO_DES) && !defined(NO_MDC2)
 #define NO_MDC2
 #endif
@@ -134,7 +136,7 @@ int main(int argc, char *argv[])
        else
                printf("pad2 - ok\n");
 
-       exit(ret);
+       EXIT(ret);
        return(ret);
        }
 #endif
index a86a98f41916aa7a62ea52ddbbeac6dcabf039f8..e024bd78730433d7e98a56599df05d11cf8108e7 100644 (file)
@@ -380,7 +380,7 @@ int PEM_ASN1_write_bio(int (*i2d)(), const char *name, BIO *bp, char *x,
                 * NOT taken from the BytesToKey function */
                EVP_BytesToKey(enc,EVP_md5(),iv,kstr,klen,1,key,NULL);
 
-               if (kstr == (unsigned char *)buf) memset(buf,0,PEM_BUFSIZE);
+               if (kstr == (unsigned char *)buf) OPENSSL_cleanse(buf,PEM_BUFSIZE);
 
                buf[0]='\0';
                PEM_proc_type(buf,PEM_TYPE_ENCRYPTED);
index da96e3f6959a0ddd9072584d72c72687f24d3eec..abee3f7b2b2d4f9a6a87b58bf33e39dda9fc8bf1 100644 (file)
@@ -60,6 +60,8 @@
 #include <stdlib.h>
 #include <openssl/rand.h>
 
+#include "../e_os.h"
+
 /* some FIPS 140-1 random number test */
 /* some simple tests */
 
@@ -202,6 +204,6 @@ int main()
                }
        printf("test 4 done\n");
        err=((err)?1:0);
-       exit(err);
+       EXIT(err);
        return(err);
        }
index 521269ded18c4f255a7dac8cb2d2f1394ef18230..bf8bc5d02fa4ff504e1c4b0eeca8cd975167d231 100644 (file)
@@ -63,6 +63,8 @@
 #include <string.h>
 #include <stdlib.h>
 
+#include "../e_os.h"
+
 #ifdef NO_RC2
 int main(int argc, char *argv[])
 {
@@ -203,7 +205,7 @@ int main(int argc, char *argv[])
                printf("ok\n");
 #endif
 
-       exit(err);
+       EXIT(err);
        return(err);
        }
 
index 3914eb6c38315c0c23ca09c9c173bbcad2ab91f2..3aa40ed23510c4eeac905b6dc2fb404b9feb2f87 100644 (file)
@@ -60,6 +60,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "../e_os.h"
+
 #ifdef NO_RC4
 int main(int argc, char *argv[])
 {
@@ -195,7 +197,7 @@ int main(int argc, char *argv[])
                        }
                }
        printf("done\n");
-       exit(err);
+       EXIT(err);
        return(0);
        }
 #endif
index 634ceac7c7ee7306263b6f7b5a3599578cfd120e..84e7c71d216aa92520ee1e0ea05e43db674e20d4 100644 (file)
@@ -63,6 +63,8 @@
 #include <string.h>
 #include <stdlib.h>
 
+#include "../e_os.h"
+
 #ifdef NO_RC5
 int main(int argc, char *argv[])
 {
@@ -318,7 +320,7 @@ int main(int argc, char *argv[])
                }
        if (err == 0) printf("cbc RC5 ok\n");
 
-       exit(err);
+       EXIT(err);
        return(err);
        }
 
index 5d79c997253baf1c19672e8801b65190daf70d08..dd3a49d7058baf731f11f3ef0e5420c5d603852f 100644 (file)
@@ -60,6 +60,8 @@
 #include <string.h>
 #include <stdlib.h>
 
+#include "../e_os.h"
+
 #ifdef NO_RIPEMD
 int main(int argc, char *argv[])
 {
@@ -124,7 +126,7 @@ int main(int argc, char *argv[])
                R++;
                P++;
                }
-       exit(err);
+       EXIT(err);
        return(0);
        }
 
index 688d06c63747a41025482394ee280213495cd0d6..8c2bd33f56fab6ba8d4989ae2b417506ea3fb9ea 100644 (file)
@@ -60,6 +60,8 @@
 #include <string.h>
 #include <stdlib.h>
 
+#include "../e_os.h"
+
 #ifdef NO_SHA
 int main(int argc, char *argv[])
 {
@@ -152,7 +154,7 @@ int main(int argc, char *argv[])
                }
        else
                printf("test 3 ok\n");
-       exit(err);
+       EXIT(err);
        return(0);
        }
 
index a5786bbf768d3ce63871b25cb54d28dc61aa3353..d9329f0307b57c30c3fa84e720ff2bd62e1cf29b 100644 (file)
@@ -60,6 +60,8 @@
 #include <string.h>
 #include <stdlib.h>
 
+#include "../e_os.h"
+
 #ifdef NO_SHA
 int main(int argc, char *argv[])
 {
@@ -152,7 +154,7 @@ int main(int argc, char *argv[])
                }
        else
                printf("test 3 ok\n");
-       exit(err);
+       EXIT(err);
        return(0);
        }
 
index 67876facc5df68d7b7189589372ea59b5b9cbf4e..e28d107d1c6e45b0b70d102b80b2b367f9cab333 100644 (file)
@@ -2,9 +2,9 @@
 
 =head1 NAME
 
-RSA_print, RSA_print_fp, DHparams_print, DHparams_print_fp, DSA_print,
-DSA_print_fp, DHparams_print, DHparams_print_fp - print cryptographic
-parameters
+RSA_print, RSA_print_fp,
+DSAparams_print, DSAparams_print_fp, DSA_print, DSA_print_fp,
+DHparams_print, DHparams_print_fp - print cryptographic parameters
 
 =head1 SYNOPSIS
 
diff --git a/e_os.h b/e_os.h
index d49c6ef7e739c7868be280a2117641186de88873..30008fa781ad63d21fe1b50c3a8da68d5b335bb9 100644 (file)
--- a/e_os.h
+++ b/e_os.h
@@ -220,9 +220,9 @@ extern "C" {
 #  endif
 
 #  if defined(WIN16) && !defined(MONOLITH) && defined(SSLEAY) && defined(_WINEXITNOPERSIST)
-#    define EXIT(n) { if (n == 0) _wsetexit(_WINEXITNOPERSIST); return(n); }
+#    define EXIT(n) do { if (n == 0) _wsetexit(_WINEXITNOPERSIST); return(n); } while(0)
 #  else
-#    define EXIT(n)            return(n);
+#    define EXIT(n)            return(n)
 #  endif
 #  define LIST_SEPARATOR_CHAR ';'
 #  ifndef X_OK
@@ -318,7 +318,7 @@ extern "C" {
 #    define LIST_SEPARATOR_CHAR ':'
 #    define NUL_DEV            "/dev/null"
 #    ifndef MONOLITH
-#      define EXIT(n)          exit(n); return(n)
+#      define EXIT(n)          do { exit(n); return(n); } while(0)
 #    else
 #      define EXIT(n)          return(n)
 #    endif
index 7a89993b4809a12190eeccd4e1f7c8acb521e608..6b414cfa5c8bf53f1d86dcadc5dcc685246d971a 100644 (file)
@@ -1471,7 +1471,7 @@ static int ssl3_get_client_key_exchange(SSL *s)
                        s->method->ssl3_enc->generate_master_secret(s,
                                s->session->master_key,
                                p,i);
-               memset(p,0,i);
+               OPENSSL_cleanse(p,i);
                }
        else
 #endif
index d6704852b45b7184bf2410b6fcc4a44f37eea6ae..3de9663e51ae002bf35b865952067c46c635ddee 100644 (file)
@@ -366,7 +366,7 @@ bad:
                        "the test anyway (and\n-d to see what happens), "
                        "or add one of -ssl2, -ssl3, -tls1, -reuse\n"
                        "to avoid protocol mismatch.\n");
-               exit(1);
+               EXIT(1);
                }
 
        if (print_time)
index 06ccb3b31087a9fdeaa3d8ba7f1dc6a5ebb3f976..005c2f48220e8d4e4390b801289ec9458aee1f10 100644 (file)
@@ -96,10 +96,10 @@ char *argv[];
        METH_init(top);
        METH_control(tmp1,METH_CONTROL_DUMP,stdout);
        METH_control(tmp2,METH_CONTROL_DUMP,stdout);
-       exit(0);
+       EXIT(0);
 err:
        ERR_load_crypto_strings();
        ERR_print_errors_fp(stderr);
-       exit(1);
+       EXIT(1);
        return(0);
        }