aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/openssl/crypto
diff options
context:
space:
mode:
authorKris Kennaway <kris@FreeBSD.org>2001-05-20 03:07:21 +0000
committerKris Kennaway <kris@FreeBSD.org>2001-05-20 03:07:21 +0000
commit5740a5e34c49bfc6885d8602958155fc91b62765 (patch)
treeaf21ae7d0d7d432ead379f1689adfee9ffe965f6 /crypto/openssl/crypto
parentde7cdddab120ecc07d412749bfb3f191c4e0afe3 (diff)
downloadsrc-5740a5e34c49bfc6885d8602958155fc91b62765.tar.gz
src-5740a5e34c49bfc6885d8602958155fc91b62765.zip
Initial import of OpenSSL 0.9.6a
Notes
Notes: svn path=/vendor-crypto/openssl/dist/; revision=76866
Diffstat (limited to 'crypto/openssl/crypto')
-rw-r--r--crypto/openssl/crypto/Makefile.ssl7
-rw-r--r--crypto/openssl/crypto/asn1/asn1_lib.c2
-rw-r--r--crypto/openssl/crypto/asn1/p7_lib.c2
-rw-r--r--crypto/openssl/crypto/asn1/x_name.c6
-rw-r--r--crypto/openssl/crypto/bn/asm/mips3.s8
-rw-r--r--crypto/openssl/crypto/bn/bn.h2
-rw-r--r--crypto/openssl/crypto/bn/bn_div.c1
-rw-r--r--crypto/openssl/crypto/bn/bn_rand.c63
-rw-r--r--crypto/openssl/crypto/bn/bntest.c62
-rw-r--r--crypto/openssl/crypto/crypto.h2
-rw-r--r--crypto/openssl/crypto/des/asm/des-586.pl4
-rw-r--r--crypto/openssl/crypto/des/asm/des686.pl2
-rw-r--r--crypto/openssl/crypto/des/asm/readme2
-rw-r--r--crypto/openssl/crypto/des/cbc_cksm.c2
-rw-r--r--crypto/openssl/crypto/des/cfb64enc.c4
-rw-r--r--crypto/openssl/crypto/des/cfb_enc.c4
-rw-r--r--crypto/openssl/crypto/des/des.h8
-rw-r--r--crypto/openssl/crypto/des/des_enc.c2
-rw-r--r--crypto/openssl/crypto/des/des_opts.c48
-rw-r--r--crypto/openssl/crypto/des/dess.cpp18
-rw-r--r--crypto/openssl/crypto/des/ecb_enc.c2
-rw-r--r--crypto/openssl/crypto/des/ede_cbcm_enc.c16
-rw-r--r--crypto/openssl/crypto/des/ncbc_enc.c8
-rw-r--r--crypto/openssl/crypto/des/ofb64enc.c2
-rw-r--r--crypto/openssl/crypto/des/ofb_enc.c2
-rw-r--r--crypto/openssl/crypto/des/pcbc_enc.c4
-rw-r--r--crypto/openssl/crypto/des/speed.c4
-rw-r--r--crypto/openssl/crypto/des/xcbc_enc.c8
-rw-r--r--crypto/openssl/crypto/dh/dh_key.c11
-rw-r--r--crypto/openssl/crypto/dh/dh_lib.c8
-rw-r--r--crypto/openssl/crypto/dsa/dsa_key.c13
-rw-r--r--crypto/openssl/crypto/dsa/dsa_lib.c8
-rw-r--r--crypto/openssl/crypto/dso/dso_dl.c19
-rw-r--r--crypto/openssl/crypto/ebcdic.c2
-rw-r--r--crypto/openssl/crypto/err/err.c20
-rw-r--r--crypto/openssl/crypto/mdc2/mdc2dgst.c4
-rw-r--r--crypto/openssl/crypto/mem_dbg.c88
-rw-r--r--crypto/openssl/crypto/opensslv.h4
-rw-r--r--crypto/openssl/crypto/pkcs12/p12_key.c11
-rw-r--r--crypto/openssl/crypto/pkcs12/p12_kiss.c1
-rw-r--r--crypto/openssl/crypto/pkcs7/pk7_doit.c13
-rw-r--r--crypto/openssl/crypto/pkcs7/pk7_smime.c13
-rw-r--r--crypto/openssl/crypto/rand/md_rand.c4
-rw-r--r--crypto/openssl/crypto/rand/rand.h4
-rw-r--r--crypto/openssl/crypto/rand/rand_egd.c7
-rw-r--r--crypto/openssl/crypto/rand/rand_win.c6
-rw-r--r--crypto/openssl/crypto/rand/randfile.c28
-rw-r--r--crypto/openssl/crypto/rsa/rsa_eay.c12
-rw-r--r--crypto/openssl/crypto/rsa/rsa_lib.c10
-rw-r--r--crypto/openssl/crypto/uid.c88
-rw-r--r--crypto/openssl/crypto/x509/x509_cmp.c18
-rw-r--r--crypto/openssl/crypto/x509v3/v3_alt.c2
52 files changed, 432 insertions, 257 deletions
diff --git a/crypto/openssl/crypto/Makefile.ssl b/crypto/openssl/crypto/Makefile.ssl
index ae761da79f84..97984f8e8355 100644
--- a/crypto/openssl/crypto/Makefile.ssl
+++ b/crypto/openssl/crypto/Makefile.ssl
@@ -34,8 +34,8 @@ SDIRS= md2 md5 sha mdc2 hmac ripemd \
GENERAL=Makefile README crypto-lib.com install.com
LIB= $(TOP)/libcrypto.a
-LIBSRC= cryptlib.c mem.c mem_dbg.c cversion.c ex_data.c tmdiff.c cpt_err.c ebcdic.c
-LIBOBJ= cryptlib.o mem.o mem_dbg.o cversion.o ex_data.o tmdiff.o cpt_err.o ebcdic.o
+LIBSRC= cryptlib.c mem.c mem_dbg.c cversion.c ex_data.c tmdiff.c cpt_err.c ebcdic.c uid.c
+LIBOBJ= cryptlib.o mem.o mem_dbg.o cversion.o ex_data.o tmdiff.o cpt_err.o ebcdic.o uid.o
SRC= $(LIBSRC)
@@ -198,3 +198,6 @@ tmdiff.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
tmdiff.o: ../include/openssl/opensslv.h ../include/openssl/safestack.h
tmdiff.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
tmdiff.o: ../include/openssl/tmdiff.h cryptlib.h
+uid.o: ../include/openssl/crypto.h ../include/openssl/opensslv.h
+uid.o: ../include/openssl/safestack.h ../include/openssl/stack.h
+uid.o: ../include/openssl/symhacks.h
diff --git a/crypto/openssl/crypto/asn1/asn1_lib.c b/crypto/openssl/crypto/asn1/asn1_lib.c
index 77447a524095..a8b651e54e7c 100644
--- a/crypto/openssl/crypto/asn1/asn1_lib.c
+++ b/crypto/openssl/crypto/asn1/asn1_lib.c
@@ -301,7 +301,7 @@ int asn1_GetSequence(ASN1_CTX *c, long *length)
return(0);
}
if (c->inf == (1|V_ASN1_CONSTRUCTED))
- c->slen= *length+ *(c->pp)-c->p;
+ c->slen= *length;
c->eos=0;
return(1);
}
diff --git a/crypto/openssl/crypto/asn1/p7_lib.c b/crypto/openssl/crypto/asn1/p7_lib.c
index b1196ef581ce..8a340b01190e 100644
--- a/crypto/openssl/crypto/asn1/p7_lib.c
+++ b/crypto/openssl/crypto/asn1/p7_lib.c
@@ -307,12 +307,14 @@ PKCS7 *d2i_PKCS7(PKCS7 **a, unsigned char **pp, long length)
}
if (Tinf == (1|V_ASN1_CONSTRUCTED))
{
+ c.q=c.p;
if (!ASN1_check_infinite_end(&c.p,c.slen))
{
c.error=ERR_R_MISSING_ASN1_EOS;
c.line=__LINE__;
goto err;
}
+ c.slen-=(c.p-c.q);
}
}
else
diff --git a/crypto/openssl/crypto/asn1/x_name.c b/crypto/openssl/crypto/asn1/x_name.c
index b832deb928b0..1885d699efd5 100644
--- a/crypto/openssl/crypto/asn1/x_name.c
+++ b/crypto/openssl/crypto/asn1/x_name.c
@@ -141,10 +141,12 @@ static int i2d_X509_NAME_entries(X509_NAME *a)
}
size+=i2d_X509_NAME_ENTRY(ne,NULL);
}
-
- ret+=ASN1_object_size(1,size,V_ASN1_SET);
if (fe != NULL)
+ {
+ /* SET OF needed only if entries is non empty */
+ ret+=ASN1_object_size(1,size,V_ASN1_SET);
fe->size=size;
+ }
r=ASN1_object_size(1,ret,V_ASN1_SEQUENCE);
diff --git a/crypto/openssl/crypto/bn/asm/mips3.s b/crypto/openssl/crypto/bn/asm/mips3.s
index 2df4dcd4b0bf..45786c00a5f3 100644
--- a/crypto/openssl/crypto/bn/asm/mips3.s
+++ b/crypto/openssl/crypto/bn/asm/mips3.s
@@ -586,13 +586,13 @@ LEAF(bn_div_3_words)
ld a0,(a3)
move ta2,a1
ld a1,-8(a3)
- move ta3,ra
- move v1,zero
+ bne a0,a2,.L_bn_div_3_words_proceed
li v0,-1
- beq a0,a2,.L_bn_div_3_words_skip_div
+ jr ra
+.L_bn_div_3_words_proceed:
+ move ta3,ra
bal bn_div_words
move ra,ta3
-.L_bn_div_3_words_skip_div:
dmultu ta2,v0
ld t2,-16(a3)
move ta0,zero
diff --git a/crypto/openssl/crypto/bn/bn.h b/crypto/openssl/crypto/bn/bn.h
index ef1cfb0259b9..b232c2ceae3e 100644
--- a/crypto/openssl/crypto/bn/bn.h
+++ b/crypto/openssl/crypto/bn/bn.h
@@ -468,6 +468,8 @@ BN_ULONG bn_sub_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int num);
# define bn_dump(a,b)
#endif
+int BN_bntest_rand(BIGNUM *rnd, int bits, int top,int bottom);
+
/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
* made after this point may be overwritten when the script is next run.
diff --git a/crypto/openssl/crypto/bn/bn_div.c b/crypto/openssl/crypto/bn/bn_div.c
index 891b6026311c..c328b5b4110b 100644
--- a/crypto/openssl/crypto/bn/bn_div.c
+++ b/crypto/openssl/crypto/bn/bn_div.c
@@ -238,6 +238,7 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
{
BN_ULONG q,l0;
#if defined(BN_DIV3W) && !defined(NO_ASM)
+ BN_ULONG bn_div_3_words(BN_ULONG*,BN_ULONG,BN_ULONG);
q=bn_div_3_words(wnump,d1,d0);
#else
BN_ULONG n0,n1,rem=0;
diff --git a/crypto/openssl/crypto/bn/bn_rand.c b/crypto/openssl/crypto/bn/bn_rand.c
index 224a0ff7a2c3..acd06199218b 100644
--- a/crypto/openssl/crypto/bn/bn_rand.c
+++ b/crypto/openssl/crypto/bn/bn_rand.c
@@ -76,7 +76,7 @@ static int bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom)
bytes=(bits+7)/8;
bit=(bits-1)%8;
- mask=0xff<<bit;
+ mask=0xff<<(bit+1);
buf=(unsigned char *)OPENSSL_malloc(bytes);
if (buf == NULL)
@@ -100,25 +100,48 @@ static int bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom)
goto err;
}
- if (top)
+#if 1
+ if (pseudorand == 2)
{
- if (bit == 0)
+ /* generate patterns that are more likely to trigger BN
+ library bugs */
+ int i;
+ unsigned char c;
+
+ for (i = 0; i < bytes; i++)
{
- buf[0]=1;
- buf[1]|=0x80;
+ RAND_pseudo_bytes(&c, 1);
+ if (c >= 128 && i > 0)
+ buf[i] = buf[i-1];
+ else if (c < 42)
+ buf[i] = 0;
+ else if (c < 84)
+ buf[i] = 255;
+ }
+ }
+#endif
+
+ if (top != -1)
+ {
+ if (top)
+ {
+ if (bit == 0)
+ {
+ buf[0]=1;
+ buf[1]|=0x80;
+ }
+ else
+ {
+ buf[0]|=(3<<(bit-1));
+ }
}
else
{
- buf[0]|=(3<<(bit-1));
- buf[0]&= ~(mask<<1);
+ buf[0]|=(1<<bit);
}
}
- else
- {
- buf[0]|=(1<<bit);
- buf[0]&= ~(mask<<1);
- }
- if (bottom) /* set bottom bits to whatever odd is */
+ buf[0] &= ~mask;
+ if (bottom) /* set bottom bit if requested */
buf[bytes-1]|=1;
if (!BN_bin2bn(buf,bytes,rnd)) goto err;
ret=1;
@@ -141,6 +164,13 @@ int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom)
return bnrand(1, rnd, bits, top, bottom);
}
+#if 1
+int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom)
+ {
+ return bnrand(2, rnd, bits, top, bottom);
+ }
+#endif
+
/* random number r: 0 <= r < range */
int BN_rand_range(BIGNUM *r, BIGNUM *range)
{
@@ -153,7 +183,7 @@ int BN_rand_range(BIGNUM *r, BIGNUM *range)
}
n = BN_num_bits(range); /* n > 0 */
-
+
if (n == 1)
{
if (!BN_zero(r)) return 0;
@@ -163,7 +193,7 @@ int BN_rand_range(BIGNUM *r, BIGNUM *range)
do
{
/* range = 11..._2, so each iteration succeeds with probability >= .75 */
- if (!BN_rand(r, n, 0, 0)) return 0;
+ if (!BN_rand(r, n, -1, 0)) return 0;
}
while (BN_cmp(r, range) >= 0);
}
@@ -173,7 +203,7 @@ int BN_rand_range(BIGNUM *r, BIGNUM *range)
* so 3*range (= 11..._2) is exactly one bit longer than range */
do
{
- if (!BN_rand(r, n + 1, 0, 0)) return 0;
+ if (!BN_rand(r, n + 1, -1, 0)) return 0;
/* If r < 3*range, use r := r MOD range
* (which is either r, r - range, or r - 2*range).
* Otherwise, iterate once more.
@@ -191,4 +221,3 @@ int BN_rand_range(BIGNUM *r, BIGNUM *range)
return 1;
}
-
diff --git a/crypto/openssl/crypto/bn/bntest.c b/crypto/openssl/crypto/bn/bntest.c
index c9801dc01614..af0c2629e87e 100644
--- a/crypto/openssl/crypto/bn/bntest.c
+++ b/crypto/openssl/crypto/bn/bntest.c
@@ -120,9 +120,7 @@ int main(int argc, char *argv[])
results = 0;
- RAND_seed(rnd_seed, sizeof rnd_seed); /* or BN_rand may fail, and we don't
- * even check its return value
- * (which we should) */
+ RAND_seed(rnd_seed, sizeof rnd_seed); /* or BN_generate_prime may fail */
argc--;
argv++;
@@ -251,10 +249,10 @@ int test_add(BIO *bp)
BN_init(&b);
BN_init(&c);
- BN_rand(&a,512,0,0);
+ BN_bntest_rand(&a,512,0,0);
for (i=0; i<num0; i++)
{
- BN_rand(&b,450+i,0,0);
+ BN_bntest_rand(&b,450+i,0,0);
a.neg=rand_neg();
b.neg=rand_neg();
if (bp == NULL)
@@ -303,14 +301,14 @@ int test_sub(BIO *bp)
{
if (i < num1)
{
- BN_rand(&a,512,0,0);
+ BN_bntest_rand(&a,512,0,0);
BN_copy(&b,&a);
if (BN_set_bit(&a,i)==0) return(0);
BN_add_word(&b,i);
}
else
{
- BN_rand(&b,400+i-num1,0,0);
+ BN_bntest_rand(&b,400+i-num1,0,0);
a.neg=rand_neg();
b.neg=rand_neg();
}
@@ -360,13 +358,13 @@ int test_div(BIO *bp, BN_CTX *ctx)
{
if (i < num1)
{
- BN_rand(&a,400,0,0);
+ BN_bntest_rand(&a,400,0,0);
BN_copy(&b,&a);
BN_lshift(&a,&a,i);
BN_add_word(&a,i);
}
else
- BN_rand(&b,50+3*(i-num1),0,0);
+ BN_bntest_rand(&b,50+3*(i-num1),0,0);
a.neg=rand_neg();
b.neg=rand_neg();
if (bp == NULL)
@@ -430,13 +428,13 @@ int test_div_recp(BIO *bp, BN_CTX *ctx)
{
if (i < num1)
{
- BN_rand(&a,400,0,0);
+ BN_bntest_rand(&a,400,0,0);
BN_copy(&b,&a);
BN_lshift(&a,&a,i);
BN_add_word(&a,i);
}
else
- BN_rand(&b,50+3*(i-num1),0,0);
+ BN_bntest_rand(&b,50+3*(i-num1),0,0);
a.neg=rand_neg();
b.neg=rand_neg();
BN_RECP_CTX_set(&recp,&b,ctx);
@@ -507,11 +505,11 @@ int test_mul(BIO *bp)
{
if (i <= num1)
{
- BN_rand(&a,100,0,0);
- BN_rand(&b,100,0,0);
+ BN_bntest_rand(&a,100,0,0);
+ BN_bntest_rand(&b,100,0,0);
}
else
- BN_rand(&b,i-num1,0,0);
+ BN_bntest_rand(&b,i-num1,0,0);
a.neg=rand_neg();
b.neg=rand_neg();
if (bp == NULL)
@@ -560,7 +558,7 @@ int test_sqr(BIO *bp, BN_CTX *ctx)
for (i=0; i<num0; i++)
{
- BN_rand(&a,40+i*10,0,0);
+ BN_bntest_rand(&a,40+i*10,0,0);
a.neg=rand_neg();
if (bp == NULL)
for (j=0; j<100; j++)
@@ -611,15 +609,15 @@ int test_mont(BIO *bp, BN_CTX *ctx)
mont=BN_MONT_CTX_new();
- BN_rand(&a,100,0,0); /**/
- BN_rand(&b,100,0,0); /**/
+ BN_bntest_rand(&a,100,0,0); /**/
+ BN_bntest_rand(&b,100,0,0); /**/
for (i=0; i<num2; i++)
{
int bits = (200*(i+1))/num2;
if (bits == 0)
continue;
- BN_rand(&n,bits,0,1);
+ BN_bntest_rand(&n,bits,0,1);
BN_MONT_CTX_set(mont,&n,ctx);
BN_to_montgomery(&A,&a,mont,ctx);
@@ -681,10 +679,10 @@ int test_mod(BIO *bp, BN_CTX *ctx)
d=BN_new();
e=BN_new();
- BN_rand(a,1024,0,0); /**/
+ BN_bntest_rand(a,1024,0,0); /**/
for (i=0; i<num0; i++)
{
- BN_rand(b,450+i*10,0,0); /**/
+ BN_bntest_rand(b,450+i*10,0,0); /**/
a->neg=rand_neg();
b->neg=rand_neg();
if (bp == NULL)
@@ -730,11 +728,11 @@ int test_mod_mul(BIO *bp, BN_CTX *ctx)
d=BN_new();
e=BN_new();
- BN_rand(c,1024,0,0); /**/
+ BN_bntest_rand(c,1024,0,0); /**/
for (i=0; i<num0; i++)
{
- BN_rand(a,475+i*10,0,0); /**/
- BN_rand(b,425+i*11,0,0); /**/
+ BN_bntest_rand(a,475+i*10,0,0); /**/
+ BN_bntest_rand(b,425+i*11,0,0); /**/
a->neg=rand_neg();
b->neg=rand_neg();
/* if (bp == NULL)
@@ -792,11 +790,11 @@ int test_mod_exp(BIO *bp, BN_CTX *ctx)
d=BN_new();
e=BN_new();
- BN_rand(c,30,0,1); /* must be odd for montgomery */
+ BN_bntest_rand(c,30,0,1); /* must be odd for montgomery */
for (i=0; i<num2; i++)
{
- BN_rand(a,20+i*5,0,0); /**/
- BN_rand(b,2+i,0,0); /**/
+ BN_bntest_rand(a,20+i*5,0,0); /**/
+ BN_bntest_rand(b,2+i,0,0); /**/
if (!BN_mod_exp(d,a,b,c,ctx))
return(00);
@@ -846,8 +844,8 @@ int test_exp(BIO *bp, BN_CTX *ctx)
for (i=0; i<num2; i++)
{
- BN_rand(a,20+i*5,0,0); /**/
- BN_rand(b,2+i,0,0); /**/
+ BN_bntest_rand(a,20+i*5,0,0); /**/
+ BN_bntest_rand(b,2+i,0,0); /**/
if (!BN_exp(d,a,b,ctx))
return(00);
@@ -897,7 +895,7 @@ int test_lshift(BIO *bp,BN_CTX *ctx,BIGNUM *a_)
else
{
a=BN_new();
- BN_rand(a,200,0,0); /**/
+ BN_bntest_rand(a,200,0,0); /**/
a->neg=rand_neg();
}
for (i=0; i<num0; i++)
@@ -949,7 +947,7 @@ int test_lshift1(BIO *bp)
b=BN_new();
c=BN_new();
- BN_rand(a,200,0,0); /**/
+ BN_bntest_rand(a,200,0,0); /**/
a->neg=rand_neg();
for (i=0; i<num0; i++)
{
@@ -993,7 +991,7 @@ int test_rshift(BIO *bp,BN_CTX *ctx)
e=BN_new();
BN_one(c);
- BN_rand(a,200,0,0); /**/
+ BN_bntest_rand(a,200,0,0); /**/
a->neg=rand_neg();
for (i=0; i<num0; i++)
{
@@ -1036,7 +1034,7 @@ int test_rshift1(BIO *bp)
b=BN_new();
c=BN_new();
- BN_rand(a,200,0,0); /**/
+ BN_bntest_rand(a,200,0,0); /**/
a->neg=rand_neg();
for (i=0; i<num0; i++)
{
diff --git a/crypto/openssl/crypto/crypto.h b/crypto/openssl/crypto/crypto.h
index df6ccaff6d6b..09ae4cb89d8f 100644
--- a/crypto/openssl/crypto/crypto.h
+++ b/crypto/openssl/crypto/crypto.h
@@ -277,6 +277,8 @@ int CRYPTO_is_mem_check_on(void);
const char *SSLeay_version(int type);
unsigned long SSLeay(void);
+int OPENSSL_issetugid(void);
+
int CRYPTO_get_ex_new_index(int idx, STACK_OF(CRYPTO_EX_DATA_FUNCS) **skp, long argl, void *argp,
CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);
diff --git a/crypto/openssl/crypto/des/asm/des-586.pl b/crypto/openssl/crypto/des/asm/des-586.pl
index f05407107783..c890766bc9ff 100644
--- a/crypto/openssl/crypto/des/asm/des-586.pl
+++ b/crypto/openssl/crypto/des/asm/des-586.pl
@@ -20,11 +20,11 @@ $L="edi";
$R="esi";
&external_label("des_SPtrans");
-&des_encrypt("des_encrypt",1);
+&des_encrypt("des_encrypt1",1);
&des_encrypt("des_encrypt2",0);
&des_encrypt3("des_encrypt3",1);
&des_encrypt3("des_decrypt3",0);
-&cbc("des_ncbc_encrypt","des_encrypt","des_encrypt",0,4,5,3,5,-1);
+&cbc("des_ncbc_encrypt","des_encrypt1","des_encrypt1",0,4,5,3,5,-1);
&cbc("des_ede3_cbc_encrypt","des_encrypt3","des_decrypt3",0,6,7,3,4,5);
&asm_finish();
diff --git a/crypto/openssl/crypto/des/asm/des686.pl b/crypto/openssl/crypto/des/asm/des686.pl
index 77dc5b51cdf9..84c3e8543814 100644
--- a/crypto/openssl/crypto/des/asm/des686.pl
+++ b/crypto/openssl/crypto/des/asm/des686.pl
@@ -46,7 +46,7 @@ EOF
$L="edi";
$R="esi";
-&des_encrypt("des_encrypt",1);
+&des_encrypt("des_encrypt1",1);
&des_encrypt("des_encrypt2",0);
&des_encrypt3("des_encrypt3",1);
diff --git a/crypto/openssl/crypto/des/asm/readme b/crypto/openssl/crypto/des/asm/readme
index f8529d9307eb..1beafe253b17 100644
--- a/crypto/openssl/crypto/des/asm/readme
+++ b/crypto/openssl/crypto/des/asm/readme
@@ -8,7 +8,7 @@ assembler for the inner DES routines in libdes :-).
The file to implement in assembler is des_enc.c. Replace the following
4 functions
-des_encrypt(DES_LONG data[2],des_key_schedule ks, int encrypt);
+des_encrypt1(DES_LONG data[2],des_key_schedule ks, int encrypt);
des_encrypt2(DES_LONG data[2],des_key_schedule ks, int encrypt);
des_encrypt3(DES_LONG data[2],des_key_schedule ks1,ks2,ks3);
des_decrypt3(DES_LONG data[2],des_key_schedule ks1,ks2,ks3);
diff --git a/crypto/openssl/crypto/des/cbc_cksm.c b/crypto/openssl/crypto/des/cbc_cksm.c
index 1e543cb2a19d..b857df09852a 100644
--- a/crypto/openssl/crypto/des/cbc_cksm.c
+++ b/crypto/openssl/crypto/des/cbc_cksm.c
@@ -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];
diff --git a/crypto/openssl/crypto/des/cfb64enc.c b/crypto/openssl/crypto/des/cfb64enc.c
index 389a232cb36b..105530dfa3ba 100644
--- a/crypto/openssl/crypto/des/cfb64enc.c
+++ b/crypto/openssl/crypto/des/cfb64enc.c
@@ -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);
diff --git a/crypto/openssl/crypto/des/cfb_enc.c b/crypto/openssl/crypto/des/cfb_enc.c
index cca34dd7c5ec..ec4fd4ea67ba 100644
--- a/crypto/openssl/crypto/des/cfb_enc.c
+++ b/crypto/openssl/crypto/des/cfb_enc.c
@@ -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
diff --git a/crypto/openssl/crypto/des/des.h b/crypto/openssl/crypto/des/des.h
index 2db9748cb410..6b8a7ee11b1d 100644
--- a/crypto/openssl/crypto/des/des.h
+++ b/crypto/openssl/crypto/des/des.h
@@ -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,
diff --git a/crypto/openssl/crypto/des/des_enc.c b/crypto/openssl/crypto/des/des_enc.c
index 8311e106281c..0bd9fa39bcd4 100644
--- a/crypto/openssl/crypto/des/des_enc.c
+++ b/crypto/openssl/crypto/des/des_enc.c
@@ -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
diff --git a/crypto/openssl/crypto/des/des_opts.c b/crypto/openssl/crypto/des/des_opts.c
index b2ca7ac31d6c..138ee1c6b47b 100644
--- a/crypto/openssl/crypto/des/des_opts.c
+++ b/crypto/openssl/crypto/des/des_opts.c
@@ -118,7 +118,7 @@ extern void exit();
#undef DES_RISC2
#undef DES_PTR
#undef D_ENCRYPT
-#define des_encrypt des_encrypt_u4_cisc_idx
+#define des_encrypt1 des_encrypt_u4_cisc_idx
#define des_encrypt2 des_encrypt2_u4_cisc_idx
#define des_encrypt3 des_encrypt3_u4_cisc_idx
#define des_decrypt3 des_decrypt3_u4_cisc_idx
@@ -130,11 +130,11 @@ extern void exit();
#undef DES_RISC2
#undef DES_PTR
#undef D_ENCRYPT
-#undef des_encrypt
+#undef des_encrypt1
#undef des_encrypt2
#undef des_encrypt3
#undef des_decrypt3
-#define des_encrypt des_encrypt_u16_cisc_idx
+#define des_encrypt1 des_encrypt_u16_cisc_idx
#define des_encrypt2 des_encrypt2_u16_cisc_idx
#define des_encrypt3 des_encrypt3_u16_cisc_idx
#define des_decrypt3 des_decrypt3_u16_cisc_idx
@@ -146,11 +146,11 @@ extern void exit();
#undef DES_RISC2
#undef DES_PTR
#undef D_ENCRYPT
-#undef des_encrypt
+#undef des_encrypt1
#undef des_encrypt2
#undef des_encrypt3
#undef des_decrypt3
-#define des_encrypt des_encrypt_u4_risc1_idx
+#define des_encrypt1 des_encrypt_u4_risc1_idx
#define des_encrypt2 des_encrypt2_u4_risc1_idx
#define des_encrypt3 des_encrypt3_u4_risc1_idx
#define des_decrypt3 des_decrypt3_u4_risc1_idx
@@ -166,11 +166,11 @@ extern void exit();
#define DES_RISC2
#undef DES_PTR
#undef D_ENCRYPT
-#undef des_encrypt
+#undef des_encrypt1
#undef des_encrypt2
#undef des_encrypt3
#undef des_decrypt3
-#define des_encrypt des_encrypt_u4_risc2_idx
+#define des_encrypt1 des_encrypt_u4_risc2_idx
#define des_encrypt2 des_encrypt2_u4_risc2_idx
#define des_encrypt3 des_encrypt3_u4_risc2_idx
#define des_decrypt3 des_decrypt3_u4_risc2_idx
@@ -182,11 +182,11 @@ extern void exit();
#undef DES_RISC2
#undef DES_PTR
#undef D_ENCRYPT
-#undef des_encrypt
+#undef des_encrypt1
#undef des_encrypt2
#undef des_encrypt3
#undef des_decrypt3
-#define des_encrypt des_encrypt_u16_risc1_idx
+#define des_encrypt1 des_encrypt_u16_risc1_idx
#define des_encrypt2 des_encrypt2_u16_risc1_idx
#define des_encrypt3 des_encrypt3_u16_risc1_idx
#define des_decrypt3 des_decrypt3_u16_risc1_idx
@@ -198,11 +198,11 @@ extern void exit();
#define DES_RISC2
#undef DES_PTR
#undef D_ENCRYPT
-#undef des_encrypt
+#undef des_encrypt1
#undef des_encrypt2
#undef des_encrypt3
#undef des_decrypt3
-#define des_encrypt des_encrypt_u16_risc2_idx
+#define des_encrypt1 des_encrypt_u16_risc2_idx
#define des_encrypt2 des_encrypt2_u16_risc2_idx
#define des_encrypt3 des_encrypt3_u16_risc2_idx
#define des_decrypt3 des_decrypt3_u16_risc2_idx
@@ -218,11 +218,11 @@ extern void exit();
#undef DES_RISC2
#define DES_PTR
#undef D_ENCRYPT
-#undef des_encrypt
+#undef des_encrypt1
#undef des_encrypt2
#undef des_encrypt3
#undef des_decrypt3
-#define des_encrypt des_encrypt_u4_cisc_ptr
+#define des_encrypt1 des_encrypt_u4_cisc_ptr
#define des_encrypt2 des_encrypt2_u4_cisc_ptr
#define des_encrypt3 des_encrypt3_u4_cisc_ptr
#define des_decrypt3 des_decrypt3_u4_cisc_ptr
@@ -234,11 +234,11 @@ extern void exit();
#undef DES_RISC2
#define DES_PTR
#undef D_ENCRYPT
-#undef des_encrypt
+#undef des_encrypt1
#undef des_encrypt2
#undef des_encrypt3
#undef des_decrypt3
-#define des_encrypt des_encrypt_u16_cisc_ptr
+#define des_encrypt1 des_encrypt_u16_cisc_ptr
#define des_encrypt2 des_encrypt2_u16_cisc_ptr
#define des_encrypt3 des_encrypt3_u16_cisc_ptr
#define des_decrypt3 des_decrypt3_u16_cisc_ptr
@@ -250,11 +250,11 @@ extern void exit();
#undef DES_RISC2
#define DES_PTR
#undef D_ENCRYPT
-#undef des_encrypt
+#undef des_encrypt1
#undef des_encrypt2
#undef des_encrypt3
#undef des_decrypt3
-#define des_encrypt des_encrypt_u4_risc1_ptr
+#define des_encrypt1 des_encrypt_u4_risc1_ptr
#define des_encrypt2 des_encrypt2_u4_risc1_ptr
#define des_encrypt3 des_encrypt3_u4_risc1_ptr
#define des_decrypt3 des_decrypt3_u4_risc1_ptr
@@ -270,11 +270,11 @@ extern void exit();
#define DES_RISC2
#define DES_PTR
#undef D_ENCRYPT
-#undef des_encrypt
+#undef des_encrypt1
#undef des_encrypt2
#undef des_encrypt3
#undef des_decrypt3
-#define des_encrypt des_encrypt_u4_risc2_ptr
+#define des_encrypt1 des_encrypt_u4_risc2_ptr
#define des_encrypt2 des_encrypt2_u4_risc2_ptr
#define des_encrypt3 des_encrypt3_u4_risc2_ptr
#define des_decrypt3 des_decrypt3_u4_risc2_ptr
@@ -286,11 +286,11 @@ extern void exit();
#undef DES_RISC2
#define DES_PTR
#undef D_ENCRYPT
-#undef des_encrypt
+#undef des_encrypt1
#undef des_encrypt2
#undef des_encrypt3
#undef des_decrypt3
-#define des_encrypt des_encrypt_u16_risc1_ptr
+#define des_encrypt1 des_encrypt_u16_risc1_ptr
#define des_encrypt2 des_encrypt2_u16_risc1_ptr
#define des_encrypt3 des_encrypt3_u16_risc1_ptr
#define des_decrypt3 des_decrypt3_u16_risc1_ptr
@@ -302,11 +302,11 @@ extern void exit();
#define DES_RISC2
#define DES_PTR
#undef D_ENCRYPT
-#undef des_encrypt
+#undef des_encrypt1
#undef des_encrypt2
#undef des_encrypt3
#undef des_decrypt3
-#define des_encrypt des_encrypt_u16_risc2_ptr
+#define des_encrypt1 des_encrypt_u16_risc2_ptr
#define des_encrypt2 des_encrypt2_u16_risc2_ptr
#define des_encrypt3 des_encrypt3_u16_risc2_ptr
#define des_decrypt3 des_decrypt3_u16_risc2_ptr
@@ -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;
diff --git a/crypto/openssl/crypto/des/dess.cpp b/crypto/openssl/crypto/des/dess.cpp
index 753e67ad9be2..5549bab90afb 100644
--- a/crypto/openssl/crypto/des/dess.cpp
+++ b/crypto/openssl/crypto/des/dess.cpp
@@ -45,19 +45,19 @@ void main(int argc,char *argv[])
{
for (i=0; i<1000; i++) /**/
{
- des_encrypt(&data[0],key,1);
+ des_encrypt1(&data[0],key,1);
GetTSC(s1);
- des_encrypt(&data[0],key,1);
- des_encrypt(&data[0],key,1);
- des_encrypt(&data[0],key,1);
+ des_encrypt1(&data[0],key,1);
+ des_encrypt1(&data[0],key,1);
+ des_encrypt1(&data[0],key,1);
GetTSC(e1);
GetTSC(s2);
- des_encrypt(&data[0],key,1);
- des_encrypt(&data[0],key,1);
- des_encrypt(&data[0],key,1);
- des_encrypt(&data[0],key,1);
+ des_encrypt1(&data[0],key,1);
+ des_encrypt1(&data[0],key,1);
+ des_encrypt1(&data[0],key,1);
+ des_encrypt1(&data[0],key,1);
GetTSC(e2);
- des_encrypt(&data[0],key,1);
+ des_encrypt1(&data[0],key,1);
}
printf("des %d %d (%d)\n",
diff --git a/crypto/openssl/crypto/des/ecb_enc.c b/crypto/openssl/crypto/des/ecb_enc.c
index b261a8aad940..d481327ef3b3 100644
--- a/crypto/openssl/crypto/des/ecb_enc.c
+++ b/crypto/openssl/crypto/des/ecb_enc.c
@@ -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;
diff --git a/crypto/openssl/crypto/des/ede_cbcm_enc.c b/crypto/openssl/crypto/des/ede_cbcm_enc.c
index c53062481ddd..b98f7e17af1d 100644
--- a/crypto/openssl/crypto/des/ede_cbcm_enc.c
+++ b/crypto/openssl/crypto/des/ede_cbcm_enc.c
@@ -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];
diff --git a/crypto/openssl/crypto/des/ncbc_enc.c b/crypto/openssl/crypto/des/ncbc_enc.c
index 3b681691a9b7..b8db07b199d6 100644
--- a/crypto/openssl/crypto/des/ncbc_enc.c
+++ b/crypto/openssl/crypto/des/ncbc_enc.c
@@ -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);
diff --git a/crypto/openssl/crypto/des/ofb64enc.c b/crypto/openssl/crypto/des/ofb64enc.c
index 64953959cab0..1a1d1f1ac470 100644
--- a/crypto/openssl/crypto/des/ofb64enc.c
+++ b/crypto/openssl/crypto/des/ofb64enc.c
@@ -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);
diff --git a/crypto/openssl/crypto/des/ofb_enc.c b/crypto/openssl/crypto/des/ofb_enc.c
index a8f425a575a1..70493e632ccf 100644
--- a/crypto/openssl/crypto/des/ofb_enc.c
+++ b/crypto/openssl/crypto/des/ofb_enc.c
@@ -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);
diff --git a/crypto/openssl/crypto/des/pcbc_enc.c b/crypto/openssl/crypto/des/pcbc_enc.c
index dd69a26d4aab..5b987f074d31 100644
--- a/crypto/openssl/crypto/des/pcbc_enc.c
+++ b/crypto/openssl/crypto/des/pcbc_enc.c
@@ -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)
diff --git a/crypto/openssl/crypto/des/speed.c b/crypto/openssl/crypto/des/speed.c
index 814b86f4aee5..1223edf29079 100644
--- a/crypto/openssl/crypto/des/speed.c
+++ b/crypto/openssl/crypto/des/speed.c
@@ -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);
diff --git a/crypto/openssl/crypto/des/xcbc_enc.c b/crypto/openssl/crypto/des/xcbc_enc.c
index 51e17e6b8a64..ccfede13aca6 100644
--- a/crypto/openssl/crypto/des/xcbc_enc.c
+++ b/crypto/openssl/crypto/des/xcbc_enc.c
@@ -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);
diff --git a/crypto/openssl/crypto/dh/dh_key.c b/crypto/openssl/crypto/dh/dh_key.c
index 6f9426dd6fc2..a6469cad2c5b 100644
--- a/crypto/openssl/crypto/dh/dh_key.c
+++ b/crypto/openssl/crypto/dh/dh_key.c
@@ -99,7 +99,6 @@ DH_METHOD *DH_OpenSSL(void)
static int generate_key(DH *dh)
{
int ok=0;
- unsigned int i;
BN_CTX ctx;
BN_MONT_CTX *mont;
BIGNUM *pub_key=NULL,*priv_key=NULL;
@@ -108,15 +107,11 @@ static int generate_key(DH *dh)
if (dh->priv_key == NULL)
{
- i=dh->length;
- if (i == 0)
- {
- /* Make the number p-1 bits long */
- i=BN_num_bits(dh->p)-1;
- }
priv_key=BN_new();
if (priv_key == NULL) goto err;
- if (!BN_rand(priv_key,i,0,0)) goto err;
+ do
+ if (!BN_rand_range(priv_key, dh->p)) goto err;
+ while (BN_is_zero(priv_key));
}
else
priv_key=dh->priv_key;
diff --git a/crypto/openssl/crypto/dh/dh_lib.c b/crypto/openssl/crypto/dh/dh_lib.c
index a8d5340bf435..8516bdafb4a3 100644
--- a/crypto/openssl/crypto/dh/dh_lib.c
+++ b/crypto/openssl/crypto/dh/dh_lib.c
@@ -120,13 +120,13 @@ DH *DH_new_method(DH_METHOD *meth)
ret->method_mont_p=NULL;
ret->references = 1;
ret->flags=ret->meth->flags;
+ CRYPTO_new_ex_data(dh_meth,ret,&ret->ex_data);
if ((ret->meth->init != NULL) && !ret->meth->init(ret))
{
+ CRYPTO_free_ex_data(dh_meth,ret,&ret->ex_data);
OPENSSL_free(ret);
ret=NULL;
}
- else
- CRYPTO_new_ex_data(dh_meth,ret,&ret->ex_data);
return(ret);
}
@@ -147,10 +147,10 @@ void DH_free(DH *r)
}
#endif
- CRYPTO_free_ex_data(dh_meth, r, &r->ex_data);
-
if(r->meth->finish) r->meth->finish(r);
+ CRYPTO_free_ex_data(dh_meth, r, &r->ex_data);
+
if (r->p != NULL) BN_clear_free(r->p);
if (r->g != NULL) BN_clear_free(r->g);
if (r->q != NULL) BN_clear_free(r->q);
diff --git a/crypto/openssl/crypto/dsa/dsa_key.c b/crypto/openssl/crypto/dsa/dsa_key.c
index af3c56d770ec..86cacfb3b9d7 100644
--- a/crypto/openssl/crypto/dsa/dsa_key.c
+++ b/crypto/openssl/crypto/dsa/dsa_key.c
@@ -68,7 +68,6 @@
int DSA_generate_key(DSA *dsa)
{
int ok=0;
- unsigned int i;
BN_CTX *ctx=NULL;
BIGNUM *pub_key=NULL,*priv_key=NULL;
@@ -81,15 +80,9 @@ int DSA_generate_key(DSA *dsa)
else
priv_key=dsa->priv_key;
- i=BN_num_bits(dsa->q);
- for (;;)
- {
- if (!BN_rand(priv_key,i,0,0))
- goto err;
- if (BN_cmp(priv_key,dsa->q) >= 0)
- BN_sub(priv_key,priv_key,dsa->q);
- if (!BN_is_zero(priv_key)) break;
- }
+ do
+ if (!BN_rand_range(priv_key,dsa->q)) goto err;
+ while (BN_is_zero(priv_key));
if (dsa->pub_key == NULL)
{
diff --git a/crypto/openssl/crypto/dsa/dsa_lib.c b/crypto/openssl/crypto/dsa/dsa_lib.c
index be30d18b8a05..5dfc0eea43ce 100644
--- a/crypto/openssl/crypto/dsa/dsa_lib.c
+++ b/crypto/openssl/crypto/dsa/dsa_lib.c
@@ -125,13 +125,13 @@ DSA *DSA_new_method(DSA_METHOD *meth)
ret->references=1;
ret->flags=ret->meth->flags;
+ CRYPTO_new_ex_data(dsa_meth,ret,&ret->ex_data);
if ((ret->meth->init != NULL) && !ret->meth->init(ret))
{
+ CRYPTO_free_ex_data(dsa_meth,ret,&ret->ex_data);
OPENSSL_free(ret);
ret=NULL;
}
- else
- CRYPTO_new_ex_data(dsa_meth,ret,&ret->ex_data);
return(ret);
}
@@ -155,10 +155,10 @@ void DSA_free(DSA *r)
}
#endif
- CRYPTO_free_ex_data(dsa_meth, r, &r->ex_data);
-
if(r->meth->finish) r->meth->finish(r);
+ CRYPTO_free_ex_data(dsa_meth, r, &r->ex_data);
+
if (r->p != NULL) BN_clear_free(r->p);
if (r->q != NULL) BN_clear_free(r->q);
if (r->g != NULL) BN_clear_free(r->g);
diff --git a/crypto/openssl/crypto/dso/dso_dl.c b/crypto/openssl/crypto/dso/dso_dl.c
index f661ec5bfb39..455bd66ecfc6 100644
--- a/crypto/openssl/crypto/dso/dso_dl.c
+++ b/crypto/openssl/crypto/dso/dso_dl.c
@@ -82,7 +82,7 @@ static int dl_unbind_func(DSO *dso, char *symname, DSO_FUNC_TYPE symptr);
static int dl_init(DSO *dso);
static int dl_finish(DSO *dso);
#endif
-static int dl_ctrl(DSO *dso, int cmd, long larg, void *parg);
+static long dl_ctrl(DSO *dso, int cmd, long larg, void *parg);
static DSO_METHOD dso_meth_dl = {
"OpenSSL 'dl' shared library method",
@@ -111,6 +111,11 @@ DSO_METHOD *DSO_METHOD_dl(void)
* type so the cast is safe.
*/
+#if defined(__hpux)
+static const char extension[] = ".sl";
+#else
+static const char extension[] = ".so";
+#endif
static int dl_load(DSO *dso, const char *filename)
{
shl_t ptr;
@@ -118,12 +123,12 @@ static int dl_load(DSO *dso, const char *filename)
int len;
/* The same comment as in dlfcn_load applies here. bleurgh. */
- len = strlen(filename);
+ len = strlen(filename) + strlen(extension);
if((dso->flags & DSO_FLAG_NAME_TRANSLATION) &&
- (len + 6 < DSO_MAX_TRANSLATED_SIZE) &&
+ (len + 3 < DSO_MAX_TRANSLATED_SIZE) &&
(strstr(filename, "/") == NULL))
{
- sprintf(translated, "lib%s.so", filename);
+ sprintf(translated, "lib%s%s", filename, extension);
ptr = shl_load(translated, BIND_IMMEDIATE, NULL);
}
else
@@ -224,7 +229,7 @@ static DSO_FUNC_TYPE dl_bind_func(DSO *dso, const char *symname)
return((DSO_FUNC_TYPE)sym);
}
-static int dl_ctrl(DSO *dso, int cmd, long larg, void *parg)
+static long dl_ctrl(DSO *dso, int cmd, long larg, void *parg)
{
if(dso == NULL)
{
@@ -236,10 +241,10 @@ static int dl_ctrl(DSO *dso, int cmd, long larg, void *parg)
case DSO_CTRL_GET_FLAGS:
return dso->flags;
case DSO_CTRL_SET_FLAGS:
- dso->flags = (int)larg;
+ dso->flags = larg;
return(0);
case DSO_CTRL_OR_FLAGS:
- dso->flags |= (int)larg;
+ dso->flags |= larg;
return(0);
default:
break;
diff --git a/crypto/openssl/crypto/ebcdic.c b/crypto/openssl/crypto/ebcdic.c
index 31397b2add77..91a7a8bcb430 100644
--- a/crypto/openssl/crypto/ebcdic.c
+++ b/crypto/openssl/crypto/ebcdic.c
@@ -211,7 +211,7 @@ ascii2ebcdic(void *dest, const void *srce, size_t count)
}
#else /*CHARSET_EBCDIC*/
-#ifdef PEDANTIC
+#if defined(PEDANTIC) || defined(VMS) || defined(__VMS)
static void *dummy=&dummy;
#endif
#endif
diff --git a/crypto/openssl/crypto/err/err.c b/crypto/openssl/crypto/err/err.c
index bfecb86c754b..be4a71ed0663 100644
--- a/crypto/openssl/crypto/err/err.c
+++ b/crypto/openssl/crypto/err/err.c
@@ -387,20 +387,18 @@ void ERR_put_error(int lib, int func, int reason, const char *file,
void ERR_clear_error(void)
{
+ int i;
ERR_STATE *es;
es=ERR_get_state();
-#if 0
- /* hmm... is this needed */
for (i=0; i<ERR_NUM_ERRORS; i++)
{
es->err_buffer[i]=0;
+ err_clear_data(es,i);
es->err_file[i]=NULL;
es->err_line[i]= -1;
- err_clear_data(es,i);
}
-#endif
es->top=es->bottom=0;
}
@@ -462,7 +460,14 @@ static unsigned long get_error_values(int inc, const char **file, int *line,
}
}
- if (data != NULL)
+ if (data == NULL)
+ {
+ if (inc)
+ {
+ err_clear_data(es, i);
+ }
+ }
+ else
{
if (es->err_data[i] == NULL)
{
@@ -747,8 +752,9 @@ void ERR_set_error_data(char *data, int flags)
if (i == 0)
i=ERR_NUM_ERRORS-1;
+ err_clear_data(es,i);
es->err_data[i]=data;
- es->err_data_flags[es->top]=flags;
+ es->err_data_flags[i]=flags;
}
void ERR_add_error_data(int num, ...)
@@ -757,7 +763,7 @@ void ERR_add_error_data(int num, ...)
int i,n,s;
char *str,*p,*a;
- s=64;
+ s=80;
str=OPENSSL_malloc(s+1);
if (str == NULL) return;
str[0]='\0';
diff --git a/crypto/openssl/crypto/mdc2/mdc2dgst.c b/crypto/openssl/crypto/mdc2/mdc2dgst.c
index c630a24c2eed..84c6c4551a16 100644
--- a/crypto/openssl/crypto/mdc2/mdc2dgst.c
+++ b/crypto/openssl/crypto/mdc2/mdc2dgst.c
@@ -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];
diff --git a/crypto/openssl/crypto/mem_dbg.c b/crypto/openssl/crypto/mem_dbg.c
index ddf4be28caa8..ef19d8f84489 100644
--- a/crypto/openssl/crypto/mem_dbg.c
+++ b/crypto/openssl/crypto/mem_dbg.c
@@ -81,7 +81,8 @@ static int mh_mode=CRYPTO_MEM_CHECK_OFF;
*/
static unsigned long order = 0; /* number of memory requests */
-static LHASH *mh=NULL; /* hash-table of memory requests (address as key) */
+static LHASH *mh=NULL; /* hash-table of memory requests (address as key);
+ * access requires MALLOC2 lock */
typedef struct app_mem_info_st
@@ -103,7 +104,8 @@ typedef struct app_mem_info_st
static LHASH *amih=NULL; /* hash-table with those app_mem_info_st's
* that are at the top of their thread's stack
- * (with `thread' as key) */
+ * (with `thread' as key);
+ * access requires MALLOC2 lock */
typedef struct mem_st
/* memory-block description */
@@ -128,7 +130,15 @@ static long options = /* extra information to be recorded */
0;
-static unsigned long disabling_thread = 0;
+static unsigned int num_disable = 0; /* num_disable > 0
+ * iff
+ * mh_mode == CRYPTO_MEM_CHECK_ON (w/o ..._ENABLE)
+ */
+static unsigned long disabling_thread = 0; /* Valid iff num_disable > 0.
+ * CRYPTO_LOCK_MALLOC2 is locked
+ * exactly in this case (by the
+ * thread named in disabling_thread).
+ */
int CRYPTO_mem_ctrl(int mode)
{
@@ -137,22 +147,23 @@ int CRYPTO_mem_ctrl(int mode)
CRYPTO_w_lock(CRYPTO_LOCK_MALLOC);
switch (mode)
{
- /* for applications: */
+ /* for applications (not to be called while multiple threads
+ * use the library): */
case CRYPTO_MEM_CHECK_ON: /* aka MemCheck_start() */
mh_mode = CRYPTO_MEM_CHECK_ON|CRYPTO_MEM_CHECK_ENABLE;
- disabling_thread = 0;
+ num_disable = 0;
break;
case CRYPTO_MEM_CHECK_OFF: /* aka MemCheck_stop() */
mh_mode = 0;
- disabling_thread = 0;
+ num_disable = 0; /* should be true *before* MemCheck_stop is used,
+ or there'll be a lot of confusion */
break;
/* switch off temporarily (for library-internal use): */
case CRYPTO_MEM_CHECK_DISABLE: /* aka MemCheck_off() */
if (mh_mode & CRYPTO_MEM_CHECK_ON)
{
- mh_mode&= ~CRYPTO_MEM_CHECK_ENABLE;
- if (disabling_thread != CRYPTO_thread_id()) /* otherwise we already have the MALLOC2 lock */
+ if (!num_disable || (disabling_thread != CRYPTO_thread_id())) /* otherwise we already have the MALLOC2 lock */
{
/* Long-time lock CRYPTO_LOCK_MALLOC2 must not be claimed while
* we're holding CRYPTO_LOCK_MALLOC, or we'll deadlock if
@@ -169,18 +180,23 @@ int CRYPTO_mem_ctrl(int mode)
* OpenSSL threads. */
CRYPTO_w_lock(CRYPTO_LOCK_MALLOC2);
CRYPTO_w_lock(CRYPTO_LOCK_MALLOC);
+ mh_mode &= ~CRYPTO_MEM_CHECK_ENABLE;
disabling_thread=CRYPTO_thread_id();
}
+ num_disable++;
}
break;
case CRYPTO_MEM_CHECK_ENABLE: /* aka MemCheck_on() */
if (mh_mode & CRYPTO_MEM_CHECK_ON)
{
- mh_mode|=CRYPTO_MEM_CHECK_ENABLE;
- if (disabling_thread != 0)
+ if (num_disable) /* always true, or something is going wrong */
{
- disabling_thread=0;
- CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC2);
+ num_disable--;
+ if (num_disable == 0)
+ {
+ mh_mode|=CRYPTO_MEM_CHECK_ENABLE;
+ CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC2);
+ }
}
}
break;
@@ -198,12 +214,12 @@ int CRYPTO_is_mem_check_on(void)
if (mh_mode & CRYPTO_MEM_CHECK_ON)
{
- CRYPTO_w_lock(CRYPTO_LOCK_MALLOC);
+ CRYPTO_r_lock(CRYPTO_LOCK_MALLOC);
ret = (mh_mode & CRYPTO_MEM_CHECK_ENABLE)
- && disabling_thread != CRYPTO_thread_id();
+ || (disabling_thread != CRYPTO_thread_id());
- CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);
+ CRYPTO_r_unlock(CRYPTO_LOCK_MALLOC);
}
return(ret);
}
@@ -293,7 +309,7 @@ int CRYPTO_push_info_(const char *info, const char *file, int line)
if (is_MemCheck_on())
{
- MemCheck_off(); /* obtains CRYPTO_LOCK_MALLOC2 */
+ MemCheck_off(); /* obtain MALLOC2 lock */
if ((ami = (APP_INFO *)OPENSSL_malloc(sizeof(APP_INFO))) == NULL)
{
@@ -330,7 +346,7 @@ int CRYPTO_push_info_(const char *info, const char *file, int line)
ami->next=amim;
}
err:
- MemCheck_on(); /* releases CRYPTO_LOCK_MALLOC2 */
+ MemCheck_on(); /* release MALLOC2 lock */
}
return(ret);
@@ -342,11 +358,11 @@ int CRYPTO_pop_info(void)
if (is_MemCheck_on()) /* _must_ be true, or something went severely wrong */
{
- MemCheck_off(); /* obtains CRYPTO_LOCK_MALLOC2 */
+ MemCheck_off(); /* obtain MALLOC2 lock */
ret=(pop_info() != NULL);
- MemCheck_on(); /* releases CRYPTO_LOCK_MALLOC2 */
+ MemCheck_on(); /* release MALLOC2 lock */
}
return(ret);
}
@@ -357,12 +373,12 @@ int CRYPTO_remove_all_info(void)
if (is_MemCheck_on()) /* _must_ be true */
{
- MemCheck_off(); /* obtains CRYPTO_LOCK_MALLOC2 */
+ MemCheck_off(); /* obtain MALLOC2 lock */
while(pop_info() != NULL)
ret++;
- MemCheck_on(); /* releases CRYPTO_LOCK_MALLOC2 */
+ MemCheck_on(); /* release MALLOC2 lock */
}
return(ret);
}
@@ -385,11 +401,12 @@ void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,
if (is_MemCheck_on())
{
- MemCheck_off(); /* obtains CRYPTO_LOCK_MALLOC2 */
+ MemCheck_off(); /* make sure we hold MALLOC2 lock */
if ((m=(MEM *)OPENSSL_malloc(sizeof(MEM))) == NULL)
{
OPENSSL_free(addr);
- MemCheck_on(); /* releases CRYPTO_LOCK_MALLOC2 */
+ MemCheck_on(); /* release MALLOC2 lock
+ * if num_disabled drops to 0 */
return;
}
if (mh == NULL)
@@ -448,7 +465,8 @@ void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,
OPENSSL_free(mm);
}
err:
- MemCheck_on(); /* releases CRYPTO_LOCK_MALLOC2 */
+ MemCheck_on(); /* release MALLOC2 lock
+ * if num_disabled drops to 0 */
}
break;
}
@@ -467,7 +485,7 @@ void CRYPTO_dbg_free(void *addr, int before_p)
if (is_MemCheck_on() && (mh != NULL))
{
- MemCheck_off();
+ MemCheck_off(); /* make sure we hold MALLOC2 lock */
m.addr=addr;
mp=(MEM *)lh_delete(mh,(char *)&m);
@@ -484,7 +502,8 @@ void CRYPTO_dbg_free(void *addr, int before_p)
OPENSSL_free(mp);
}
- MemCheck_on(); /* releases CRYPTO_LOCK_MALLOC2 */
+ MemCheck_on(); /* release MALLOC2 lock
+ * if num_disabled drops to 0 */
}
break;
case 1:
@@ -518,7 +537,7 @@ void CRYPTO_dbg_realloc(void *addr1, void *addr2, int num,
if (is_MemCheck_on())
{
- MemCheck_off(); /* obtains CRYPTO_LOCK_MALLOC2 */
+ MemCheck_off(); /* make sure we hold MALLOC2 lock */
m.addr=addr1;
mp=(MEM *)lh_delete(mh,(char *)&m);
@@ -535,7 +554,8 @@ void CRYPTO_dbg_realloc(void *addr1, void *addr2, int num,
lh_insert(mh,(char *)mp);
}
- MemCheck_on(); /* releases CRYPTO_LOCK_MALLOC2 */
+ MemCheck_on(); /* release MALLOC2 lock
+ * if num_disabled drops to 0 */
}
break;
}
@@ -642,10 +662,12 @@ void CRYPTO_mem_leaks(BIO *b)
if (mh == NULL && amih == NULL)
return;
+
+ MemCheck_off(); /* obtain MALLOC2 lock */
+
ml.bio=b;
ml.bytes=0;
ml.chunks=0;
- MemCheck_off(); /* obtains CRYPTO_LOCK_MALLOC2 */
if (mh != NULL)
lh_doall_arg(mh,(void (*)())print_leak,(char *)&ml);
if (ml.chunks != 0)
@@ -697,13 +719,7 @@ void CRYPTO_mem_leaks(BIO *b)
mh_mode = old_mh_mode;
CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);
}
- MemCheck_on(); /* releases CRYPTO_LOCK_MALLOC2 */
-
-#if 0
- lh_stats_bio(mh,b);
- lh_node_stats_bio(mh,b);
- lh_node_usage_stats_bio(mh,b);
-#endif
+ MemCheck_on(); /* release MALLOC2 lock */
}
#ifndef NO_FP_API
diff --git a/crypto/openssl/crypto/opensslv.h b/crypto/openssl/crypto/opensslv.h
index 4c644abe4400..8566730aaa16 100644
--- a/crypto/openssl/crypto/opensslv.h
+++ b/crypto/openssl/crypto/opensslv.h
@@ -25,8 +25,8 @@
* (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for
* major minor fix final patch/beta)
*/
-#define OPENSSL_VERSION_NUMBER 0x00906010L
-#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.6a-dev XX xxx XXXX"
+#define OPENSSL_VERSION_NUMBER 0x0090601fL
+#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.6a 5 Apr 2001"
#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT
diff --git a/crypto/openssl/crypto/pkcs12/p12_key.c b/crypto/openssl/crypto/pkcs12/p12_key.c
index a9b4b8c9721e..a4fd5b98ec9a 100644
--- a/crypto/openssl/crypto/pkcs12/p12_key.c
+++ b/crypto/openssl/crypto/pkcs12/p12_key.c
@@ -102,7 +102,7 @@ int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,
const EVP_MD *md_type)
{
unsigned char *B, *D, *I, *p, *Ai;
- int Slen, Plen, Ilen;
+ int Slen, Plen, Ilen, Ijlen;
int i, j, u, v;
BIGNUM *Ij, *Bpl1; /* These hold Ij and B + 1 */
EVP_MD_CTX ctx;
@@ -180,10 +180,17 @@ int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,
BN_bin2bn (I + j, v, Ij);
BN_add (Ij, Ij, Bpl1);
BN_bn2bin (Ij, B);
+ Ijlen = BN_num_bytes (Ij);
/* If more than 2^(v*8) - 1 cut off MSB */
- if (BN_num_bytes (Ij) > v) {
+ if (Ijlen > v) {
BN_bn2bin (Ij, B);
memcpy (I + j, B + 1, v);
+#ifndef PKCS12_BROKEN_KEYGEN
+ /* If less than v bytes pad with zeroes */
+ } else if (Ijlen < v) {
+ memset(I + j, 0, v - Ijlen);
+ BN_bn2bin(Ij, I + j + v - Ijlen);
+#endif
} else BN_bn2bin (Ij, I + j);
}
}
diff --git a/crypto/openssl/crypto/pkcs12/p12_kiss.c b/crypto/openssl/crypto/pkcs12/p12_kiss.c
index 1fbbd6c99f90..5d67f19b4552 100644
--- a/crypto/openssl/crypto/pkcs12/p12_kiss.c
+++ b/crypto/openssl/crypto/pkcs12/p12_kiss.c
@@ -264,6 +264,7 @@ static int parse_bag(PKCS12_SAFEBAG *bag, const char *pass, int passlen,
if (lkey) {
*keymatch |= MATCH_CERT;
if (cert) *cert = x509;
+ else X509_free(x509);
} else {
if(ca) sk_X509_push (*ca, x509);
else X509_free(x509);
diff --git a/crypto/openssl/crypto/pkcs7/pk7_doit.c b/crypto/openssl/crypto/pkcs7/pk7_doit.c
index 099e9651c1c3..bf43d030ade6 100644
--- a/crypto/openssl/crypto/pkcs7/pk7_doit.c
+++ b/crypto/openssl/crypto/pkcs7/pk7_doit.c
@@ -370,7 +370,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
if (ri == NULL) {
PKCS7err(PKCS7_F_PKCS7_DATADECODE,
PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE);
- return(NULL);
+ goto err;
}
jj=EVP_PKEY_size(pkey);
@@ -393,7 +393,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
BIO_get_cipher_ctx(etmp,&evp_ctx);
EVP_CipherInit(evp_ctx,evp_cipher,NULL,NULL,0);
if (EVP_CIPHER_asn1_to_param(evp_ctx,enc_alg->parameter) < 0)
- return(NULL);
+ goto err;
if (jj != EVP_CIPHER_CTX_key_length(evp_ctx)) {
/* Some S/MIME clients don't use the same key
@@ -588,8 +588,10 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
pp=NULL;
}
+#ifndef NO_DSA
if (si->pkey->type == EVP_PKEY_DSA)
ctx_tmp.digest=EVP_dss1();
+#endif
if (!EVP_SignFinal(&ctx_tmp,(unsigned char *)buf->data,
(unsigned int *)&buf->length,si->pkey))
@@ -783,7 +785,14 @@ for (ii=0; ii<md_len; ii++) printf("%02X",md_dat[ii]); printf(" calc\n");
os=si->enc_digest;
pkey = X509_get_pubkey(x509);
+ if (!pkey)
+ {
+ ret = -1;
+ goto err;
+ }
+#ifndef NO_DSA
if(pkey->type == EVP_PKEY_DSA) mdc_tmp.digest=EVP_dss1();
+#endif
i=EVP_VerifyFinal(&mdc_tmp,os->data,os->length, pkey);
EVP_PKEY_free(pkey);
diff --git a/crypto/openssl/crypto/pkcs7/pk7_smime.c b/crypto/openssl/crypto/pkcs7/pk7_smime.c
index d716f9faeba6..3d3214f5eee8 100644
--- a/crypto/openssl/crypto/pkcs7/pk7_smime.c
+++ b/crypto/openssl/crypto/pkcs7/pk7_smime.c
@@ -153,7 +153,7 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
PKCS7_SIGNER_INFO *si;
X509_STORE_CTX cert_ctx;
char buf[4096];
- int i, j=0, k;
+ int i, j=0, k, ret = 0;
BIO *p7bio;
BIO *tmpout;
@@ -258,18 +258,15 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
}
}
- sk_X509_free(signers);
- if(indata) BIO_pop(p7bio);
- BIO_free_all(p7bio);
-
- return 1;
+ ret = 1;
err:
+ if(indata) BIO_pop(p7bio);
+ BIO_free_all(p7bio);
sk_X509_free(signers);
- BIO_free(p7bio);
- return 0;
+ return ret;
}
STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags)
diff --git a/crypto/openssl/crypto/rand/md_rand.c b/crypto/openssl/crypto/rand/md_rand.c
index d167dea77db6..567838f6c334 100644
--- a/crypto/openssl/crypto/rand/md_rand.c
+++ b/crypto/openssl/crypto/rand/md_rand.c
@@ -482,12 +482,12 @@ static int ssleay_rand_bytes(unsigned char *buf, int num)
unpredictable */
static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num)
{
- int ret, err;
+ int ret;
ret = RAND_bytes(buf, num);
if (ret == 0)
{
- err = ERR_peek_error();
+ long err = ERR_peek_error();
if (ERR_GET_LIB(err) == ERR_LIB_RAND &&
ERR_GET_REASON(err) == RAND_R_PRNG_NOT_SEEDED)
(void)ERR_get_error();
diff --git a/crypto/openssl/crypto/rand/rand.h b/crypto/openssl/crypto/rand/rand.h
index 971880edaa2a..918f865d90fa 100644
--- a/crypto/openssl/crypto/rand/rand.h
+++ b/crypto/openssl/crypto/rand/rand.h
@@ -59,6 +59,8 @@
#ifndef HEADER_RAND_H
#define HEADER_RAND_H
+#include <stdlib.h>
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -87,7 +89,7 @@ void RAND_seed(const void *buf,int num);
void RAND_add(const void *buf,int num,double entropy);
int RAND_load_file(const char *file,long max_bytes);
int RAND_write_file(const char *file);
-const char *RAND_file_name(char *file,int num);
+const char *RAND_file_name(char *file,size_t num);
int RAND_status(void);
int RAND_egd(const char *path);
int RAND_egd_bytes(const char *path,int bytes);
diff --git a/crypto/openssl/crypto/rand/rand_egd.c b/crypto/openssl/crypto/rand/rand_egd.c
index 02a0d86fa330..79b5e6fa57f8 100644
--- a/crypto/openssl/crypto/rand/rand_egd.c
+++ b/crypto/openssl/crypto/rand/rand_egd.c
@@ -74,7 +74,14 @@ int RAND_egd_bytes(const char *path,int bytes)
#include OPENSSL_UNISTD
#include <sys/types.h>
#include <sys/socket.h>
+#ifndef NO_SYS_UN_H
#include <sys/un.h>
+#else
+struct sockaddr_un {
+ short sun_family; /* AF_UNIX */
+ char sun_path[108]; /* path name (gag) */
+};
+#endif /* NO_SYS_UN_H */
#include <string.h>
#ifndef offsetof
diff --git a/crypto/openssl/crypto/rand/rand_win.c b/crypto/openssl/crypto/rand/rand_win.c
index 8850b9ae916c..3d137badd0e5 100644
--- a/crypto/openssl/crypto/rand/rand_win.c
+++ b/crypto/openssl/crypto/rand/rand_win.c
@@ -577,7 +577,8 @@ static void readtimer(void)
if (have_tsc) {
__try {
__asm {
- rdtsc
+ _emit 0x0f
+ _emit 0x31
mov cyclecount, eax
}
RAND_add(&cyclecount, sizeof(cyclecount), 1);
@@ -725,8 +726,9 @@ int RAND_poll(void)
#ifdef DEVRANDOM
return 1;
-#endif
+#else
return 0;
+#endif
}
#endif
diff --git a/crypto/openssl/crypto/rand/randfile.c b/crypto/openssl/crypto/rand/randfile.c
index 02f16aa81032..7548ac324c05 100644
--- a/crypto/openssl/crypto/rand/randfile.c
+++ b/crypto/openssl/crypto/rand/randfile.c
@@ -73,7 +73,7 @@
# include <sys/stat.h>
#endif
-#include <openssl/e_os.h>
+#include "openssl/e_os.h"
#include <openssl/crypto.h>
#include <openssl/rand.h>
@@ -194,12 +194,13 @@ err:
return (rand_err ? -1 : ret);
}
-const char *RAND_file_name(char *buf, int size)
+const char *RAND_file_name(char *buf, size_t size)
{
- char *s;
+ char *s=NULL;
char *ret=NULL;
- s=getenv("RANDFILE");
+ if (OPENSSL_issetugid() == 0)
+ s=getenv("RANDFILE");
if (s != NULL)
{
strncpy(buf,s,size-1);
@@ -208,16 +209,19 @@ const char *RAND_file_name(char *buf, int size)
}
else
{
- s=getenv("HOME");
- if (s == NULL) return(RFILE);
- if (((int)(strlen(s)+strlen(RFILE)+2)) > size)
- return(RFILE);
- strcpy(buf,s);
+ if (OPENSSL_issetugid() == 0)
+ s=getenv("HOME");
+ if (s != NULL && (strlen(s)+strlen(RFILE)+2 < size))
+ {
+ strcpy(buf,s);
#ifndef VMS
- strcat(buf,"/");
+ strcat(buf,"/");
#endif
- strcat(buf,RFILE);
- ret=buf;
+ strcat(buf,RFILE);
+ ret=buf;
+ }
+ else
+ buf[0] = '\0'; /* no file name */
}
return(ret);
}
diff --git a/crypto/openssl/crypto/rsa/rsa_eay.c b/crypto/openssl/crypto/rsa/rsa_eay.c
index 62618fe5a999..3e3832025781 100644
--- a/crypto/openssl/crypto/rsa/rsa_eay.c
+++ b/crypto/openssl/crypto/rsa/rsa_eay.c
@@ -443,13 +443,14 @@ err:
static int RSA_eay_mod_exp(BIGNUM *r0, BIGNUM *I, RSA *rsa)
{
- BIGNUM r1,m1;
+ BIGNUM r1,m1,vrfy;
int ret=0;
BN_CTX *ctx;
if ((ctx=BN_CTX_new()) == NULL) goto err;
BN_init(&m1);
BN_init(&r1);
+ BN_init(&vrfy);
if (rsa->flags & RSA_FLAG_CACHE_PRIVATE)
{
@@ -530,10 +531,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 (!rsa->meth->bn_mod_exp(&vrfy,r0,rsa->e,rsa->n,ctx,NULL)) goto err;
+ if (BN_cmp(I, &vrfy) != 0)
+ {
+ if (!rsa->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);
}
diff --git a/crypto/openssl/crypto/rsa/rsa_lib.c b/crypto/openssl/crypto/rsa/rsa_lib.c
index bbddd3f0f0bf..422643e9f2e8 100644
--- a/crypto/openssl/crypto/rsa/rsa_lib.c
+++ b/crypto/openssl/crypto/rsa/rsa_lib.c
@@ -145,13 +145,13 @@ RSA *RSA_new_method(RSA_METHOD *meth)
ret->blinding=NULL;
ret->bignum_data=NULL;
ret->flags=ret->meth->flags;
+ CRYPTO_new_ex_data(rsa_meth,ret,&ret->ex_data);
if ((ret->meth->init != NULL) && !ret->meth->init(ret))
{
+ CRYPTO_free_ex_data(rsa_meth,ret,&ret->ex_data);
OPENSSL_free(ret);
ret=NULL;
}
- else
- CRYPTO_new_ex_data(rsa_meth,ret,&ret->ex_data);
return(ret);
}
@@ -174,11 +174,11 @@ void RSA_free(RSA *r)
}
#endif
- CRYPTO_free_ex_data(rsa_meth,r,&r->ex_data);
-
if (r->meth->finish != NULL)
r->meth->finish(r);
+ CRYPTO_free_ex_data(rsa_meth,r,&r->ex_data);
+
if (r->n != NULL) BN_clear_free(r->n);
if (r->e != NULL) BN_clear_free(r->e);
if (r->d != NULL) BN_clear_free(r->d);
@@ -272,7 +272,7 @@ int RSA_blinding_on(RSA *rsa, BN_CTX *p_ctx)
BN_CTX_start(ctx);
A = BN_CTX_get(ctx);
- if (!BN_rand(A,BN_num_bits(rsa->n)-1,1,0)) goto err;
+ if (!BN_rand_range(A,rsa->n)) goto err;
if ((Ai=BN_mod_inverse(NULL,A,rsa->n,ctx)) == NULL) goto err;
if (!rsa->meth->bn_mod_exp(A,A,rsa->e,rsa->n,ctx,rsa->_method_mod_n))
diff --git a/crypto/openssl/crypto/uid.c b/crypto/openssl/crypto/uid.c
new file mode 100644
index 000000000000..b5b61b76d4e3
--- /dev/null
+++ b/crypto/openssl/crypto/uid.c
@@ -0,0 +1,88 @@
+/* crypto/uid.c */
+/* ====================================================================
+ * Copyright (c) 2001 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * licensing@OpenSSL.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+
+#include <openssl/crypto.h>
+
+#if defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD__ > 2)
+
+#include <unistd.h>
+
+int OPENSSL_issetugid(void)
+ {
+ return issetugid();
+ }
+
+#elif defined(WIN32)
+
+int OPENSSL_issetugid(void)
+ {
+ return 0;
+ }
+
+#else
+
+#include <unistd.h>
+#include <sys/types.h>
+
+int OPENSSL_issetugid(void)
+ {
+ if (getuid() != geteuid()) return 1;
+ if (getgid() != getegid()) return 1;
+ return 0;
+ }
+#endif
+
+
+
diff --git a/crypto/openssl/crypto/x509/x509_cmp.c b/crypto/openssl/crypto/x509/x509_cmp.c
index b147d573d2f9..3f9f9b3d472e 100644
--- a/crypto/openssl/crypto/x509/x509_cmp.c
+++ b/crypto/openssl/crypto/x509/x509_cmp.c
@@ -199,19 +199,13 @@ unsigned long X509_NAME_hash(X509_NAME *x)
{
unsigned long ret=0;
unsigned char md[16];
- unsigned char str[256],*p,*pp;
- int i;
-
- i=i2d_X509_NAME(x,NULL);
- if (i > sizeof(str))
- p=OPENSSL_malloc(i);
- else
- p=str;
- pp=p;
- i2d_X509_NAME(x,&pp);
- MD5((unsigned char *)p,i,&(md[0]));
- if (p != str) OPENSSL_free(p);
+ /* Ensure cached version is up to date */
+ i2d_X509_NAME(x,NULL);
+ /* Use cached encoding directly rather than copying: this should
+ * keep libsafe happy.
+ */
+ MD5((unsigned char *)x->bytes->data,x->bytes->length,&(md[0]));
ret=( ((unsigned long)md[0] )|((unsigned long)md[1]<<8L)|
((unsigned long)md[2]<<16L)|((unsigned long)md[3]<<24L)
diff --git a/crypto/openssl/crypto/x509v3/v3_alt.c b/crypto/openssl/crypto/x509v3/v3_alt.c
index 733919f2507b..94bebcd4480c 100644
--- a/crypto/openssl/crypto/x509v3/v3_alt.c
+++ b/crypto/openssl/crypto/x509v3/v3_alt.c
@@ -270,7 +270,7 @@ static int copy_email(X509V3_CTX *ctx, STACK_OF(GENERAL_NAME) *gens)
/* Now add any email address(es) to STACK */
i = -1;
while((i = X509_NAME_get_index_by_NID(nm,
- NID_pkcs9_emailAddress, i)) > 0) {
+ NID_pkcs9_emailAddress, i)) >= 0) {
ne = X509_NAME_get_entry(nm, i);
email = M_ASN1_IA5STRING_dup(X509_NAME_ENTRY_get_data(ne));
if(!email || !(gen = GENERAL_NAME_new())) {