Resolve conflicts after import of OpenSSL 0.9.8d.

This commit is contained in:
Simon L. B. Nielsen 2006-10-01 07:46:16 +00:00
parent 02d3319f28
commit 74608424ab
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=162914
8 changed files with 235 additions and 27 deletions

View File

@ -164,6 +164,9 @@
#ifndef OPENSSL_NO_AES
#include <openssl/aes.h>
#endif
#ifndef OPENSSL_NO_CAMELLIA
#include <openssl/camellia.h>
#endif
#ifndef OPENSSL_NO_MD2
#include <openssl/md2.h>
#endif
@ -269,7 +272,7 @@ static void print_result(int alg,int run_no,int count,double time_used);
static int do_multi(int multi);
#endif
#define ALGOR_NUM 21
#define ALGOR_NUM 24
#define SIZE_NUM 5
#define RSA_NUM 4
#define DSA_NUM 3
@ -281,7 +284,9 @@ static const char *names[ALGOR_NUM]={
"md2","mdc2","md4","md5","hmac(md5)","sha1","rmd160","rc4",
"des cbc","des ede3","idea cbc",
"rc2 cbc","rc5-32/12 cbc","blowfish cbc","cast cbc",
"aes-128 cbc","aes-192 cbc","aes-256 cbc","evp","sha256","sha512"};
"aes-128 cbc","aes-192 cbc","aes-256 cbc",
"camellia-128 cbc","camellia-192 cbc","camellia-256 cbc",
"evp","sha256","sha512"};
static double results[ALGOR_NUM][SIZE_NUM];
static int lengths[SIZE_NUM]={16,64,256,1024,8*1024};
static double rsa_results[RSA_NUM][2];
@ -548,6 +553,17 @@ int MAIN(int argc, char **argv)
0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,
0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,0x56};
#endif
#ifndef OPENSSL_NO_CAMELLIA
static const unsigned char ckey24[24]=
{0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,
0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
static const unsigned char ckey32[32]=
{0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,
0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,
0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,0x56};
#endif
#ifndef OPENSSL_NO_AES
#define MAX_BLOCK_SIZE 128
#else
@ -567,6 +583,9 @@ int MAIN(int argc, char **argv)
#ifndef OPENSSL_NO_AES
AES_KEY aes_ks1, aes_ks2, aes_ks3;
#endif
#ifndef OPENSSL_NO_CAMELLIA
CAMELLIA_KEY camellia_ks1, camellia_ks2, camellia_ks3;
#endif
#define D_MD2 0
#define D_MDC2 1
#define D_MD4 2
@ -585,9 +604,12 @@ int MAIN(int argc, char **argv)
#define D_CBC_128_AES 15
#define D_CBC_192_AES 16
#define D_CBC_256_AES 17
#define D_EVP 18
#define D_SHA256 19
#define D_SHA512 20
#define D_CBC_128_CML 18
#define D_CBC_192_CML 19
#define D_CBC_256_CML 20
#define D_EVP 21
#define D_SHA256 22
#define D_SHA512 23
double d=0.0;
long c[ALGOR_NUM][SIZE_NUM];
#define R_DSA_512 0
@ -930,6 +952,12 @@ int MAIN(int argc, char **argv)
else if (strcmp(*argv,"aes-256-cbc") == 0) doit[D_CBC_256_AES]=1;
else
#endif
#ifndef OPENSSL_NO_CAMELLIA
if (strcmp(*argv,"camellia-128-cbc") == 0) doit[D_CBC_128_CML]=1;
else if (strcmp(*argv,"camellia-192-cbc") == 0) doit[D_CBC_192_CML]=1;
else if (strcmp(*argv,"camellia-256-cbc") == 0) doit[D_CBC_256_CML]=1;
else
#endif
#ifndef OPENSSL_NO_RSA
#if 0 /* was: #ifdef RSAref */
if (strcmp(*argv,"rsaref") == 0)
@ -1000,6 +1028,15 @@ int MAIN(int argc, char **argv)
}
else
#endif
#ifndef OPENSSL_NO_CAMELLIA
if (strcmp(*argv,"camellia") == 0)
{
doit[D_CBC_128_CML]=1;
doit[D_CBC_192_CML]=1;
doit[D_CBC_256_CML]=1;
}
else
#endif
#ifndef OPENSSL_NO_RSA
if (strcmp(*argv,"rsa") == 0)
{
@ -1126,6 +1163,10 @@ int MAIN(int argc, char **argv)
#ifndef OPENSSL_NO_AES
BIO_printf(bio_err,"aes-128-cbc aes-192-cbc aes-256-cbc ");
#endif
#ifndef OPENSSL_NO_CAMELLIA
BIO_printf(bio_err,"\n");
BIO_printf(bio_err,"camellia-128-cbc camellia-192-cbc camellia-256-cbc ");
#endif
#ifndef OPENSSL_NO_RC4
BIO_printf(bio_err,"rc4");
#endif
@ -1163,6 +1204,9 @@ int MAIN(int argc, char **argv)
#ifndef OPENSSL_NO_AES
BIO_printf(bio_err,"aes ");
#endif
#ifndef OPENSSL_NO_CAMELLIA
BIO_printf(bio_err,"camellia ");
#endif
#ifndef OPENSSL_NO_RSA
BIO_printf(bio_err,"rsa ");
#endif
@ -1171,7 +1215,8 @@ int MAIN(int argc, char **argv)
#endif
#if !defined(OPENSSL_NO_IDEA) || !defined(OPENSSL_NO_RC2) || \
!defined(OPENSSL_NO_DES) || !defined(OPENSSL_NO_RSA) || \
!defined(OPENSSL_NO_BF) || !defined(OPENSSL_NO_AES)
!defined(OPENSSL_NO_BF) || !defined(OPENSSL_NO_AES) || \
!defined(OPENSSL_NO_CAMELLIA)
BIO_printf(bio_err,"\n");
#endif
@ -1265,6 +1310,11 @@ int MAIN(int argc, char **argv)
AES_set_encrypt_key(key24,192,&aes_ks2);
AES_set_encrypt_key(key32,256,&aes_ks3);
#endif
#ifndef OPENSSL_NO_CAMELLIA
Camellia_set_key(key16,128,&camellia_ks1);
Camellia_set_key(ckey24,192,&camellia_ks2);
Camellia_set_key(ckey32,256,&camellia_ks3);
#endif
#ifndef OPENSSL_NO_IDEA
idea_set_encrypt_key(key16,&idea_ks);
#endif
@ -1318,6 +1368,9 @@ int MAIN(int argc, char **argv)
c[D_CBC_128_AES][0]=count;
c[D_CBC_192_AES][0]=count;
c[D_CBC_256_AES][0]=count;
c[D_CBC_128_CML][0]=count;
c[D_CBC_192_CML][0]=count;
c[D_CBC_256_CML][0]=count;
c[D_SHA256][0]=count;
c[D_SHA512][0]=count;
@ -1350,6 +1403,9 @@ int MAIN(int argc, char **argv)
c[D_CBC_128_AES][i]=c[D_CBC_128_AES][i-1]*l0/l1;
c[D_CBC_192_AES][i]=c[D_CBC_192_AES][i-1]*l0/l1;
c[D_CBC_256_AES][i]=c[D_CBC_256_AES][i-1]*l0/l1;
c[D_CBC_128_CML][i]=c[D_CBC_128_CML][i-1]*l0/l1;
c[D_CBC_192_CML][i]=c[D_CBC_192_CML][i-1]*l0/l1;
c[D_CBC_256_CML][i]=c[D_CBC_256_CML][i-1]*l0/l1;
}
#ifndef OPENSSL_NO_RSA
rsa_c[R_RSA_512][0]=count/2000;
@ -1743,6 +1799,51 @@ int MAIN(int argc, char **argv)
}
}
#endif
#ifndef OPENSSL_NO_CAMELLIA
if (doit[D_CBC_128_CML])
{
for (j=0; j<SIZE_NUM; j++)
{
print_message(names[D_CBC_128_CML],c[D_CBC_128_CML][j],lengths[j]);
Time_F(START);
for (count=0,run=1; COND(c[D_CBC_128_CML][j]); count++)
Camellia_cbc_encrypt(buf,buf,
(unsigned long)lengths[j],&camellia_ks1,
iv,CAMELLIA_ENCRYPT);
d=Time_F(STOP);
print_result(D_CBC_128_CML,j,count,d);
}
}
if (doit[D_CBC_192_CML])
{
for (j=0; j<SIZE_NUM; j++)
{
print_message(names[D_CBC_192_CML],c[D_CBC_192_CML][j],lengths[j]);
Time_F(START);
for (count=0,run=1; COND(c[D_CBC_192_CML][j]); count++)
Camellia_cbc_encrypt(buf,buf,
(unsigned long)lengths[j],&camellia_ks2,
iv,CAMELLIA_ENCRYPT);
d=Time_F(STOP);
print_result(D_CBC_192_CML,j,count,d);
}
}
if (doit[D_CBC_256_CML])
{
for (j=0; j<SIZE_NUM; j++)
{
print_message(names[D_CBC_256_CML],c[D_CBC_256_CML][j],lengths[j]);
Time_F(START);
for (count=0,run=1; COND(c[D_CBC_256_CML][j]); count++)
Camellia_cbc_encrypt(buf,buf,
(unsigned long)lengths[j],&camellia_ks3,
iv,CAMELLIA_ENCRYPT);
d=Time_F(STOP);
print_result(D_CBC_256_CML,j,count,d);
}
}
#endif
#ifndef OPENSSL_NO_IDEA
if (doit[D_CBC_IDEA])

View File

@ -738,6 +738,29 @@ const EVP_CIPHER *EVP_aes_256_ofb(void);
const EVP_CIPHER *EVP_aes_256_ctr(void);
#endif
#endif
#ifndef OPENSSL_NO_CAMELLIA
const EVP_CIPHER *EVP_camellia_128_ecb(void);
const EVP_CIPHER *EVP_camellia_128_cbc(void);
const EVP_CIPHER *EVP_camellia_128_cfb1(void);
const EVP_CIPHER *EVP_camellia_128_cfb8(void);
const EVP_CIPHER *EVP_camellia_128_cfb128(void);
# define EVP_camellia_128_cfb EVP_camellia_128_cfb128
const EVP_CIPHER *EVP_camellia_128_ofb(void);
const EVP_CIPHER *EVP_camellia_192_ecb(void);
const EVP_CIPHER *EVP_camellia_192_cbc(void);
const EVP_CIPHER *EVP_camellia_192_cfb1(void);
const EVP_CIPHER *EVP_camellia_192_cfb8(void);
const EVP_CIPHER *EVP_camellia_192_cfb128(void);
# define EVP_camellia_192_cfb EVP_camellia_192_cfb128
const EVP_CIPHER *EVP_camellia_192_ofb(void);
const EVP_CIPHER *EVP_camellia_256_ecb(void);
const EVP_CIPHER *EVP_camellia_256_cbc(void);
const EVP_CIPHER *EVP_camellia_256_cfb1(void);
const EVP_CIPHER *EVP_camellia_256_cfb8(void);
const EVP_CIPHER *EVP_camellia_256_cfb128(void);
# define EVP_camellia_256_cfb EVP_camellia_256_cfb128
const EVP_CIPHER *EVP_camellia_256_ofb(void);
#endif
void OPENSSL_add_all_algorithms_noconf(void);
void OPENSSL_add_all_algorithms_conf(void);
@ -854,6 +877,7 @@ void ERR_load_EVP_strings(void);
/* Function codes. */
#define EVP_F_AES_INIT_KEY 133
#define EVP_F_CAMELLIA_INIT_KEY 159
#define EVP_F_D2I_PKEY 100
#define EVP_F_DSAPKEY2PKCS8 134
#define EVP_F_DSA_PKEY2PKCS8 135
@ -897,6 +921,7 @@ void ERR_load_EVP_strings(void);
#define EVP_R_BAD_KEY_LENGTH 137
#define EVP_R_BN_DECODE_ERROR 112
#define EVP_R_BN_PUBKEY_ERROR 113
#define EVP_R_CAMELLIA_KEY_SETUP_FAILED 157
#define EVP_R_CIPHER_PARAMETER_ERROR 122
#define EVP_R_CTRL_NOT_IMPLEMENTED 132
#define EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED 133

View File

@ -160,6 +160,17 @@ struct rsa_st
BN_BLINDING *mt_blinding;
};
#ifndef OPENSSL_RSA_MAX_MODULUS_BITS
# define OPENSSL_RSA_MAX_MODULUS_BITS 16384
#endif
#ifndef OPENSSL_RSA_SMALL_MODULUS_BITS
# define OPENSSL_RSA_SMALL_MODULUS_BITS 3072
#endif
#ifndef OPENSSL_RSA_MAX_PUBEXP_BITS
# define OPENSSL_RSA_MAX_PUBEXP_BITS 64 /* exponent limit enforced for "large" modulus only */
#endif
#define RSA_3 0x3L
#define RSA_F4 0x10001L
@ -408,6 +419,7 @@ void ERR_load_RSA_strings(void);
#define RSA_R_IQMP_NOT_INVERSE_OF_Q 126
#define RSA_R_KEY_SIZE_TOO_SMALL 120
#define RSA_R_LAST_OCTET_INVALID 134
#define RSA_R_MODULUS_TOO_LARGE 105
#define RSA_R_NO_PUBLIC_EXPONENT 140
#define RSA_R_NULL_BEFORE_BLOCK_MISSING 113
#define RSA_R_N_DOES_NOT_EQUAL_P_Q 127

View File

@ -56,7 +56,7 @@
* [including the GNU Public Licence.]
*/
/* ====================================================================
* Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved.
* Copyright (c) 1998-2006 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
@ -169,6 +169,28 @@ static int RSA_eay_public_encrypt(int flen, const unsigned char *from,
unsigned char *buf=NULL;
BN_CTX *ctx=NULL;
if (BN_num_bits(rsa->n) > OPENSSL_RSA_MAX_MODULUS_BITS)
{
RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT, RSA_R_MODULUS_TOO_LARGE);
return -1;
}
if (BN_ucmp(rsa->n, rsa->e) <= 0)
{
RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT, RSA_R_BAD_E_VALUE);
return -1;
}
/* for large moduli, enforce exponent limit */
if (BN_num_bits(rsa->n) > OPENSSL_RSA_SMALL_MODULUS_BITS)
{
if (BN_num_bits(rsa->e) > OPENSSL_RSA_MAX_PUBEXP_BITS)
{
RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT, RSA_R_BAD_E_VALUE);
return -1;
}
}
if ((ctx=BN_CTX_new()) == NULL) goto err;
BN_CTX_start(ctx);
f = BN_CTX_get(ctx);
@ -239,40 +261,63 @@ static int RSA_eay_public_encrypt(int flen, const unsigned char *from,
return(r);
}
static BN_BLINDING *rsa_get_blinding(RSA *rsa, BIGNUM **r, int *local, BN_CTX *ctx)
static BN_BLINDING *rsa_get_blinding(RSA *rsa, int *local, BN_CTX *ctx)
{
BN_BLINDING *ret;
int got_write_lock = 0;
CRYPTO_r_lock(CRYPTO_LOCK_RSA);
if (rsa->blinding == NULL)
{
CRYPTO_r_unlock(CRYPTO_LOCK_RSA);
CRYPTO_w_lock(CRYPTO_LOCK_RSA);
got_write_lock = 1;
if (rsa->blinding == NULL)
{
CRYPTO_w_lock(CRYPTO_LOCK_RSA);
if (rsa->blinding == NULL)
rsa->blinding = RSA_setup_blinding(rsa, ctx);
CRYPTO_w_unlock(CRYPTO_LOCK_RSA);
}
rsa->blinding = RSA_setup_blinding(rsa, ctx);
}
ret = rsa->blinding;
if (ret == NULL)
return NULL;
goto err;
if (BN_BLINDING_get_thread_id(ret) != CRYPTO_thread_id())
if (BN_BLINDING_get_thread_id(ret) == CRYPTO_thread_id())
{
*local = 0;
/* rsa->blinding is ours! */
*local = 1;
}
else
{
/* resort to rsa->mt_blinding instead */
*local = 0; /* instructs rsa_blinding_convert(), rsa_blinding_invert()
* that the BN_BLINDING is shared, meaning that accesses
* require locks, and that the blinding factor must be
* stored outside the BN_BLINDING
*/
if (rsa->mt_blinding == NULL)
{
CRYPTO_w_lock(CRYPTO_LOCK_RSA);
if (!got_write_lock)
{
CRYPTO_r_unlock(CRYPTO_LOCK_RSA);
CRYPTO_w_lock(CRYPTO_LOCK_RSA);
got_write_lock = 1;
}
if (rsa->mt_blinding == NULL)
rsa->mt_blinding = RSA_setup_blinding(rsa, ctx);
CRYPTO_w_unlock(CRYPTO_LOCK_RSA);
}
ret = rsa->mt_blinding;
}
else
*local = 1;
err:
if (got_write_lock)
CRYPTO_w_unlock(CRYPTO_LOCK_RSA);
else
CRYPTO_r_unlock(CRYPTO_LOCK_RSA);
return ret;
}
@ -359,7 +404,7 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
if (!(rsa->flags & RSA_FLAG_NO_BLINDING))
{
blinding = rsa_get_blinding(rsa, &br, &local_blinding, ctx);
blinding = rsa_get_blinding(rsa, &local_blinding, ctx);
if (blinding == NULL)
{
RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT, ERR_R_INTERNAL_ERROR);
@ -480,7 +525,7 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
if (!(rsa->flags & RSA_FLAG_NO_BLINDING))
{
blinding = rsa_get_blinding(rsa, &br, &local_blinding, ctx);
blinding = rsa_get_blinding(rsa, &local_blinding, ctx);
if (blinding == NULL)
{
RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT, ERR_R_INTERNAL_ERROR);
@ -575,6 +620,28 @@ static int RSA_eay_public_decrypt(int flen, const unsigned char *from,
unsigned char *buf=NULL;
BN_CTX *ctx=NULL;
if (BN_num_bits(rsa->n) > OPENSSL_RSA_MAX_MODULUS_BITS)
{
RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT, RSA_R_MODULUS_TOO_LARGE);
return -1;
}
if (BN_ucmp(rsa->n, rsa->e) <= 0)
{
RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT, RSA_R_BAD_E_VALUE);
return -1;
}
/* for large moduli, enforce exponent limit */
if (BN_num_bits(rsa->n) > OPENSSL_RSA_SMALL_MODULUS_BITS)
{
if (BN_num_bits(rsa->e) > OPENSSL_RSA_MAX_PUBEXP_BITS)
{
RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT, RSA_R_BAD_E_VALUE);
return -1;
}
}
if((ctx = BN_CTX_new()) == NULL) goto err;
BN_CTX_start(ctx);
f = BN_CTX_get(ctx);

View File

@ -196,7 +196,7 @@ int RSA_verify(int dtype, const unsigned char *m, unsigned int m_len,
/* Parameters to the signature algorithm can also be used to
create forgeries */
if(sig->algor->parameter
&& sig->algor->parameter->type != V_ASN1_NULL)
&& ASN1_TYPE_get(sig->algor->parameter) != V_ASN1_NULL)
{
RSAerr(RSA_F_RSA_VERIFY,RSA_R_BAD_SIGNATURE);
goto err;

View File

@ -520,7 +520,8 @@ static int get_server_hello(SSL *s)
CRYPTO_add(&s->session->peer->references, 1, CRYPTO_LOCK_X509);
}
if (s->session->peer != s->session->sess_cert->peer_key->x509)
if (s->session->sess_cert == NULL
|| s->session->peer != s->session->sess_cert->peer_key->x509)
/* can't happen */
{
ssl2_return_error(s, SSL2_PE_UNDEFINED_ERROR);

View File

@ -178,7 +178,7 @@ OPENSSL_GLOBAL SSL_CIPHER ssl2_ciphers[]={
SSL_ALL_STRENGTHS,
},
/* RC4_64_WITH_MD5 */
#if 1
#if 0
{
1,
SSL2_TXT_RC4_64_WITH_MD5,

View File

@ -20,7 +20,7 @@ $cc='gcc';
if ($debug)
{ $cflags="-DL_ENDIAN -DDSO_WIN32 -g2 -ggdb"; }
else
{ $cflags="-DL_ENDIAN -DDSO_WIN32 -fomit-frame-pointer -O3 -mcpu=i486 -Wall"; }
{ $cflags="-DL_ENDIAN -DDSO_WIN32 -fomit-frame-pointer -O3 -march=i486 -Wall"; }
if ($gaswin and !$no_asm)
{
@ -44,6 +44,8 @@ if ($gaswin and !$no_asm)
$rmd160_asm_src='crypto/ripemd/asm/rm-win32.s';
$sha1_asm_obj='$(OBJ_D)\s1-win32.o';
$sha1_asm_src='crypto/sha/asm/s1-win32.s';
$cpuid_asm_obj='$(OBJ_D)\cpu-win32.o';
$cpuid_asm_src='crypto/cpu-win32.s';
$cflags.=" -DBN_ASM -DMD5_ASM -DSHA1_ASM -DOPENSSL_BN_ASM_PART_WORDS";
}