Hi,
Included in this mail is a patch for 11 test programs and one
apps program (ca.c). I have fixed some memory leaks, global
variable collisions and minimized name-space pollution in
the test program library which I build for the RTOS.
Some of the changes in ca.c have been submitted earlier,
I hope this doesn't matter. The new fix in ca.c is
'+ ASN1_UTCTIME_free(tmptm);'. I will try to get my CVS
act together someday soon *cough*.
By making both apps/openssl and the test programs into
a library and writing an Expect script that does the same
job as 'make test', I have finally been able to run the
complete test suite on my target. The good news is that
it now passes with no errors or memory leaks :) As a
result, a new target could be added to the 0.9.4 openssl
test succeeded list (if there is any?) - OSE for powerpc
on MBX860, Motorola mpc860en, 40Mhz. Not a very common
target I agree but nice to see the complete openssl test
suite pass on a rtos as well, portable code indeed :)
Thanks,
Lennart Bang
[EMAIL PROTECTED]
--- openssl-0.9.4/apps/ca.c Fri Aug 6 20:47:09 1999
+++ openssl-0.9.4-mod/apps/ca.c Tue Sep 14 15:31:16 1999
@@ -271,9 +271,14 @@
apps_startup();
+ key = NULL;
+ section = NULL;
+ conf = NULL;
+
X509V3_add_standard_extensions();
preserve=0;
+ msie_hack=0;
if (bio_err == NULL)
if ((bio_err=BIO_new(BIO_s_file())) != NULL)
BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
@@ -584,12 +589,14 @@
perror(outdir);
goto err;
}
+#ifdef S_IFDIR
if (!(sb.st_mode & S_IFDIR))
{
BIO_printf(bio_err,"%s need to be a directory\n",outdir);
perror(outdir);
goto err;
}
+#endif
}
/*****************************************************************/
@@ -1883,6 +1890,7 @@
X509_NAME_free(CAname);
if (subject != NULL)
X509_NAME_free(subject);
+ ASN1_UTCTIME_free(tmptm);
if (ok <= 0)
{
if (ret != NULL) X509_free(ret);
--- openssl-0.9.4/crypto/bn/bntest.c Wed Sep 8 11:23:26 1999
+++ openssl-0.9.4-mod/crypto/bn/bntest.c Fri Sep 10 11:29:35 1999
@@ -104,6 +104,8 @@
BIO *out;
char *outfile=NULL;
+ results = 0;
+
argc--;
argv++;
while (argc >= 1)
@@ -206,6 +208,9 @@
fprintf(stderr,"test BN_exp\n");
if (!test_exp(out,ctx)) goto err;
fflush(stdout);
+
+ BN_CTX_free(ctx);
+ BIO_free(out);
/**/
exit(0);
--- openssl-0.9.4/crypto/bn/exptest.c Thu Apr 29 15:07:56 1999
+++ openssl-0.9.4-mod/crypto/bn/exptest.c Fri Sep 10 11:14:19 1999
@@ -160,7 +160,15 @@
exit(1);
}
}
+ BN_free(r_mont);
+ BN_free(r_recp);
+ BN_free(r_simple);
+ BN_free(a);
+ BN_free(b);
+ BN_free(m);
+ BN_CTX_free(ctx);
CRYPTO_mem_leaks(out);
+ BIO_free(out);
printf(" done\n");
exit(0);
err:
--- openssl-0.9.4/crypto/dsa/dsatest.c Fri Jul 9 15:27:27 1999
+++ openssl-0.9.4-mod/crypto/dsa/dsatest.c Thu Sep 9 15:22:41 1999
@@ -194,7 +194,7 @@
ERR_print_errors(bio_err);
if (dsa != NULL) DSA_free(dsa);
CRYPTO_mem_leaks(bio_err);
- if (bio_err != NULL) BIO_free(bio_err);
+ if (bio_err != NULL) { BIO_free(bio_err); bio_err = NULL; }
exit(!ret);
return(0);
}
--- openssl-0.9.4/crypto/dh/dhtest.c Sat Jun 12 08:52:42 1999
+++ openssl-0.9.4-mod/crypto/dh/dhtest.c Fri Sep 10 10:41:06 1999
@@ -87,14 +87,13 @@
#include "bss_file.c"
#endif
-BIO *out=NULL;
-
int main(int argc, char *argv[])
{
DH *a,*b;
char buf[12];
unsigned char *abuf=NULL,*bbuf=NULL;
int i,alen,blen,aout,bout,ret=1;
+ BIO *out;
#ifdef WIN32
CRYPTO_malloc_init();
@@ -167,6 +166,9 @@
err:
if (abuf != NULL) Free(abuf);
if (bbuf != NULL) Free(bbuf);
+ if(b != NULL) DH_free(b);
+ if(a != NULL) DH_free(a);
+ BIO_free(out);
exit(ret);
return(ret);
}
--- openssl-0.9.4/ssl/ssltest.c Thu Aug 5 10:50:17 1999
+++ openssl-0.9.4-mod/ssl/ssltest.c Tue Sep 14 11:50:29 1999
@@ -85,19 +85,19 @@
# define TEST_CLIENT_CERT "../apps/client.pem"
#endif
-int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx);
+static int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx);
#ifndef NO_RSA
static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export,int keylength);
#endif
#ifndef NO_DH
static DH *get_dh512(void);
#endif
-BIO *bio_err=NULL;
-BIO *bio_stdout=NULL;
+static BIO *bio_err=NULL;
+static BIO *bio_stdout=NULL;
static char *cipher=NULL;
-int verbose=0;
-int debug=0;
+static int verbose=0;
+static int debug=0;
#if 0
/* Not used yet. */
#ifdef FIONBIO
@@ -163,12 +163,15 @@
#ifndef NO_DH
DH *dh;
#endif
+ verbose = 0;
+ debug = 0;
+ cipher = 0;
+
+ CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
bio_stdout=BIO_new_fp(stdout,BIO_NOCLOSE);
- CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
-
argc--;
argv++;
@@ -421,6 +424,7 @@
ERR_remove_state(0);
EVP_cleanup();
CRYPTO_mem_leaks(bio_err);
+ if (bio_err != NULL) BIO_free(bio_err);
EXIT(ret);
}
@@ -1091,7 +1095,7 @@
return(ret);
}
-int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx)
+static int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx)
{
char *s,buf[256];
--- openssl-0.9.4/crypto/rsa/rsa_oaep_test.c Fri Jul 9 15:27:28 1999
+++ openssl-0.9.4-mod/crypto/rsa/rsa_oaep_test.c Mon Sep 13 14:28:31 1999
@@ -203,7 +203,7 @@
return(0);
}
-int main()
+int main(int argc, char *argv[])
{
int err=0;
int v;
--- openssl-0.9.4/crypto/des/destest.c Sat Jun 12 08:52:41 1999
+++ openssl-0.9.4-mod/crypto/des/destest.c Wed Sep 15 08:24:54 1999
@@ -309,8 +309,8 @@
0x3d,0x6d,0x5b,0xe3,0x25,0x5a,0xf8,0xc3
};
-DES_LONG cbc_cksum_ret=0xB462FEF7L;
-unsigned char cbc_cksum_data[8]={0x1D,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4};
+static DES_LONG cbc_cksum_ret=0xB462FEF7L;
+static unsigned char cbc_cksum_data[8]={0x1D,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4};
static char *pt(unsigned char *p);
static int cfb_test(int bits, unsigned char *cfb_cipher);
--- openssl-0.9.4/crypto/bf/bftest.c Thu Jun 10 15:29:28 1999
+++ openssl-0.9.4-mod/crypto/bf/bftest.c Wed Sep 15 08:24:06 1999
@@ -76,18 +76,18 @@
#include <openssl/ebcdic.h>
#endif
-char *bf_key[2]={
+static char *bf_key[2]={
"abcdefghijklmnopqrstuvwxyz",
"Who is John Galt?"
};
/* big endian */
-BF_LONG bf_plain[2][2]={
+static BF_LONG bf_plain[2][2]={
{0x424c4f57L,0x46495348L},
{0xfedcba98L,0x76543210L}
};
-BF_LONG bf_cipher[2][2]={
+static BF_LONG bf_cipher[2][2]={
{0x324ed0feL,0xf413a203L},
{0xcc91732bL,0x8022f684L}
};
@@ -228,16 +228,16 @@
0x63,0xC2,0xCF,0x80,0xDA};
#define KEY_TEST_NUM 25
-unsigned char key_test[KEY_TEST_NUM]={
+static unsigned char key_test[KEY_TEST_NUM]={
0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87,
0x78,0x69,0x5a,0x4b,0x3c,0x2d,0x1e,0x0f,
0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,
0x88};
-unsigned char key_data[8]=
+static unsigned char key_data[8]=
{0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10};
-unsigned char key_out[KEY_TEST_NUM][8]={
+static unsigned char key_out[KEY_TEST_NUM][8]={
{0xF9,0xAD,0x59,0x7C,0x49,0xDB,0x00,0x5E},
{0xE9,0x1D,0x21,0xC1,0xD9,0x61,0xA6,0xD6},
{0xE9,0xC2,0xB7,0x0A,0x1B,0xC6,0x5C,0xF3},
--- openssl-0.9.4/crypto/rc4/rc4test.c Tue Apr 27 00:14:30 1999
+++ openssl-0.9.4-mod/crypto/rc4/rc4test.c Wed Sep 15 08:27:00 1999
@@ -69,7 +69,7 @@
#else
#include <openssl/rc4.h>
-unsigned char keys[7][30]={
+static unsigned char keys[7][30]={
{8,0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef},
{8,0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef},
{8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
@@ -78,8 +78,8 @@
{4,0xef,0x01,0x23,0x45},
};
-unsigned char data_len[7]={8,8,8,20,28,10};
-unsigned char data[7][30]={
+static unsigned char data_len[7]={8,8,8,20,28,10};
+static unsigned char data[7][30]={
{0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,0xff},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff},
@@ -94,7 +94,7 @@
{0},
};
-unsigned char output[7][30]={
+static unsigned char output[7][30]={
{0x75,0xb7,0x87,0x80,0x99,0xe0,0xc5,0x96,0x00},
{0x74,0x94,0xc2,0xe7,0x10,0x4b,0x08,0x79,0x00},
{0xde,0x18,0x89,0x41,0xa3,0x37,0x5d,0x3a,0x00},
--- openssl-0.9.4/crypto/cast/casttest.c Tue Apr 27 00:13:54 1999
+++ openssl-0.9.4-mod/crypto/cast/casttest.c Wed Sep 15 08:32:07 1999
@@ -71,32 +71,32 @@
#define FULL_TEST
-unsigned char k[16]={
+static unsigned char k[16]={
0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78,
0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9A
};
-unsigned char in[8]={ 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF};
+static unsigned char in[8]={ 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF};
-int k_len[3]={16,10,5};
-unsigned char c[3][8]={
+static int k_len[3]={16,10,5};
+static unsigned char c[3][8]={
{0x23,0x8B,0x4F,0xE5,0x84,0x7E,0x44,0xB2},
{0xEB,0x6A,0x71,0x1A,0x2C,0x02,0x27,0x1B},
{0x7A,0xC8,0x16,0xD1,0x6E,0x9B,0x30,0x2E},
};
-unsigned char out[80];
+static unsigned char out[80];
-unsigned char in_a[16]={
+static unsigned char in_a[16]={
0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78,
0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9A};
-unsigned char in_b[16]={
+static unsigned char in_b[16]={
0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78,
0x23,0x45,0x67,0x89,0x34,0x56,0x78,0x9A};
-unsigned char c_a[16]={
+static unsigned char c_a[16]={
0xEE,0xA9,0xD0,0xA2,0x49,0xFD,0x3B,0xA6,
0xB3,0x43,0x6F,0xB8,0x9D,0x6D,0xCA,0x92};
-unsigned char c_b[16]={
+static unsigned char c_b[16]={
0xB2,0xC9,0x5E,0xB0,0x0C,0x31,0xAD,0x71,
0x80,0xAC,0x05,0xB8,0xE8,0x3D,0x69,0x6E};
--- openssl-0.9.4/crypto/rc2/rc2test.c Tue Apr 27 00:14:28 1999
+++ openssl-0.9.4-mod/crypto/rc2/rc2test.c Wed Sep 15 08:40:31 1999
@@ -72,7 +72,7 @@
#else
#include <openssl/rc2.h>
-unsigned char RC2key[4][16]={
+static unsigned char RC2key[4][16]={
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
@@ -83,14 +83,14 @@
0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F},
};
-unsigned char RC2plain[4][8]={
+static unsigned char RC2plain[4][8]={
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
};
-unsigned char RC2cipher[4][8]={
+static unsigned char RC2cipher[4][8]={
{0x1C,0x19,0x8A,0x83,0x8D,0xF0,0x28,0xB7},
{0x21,0x82,0x9C,0x78,0xA9,0xF9,0xC0,0x74},
{0x13,0xDB,0x35,0x17,0xD3,0x21,0x86,0x9E},
--- openssl-0.9.4/crypto/rc5/rc5test.c Tue Apr 27 00:14:32 1999
+++ openssl-0.9.4-mod/crypto/rc5/rc5test.c Wed Sep 15 08:42:16 1999
@@ -72,7 +72,7 @@
#else
#include <openssl/rc5.h>
-unsigned char RC5key[5][16]={
+static unsigned char RC5key[5][16]={
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x91,0x5f,0x46,0x19,0xbe,0x41,0xb2,0x51,
@@ -85,7 +85,7 @@
0x24,0x97,0x57,0x4d,0x7f,0x15,0x31,0x25},
};
-unsigned char RC5plain[5][8]={
+static unsigned char RC5plain[5][8]={
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x21,0xA5,0xDB,0xEE,0x15,0x4B,0x8F,0x6D},
{0xF7,0xC0,0x13,0xAC,0x5B,0x2B,0x89,0x52},
@@ -93,7 +93,7 @@
{0x65,0xC1,0x78,0xB2,0x84,0xD1,0x97,0xCC},
};
-unsigned char RC5cipher[5][8]={
+static unsigned char RC5cipher[5][8]={
{0x21,0xA5,0xDB,0xEE,0x15,0x4B,0x8F,0x6D},
{0xF7,0xC0,0x13,0xAC,0x5B,0x2B,0x89,0x52},
{0x2F,0x42,0xB3,0xB7,0x03,0x69,0xFC,0x92},
@@ -102,7 +102,7 @@
};
#define RC5_CBC_NUM 27
-unsigned char rc5_cbc_cipher[RC5_CBC_NUM][8]={
+static unsigned char rc5_cbc_cipher[RC5_CBC_NUM][8]={
{0x7a,0x7b,0xba,0x4d,0x79,0x11,0x1d,0x1e},
{0x79,0x7b,0xba,0x4d,0x78,0x11,0x1d,0x1e},
{0x7a,0x7b,0xba,0x4d,0x79,0x11,0x1d,0x1f},
@@ -132,7 +132,7 @@
{0x7f,0xd1,0xa0,0x23,0xa5,0xbb,0xa2,0x17},
};
-unsigned char rc5_cbc_key[RC5_CBC_NUM][17]={
+static unsigned char rc5_cbc_key[RC5_CBC_NUM][17]={
{ 1,0x00},
{ 1,0x00},
{ 1,0x00},
@@ -165,7 +165,7 @@
{ 5,0x01,0x02,0x03,0x04,0x05},
};
-unsigned char rc5_cbc_plain[RC5_CBC_NUM][8]={
+static unsigned char rc5_cbc_plain[RC5_CBC_NUM][8]={
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
@@ -195,14 +195,14 @@
{0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x01},
};
-int rc5_cbc_rounds[RC5_CBC_NUM]={
+static int rc5_cbc_rounds[RC5_CBC_NUM]={
0, 0, 0, 0, 0, 1, 2, 2,
8, 8,12,16, 8,12,16,12,
8,12,16, 8,12,16,12, 8,
8, 8, 8,
};
-unsigned char rc5_cbc_iv[RC5_CBC_NUM][8]={
+static unsigned char rc5_cbc_iv[RC5_CBC_NUM][8]={
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01},
______________________________________________________________________
OpenSSL Project http://www.openssl.org
Development Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]