aboutsummaryrefslogtreecommitdiff
path: root/crypto/evp
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/evp')
-rw-r--r--crypto/evp/Makefile.ssl16
-rw-r--r--crypto/evp/bio_b64.c117
-rw-r--r--crypto/evp/bio_enc.c23
-rw-r--r--crypto/evp/bio_md.c2
-rw-r--r--crypto/evp/c_all.c39
-rw-r--r--crypto/evp/digest.c2
-rw-r--r--crypto/evp/e_cbc_3d.c22
-rw-r--r--crypto/evp/e_cbc_bf.c15
-rw-r--r--crypto/evp/e_cbc_c.c119
-rw-r--r--crypto/evp/e_cbc_d.c17
-rw-r--r--crypto/evp/e_cbc_i.c17
-rw-r--r--crypto/evp/e_cbc_r2.c33
-rw-r--r--crypto/evp/e_cbc_r5.c120
-rw-r--r--crypto/evp/e_cfb_3d.c50
-rw-r--r--crypto/evp/e_cfb_bf.c21
-rw-r--r--crypto/evp/e_cfb_c.c121
-rw-r--r--crypto/evp/e_cfb_d.c21
-rw-r--r--crypto/evp/e_cfb_i.c19
-rw-r--r--crypto/evp/e_cfb_r2.c21
-rw-r--r--crypto/evp/e_cfb_r5.c122
-rw-r--r--crypto/evp/e_dsa.c2
-rw-r--r--crypto/evp/e_ecb_3d.c11
-rw-r--r--crypto/evp/e_ecb_bf.c11
-rw-r--r--crypto/evp/e_ecb_c.c122
-rw-r--r--crypto/evp/e_ecb_d.c11
-rw-r--r--crypto/evp/e_ecb_i.c13
-rw-r--r--crypto/evp/e_ecb_r2.c11
-rw-r--r--crypto/evp/e_ecb_r5.c123
-rw-r--r--crypto/evp/e_null.c6
-rw-r--r--crypto/evp/e_ofb_3d.c46
-rw-r--r--crypto/evp/e_ofb_bf.c21
-rw-r--r--crypto/evp/e_ofb_c.c122
-rw-r--r--crypto/evp/e_ofb_d.c21
-rw-r--r--crypto/evp/e_ofb_i.c19
-rw-r--r--crypto/evp/e_ofb_r2.c21
-rw-r--r--crypto/evp/e_ofb_r5.c123
-rw-r--r--crypto/evp/e_rc4.c20
-rw-r--r--crypto/evp/e_xcbc_d.c13
-rw-r--r--crypto/evp/encode.c22
-rw-r--r--crypto/evp/evp.err9
-rw-r--r--crypto/evp/evp.h277
-rw-r--r--crypto/evp/evp_enc.c11
-rw-r--r--crypto/evp/evp_err.c13
-rw-r--r--crypto/evp/evp_key.c8
-rw-r--r--crypto/evp/evp_lib.c117
-rw-r--r--crypto/evp/m_dss.c10
-rw-r--r--crypto/evp/m_dss1.c4
-rw-r--r--crypto/evp/m_md2.c4
-rw-r--r--crypto/evp/m_md5.c4
-rw-r--r--crypto/evp/m_mdc2.c4
-rw-r--r--crypto/evp/m_null.c6
-rw-r--r--crypto/evp/m_ripemd.c81
-rw-r--r--crypto/evp/m_sha.c4
-rw-r--r--crypto/evp/m_sha1.c4
-rw-r--r--crypto/evp/names.c6
-rw-r--r--crypto/evp/p_dec.c84
-rw-r--r--crypto/evp/p_enc.c83
-rw-r--r--crypto/evp/p_lib.c44
-rw-r--r--crypto/evp/p_open.c7
-rw-r--r--crypto/evp/p_seal.c23
-rw-r--r--crypto/evp/p_sign.c6
-rw-r--r--crypto/evp/p_verify.c7
-rw-r--r--crypto/evp/pk_lib.c82
63 files changed, 2236 insertions, 317 deletions
diff --git a/crypto/evp/Makefile.ssl b/crypto/evp/Makefile.ssl
index 2033811..8bf2516 100644
--- a/crypto/evp/Makefile.ssl
+++ b/crypto/evp/Makefile.ssl
@@ -29,10 +29,13 @@ LIBSRC= encode.c digest.c evp_enc.c evp_key.c \
e_cfb_3d.c e_ofb_3d.c e_xcbc_d.c \
e_ecb_r2.c e_cbc_r2.c e_cfb_r2.c e_ofb_r2.c \
e_ecb_bf.c e_cbc_bf.c e_cfb_bf.c e_ofb_bf.c \
+ e_ecb_c.c e_cbc_c.c e_cfb_c.c e_ofb_c.c \
+ e_ecb_r5.c e_cbc_r5.c e_cfb_r5.c e_ofb_r5.c \
m_null.c m_md2.c m_md5.c m_sha.c m_sha1.c m_dss.c m_dss1.c m_mdc2.c \
- p_open.c p_seal.c p_sign.c p_verify.c p_lib.c \
+ m_ripemd.c \
+ p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c \
bio_md.c bio_b64.c bio_enc.c $(ERRC).c e_null.c \
- c_all.c
+ c_all.c evp_lib.c
LIBOBJ= encode.o digest.o evp_enc.o evp_key.o \
e_ecb_d.o e_cbc_d.o e_cfb_d.o e_ofb_d.o \
@@ -41,10 +44,13 @@ LIBOBJ= encode.o digest.o evp_enc.o evp_key.o \
e_cfb_3d.o e_ofb_3d.o e_xcbc_d.o \
e_ecb_r2.o e_cbc_r2.o e_cfb_r2.o e_ofb_r2.o \
e_ecb_bf.o e_cbc_bf.o e_cfb_bf.o e_ofb_bf.o \
+ e_ecb_c.o e_cbc_c.o e_cfb_c.o e_ofb_c.o \
+ e_ecb_r5.o e_cbc_r5.o e_cfb_r5.o e_ofb_r5.o \
m_null.o m_md2.o m_md5.o m_sha.o m_sha1.o m_dss.o m_dss1.o m_mdc2.o \
- p_open.o p_seal.o p_sign.o p_verify.o p_lib.o \
+ m_ripemd.o \
+ p_open.o p_seal.o p_sign.o p_verify.o p_lib.o p_enc.o p_dec.o \
bio_md.o bio_b64.o bio_enc.o $(ERRC).o e_null.o \
- c_all.o
+ c_all.o evp_lib.o
SRC= $(LIBSRC)
@@ -100,6 +106,6 @@ clean:
errors:
perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
- perl ../err/err_genc.pl $(ERR).h $(ERRC).c
+ perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/crypto/evp/bio_b64.c b/crypto/evp/bio_b64.c
index e362dc3..73172b9 100644
--- a/crypto/evp/bio_b64.c
+++ b/crypto/evp/bio_b64.c
@@ -1,5 +1,5 @@
/* crypto/evp/bio_b64.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -81,6 +81,7 @@ static int b64_free();
#endif
#define B64_BLOCK_SIZE 1024
+#define B64_BLOCK_SIZE2 768
#define B64_NONE 0
#define B64_ENCODE 1
#define B64_DECODE 2
@@ -155,7 +156,7 @@ BIO *b;
char *out;
int outl;
{
- int ret=0,i,ii,j,k,x,n,num;
+ int ret=0,i,ii,j,k,x,n,num,ret_code=0;
BIO_B64_CTX *ctx;
unsigned char *p,*q;
@@ -169,6 +170,7 @@ int outl;
ctx->encode=B64_DECODE;
ctx->buf_len=0;
ctx->buf_off=0;
+ ctx->tmp_len=0;
EVP_DecodeInit(&(ctx->base64));
}
@@ -192,6 +194,7 @@ int outl;
/* At this point, we have room of outl bytes and an empty
* buffer, so we should read in some more. */
+ ret_code=0;
while (outl > 0)
{
if (ctx->cont <= 0) break;
@@ -201,16 +204,24 @@ int outl;
if (i <= 0)
{
+ ret_code=i;
+
/* Should be continue next time we are called? */
if (!BIO_should_retry(b->next_bio))
ctx->cont=i;
+ /* else we should continue when called again */
break;
}
i+=ctx->tmp_len;
/* We need to scan, a line at a time until we
* have a valid line if we are starting. */
- if (ctx->start)
+ if (ctx->start && (BIO_get_flags(b) & BIO_FLAGS_BASE64_NO_NL))
+ {
+ /* ctx->start=1; */
+ ctx->tmp_len=0;
+ }
+ else if (ctx->start)
{
q=p=(unsigned char *)ctx->tmp;
for (j=0; j<i; j++)
@@ -273,13 +284,51 @@ int outl;
else
ctx->tmp_len=0;
}
- i=EVP_DecodeUpdate(&(ctx->base64),
- (unsigned char *)ctx->buf,&ctx->buf_len,
- (unsigned char *)ctx->tmp,i);
+
+ if (BIO_get_flags(b) & BIO_FLAGS_BASE64_NO_NL)
+ {
+ int z,jj;
+
+ jj=(i>>2)<<2;
+ z=EVP_DecodeBlock((unsigned char *)ctx->buf,
+ (unsigned char *)ctx->tmp,jj);
+ if (jj > 2)
+ {
+ if (ctx->tmp[jj-1] == '=')
+ {
+ z--;
+ if (ctx->tmp[jj-2] == '=')
+ z--;
+ }
+ }
+ /* z is now number of output bytes and jj is the
+ * number consumed */
+ if (jj != i)
+ {
+ memcpy((unsigned char *)ctx->tmp,
+ (unsigned char *)&(ctx->tmp[jj]),i-jj);
+ ctx->tmp_len=i-jj;
+ }
+ ctx->buf_len=0;
+ if (z > 0)
+ {
+ ctx->buf_len=z;
+ i=1;
+ }
+ else
+ i=z;
+ }
+ else
+ {
+ i=EVP_DecodeUpdate(&(ctx->base64),
+ (unsigned char *)ctx->buf,&ctx->buf_len,
+ (unsigned char *)ctx->tmp,i);
+ }
ctx->cont=i;
ctx->buf_off=0;
if (i < 0)
{
+ ret_code=0;
ctx->buf_len=0;
break;
}
@@ -302,7 +351,7 @@ int outl;
}
BIO_clear_retry_flags(b);
BIO_copy_next_retry(b);
- return((ret == 0)?ctx->cont:ret);
+ return((ret == 0)?ret_code:ret);
}
static int b64_write(b,in,inl)
@@ -321,6 +370,7 @@ int inl;
ctx->encode=B64_ENCODE;
ctx->buf_len=0;
ctx->buf_off=0;
+ ctx->tmp_len=0;
EVP_EncodeInit(&(ctx->base64));
}
@@ -344,9 +394,41 @@ int inl;
while (inl > 0)
{
n=(inl > B64_BLOCK_SIZE)?B64_BLOCK_SIZE:inl;
- EVP_EncodeUpdate(&(ctx->base64),
- (unsigned char *)ctx->buf,&ctx->buf_len,
- (unsigned char *)in,n);
+
+ if (BIO_get_flags(b) & BIO_FLAGS_BASE64_NO_NL)
+ {
+ if (ctx->tmp_len > 0)
+ {
+ n=3-ctx->tmp_len;
+ memcpy(&(ctx->tmp[ctx->tmp_len]),in,n);
+ ctx->tmp_len+=n;
+ n=ctx->tmp_len;
+ if (n < 3)
+ break;
+ ctx->buf_len=EVP_EncodeBlock(
+ (unsigned char *)ctx->buf,
+ (unsigned char *)ctx->tmp,n);
+ }
+ else
+ {
+ if (n < 3)
+ {
+ memcpy(&(ctx->tmp[0]),in,n);
+ ctx->tmp_len=n;
+ break;
+ }
+ n-=n%3;
+ ctx->buf_len=EVP_EncodeBlock(
+ (unsigned char *)ctx->buf,
+ (unsigned char *)in,n);
+ }
+ }
+ else
+ {
+ EVP_EncodeUpdate(&(ctx->base64),
+ (unsigned char *)ctx->buf,&ctx->buf_len,
+ (unsigned char *)in,n);
+ }
inl-=n;
in+=n;
@@ -419,7 +501,20 @@ again:
break;
}
}
- if (ctx->base64.num != 0)
+ if (BIO_get_flags(b) & BIO_FLAGS_BASE64_NO_NL)
+ {
+ if (ctx->tmp_len != 0)
+ {
+ ctx->buf_len=EVP_EncodeBlock(
+ (unsigned char *)ctx->buf,
+ (unsigned char *)ctx->tmp,
+ ctx->tmp_len);
+ ctx->buf_off=0;
+ ctx->tmp_len=0;
+ goto again;
+ }
+ }
+ else if (ctx->base64.num != 0)
{
ctx->buf_off=0;
EVP_EncodeFinal(&(ctx->base64),
diff --git a/crypto/evp/bio_enc.c b/crypto/evp/bio_enc.c
index 6020736..6c30ddf 100644
--- a/crypto/evp/bio_enc.c
+++ b/crypto/evp/bio_enc.c
@@ -1,5 +1,5 @@
/* crypto/evp/bio_enc.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -116,6 +116,7 @@ BIO *bi;
BIO_ENC_CTX *ctx;
ctx=(BIO_ENC_CTX *)Malloc(sizeof(BIO_ENC_CTX));
+ EVP_CIPHER_CTX_init(&ctx->cipher);
if (ctx == NULL) return(0);
ctx->buf_len=0;
@@ -377,6 +378,26 @@ again:
return(ret);
}
+/*
+void BIO_set_cipher_ctx(b,c)
+BIO *b;
+EVP_CIPHER_ctx *c;
+ {
+ if (b == NULL) return;
+
+ if ((b->callback != NULL) &&
+ (b->callback(b,BIO_CB_CTRL,(char *)c,BIO_CTRL_SET,e,0L) <= 0))
+ return;
+
+ b->init=1;
+ ctx=(BIO_ENC_CTX *)b->ptr;
+ memcpy(ctx->cipher,c,sizeof(EVP_CIPHER_CTX));
+
+ if (b->callback != NULL)
+ b->callback(b,BIO_CB_CTRL,(char *)c,BIO_CTRL_SET,e,1L);
+ }
+*/
+
void BIO_set_cipher(b,c,k,i,e)
BIO *b;
EVP_CIPHER *c;
diff --git a/crypto/evp/bio_md.c b/crypto/evp/bio_md.c
index 0d6508c..fa5fdc0 100644
--- a/crypto/evp/bio_md.c
+++ b/crypto/evp/bio_md.c
@@ -1,5 +1,5 @@
/* crypto/evp/bio_md.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
diff --git a/crypto/evp/c_all.c b/crypto/evp/c_all.c
index b618d8d..e77d1c8 100644
--- a/crypto/evp/c_all.c
+++ b/crypto/evp/c_all.c
@@ -1,5 +1,5 @@
/* crypto/evp/c_all.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -97,6 +97,7 @@ void SSLeay_add_all_ciphers()
#ifndef NO_RC4
EVP_add_cipher(EVP_rc4());
+ EVP_add_cipher(EVP_rc4_40());
#endif
#ifndef NO_IDEA
@@ -113,6 +114,7 @@ void SSLeay_add_all_ciphers()
EVP_add_cipher(EVP_rc2_cfb());
EVP_add_cipher(EVP_rc2_ofb());
EVP_add_cipher(EVP_rc2_cbc());
+ EVP_add_cipher(EVP_rc2_40_cbc());
EVP_add_alias(SN_rc2_cbc,"RC2");
EVP_add_alias(SN_rc2_cbc,"rc2");
#endif
@@ -126,6 +128,28 @@ void SSLeay_add_all_ciphers()
EVP_add_alias(SN_bf_cbc,"bf");
EVP_add_alias(SN_bf_cbc,"blowfish");
#endif
+
+#ifndef NO_CAST
+ EVP_add_cipher(EVP_cast5_ecb());
+ EVP_add_cipher(EVP_cast5_cfb());
+ EVP_add_cipher(EVP_cast5_ofb());
+ EVP_add_cipher(EVP_cast5_cbc());
+ EVP_add_alias(SN_cast5_cbc,"CAST");
+ EVP_add_alias(SN_cast5_cbc,"cast");
+ EVP_add_alias(SN_cast5_cbc,"CAST-cbc");
+ EVP_add_alias(SN_cast5_cbc,"cast-cbc");
+#endif
+
+#ifndef NO_RC5
+ EVP_add_cipher(EVP_rc5_32_12_16_ecb());
+ EVP_add_cipher(EVP_rc5_32_12_16_cfb());
+ EVP_add_cipher(EVP_rc5_32_12_16_ofb());
+ EVP_add_cipher(EVP_rc5_32_12_16_cbc());
+ EVP_add_alias(SN_rc5_cbc,"rc5");
+ EVP_add_alias(SN_rc5_cbc,"RC5");
+ EVP_add_alias(SN_rc5_cbc,"rc5-cbc");
+ EVP_add_alias(SN_rc5_cbc,"RC5-cbc");
+#endif
}
@@ -134,8 +158,10 @@ void SSLeay_add_all_digests()
#ifndef NO_MD2
EVP_add_digest(EVP_md2());
#endif
-#ifndef NO_MD2
+#ifndef NO_MD5
EVP_add_digest(EVP_md5());
+ EVP_add_alias(SN_md5,"ssl2-md5");
+ EVP_add_alias(SN_md5,"ssl3-md5");
#endif
#ifndef NO_SHA
EVP_add_digest(EVP_sha());
@@ -145,11 +171,20 @@ void SSLeay_add_all_digests()
#endif
#ifndef NO_SHA1
EVP_add_digest(EVP_sha1());
+ EVP_add_alias(SN_sha1,"ssl3-sha1");
#ifndef NO_DSA
EVP_add_digest(EVP_dss1());
+ EVP_add_alias(SN_dsaWithSHA1,SN_dsaWithSHA1_2);
+ EVP_add_alias(SN_dsaWithSHA1,"DSS1");
+ EVP_add_alias(SN_dsaWithSHA1,"dss1");
#endif
#endif
#if !defined(NO_MDC2) && !defined(NO_DES)
EVP_add_digest(EVP_mdc2());
#endif
+#ifndef NO_RIPEMD160
+ EVP_add_digest(EVP_ripemd160());
+ EVP_add_alias(SN_ripemd160,"ripemd");
+ EVP_add_alias(SN_ripemd160,"rmd160");
+#endif
}
diff --git a/crypto/evp/digest.c b/crypto/evp/digest.c
index 035218d..d65f003 100644
--- a/crypto/evp/digest.c
+++ b/crypto/evp/digest.c
@@ -1,5 +1,5 @@
/* crypto/evp/digest.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
diff --git a/crypto/evp/e_cbc_3d.c b/crypto/evp/e_cbc_3d.c
index 3749759..5761bf1 100644
--- a/crypto/evp/e_cbc_3d.c
+++ b/crypto/evp/e_cbc_3d.c
@@ -1,5 +1,5 @@
/* crypto/evp/e_cbc_3d.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -80,6 +80,11 @@ static EVP_CIPHER d_cbc_ede_cipher2=
8,16,8,
des_cbc_ede_init_key,
des_cbc_ede_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
+ EVP_CIPHER_get_asn1_iv,
+ EVP_CIPHER_set_asn1_iv,
};
static EVP_CIPHER d_cbc_ede_cipher3=
@@ -88,6 +93,11 @@ static EVP_CIPHER d_cbc_ede_cipher3=
8,24,8,
des_cbc_ede3_init_key,
des_cbc_ede_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
+ EVP_CIPHER_set_asn1_iv,
+ EVP_CIPHER_get_asn1_iv,
};
EVP_CIPHER *EVP_des_ede_cbc()
@@ -107,8 +117,8 @@ unsigned char *iv;
int enc;
{
if (iv != NULL)
- memcpy(&(ctx->c.des_ede.oiv[0]),iv,8);
- memcpy(&(ctx->c.des_ede.iv[0]),&(ctx->c.des_ede.oiv[0]),8);
+ memcpy(&(ctx->oiv[0]),iv,8);
+ memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
if (key != NULL)
{
@@ -127,8 +137,8 @@ unsigned char *iv;
int enc;
{
if (iv != NULL)
- memcpy(&(ctx->c.des_ede.oiv[0]),iv,8);
- memcpy(&(ctx->c.des_ede.iv[0]),&(ctx->c.des_ede.oiv[0]),8);
+ memcpy(&(ctx->oiv[0]),iv,8);
+ memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
if (key != NULL)
{
@@ -148,6 +158,6 @@ unsigned int inl;
(des_cblock *)in,(des_cblock *)out,
(long)inl, ctx->c.des_ede.ks1,
ctx->c.des_ede.ks2,ctx->c.des_ede.ks3,
- (des_cblock *)&(ctx->c.des_ede.iv[0]),
+ (des_cblock *)&(ctx->iv[0]),
ctx->encrypt);
}
diff --git a/crypto/evp/e_cbc_bf.c b/crypto/evp/e_cbc_bf.c
index d6278e2..be605f4 100644
--- a/crypto/evp/e_cbc_bf.c
+++ b/crypto/evp/e_cbc_bf.c
@@ -1,5 +1,5 @@
/* crypto/evp/e_cbc_bf.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -79,6 +79,11 @@ static EVP_CIPHER bfish_cbc_cipher=
8,EVP_BLOWFISH_KEY_SIZE,8,
bf_cbc_init_key,
bf_cbc_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.bf_ks)),
+ EVP_CIPHER_get_asn1_iv,
+ EVP_CIPHER_set_asn1_iv,
};
EVP_CIPHER *EVP_bf_cbc()
@@ -93,10 +98,10 @@ unsigned char *iv;
int enc;
{
if (iv != NULL)
- memcpy(&(ctx->c.bf_cbc.oiv[0]),iv,8);
- memcpy(&(ctx->c.bf_cbc.iv[0]),&(ctx->c.bf_cbc.oiv[0]),8);
+ memcpy(&(ctx->oiv[0]),iv,8);
+ memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
if (key != NULL)
- BF_set_key(&(ctx->c.bf_cbc.ks),EVP_BLOWFISH_KEY_SIZE,key);
+ BF_set_key(&(ctx->c.bf_ks),EVP_BLOWFISH_KEY_SIZE,key);
}
static void bf_cbc_cipher(ctx,out,in,inl)
@@ -107,7 +112,7 @@ unsigned int inl;
{
BF_cbc_encrypt(
in,out,(long)inl,
- &(ctx->c.bf_cbc.ks),&(ctx->c.bf_cbc.iv[0]),
+ &(ctx->c.bf_ks),&(ctx->iv[0]),
ctx->encrypt);
}
diff --git a/crypto/evp/e_cbc_c.c b/crypto/evp/e_cbc_c.c
new file mode 100644
index 0000000..b50c787
--- /dev/null
+++ b/crypto/evp/e_cbc_c.c
@@ -0,0 +1,119 @@
+/* crypto/evp/e_cbc_c.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 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 acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS 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 AUTHOR OR 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef NO_CAST
+
+#include <stdio.h>
+#include "cryptlib.h"
+#include "evp.h"
+#include "objects.h"
+
+#ifndef NOPROTO
+static void cast_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
+ unsigned char *iv,int enc);
+static void cast_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
+ unsigned char *in, unsigned int inl);
+#else
+static void cast_cbc_init_key();
+static void cast_cbc_cipher();
+#endif
+
+static EVP_CIPHER cast5_cbc_cipher=
+ {
+ NID_cast5_cbc,
+ 8,EVP_CAST5_KEY_SIZE,8,
+ cast_cbc_init_key,
+ cast_cbc_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)),
+ EVP_CIPHER_get_asn1_iv,
+ EVP_CIPHER_set_asn1_iv,
+ };
+
+EVP_CIPHER *EVP_cast5_cbc()
+ {
+ return(&cast5_cbc_cipher);
+ }
+
+static void cast_cbc_init_key(ctx,key,iv,enc)
+EVP_CIPHER_CTX *ctx;
+unsigned char *key;
+unsigned char *iv;
+int enc;
+ {
+ if (iv != NULL)
+ memcpy(&(ctx->oiv[0]),iv,8);
+ memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
+ if (key != NULL)
+ CAST_set_key(&(ctx->c.cast_ks),EVP_CAST5_KEY_SIZE,key);
+ }
+
+static void cast_cbc_cipher(ctx,out,in,inl)
+EVP_CIPHER_CTX *ctx;
+unsigned char *out;
+unsigned char *in;
+unsigned int inl;
+ {
+ CAST_cbc_encrypt(
+ in,out,(long)inl,
+ &(ctx->c.cast_ks),&(ctx->iv[0]),
+ ctx->encrypt);
+ }
+
+#endif
diff --git a/crypto/evp/e_cbc_d.c b/crypto/evp/e_cbc_d.c
index accc01e..c67706e 100644
--- a/crypto/evp/e_cbc_d.c
+++ b/crypto/evp/e_cbc_d.c
@@ -1,5 +1,5 @@
/* crypto/evp/e_cbc_d.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -77,6 +77,11 @@ static EVP_CIPHER d_cbc_cipher=
8,8,8,
des_cbc_init_key,
des_cbc_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)),
+ EVP_CIPHER_get_asn1_iv,
+ EVP_CIPHER_set_asn1_iv,
};
EVP_CIPHER *EVP_des_cbc()
@@ -91,10 +96,10 @@ unsigned char *iv;
int enc;
{
if (iv != NULL)
- memcpy(&(ctx->c.des_cbc.oiv[0]),iv,8);
- memcpy(&(ctx->c.des_cbc.iv[0]),&(ctx->c.des_cbc.oiv[0]),8);
+ memcpy(&(ctx->oiv[0]),iv,8);
+ memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
if (key != NULL)
- des_set_key((des_cblock *)key,ctx->c.des_cbc.ks);
+ des_set_key((des_cblock *)key,ctx->c.des_ks);
}
static void des_cbc_cipher(ctx,out,in,inl)
@@ -105,7 +110,7 @@ unsigned int inl;
{
des_ncbc_encrypt(
(des_cblock *)in,(des_cblock *)out,
- (long)inl, ctx->c.des_cbc.ks,
- (des_cblock *)&(ctx->c.des_cbc.iv[0]),
+ (long)inl, ctx->c.des_ks,
+ (des_cblock *)&(ctx->iv[0]),
ctx->encrypt);
}
diff --git a/crypto/evp/e_cbc_i.c b/crypto/evp/e_cbc_i.c
index abfb5ed..312ffcb 100644
--- a/crypto/evp/e_cbc_i.c
+++ b/crypto/evp/e_cbc_i.c
@@ -1,5 +1,5 @@
/* crypto/evp/e_cbc_i.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -79,6 +79,11 @@ static EVP_CIPHER i_cbc_cipher=
8,16,8,
idea_cbc_init_key,
idea_cbc_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.idea_ks)),
+ EVP_CIPHER_get_asn1_iv,
+ EVP_CIPHER_set_asn1_iv,
};
EVP_CIPHER *EVP_idea_cbc()
@@ -93,18 +98,18 @@ unsigned char *iv;
int enc;
{
if (iv != NULL)
- memcpy(&(ctx->c.idea_cbc.oiv[0]),iv,8);
- memcpy(&(ctx->c.idea_cbc.iv[0]),&(ctx->c.idea_cbc.oiv[0]),8);
+ memcpy(&(ctx->oiv[0]),iv,8);
+ memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
if (key != NULL)
{
if (enc)
- idea_set_encrypt_key(key,&(ctx->c.idea_cbc.ks));
+ idea_set_encrypt_key(key,&(ctx->c.idea_ks));
else
{
IDEA_KEY_SCHEDULE tmp;
idea_set_encrypt_key(key,&tmp);
- idea_set_decrypt_key(&tmp,&(ctx->c.idea_cbc.ks));
+ idea_set_decrypt_key(&tmp,&(ctx->c.idea_ks));
memset((unsigned char *)&tmp,0,
sizeof(IDEA_KEY_SCHEDULE));
}
@@ -119,7 +124,7 @@ unsigned int inl;
{
idea_cbc_encrypt(
in,out,(long)inl,
- &(ctx->c.idea_cbc.ks),&(ctx->c.idea_cbc.iv[0]),
+ &(ctx->c.idea_ks),&(ctx->iv[0]),
ctx->encrypt);
}
diff --git a/crypto/evp/e_cbc_r2.c b/crypto/evp/e_cbc_r2.c
index 2e3f855..4f8002f 100644
--- a/crypto/evp/e_cbc_r2.c
+++ b/crypto/evp/e_cbc_r2.c
@@ -1,5 +1,5 @@
/* crypto/evp/e_cbc_r2.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -79,12 +79,33 @@ static EVP_CIPHER r2_cbc_cipher=
8,EVP_RC2_KEY_SIZE,8,
rc2_cbc_init_key,
rc2_cbc_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)),
+ EVP_CIPHER_get_asn1_iv,
+ EVP_CIPHER_set_asn1_iv,
+ };
+
+static EVP_CIPHER r2_40_cbc_cipher=
+ {
+ NID_rc2_40_cbc,
+ 8,5 /* 40 bit */,8,
+ rc2_cbc_init_key,
+ rc2_cbc_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)),
};
EVP_CIPHER *EVP_rc2_cbc()
{
return(&r2_cbc_cipher);
}
+
+EVP_CIPHER *EVP_rc2_40_cbc()
+ {
+ return(&r2_40_cbc_cipher);
+ }
static void rc2_cbc_init_key(ctx,key,iv,enc)
EVP_CIPHER_CTX *ctx;
@@ -93,11 +114,11 @@ unsigned char *iv;
int enc;
{
if (iv != NULL)
- memcpy(&(ctx->c.rc2_cbc.oiv[0]),iv,8);
- memcpy(&(ctx->c.rc2_cbc.iv[0]),&(ctx->c.rc2_cbc.oiv[0]),8);
+ memcpy(&(ctx->oiv[0]),iv,8);
+ memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
if (key != NULL)
- RC2_set_key(&(ctx->c.rc2_cbc.ks),EVP_RC2_KEY_SIZE,key,
- EVP_RC2_KEY_SIZE*8);
+ RC2_set_key(&(ctx->c.rc2_ks),EVP_CIPHER_CTX_key_length(ctx),
+ key,EVP_CIPHER_CTX_key_length(ctx)*8);
}
static void rc2_cbc_cipher(ctx,out,in,inl)
@@ -108,7 +129,7 @@ unsigned int inl;
{
RC2_cbc_encrypt(
in,out,(long)inl,
- &(ctx->c.rc2_cbc.ks),&(ctx->c.rc2_cbc.iv[0]),
+ &(ctx->c.rc2_ks),&(ctx->iv[0]),
ctx->encrypt);
}
diff --git a/crypto/evp/e_cbc_r5.c b/crypto/evp/e_cbc_r5.c
new file mode 100644
index 0000000..f7d46ca
--- /dev/null
+++ b/crypto/evp/e_cbc_r5.c
@@ -0,0 +1,120 @@
+/* crypto/evp/e_cbc_r5.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 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 acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS 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 AUTHOR OR 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef NO_RC5
+
+#include <stdio.h>
+#include "cryptlib.h"
+#include "evp.h"
+#include "objects.h"
+
+#ifndef NOPROTO
+static void r_32_12_16_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
+ unsigned char *iv,int enc);
+static void r_32_12_16_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
+ unsigned char *in, unsigned int inl);
+#else
+static void r_32_12_16_cbc_init_key();
+static void r_32_12_16_cbc_cipher();
+#endif
+
+static EVP_CIPHER rc5_32_12_16_cbc_cipher=
+ {
+ NID_rc5_cbc,
+ 8,EVP_RC5_32_12_16_KEY_SIZE,8,
+ r_32_12_16_cbc_init_key,
+ r_32_12_16_cbc_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc5_ks)),
+ NULL,
+ NULL,
+ };
+
+EVP_CIPHER *EVP_rc5_32_12_16_cbc()
+ {
+ return(&rc5_32_12_16_cbc_cipher);
+ }
+
+static void r_32_12_16_cbc_init_key(ctx,key,iv,enc)
+EVP_CIPHER_CTX *ctx;
+unsigned char *key;
+unsigned char *iv;
+int enc;
+ {
+ if (iv != NULL)
+ memcpy(&(ctx->oiv[0]),iv,8);
+ memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
+ if (key != NULL)
+ RC5_32_set_key(&(ctx->c.rc5_ks),EVP_RC5_32_12_16_KEY_SIZE,
+ key,RC5_12_ROUNDS);
+ }
+
+static void r_32_12_16_cbc_cipher(ctx,out,in,inl)
+EVP_CIPHER_CTX *ctx;
+unsigned char *out;
+unsigned char *in;
+unsigned int inl;
+ {
+ RC5_32_cbc_encrypt(
+ in,out,(long)inl,
+ &(ctx->c.rc5_ks),&(ctx->iv[0]),
+ ctx->encrypt);
+ }
+
+#endif
diff --git a/crypto/evp/e_cfb_3d.c b/crypto/evp/e_cfb_3d.c
index 3d6577a..e7e3419 100644
--- a/crypto/evp/e_cfb_3d.c
+++ b/crypto/evp/e_cfb_3d.c
@@ -1,5 +1,5 @@
/* crypto/evp/e_cfb_3d.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -80,6 +80,11 @@ static EVP_CIPHER d_ede_cfb_cipher2=
1,16,8,
des_ede_cfb_init_key,
des_ede_cfb_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
+ EVP_CIPHER_set_asn1_iv,
+ EVP_CIPHER_get_asn1_iv,
};
static EVP_CIPHER d_ede3_cfb_cipher3=
@@ -88,6 +93,11 @@ static EVP_CIPHER d_ede3_cfb_cipher3=
1,24,8,
des_ede3_cfb_init_key,
des_ede_cfb_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
+ EVP_CIPHER_set_asn1_iv,
+ EVP_CIPHER_get_asn1_iv,
};
EVP_CIPHER *EVP_des_ede_cfb()
@@ -106,18 +116,18 @@ unsigned char *key;
unsigned char *iv;
int enc;
{
- ctx->c.des_cfb.num=0;
+ ctx->num=0;
if (iv != NULL)
- memcpy(&(ctx->c.des_cfb.oiv[0]),iv,8);
- memcpy(&(ctx->c.des_cfb.iv[0]),&(ctx->c.des_cfb.oiv[0]),8);
+ memcpy(&(ctx->oiv[0]),iv,8);
+ memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
if (key != NULL)
{
- des_set_key((des_cblock *)key,ctx->c.des_cfb.ks);
- des_set_key((des_cblock *)&(key[8]),ctx->c.des_cfb.ks2);
- memcpy( (char *)ctx->c.des_cfb.ks3,
- (char *)ctx->c.des_cfb.ks,
- sizeof(ctx->c.des_cfb.ks));
+ des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
+ des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
+ memcpy( (char *)ctx->c.des_ede.ks3,
+ (char *)ctx->c.des_ede.ks1,
+ sizeof(ctx->c.des_ede.ks1));
}
}
@@ -127,16 +137,16 @@ unsigned char *key;
unsigned char *iv;
int enc;
{
- ctx->c.des_cfb.num=0;
+ ctx->num=0;
if (iv != NULL)
- memcpy(&(ctx->c.des_cfb.oiv[0]),iv,8);
- memcpy(&(ctx->c.des_cfb.iv[0]),&(ctx->c.des_cfb.oiv[0]),8);
+ memcpy(&(ctx->oiv[0]),iv,8);
+ memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
if (key != NULL)
{
- des_set_key((des_cblock *)key,ctx->c.des_cfb.ks);
- des_set_key((des_cblock *)&(key[8]),ctx->c.des_cfb.ks2);
- des_set_key((des_cblock *)&(key[16]),ctx->c.des_cfb.ks3);
+ des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
+ des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
+ des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3);
}
}
@@ -148,9 +158,9 @@ unsigned int inl;
{
des_ede3_cfb64_encrypt(
in,out,(long)inl,
- ctx->c.des_cfb.ks,
- ctx->c.des_cfb.ks2,
- ctx->c.des_cfb.ks3,
- (des_cblock *)&(ctx->c.des_cfb.iv[0]),
- &ctx->c.des_cfb.num,ctx->encrypt);
+ ctx->c.des_ede.ks1,
+ ctx->c.des_ede.ks2,
+ ctx->c.des_ede.ks3,
+ (des_cblock *)&(ctx->iv[0]),
+ &ctx->num,ctx->encrypt);
}
diff --git a/crypto/evp/e_cfb_bf.c b/crypto/evp/e_cfb_bf.c
index be15d14..8aba256 100644
--- a/crypto/evp/e_cfb_bf.c
+++ b/crypto/evp/e_cfb_bf.c
@@ -1,5 +1,5 @@
/* crypto/evp/e_cfb_bf.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -79,6 +79,11 @@ static EVP_CIPHER bfish_cfb_cipher=
1,EVP_BLOWFISH_KEY_SIZE,8,
bf_cfb_init_key,
bf_cfb_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.bf_ks)),
+ EVP_CIPHER_set_asn1_iv,
+ EVP_CIPHER_get_asn1_iv,
};
EVP_CIPHER *EVP_bf_cfb()
@@ -92,13 +97,13 @@ unsigned char *key;
unsigned char *iv;
int enc;
{
- ctx->c.bf_cfb.num=0;
+ ctx->num=0;
if (iv != NULL)
- memcpy(&(ctx->c.bf_cfb.oiv[0]),iv,8);
- memcpy(&(ctx->c.bf_cfb.iv[0]),&(ctx->c.bf_cfb.oiv[0]),8);
+ memcpy(&(ctx->oiv[0]),iv,8);
+ memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
if (key != NULL)
- BF_set_key(&(ctx->c.bf_cfb.ks),EVP_BLOWFISH_KEY_SIZE,key);
+ BF_set_key(&(ctx->c.bf_ks),EVP_BLOWFISH_KEY_SIZE,key);
}
static void bf_cfb_cipher(ctx,out,in,inl)
@@ -109,8 +114,8 @@ unsigned int inl;
{
BF_cfb64_encrypt(
in,out,
- (long)inl, &(ctx->c.bf_cfb.ks),
- &(ctx->c.bf_cfb.iv[0]),
- &ctx->c.bf_cfb.num,ctx->encrypt);
+ (long)inl, &(ctx->c.bf_ks),
+ &(ctx->iv[0]),
+ &ctx->num,ctx->encrypt);
}
#endif
diff --git a/crypto/evp/e_cfb_c.c b/crypto/evp/e_cfb_c.c
new file mode 100644
index 0000000..936df55
--- /dev/null
+++ b/crypto/evp/e_cfb_c.c
@@ -0,0 +1,121 @@
+/* crypto/evp/e_cfb_c.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 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 acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS 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 AUTHOR OR 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef NO_CAST
+
+#include <stdio.h>
+#include "cryptlib.h"
+#include "evp.h"
+#include "objects.h"
+
+#ifndef NOPROTO
+static void cast_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
+ unsigned char *iv,int enc);
+static void cast_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
+ unsigned char *in, unsigned int inl);
+#else
+static void cast_cfb_init_key();
+static void cast_cfb_cipher();
+#endif
+
+static EVP_CIPHER cast5_cfb_cipher=
+ {
+ NID_cast5_cfb64,
+ 1,EVP_CAST5_KEY_SIZE,8,
+ cast_cfb_init_key,
+ cast_cfb_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)),
+ EVP_CIPHER_set_asn1_iv,
+ EVP_CIPHER_get_asn1_iv,
+ };
+
+EVP_CIPHER *EVP_cast5_cfb()
+ {
+ return(&cast5_cfb_cipher);
+ }
+
+static void cast_cfb_init_key(ctx,key,iv,enc)
+EVP_CIPHER_CTX *ctx;
+unsigned char *key;
+unsigned char *iv;
+int enc;
+ {
+ ctx->num=0;
+
+ if (iv != NULL)
+ memcpy(&(ctx->oiv[0]),iv,8);
+ memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
+ if (key != NULL)
+ CAST_set_key(&(ctx->c.cast_ks),EVP_CAST5_KEY_SIZE,key);
+ }
+
+static void cast_cfb_cipher(ctx,out,in,inl)
+EVP_CIPHER_CTX *ctx;
+unsigned char *out;
+unsigned char *in;
+unsigned int inl;
+ {
+ CAST_cfb64_encrypt(
+ in,out,
+ (long)inl, &(ctx->c.cast_ks),
+ &(ctx->iv[0]),
+ &ctx->num,ctx->encrypt);
+ }
+#endif
diff --git a/crypto/evp/e_cfb_d.c b/crypto/evp/e_cfb_d.c
index 75af87a..9ae4558 100644
--- a/crypto/evp/e_cfb_d.c
+++ b/crypto/evp/e_cfb_d.c
@@ -1,5 +1,5 @@
/* crypto/evp/e_cfb_d.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -77,6 +77,11 @@ static EVP_CIPHER d_cfb_cipher=
1,8,8,
des_cfb_init_key,
des_cfb_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)),
+ EVP_CIPHER_set_asn1_iv,
+ EVP_CIPHER_get_asn1_iv,
};
EVP_CIPHER *EVP_des_cfb()
@@ -90,13 +95,13 @@ unsigned char *key;
unsigned char *iv;
int enc;
{
- ctx->c.des_cfb.num=0;
+ ctx->num=0;
if (iv != NULL)
- memcpy(&(ctx->c.des_cfb.oiv[0]),iv,8);
- memcpy(&(ctx->c.des_cfb.iv[0]),&(ctx->c.des_cfb.oiv[0]),8);
+ memcpy(&(ctx->oiv[0]),iv,8);
+ memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
if (key != NULL)
- des_set_key((des_cblock *)key,ctx->c.des_cfb.ks);
+ des_set_key((des_cblock *)key,ctx->c.des_ks);
}
static void des_cfb_cipher(ctx,out,in,inl)
@@ -107,7 +112,7 @@ unsigned int inl;
{
des_cfb64_encrypt(
in,out,
- (long)inl, ctx->c.des_cfb.ks,
- (des_cblock *)&(ctx->c.des_cfb.iv[0]),
- &ctx->c.des_cfb.num,ctx->encrypt);
+ (long)inl, ctx->c.des_ks,
+ (des_cblock *)&(ctx->iv[0]),
+ &ctx->num,ctx->encrypt);
}
diff --git a/crypto/evp/e_cfb_i.c b/crypto/evp/e_cfb_i.c
index 7fe2fbf..9225efa 100644
--- a/crypto/evp/e_cfb_i.c
+++ b/crypto/evp/e_cfb_i.c
@@ -1,5 +1,5 @@
/* crypto/evp/e_cfb_i.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -79,6 +79,11 @@ static EVP_CIPHER i_cfb_cipher=
1,IDEA_KEY_LENGTH,IDEA_BLOCK,
idea_cfb_init_key,
idea_cfb_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.idea_ks)),
+ EVP_CIPHER_set_asn1_iv,
+ EVP_CIPHER_get_asn1_iv,
};
EVP_CIPHER *EVP_idea_cfb()
@@ -92,13 +97,13 @@ unsigned char *key;
unsigned char *iv;
int enc;
{
- ctx->c.idea_cfb.num=0;
+ ctx->num=0;
if (iv != NULL)
- memcpy(&(ctx->c.idea_cfb.oiv[0]),iv,8);
- memcpy(&(ctx->c.idea_cfb.iv[0]),&(ctx->c.idea_cfb.oiv[0]),8);
+ memcpy(&(ctx->oiv[0]),iv,8);
+ memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
if (key != NULL)
- idea_set_encrypt_key(key,&(ctx->c.idea_cfb.ks));
+ idea_set_encrypt_key(key,&(ctx->c.idea_ks));
}
static void idea_cfb_cipher(ctx,out,in,inl)
@@ -109,8 +114,8 @@ unsigned int inl;
{
idea_cfb64_encrypt(
in,out,(long)inl,
- &(ctx->c.idea_cfb.ks),&(ctx->c.idea_cfb.iv[0]),
- &ctx->c.idea_cfb.num,ctx->encrypt);
+ &(ctx->c.idea_ks),&(ctx->iv[0]),
+ &ctx->num,ctx->encrypt);
}
#endif
diff --git a/crypto/evp/e_cfb_r2.c b/crypto/evp/e_cfb_r2.c
index a63c0f1..af5a39d 100644
--- a/crypto/evp/e_cfb_r2.c
+++ b/crypto/evp/e_cfb_r2.c
@@ -1,5 +1,5 @@
/* crypto/evp/e_cfb_r2.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -79,6 +79,11 @@ static EVP_CIPHER r2_cfb_cipher=
1,EVP_RC2_KEY_SIZE,8,
rc2_cfb_init_key,
rc2_cfb_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)),
+ EVP_CIPHER_set_asn1_iv,
+ EVP_CIPHER_get_asn1_iv,
};
EVP_CIPHER *EVP_rc2_cfb()
@@ -92,13 +97,13 @@ unsigned char *key;
unsigned char *iv;
int enc;
{
- ctx->c.rc2_cfb.num=0;
+ ctx->num=0;
if (iv != NULL)
- memcpy(&(ctx->c.rc2_cfb.oiv[0]),iv,8);
- memcpy(&(ctx->c.rc2_cfb.iv[0]),&(ctx->c.rc2_cfb.oiv[0]),8);
+ memcpy(&(ctx->oiv[0]),iv,8);
+ memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
if (key != NULL)
- RC2_set_key(&(ctx->c.rc2_cfb.ks),EVP_RC2_KEY_SIZE,key,
+ RC2_set_key(&(ctx->c.rc2_ks),EVP_RC2_KEY_SIZE,key,
EVP_RC2_KEY_SIZE*8);
}
@@ -110,8 +115,8 @@ unsigned int inl;
{
RC2_cfb64_encrypt(
in,out,
- (long)inl, &(ctx->c.rc2_cfb.ks),
- &(ctx->c.rc2_cfb.iv[0]),
- &ctx->c.rc2_cfb.num,ctx->encrypt);
+ (long)inl, &(ctx->c.rc2_ks),
+ &(ctx->iv[0]),
+ &ctx->num,ctx->encrypt);
}
#endif
diff --git a/crypto/evp/e_cfb_r5.c b/crypto/evp/e_cfb_r5.c
new file mode 100644
index 0000000..a2fddae
--- /dev/null
+++ b/crypto/evp/e_cfb_r5.c
@@ -0,0 +1,122 @@
+/* crypto/evp/e_cfb_r5.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 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 acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS 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 AUTHOR OR 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef NO_RC5
+
+#include <stdio.h>
+#include "cryptlib.h"
+#include "evp.h"
+#include "objects.h"
+
+#ifndef NOPROTO
+static void rc5_32_12_16_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
+ unsigned char *iv,int enc);
+static void rc5_32_12_16_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
+ unsigned char *in, unsigned int inl);
+#else
+static void rc5_32_12_16_cfb_init_key();
+static void rc5_32_12_16_cfb_cipher();
+#endif
+
+static EVP_CIPHER rc5_cfb_cipher=
+ {
+ NID_rc5_cfb64,
+ 1,EVP_RC5_32_12_16_KEY_SIZE,8,
+ rc5_32_12_16_cfb_init_key,
+ rc5_32_12_16_cfb_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc5_ks)),
+ EVP_CIPHER_set_asn1_iv,
+ EVP_CIPHER_get_asn1_iv,
+ };
+
+EVP_CIPHER *EVP_rc5_32_12_16_cfb()
+ {
+ return(&rc5_cfb_cipher);
+ }
+
+static void rc5_32_12_16_cfb_init_key(ctx,key,iv,enc)
+EVP_CIPHER_CTX *ctx;
+unsigned char *key;
+unsigned char *iv;
+int enc;
+ {
+ ctx->num=0;
+
+ if (iv != NULL)
+ memcpy(&(ctx->oiv[0]),iv,8);
+ memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
+ if (key != NULL)
+ RC5_32_set_key(&(ctx->c.rc5_ks),EVP_RC5_32_12_16_KEY_SIZE,key,
+ RC5_12_ROUNDS);
+ }
+
+static void rc5_32_12_16_cfb_cipher(ctx,out,in,inl)
+EVP_CIPHER_CTX *ctx;
+unsigned char *out;
+unsigned char *in;
+unsigned int inl;
+ {
+ RC5_32_cfb64_encrypt(
+ in,out,
+ (long)inl, &(ctx->c.rc5_ks),
+ &(ctx->iv[0]),
+ &ctx->num,ctx->encrypt);
+ }
+#endif
diff --git a/crypto/evp/e_dsa.c b/crypto/evp/e_dsa.c
index f3dc78e..6715c3e 100644
--- a/crypto/evp/e_dsa.c
+++ b/crypto/evp/e_dsa.c
@@ -1,5 +1,5 @@
/* crypto/evp/e_dsa.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
diff --git a/crypto/evp/e_ecb_3d.c b/crypto/evp/e_ecb_3d.c
index 0a19805..908fc07 100644
--- a/crypto/evp/e_ecb_3d.c
+++ b/crypto/evp/e_ecb_3d.c
@@ -1,5 +1,5 @@
/* crypto/evp/e_ecb_3d.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -80,6 +80,11 @@ static EVP_CIPHER d_ede_cipher2=
8,16,0,
des_ede_init_key,
des_ede_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
+ NULL,
+ NULL,
};
static EVP_CIPHER d_ede3_cipher3=
@@ -88,6 +93,10 @@ static EVP_CIPHER d_ede3_cipher3=
8,24,0,
des_ede3_init_key,
des_ede_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
+ NULL,
};
EVP_CIPHER *EVP_des_ede()
diff --git a/crypto/evp/e_ecb_bf.c b/crypto/evp/e_ecb_bf.c
index f625862..142a9d3 100644
--- a/crypto/evp/e_ecb_bf.c
+++ b/crypto/evp/e_ecb_bf.c
@@ -1,5 +1,5 @@
/* crypto/evp/e_ecb_bf.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -79,6 +79,11 @@ static EVP_CIPHER bfish_ecb_cipher=
8,EVP_BLOWFISH_KEY_SIZE,0,
bf_ecb_init_key,
bf_ecb_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.bf_ks)),
+ NULL,
+ NULL,
};
EVP_CIPHER *EVP_bf_ecb()
@@ -93,7 +98,7 @@ unsigned char *iv;
int enc;
{
if (key != NULL)
- BF_set_key(&(ctx->c.bf_ecb.ks),EVP_BLOWFISH_KEY_SIZE,key);
+ BF_set_key(&(ctx->c.bf_ks),EVP_BLOWFISH_KEY_SIZE,key);
}
static void bf_ecb_cipher(ctx,out,in,inl)
@@ -110,7 +115,7 @@ unsigned int inl;
{
BF_ecb_encrypt(
&(in[i]),&(out[i]),
- &(ctx->c.bf_ecb.ks),ctx->encrypt);
+ &(ctx->c.bf_ks),ctx->encrypt);
}
}
diff --git a/crypto/evp/e_ecb_c.c b/crypto/evp/e_ecb_c.c
new file mode 100644
index 0000000..34e0c18
--- /dev/null
+++ b/crypto/evp/e_ecb_c.c
@@ -0,0 +1,122 @@
+/* crypto/evp/e_ecb_c.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 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 acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS 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 AUTHOR OR 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef NO_CAST
+
+#include <stdio.h>
+#include "cryptlib.h"
+#include "evp.h"
+#include "objects.h"
+
+#ifndef NOPROTO
+static void cast_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
+ unsigned char *iv,int enc);
+static void cast_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
+ unsigned char *in, unsigned int inl);
+#else
+static void cast_ecb_init_key();
+static void cast_ecb_cipher();
+#endif
+
+static EVP_CIPHER cast5_ecb_cipher=
+ {
+ NID_cast5_ecb,
+ 8,EVP_CAST5_KEY_SIZE,0,
+ cast_ecb_init_key,
+ cast_ecb_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)),
+ NULL,
+ NULL,
+ };
+
+EVP_CIPHER *EVP_cast5_ecb()
+ {
+ return(&cast5_ecb_cipher);
+ }
+
+static void cast_ecb_init_key(ctx,key,iv,enc)
+EVP_CIPHER_CTX *ctx;
+unsigned char *key;
+unsigned char *iv;
+int enc;
+ {
+ if (key != NULL)
+ CAST_set_key(&(ctx->c.cast_ks),EVP_CAST5_KEY_SIZE,key);
+ }
+
+static void cast_ecb_cipher(ctx,out,in,inl)
+EVP_CIPHER_CTX *ctx;
+unsigned char *out;
+unsigned char *in;
+unsigned int inl;
+ {
+ unsigned int i;
+
+ if (inl < 8) return;
+ inl-=8;
+ for (i=0; i<=inl; i+=8)
+ {
+ CAST_ecb_encrypt(
+ &(in[i]),&(out[i]),
+ &(ctx->c.cast_ks),ctx->encrypt);
+ }
+ }
+
+#endif
diff --git a/crypto/evp/e_ecb_d.c b/crypto/evp/e_ecb_d.c
index b1b80e6..7a409d6 100644
--- a/crypto/evp/e_ecb_d.c
+++ b/crypto/evp/e_ecb_d.c
@@ -1,5 +1,5 @@
/* crypto/evp/e_ecb_d.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -77,6 +77,11 @@ static EVP_CIPHER d_ecb_cipher=
8,8,0,
des_ecb_init_key,
des_ecb_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)),
+ NULL,
+ NULL,
};
EVP_CIPHER *EVP_des_ecb()
@@ -91,7 +96,7 @@ unsigned char *iv;
int enc;
{
if (key != NULL)
- des_set_key((des_cblock *)key,ctx->c.des_ecb.ks);
+ des_set_key((des_cblock *)key,ctx->c.des_ks);
}
static void des_ecb_cipher(ctx,out,in,inl)
@@ -108,6 +113,6 @@ unsigned int inl;
{
des_ecb_encrypt(
(des_cblock *)&(in[i]),(des_cblock *)&(out[i]),
- ctx->c.des_ecb.ks,ctx->encrypt);
+ ctx->c.des_ks,ctx->encrypt);
}
}
diff --git a/crypto/evp/e_ecb_i.c b/crypto/evp/e_ecb_i.c
index 318c4c3..e24022a 100644
--- a/crypto/evp/e_ecb_i.c
+++ b/crypto/evp/e_ecb_i.c
@@ -1,5 +1,5 @@
/* crypto/evp/e_ecb_i.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -79,6 +79,11 @@ static EVP_CIPHER i_ecb_cipher=
8,16,0,
idea_ecb_init_key,
idea_ecb_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.idea_ks)),
+ NULL,
+ NULL,
};
EVP_CIPHER *EVP_idea_ecb()
@@ -95,13 +100,13 @@ int enc;
if (key != NULL)
{
if (enc)
- idea_set_encrypt_key(key,&(ctx->c.idea_ecb.ks));
+ idea_set_encrypt_key(key,&(ctx->c.idea_ks));
else
{
IDEA_KEY_SCHEDULE tmp;
idea_set_encrypt_key(key,&tmp);
- idea_set_decrypt_key(&tmp, &(ctx->c.idea_ecb.ks));
+ idea_set_decrypt_key(&tmp, &(ctx->c.idea_ks));
memset((unsigned char *)&tmp,0,
sizeof(IDEA_KEY_SCHEDULE));
}
@@ -121,7 +126,7 @@ unsigned int inl;
for (i=0; i<=inl; i+=8)
{
idea_ecb_encrypt(
- &(in[i]),&(out[i]),&(ctx->c.idea_ecb.ks));
+ &(in[i]),&(out[i]),&(ctx->c.idea_ks));
}
}
diff --git a/crypto/evp/e_ecb_r2.c b/crypto/evp/e_ecb_r2.c
index 66d25f6..e35b06d 100644
--- a/crypto/evp/e_ecb_r2.c
+++ b/crypto/evp/e_ecb_r2.c
@@ -1,5 +1,5 @@
/* crypto/evp/e_ecb_r2.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -79,6 +79,11 @@ static EVP_CIPHER r2_ecb_cipher=
8,EVP_RC2_KEY_SIZE,0,
rc2_ecb_init_key,
rc2_ecb_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)),
+ NULL,
+ NULL,
};
EVP_CIPHER *EVP_rc2_ecb()
@@ -93,7 +98,7 @@ unsigned char *iv;
int enc;
{
if (key != NULL)
- RC2_set_key(&(ctx->c.rc2_ecb.ks),EVP_RC2_KEY_SIZE,key,
+ RC2_set_key(&(ctx->c.rc2_ks),EVP_RC2_KEY_SIZE,key,
EVP_RC2_KEY_SIZE*8);
}
@@ -111,7 +116,7 @@ unsigned int inl;
{
RC2_ecb_encrypt(
&(in[i]),&(out[i]),
- &(ctx->c.rc2_ecb.ks),ctx->encrypt);
+ &(ctx->c.rc2_ks),ctx->encrypt);
}
}
diff --git a/crypto/evp/e_ecb_r5.c b/crypto/evp/e_ecb_r5.c
new file mode 100644
index 0000000..08f4a82
--- /dev/null
+++ b/crypto/evp/e_ecb_r5.c
@@ -0,0 +1,123 @@
+/* crypto/evp/e_ecb_r5.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 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 acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS 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 AUTHOR OR 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef NO_RC5
+
+#include <stdio.h>
+#include "cryptlib.h"
+#include "evp.h"
+#include "objects.h"
+
+#ifndef NOPROTO
+static void rc5_32_12_16_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
+ unsigned char *iv,int enc);
+static void rc5_32_12_16_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
+ unsigned char *in, unsigned int inl);
+#else
+static void rc5_32_12_16_ecb_init_key();
+static void rc5_32_12_16_ecb_cipher();
+#endif
+
+static EVP_CIPHER rc5_ecb_cipher=
+ {
+ NID_rc5_ecb,
+ 8,EVP_RC5_32_12_16_KEY_SIZE,0,
+ rc5_32_12_16_ecb_init_key,
+ rc5_32_12_16_ecb_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc5_ks)),
+ NULL,
+ NULL,
+ };
+
+EVP_CIPHER *EVP_rc5_32_12_16_ecb()
+ {
+ return(&rc5_ecb_cipher);
+ }
+
+static void rc5_32_12_16_ecb_init_key(ctx,key,iv,enc)
+EVP_CIPHER_CTX *ctx;
+unsigned char *key;
+unsigned char *iv;
+int enc;
+ {
+ if (key != NULL)
+ RC5_32_set_key(&(ctx->c.rc5_ks),EVP_RC5_32_12_16_KEY_SIZE,key,
+ RC5_12_ROUNDS);
+ }
+
+static void rc5_32_12_16_ecb_cipher(ctx,out,in,inl)
+EVP_CIPHER_CTX *ctx;
+unsigned char *out;
+unsigned char *in;
+unsigned int inl;
+ {
+ unsigned int i;
+
+ if (inl < 8) return;
+ inl-=8;
+ for (i=0; i<=inl; i+=8)
+ {
+ RC5_32_ecb_encrypt(
+ &(in[i]),&(out[i]),
+ &(ctx->c.rc5_ks),ctx->encrypt);
+ }
+ }
+
+#endif
diff --git a/crypto/evp/e_null.c b/crypto/evp/e_null.c
index c30e273..e4e7ca7 100644
--- a/crypto/evp/e_null.c
+++ b/crypto/evp/e_null.c
@@ -1,5 +1,5 @@
/* crypto/evp/e_null.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -77,6 +77,10 @@ static EVP_CIPHER n_cipher=
1,0,0,
null_init_key,
null_cipher,
+ NULL,
+ 0,
+ NULL,
+ NULL,
};
EVP_CIPHER *EVP_enc_null()
diff --git a/crypto/evp/e_ofb_3d.c b/crypto/evp/e_ofb_3d.c
index 7dbe50f..c3add18 100644
--- a/crypto/evp/e_ofb_3d.c
+++ b/crypto/evp/e_ofb_3d.c
@@ -1,5 +1,5 @@
/* crypto/evp/e_ofb_3d.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -80,6 +80,11 @@ static EVP_CIPHER d_ede_ofb_cipher2=
1,16,8,
des_ede_ofb_init_key,
des_ede_ofb_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
+ EVP_CIPHER_set_asn1_iv,
+ EVP_CIPHER_get_asn1_iv,
};
static EVP_CIPHER d_ede3_ofb_cipher3=
@@ -88,6 +93,11 @@ static EVP_CIPHER d_ede3_ofb_cipher3=
1,24,8,
des_ede3_ofb_init_key,
des_ede_ofb_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
+ EVP_CIPHER_set_asn1_iv,
+ EVP_CIPHER_get_asn1_iv,
};
EVP_CIPHER *EVP_des_ede_ofb()
@@ -106,18 +116,18 @@ unsigned char *key;
unsigned char *iv;
int enc;
{
- ctx->c.des_cfb.num=0;
+ ctx->num=0;
if (iv != NULL)
- memcpy(&(ctx->c.des_cfb.oiv[0]),iv,8);
- memcpy(&(ctx->c.des_cfb.iv[0]),&(ctx->c.des_cfb.oiv[0]),8);
+ memcpy(&(ctx->oiv[0]),iv,8);
+ memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
if (key != NULL)
{
- des_set_key((des_cblock *)key,ctx->c.des_cfb.ks);
- des_set_key((des_cblock *)&(key[8]),ctx->c.des_cfb.ks2);
- memcpy( (char *)ctx->c.des_cfb.ks3,
- (char *)ctx->c.des_cfb.ks,
- sizeof(ctx->c.des_cfb.ks));
+ des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
+ des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
+ memcpy( (char *)ctx->c.des_ede.ks3,
+ (char *)ctx->c.des_ede.ks1,
+ sizeof(ctx->c.des_ede.ks1));
}
}
@@ -127,16 +137,16 @@ unsigned char *key;
unsigned char *iv;
int enc;
{
- ctx->c.des_cfb.num=0;
+ ctx->num=0;
if (iv != NULL)
- memcpy(&(ctx->c.des_cfb.oiv[0]),iv,8);
- memcpy(&(ctx->c.des_cfb.iv[0]),&(ctx->c.des_cfb.oiv[0]),8);
+ memcpy(&(ctx->oiv[0]),iv,8);
+ memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
if (key != NULL)
{
- des_set_key((des_cblock *)key,ctx->c.des_cfb.ks);
- des_set_key((des_cblock *)&(key[8]),ctx->c.des_cfb.ks2);
- des_set_key((des_cblock *)&(key[16]),ctx->c.des_cfb.ks3);
+ des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
+ des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
+ des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3);
}
}
@@ -149,7 +159,7 @@ unsigned int inl;
des_ede3_ofb64_encrypt(
in,out,
(long)inl,
- ctx->c.des_cfb.ks, ctx->c.des_cfb.ks2, ctx->c.des_cfb.ks3,
- (des_cblock *)&(ctx->c.des_cfb.iv[0]),
- &ctx->c.des_cfb.num);
+ ctx->c.des_ede.ks1, ctx->c.des_ede.ks2, ctx->c.des_ede.ks3,
+ (des_cblock *)&(ctx->iv[0]),
+ &ctx->num);
}
diff --git a/crypto/evp/e_ofb_bf.c b/crypto/evp/e_ofb_bf.c
index 078f171..492f9b9 100644
--- a/crypto/evp/e_ofb_bf.c
+++ b/crypto/evp/e_ofb_bf.c
@@ -1,5 +1,5 @@
/* crypto/evp/e_ofb_bf.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -79,6 +79,11 @@ static EVP_CIPHER bfish_ofb_cipher=
1,EVP_BLOWFISH_KEY_SIZE,8,
bf_ofb_init_key,
bf_ofb_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.bf_ks)),
+ EVP_CIPHER_set_asn1_iv,
+ EVP_CIPHER_get_asn1_iv,
};
EVP_CIPHER *EVP_bf_ofb()
@@ -92,13 +97,13 @@ unsigned char *key;
unsigned char *iv;
int enc;
{
- ctx->c.bf_cfb.num=0;
+ ctx->num=0;
if (iv != NULL)
- memcpy(&(ctx->c.bf_cfb.oiv[0]),iv,8);
- memcpy(&(ctx->c.bf_cfb.iv[0]),&(ctx->c.bf_cfb.oiv[0]),8);
+ memcpy(&(ctx->oiv[0]),iv,8);
+ memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
if (key != NULL)
- BF_set_key(&(ctx->c.bf_cfb.ks),EVP_BLOWFISH_KEY_SIZE,key);
+ BF_set_key(&(ctx->c.bf_ks),EVP_BLOWFISH_KEY_SIZE,key);
}
static void bf_ofb_cipher(ctx,out,in,inl)
@@ -109,9 +114,9 @@ unsigned int inl;
{
BF_ofb64_encrypt(
in,out,
- (long)inl, &(ctx->c.bf_cfb.ks),
- &(ctx->c.bf_cfb.iv[0]),
- &ctx->c.bf_cfb.num);
+ (long)inl, &(ctx->c.bf_ks),
+ &(ctx->iv[0]),
+ &ctx->num);
}
#endif
diff --git a/crypto/evp/e_ofb_c.c b/crypto/evp/e_ofb_c.c
new file mode 100644
index 0000000..f1eef44
--- /dev/null
+++ b/crypto/evp/e_ofb_c.c
@@ -0,0 +1,122 @@
+/* crypto/evp/e_ofb_c.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 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 acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS 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 AUTHOR OR 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef NO_CAST
+
+#include <stdio.h>
+#include "cryptlib.h"
+#include "evp.h"
+#include "objects.h"
+
+#ifndef NOPROTO
+static void cast_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
+ unsigned char *iv,int enc);
+static void cast_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
+ unsigned char *in, unsigned int inl);
+#else
+static void cast_ofb_init_key();
+static void cast_ofb_cipher();
+#endif
+
+static EVP_CIPHER cast5_ofb_cipher=
+ {
+ NID_cast5_ofb64,
+ 1,EVP_CAST5_KEY_SIZE,8,
+ cast_ofb_init_key,
+ cast_ofb_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)),
+ EVP_CIPHER_set_asn1_iv,
+ EVP_CIPHER_get_asn1_iv,
+ };
+
+EVP_CIPHER *EVP_cast5_ofb()
+ {
+ return(&cast5_ofb_cipher);
+ }
+
+static void cast_ofb_init_key(ctx,key,iv,enc)
+EVP_CIPHER_CTX *ctx;
+unsigned char *key;
+unsigned char *iv;
+int enc;
+ {
+ ctx->num=0;
+
+ if (iv != NULL)
+ memcpy(&(ctx->oiv[0]),iv,8);
+ memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
+ if (key != NULL)
+ CAST_set_key(&(ctx->c.cast_ks),EVP_CAST5_KEY_SIZE,key);
+ }
+
+static void cast_ofb_cipher(ctx,out,in,inl)
+EVP_CIPHER_CTX *ctx;
+unsigned char *out;
+unsigned char *in;
+unsigned int inl;
+ {
+ CAST_ofb64_encrypt(
+ in,out,
+ (long)inl, &(ctx->c.cast_ks),
+ &(ctx->iv[0]),
+ &ctx->num);
+ }
+
+#endif
diff --git a/crypto/evp/e_ofb_d.c b/crypto/evp/e_ofb_d.c
index a48af2e..09d4b41 100644
--- a/crypto/evp/e_ofb_d.c
+++ b/crypto/evp/e_ofb_d.c
@@ -1,5 +1,5 @@
/* crypto/evp/e_ofb_d.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -77,6 +77,11 @@ static EVP_CIPHER d_ofb_cipher=
1,8,8,
des_ofb_init_key,
des_ofb_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)),
+ EVP_CIPHER_set_asn1_iv,
+ EVP_CIPHER_get_asn1_iv,
};
EVP_CIPHER *EVP_des_ofb()
@@ -90,13 +95,13 @@ unsigned char *key;
unsigned char *iv;
int enc;
{
- ctx->c.des_cfb.num=0;
+ ctx->num=0;
if (iv != NULL)
- memcpy(&(ctx->c.des_cfb.oiv[0]),iv,8);
- memcpy(&(ctx->c.des_cfb.iv[0]),&(ctx->c.des_cfb.oiv[0]),8);
+ memcpy(&(ctx->oiv[0]),iv,8);
+ memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
if (key != NULL)
- des_set_key((des_cblock *)key,ctx->c.des_cfb.ks);
+ des_set_key((des_cblock *)key,ctx->c.des_ks);
}
static void des_ofb_cipher(ctx,out,in,inl)
@@ -107,7 +112,7 @@ unsigned int inl;
{
des_ofb64_encrypt(
in,out,
- (long)inl, ctx->c.des_cfb.ks,
- (des_cblock *)&(ctx->c.des_cfb.iv[0]),
- &ctx->c.des_cfb.num);
+ (long)inl, ctx->c.des_ks,
+ (des_cblock *)&(ctx->iv[0]),
+ &ctx->num);
}
diff --git a/crypto/evp/e_ofb_i.c b/crypto/evp/e_ofb_i.c
index dbf370b..96c8afd 100644
--- a/crypto/evp/e_ofb_i.c
+++ b/crypto/evp/e_ofb_i.c
@@ -1,5 +1,5 @@
/* crypto/evp/e_ofb_i.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -79,6 +79,11 @@ static EVP_CIPHER i_ofb_cipher=
1,IDEA_KEY_LENGTH,IDEA_BLOCK,
idea_ofb_init_key,
idea_ofb_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.idea_ks)),
+ EVP_CIPHER_set_asn1_iv,
+ EVP_CIPHER_get_asn1_iv,
};
EVP_CIPHER *EVP_idea_ofb()
@@ -92,13 +97,13 @@ unsigned char *key;
unsigned char *iv;
int enc;
{
- ctx->c.idea_cfb.num=0;
+ ctx->num=0;
if (iv != NULL)
- memcpy(&(ctx->c.idea_cfb.oiv[0]),iv,8);
- memcpy(&(ctx->c.idea_cfb.iv[0]),&(ctx->c.idea_cfb.oiv[0]),8);
+ memcpy(&(ctx->oiv[0]),iv,8);
+ memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
if (key != NULL)
- idea_set_encrypt_key(key,&(ctx->c.idea_cfb.ks));
+ idea_set_encrypt_key(key,&(ctx->c.idea_ks));
}
static void idea_ofb_cipher(ctx,out,in,inl)
@@ -109,8 +114,8 @@ unsigned int inl;
{
idea_ofb64_encrypt(
in,out,(long)inl,
- &(ctx->c.idea_cfb.ks),&(ctx->c.idea_cfb.iv[0]),
- &ctx->c.idea_cfb.num);
+ &(ctx->c.idea_ks),&(ctx->iv[0]),
+ &ctx->num);
}
#endif
diff --git a/crypto/evp/e_ofb_r2.c b/crypto/evp/e_ofb_r2.c
index 04e13b3..0f6d729 100644
--- a/crypto/evp/e_ofb_r2.c
+++ b/crypto/evp/e_ofb_r2.c
@@ -1,5 +1,5 @@
/* crypto/evp/e_ofb_r2.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -79,6 +79,11 @@ static EVP_CIPHER r2_ofb_cipher=
1,EVP_RC2_KEY_SIZE,8,
rc2_ofb_init_key,
rc2_ofb_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)),
+ EVP_CIPHER_set_asn1_iv,
+ EVP_CIPHER_get_asn1_iv,
};
EVP_CIPHER *EVP_rc2_ofb()
@@ -92,13 +97,13 @@ unsigned char *key;
unsigned char *iv;
int enc;
{
- ctx->c.rc2_cfb.num=0;
+ ctx->num=0;
if (iv != NULL)
- memcpy(&(ctx->c.rc2_cfb.oiv[0]),iv,8);
- memcpy(&(ctx->c.rc2_cfb.iv[0]),&(ctx->c.rc2_cfb.oiv[0]),8);
+ memcpy(&(ctx->oiv[0]),iv,8);
+ memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
if (key != NULL)
- RC2_set_key(&(ctx->c.rc2_cfb.ks),EVP_RC2_KEY_SIZE,key,
+ RC2_set_key(&(ctx->c.rc2_ks),EVP_RC2_KEY_SIZE,key,
EVP_RC2_KEY_SIZE*8);
}
@@ -110,9 +115,9 @@ unsigned int inl;
{
RC2_ofb64_encrypt(
in,out,
- (long)inl, &(ctx->c.rc2_cfb.ks),
- &(ctx->c.rc2_cfb.iv[0]),
- &ctx->c.rc2_cfb.num);
+ (long)inl, &(ctx->c.rc2_ks),
+ &(ctx->iv[0]),
+ &ctx->num);
}
#endif
diff --git a/crypto/evp/e_ofb_r5.c b/crypto/evp/e_ofb_r5.c
new file mode 100644
index 0000000..db28d6c
--- /dev/null
+++ b/crypto/evp/e_ofb_r5.c
@@ -0,0 +1,123 @@
+/* crypto/evp/e_ofb_r5.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 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 acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS 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 AUTHOR OR 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#ifndef NO_RC5
+
+#include <stdio.h>
+#include "cryptlib.h"
+#include "evp.h"
+#include "objects.h"
+
+#ifndef NOPROTO
+static void rc5_32_12_16_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
+ unsigned char *iv,int enc);
+static void rc5_32_12_16_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
+ unsigned char *in, unsigned int inl);
+#else
+static void rc5_32_12_16_ofb_init_key();
+static void rc5_32_12_16_ofb_cipher();
+#endif
+
+static EVP_CIPHER rc5_ofb_cipher=
+ {
+ NID_rc5_ofb64,
+ 1,EVP_RC5_32_12_16_KEY_SIZE,8,
+ rc5_32_12_16_ofb_init_key,
+ rc5_32_12_16_ofb_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc5_ks)),
+ EVP_CIPHER_set_asn1_iv,
+ EVP_CIPHER_get_asn1_iv,
+ };
+
+EVP_CIPHER *EVP_rc5_32_12_16_ofb()
+ {
+ return(&rc5_ofb_cipher);
+ }
+
+static void rc5_32_12_16_ofb_init_key(ctx,key,iv,enc)
+EVP_CIPHER_CTX *ctx;
+unsigned char *key;
+unsigned char *iv;
+int enc;
+ {
+ ctx->num=0;
+
+ if (iv != NULL)
+ memcpy(&(ctx->oiv[0]),iv,8);
+ memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
+ if (key != NULL)
+ RC5_32_set_key(&(ctx->c.rc5_ks),EVP_RC5_32_12_16_KEY_SIZE,key,
+ RC5_12_ROUNDS);
+ }
+
+static void rc5_32_12_16_ofb_cipher(ctx,out,in,inl)
+EVP_CIPHER_CTX *ctx;
+unsigned char *out;
+unsigned char *in;
+unsigned int inl;
+ {
+ RC5_32_ofb64_encrypt(
+ in,out,
+ (long)inl, &(ctx->c.rc5_ks),
+ &(ctx->iv[0]),
+ &ctx->num);
+ }
+
+#endif
diff --git a/crypto/evp/e_rc4.c b/crypto/evp/e_rc4.c
index e1ffb5d..7e9790a 100644
--- a/crypto/evp/e_rc4.c
+++ b/crypto/evp/e_rc4.c
@@ -1,5 +1,5 @@
/* crypto/evp/e_rc4.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -79,6 +79,19 @@ static EVP_CIPHER r4_cipher=
1,EVP_RC4_KEY_SIZE,0,
rc4_init_key,
rc4_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc4)),
+ NULL,
+ NULL,
+ };
+
+static EVP_CIPHER r4_40_cipher=
+ {
+ NID_rc4_40,
+ 1,5 /* 40 bit */,0,
+ rc4_init_key,
+ rc4_cipher,
};
EVP_CIPHER *EVP_rc4()
@@ -86,6 +99,11 @@ EVP_CIPHER *EVP_rc4()
return(&r4_cipher);
}
+EVP_CIPHER *EVP_rc4_40()
+ {
+ return(&r4_40_cipher);
+ }
+
static void rc4_init_key(ctx,key,iv,enc)
EVP_CIPHER_CTX *ctx;
unsigned char *key;
diff --git a/crypto/evp/e_xcbc_d.c b/crypto/evp/e_xcbc_d.c
index 55fe086..0d7fda0 100644
--- a/crypto/evp/e_xcbc_d.c
+++ b/crypto/evp/e_xcbc_d.c
@@ -1,5 +1,5 @@
/* crypto/evp/e_xcbc_d.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -77,6 +77,11 @@ static EVP_CIPHER d_xcbc_cipher=
8,24,8,
desx_cbc_init_key,
desx_cbc_cipher,
+ NULL,
+ sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
+ sizeof((((EVP_CIPHER_CTX *)NULL)->c.desx_cbc)),
+ EVP_CIPHER_set_asn1_iv,
+ EVP_CIPHER_get_asn1_iv,
};
EVP_CIPHER *EVP_desx_cbc()
@@ -91,8 +96,8 @@ unsigned char *iv;
int enc;
{
if (iv != NULL)
- memcpy(&(ctx->c.desx_cbc.oiv[0]),iv,8);
- memcpy(&(ctx->c.desx_cbc.iv[0]),&(ctx->c.desx_cbc.oiv[0]),8);
+ memcpy(&(ctx->oiv[0]),iv,8);
+ memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
if (key != NULL)
{
des_set_key((des_cblock *)key,ctx->c.desx_cbc.ks);
@@ -110,7 +115,7 @@ unsigned int inl;
des_xcbc_encrypt(
(des_cblock *)in,(des_cblock *)out,
(long)inl, ctx->c.desx_cbc.ks,
- (des_cblock *)&(ctx->c.desx_cbc.iv[0]),
+ (des_cblock *)&(ctx->iv[0]),
(des_cblock *)&(ctx->c.desx_cbc.inw[0]),
(des_cblock *)&(ctx->c.desx_cbc.outw[0]),
ctx->encrypt);
diff --git a/crypto/evp/encode.c b/crypto/evp/encode.c
index 7cd6524..14d47c1 100644
--- a/crypto/evp/encode.c
+++ b/crypto/evp/encode.c
@@ -1,5 +1,5 @@
/* crypto/evp/encode.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -224,6 +224,7 @@ EVP_ENCODE_CTX *ctx;
ctx->length=30;
ctx->num=0;
ctx->line_num=0;
+ ctx->expect_nl=0;
}
/* -1 for error
@@ -237,12 +238,13 @@ int *outl;
unsigned char *in;
int inl;
{
- int seof= -1,eof=0,rv= -1,ret=0,i,v,tmp,n,ln,tmp2;
+ int seof= -1,eof=0,rv= -1,ret=0,i,v,tmp,n,ln,tmp2,exp_nl;
unsigned char *d;
n=ctx->num;
d=ctx->enc_data;
ln=ctx->line_num;
+ exp_nl=ctx->expect_nl;
/* last line of input. */
if ((inl == 0) || ((n == 0) && (conv_ascii2bin(in[0]) == B64_EOF)))
@@ -280,7 +282,16 @@ int inl;
}
/* eoln */
- if (v == B64_EOLN) ln=0;
+ if (v == B64_EOLN)
+ {
+ ln=0;
+ if (exp_nl)
+ {
+ exp_nl=0;
+ continue;
+ }
+ }
+ exp_nl=0;
/* If we are at the end of input and it looks like a
* line, process it. */
@@ -289,6 +300,10 @@ int inl;
if ((v == B64_EOF) || (n >= 64))
{
+ /* This is needed to work correctly on 64 byte input
+ * lines. We process the line and then need to
+ * accept the '\n' */
+ if ((v != B64_EOF) && (n >= 64)) exp_nl=1;
tmp2=v;
if (n > 0)
{
@@ -322,6 +337,7 @@ end:
*outl=ret;
ctx->num=n;
ctx->line_num=ln;
+ ctx->expect_nl=exp_nl;
return(rv);
}
diff --git a/crypto/evp/evp.err b/crypto/evp/evp.err
index 0630b99..cfc1743 100644
--- a/crypto/evp/evp.err
+++ b/crypto/evp/evp.err
@@ -5,10 +5,11 @@
#define EVP_F_EVP_DECRYPTFINAL 101
#define EVP_F_EVP_OPENINIT 102
#define EVP_F_EVP_PKEY_COPY_PARAMETERS 103
-#define EVP_F_EVP_PKEY_NEW 104
-#define EVP_F_EVP_SEALINIT 105
-#define EVP_F_EVP_SIGNFINAL 106
-#define EVP_F_EVP_VERIFYFINAL 107
+#define EVP_F_EVP_PKEY_DECRYPT 104
+#define EVP_F_EVP_PKEY_ENCRYPT 105
+#define EVP_F_EVP_PKEY_NEW 106
+#define EVP_F_EVP_SIGNFINAL 107
+#define EVP_F_EVP_VERIFYFINAL 108
/* Reason codes. */
#define EVP_R_BAD_DECRYPT 100
diff --git a/crypto/evp/evp.h b/crypto/evp/evp.h
index 3ece7fb..b39fad9 100644
--- a/crypto/evp/evp.h
+++ b/crypto/evp/evp.h
@@ -1,5 +1,5 @@
/* crypto/evp/evp.h */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -72,6 +72,9 @@ extern "C" {
#if !defined(NO_SHA) || !defined(NO_SHA1)
#include "sha.h"
#endif
+#ifndef NO_RIPEMD
+#include "ripemd.h"
+#endif
#ifndef NO_DES
#include "des.h"
#endif
@@ -81,9 +84,15 @@ extern "C" {
#ifndef NO_RC2
#include "rc2.h"
#endif
+#ifndef NO_RC5
+#include "rc5.h"
+#endif
#ifndef NO_BLOWFISH
#include "blowfish.h"
#endif
+#ifndef NO_CAST
+#include "cast.h"
+#endif
#ifndef NO_IDEA
#include "idea.h"
#endif
@@ -91,12 +100,14 @@ extern "C" {
#include "mdc2.h"
#endif
-#define EVP_RC2_KEY_SIZE 16
-#define EVP_RC4_KEY_SIZE 16
-#define EVP_BLOWFISH_KEY_SIZE 16
-#define EVP_MAX_MD_SIZE 20
-#define EVP_MAX_KEY_LENGTH 24
-#define EVP_MAX_IV_LENGTH 8
+#define EVP_RC2_KEY_SIZE 16
+#define EVP_RC4_KEY_SIZE 16
+#define EVP_BLOWFISH_KEY_SIZE 16
+#define EVP_CAST5_KEY_SIZE 16
+#define EVP_RC5_32_12_16_KEY_SIZE 16
+#define EVP_MAX_MD_SIZE (16+20) /* The SSLv3 md5+sha1 type */
+#define EVP_MAX_KEY_LENGTH 24
+#define EVP_MAX_IV_LENGTH 8
#ifndef NO_RSA
#include "rsa.h"
@@ -132,10 +143,15 @@ extern "C" {
#define EVP_PKEY_RSA NID_rsaEncryption
#define EVP_PKEY_RSA2 NID_rsa
#define EVP_PKEY_DSA NID_dsa
+#define EVP_PKEY_DSA1 NID_dsa_2
#define EVP_PKEY_DSA2 NID_dsaWithSHA
#define EVP_PKEY_DSA3 NID_dsaWithSHA1
+#define EVP_PKEY_DSA4 NID_dsaWithSHA1_2
#define EVP_PKEY_DH NID_dhKeyAgreement
+/* Type needs to be a bit field
+ * Sub-type needs to be for variations on the method, as in, can it do
+ * arbitary encryption.... */
typedef struct evp_pkey_st
{
int type;
@@ -155,6 +171,79 @@ typedef struct evp_pkey_st
#endif
} EVP_PKEY;
+#define EVP_PKEY_MO_SIGN 0x0001
+#define EVP_PKEY_MO_VERIFY 0x0002
+#define EVP_PKEY_MO_ENCRYPT 0x0004
+#define EVP_PKEY_MO_DECRYPT 0x0008
+
+#if 0
+/* This structure is required to tie the message digest and signing together.
+ * The lookup can be done by md/pkey_method, oid, oid/pkey_method, or
+ * oid, md and pkey.
+ * This is required because for various smart-card perform the digest and
+ * signing/verification on-board. To handle this case, the specific
+ * EVP_MD and EVP_PKEY_METHODs need to be closely associated.
+ * When a PKEY is created, it will have a EVP_PKEY_METHOD ossociated with it.
+ * This can either be software or a token to provide the required low level
+ * routines.
+ */
+typedef struct evp_pkey_md_st
+ {
+ int oid;
+ EVP_MD *md;
+ EVP_PKEY_METHOD *pkey;
+ } EVP_PKEY_MD;
+
+#define EVP_rsa_md2()
+ EVP_PKEY_MD_add(NID_md2WithRSAEncryption,\
+ EVP_rsa_pkcs1(),EVP_md2())
+#define EVP_rsa_md5()
+ EVP_PKEY_MD_add(NID_md5WithRSAEncryption,\
+ EVP_rsa_pkcs1(),EVP_md5())
+#define EVP_rsa_sha0()
+ EVP_PKEY_MD_add(NID_shaWithRSAEncryption,\
+ EVP_rsa_pkcs1(),EVP_sha())
+#define EVP_rsa_sha1()
+ EVP_PKEY_MD_add(NID_sha1WithRSAEncryption,\
+ EVP_rsa_pkcs1(),EVP_sha1())
+#define EVP_rsa_ripemd160()
+ EVP_PKEY_MD_add(NID_ripemd160WithRSA,\
+ EVP_rsa_pkcs1(),EVP_ripemd160())
+#define EVP_rsa_mdc2()
+ EVP_PKEY_MD_add(NID_mdc2WithRSA,\
+ EVP_rsa_octet_string(),EVP_mdc2())
+#define EVP_dsa_sha()
+ EVP_PKEY_MD_add(NID_dsaWithSHA,\
+ EVP_dsa(),EVP_mdc2())
+#define EVP_dsa_sha1()
+ EVP_PKEY_MD_add(NID_dsaWithSHA1,\
+ EVP_dsa(),EVP_sha1())
+
+typedef struct evp_pkey_method_st
+ {
+ char *name;
+ int flags;
+ int type; /* RSA, DSA, an SSLeay specific constant */
+ int oid; /* For the pub-key type */
+ int encrypt_oid; /* pub/priv key encryption */
+
+ int (*sign)();
+ int (*verify)();
+ struct {
+ int
+ int (*set)(); /* get and/or set the underlying type */
+ int (*get)();
+ int (*encrypt)();
+ int (*decrypt)();
+ int (*i2d)();
+ int (*d2i)();
+ int (*dup)();
+ } pub,priv;
+ int (*set_asn1_parameters)();
+ int (*get_asn1_parameters)();
+ } EVP_PKEY_METHOD;
+#endif
+
#ifndef EVP_MD
typedef struct env_md_st
{
@@ -167,14 +256,17 @@ typedef struct env_md_st
int (*sign)();
int (*verify)();
- int required_pkey_type[4]; /*EVP_PKEY_xxx */
+ int required_pkey_type[5]; /*EVP_PKEY_xxx */
+ int block_size;
+ int ctx_size; /* how big does the ctx need to be */
} EVP_MD;
#define EVP_PKEY_NULL_method NULL,NULL,{0,0,0,0}
#ifndef NO_DSA
#define EVP_PKEY_DSA_method DSA_sign,DSA_verify, \
- {EVP_PKEY_DSA,EVP_PKEY_DSA2,EVP_PKEY_DSA3,0}
+ {EVP_PKEY_DSA,EVP_PKEY_DSA2,EVP_PKEY_DSA3, \
+ EVP_PKEY_DSA4,0}
#else
#define EVP_PKEY_DSA_method EVP_PKEY_NULL_method
#endif
@@ -204,6 +296,9 @@ typedef struct env_md_ctx_st
#ifndef NO_MD5
MD5_CTX md5;
#endif
+#ifndef NO_MD5
+ RIPEMD160_CTX ripemd160;
+#endif
#if !defined(NO_SHA) || !defined(NO_SHA1)
SHA_CTX sha;
#endif
@@ -222,6 +317,11 @@ typedef struct evp_cipher_st
void (*init)(); /* init for encryption */
void (*do_cipher)(); /* encrypt data */
void (*cleanup)(); /* used by cipher method */
+ int ctx_size; /* how big the ctx needs to be */
+ /* int set_asn1_parameters(EVP_CIPHER_CTX,ASN1_TYPE *); */
+ int (*set_asn1_parameters)(); /* Populate a ASN1_TYPE with parameters */
+ /* int get_asn1_parameters(EVP_CIPHER_CTX,ASN1_TYPE *); */
+ int (*get_asn1_parameters)(); /* Get parameters from a ASN1_TYPE */
} EVP_CIPHER;
typedef struct evp_cipher_info_st
@@ -235,7 +335,12 @@ typedef struct evp_cipher_ctx_st
EVP_CIPHER *cipher;
int encrypt; /* encrypt or decrypt */
int buf_len; /* number we have left */
- unsigned char buf[8];
+
+ unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */
+ unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */
+ unsigned char buf[EVP_MAX_IV_LENGTH]; /* saved partial block */
+ int num; /* used by cfb/ofb mode */
+
char *app_data; /* aplication stuff */
union {
#ifndef NO_RC4
@@ -246,102 +351,34 @@ typedef struct evp_cipher_ctx_st
} rc4;
#endif
#ifndef NO_DES
+ des_key_schedule des_ks;/* key schedule */
struct
{
des_key_schedule ks;/* key schedule */
- } des_ecb;
-
- struct
- {
- C_Block oiv; /* original iv */
- C_Block iv; /* working iv */
- des_key_schedule ks;/* key schedule */
- } des_cbc;
-
- struct
- {
- C_Block oiv; /* original iv */
- C_Block iv; /* working iv */
C_Block inw;
C_Block outw;
- des_key_schedule ks;/* key schedule */
} desx_cbc;
-
struct
{
- C_Block oiv; /* original iv */
- C_Block iv; /* working iv */
- des_key_schedule ks;/* key schedule */
+ des_key_schedule ks1;/* key schedule */
des_key_schedule ks2;/* key schedule (for ede) */
des_key_schedule ks3;/* key schedule (for ede3) */
- int num; /* used by cfb mode */
- } des_cfb;
-
- struct
- {
- C_Block oiv; /* original iv */
- C_Block iv; /* working iv */
- des_key_schedule ks1;/* ksched 1 */
- des_key_schedule ks2;/* ksched 2 */
- des_key_schedule ks3;/* ksched 3 */
} des_ede;
#endif
#ifndef NO_IDEA
- struct
- {
- IDEA_KEY_SCHEDULE ks;/* key schedule */
- } idea_ecb;
- struct
- {
- unsigned char oiv[8];/* original iv */
- unsigned char iv[8]; /* working iv */
- IDEA_KEY_SCHEDULE ks;/* key schedule */
- } idea_cbc;
- struct
- {
- unsigned char oiv[8];/* original iv */
- unsigned char iv[8]; /* working iv */
- IDEA_KEY_SCHEDULE ks;/* key schedule */
- int num; /* used by cfb mode */
- } idea_cfb;
+ IDEA_KEY_SCHEDULE idea_ks;/* key schedule */
#endif
#ifndef NO_RC2
- struct
- {
- RC2_KEY ks;/* key schedule */
- } rc2_ecb;
- struct
- {
- unsigned char oiv[8];/* original iv */
- unsigned char iv[8]; /* working iv */
- RC2_KEY ks;/* key schedule */
- } rc2_cbc;
- struct
- {
- unsigned char oiv[8];/* original iv */
- unsigned char iv[8]; /* working iv */
- RC2_KEY ks;/* key schedule */
- int num; /* used by cfb mode */
- } rc2_cfb;
+ RC2_KEY rc2_ks;/* key schedule */
+#endif
+#ifndef NO_RC5
+ RC5_32_KEY rc5_ks;/* key schedule */
#endif
#ifndef NO_BLOWFISH
- struct
- {
- BF_KEY ks;/* key schedule */
- } bf_ecb;
- struct
- {
- unsigned char oiv[8];/* original iv */
- unsigned char iv[8]; /* working iv */
- BF_KEY ks;/* key schedule */
- } bf_cbc;
- struct
- {
- unsigned char oiv[8];/* original iv */
- unsigned char iv[8]; /* working iv */
- BF_KEY ks;/* key schedule */
- int num; /* used by cfb mode */
- } bf_cfb;
+ BF_KEY bf_ks;/* key schedule */
+#endif
+#ifndef NO_CAST
+ CAST_KEY cast_ks;/* key schedule */
#endif
} c;
} EVP_CIPHER_CTX;
@@ -356,6 +393,7 @@ typedef struct evp_Encode_Ctx_st
* line is decoded */
unsigned char enc_data[80]; /* data to encode */
int line_num; /* number read on current line */
+ int expect_nl;
} EVP_ENCODE_CTX;
#define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\
@@ -374,7 +412,10 @@ typedef struct evp_Encode_Ctx_st
#define EVP_MD_type(e) ((e)->type)
#define EVP_MD_pkey_type(e) ((e)->pkey_type)
#define EVP_MD_size(e) ((e)->md_size)
-#define EVP_MD_CTX_size(e) ((e)->digest->md_size)
+#define EVP_MD_block_size(e) ((e)->block_size)
+
+#define EVP_MD_CTX_size(e) EVP_MD_size((e)->digest)
+#define EVP_MD_CTX_block_size(e) EVP_MD_block_size((e)->digest)
#define EVP_MD_CTX_type(e) ((e)->digest)
#define EVP_CIPHER_nid(e) ((e)->nid)
@@ -471,6 +512,7 @@ int EVP_DecodeBlock(unsigned char *t, unsigned
void ERR_load_EVP_strings(void );
+void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a);
void EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a);
#ifdef HEADER_BIO_H
@@ -489,6 +531,7 @@ EVP_MD *EVP_sha1(void);
EVP_MD *EVP_dss(void);
EVP_MD *EVP_dss1(void);
EVP_MD *EVP_mdc2(void);
+EVP_MD *EVP_ripemd160(void);
EVP_CIPHER *EVP_enc_null(void); /* does nothing :-) */
EVP_CIPHER *EVP_des_ecb(void);
@@ -505,18 +548,28 @@ EVP_CIPHER *EVP_des_ede_cbc(void);
EVP_CIPHER *EVP_des_ede3_cbc(void);
EVP_CIPHER *EVP_desx_cbc(void);
EVP_CIPHER *EVP_rc4(void);
+EVP_CIPHER *EVP_rc4_40(void);
EVP_CIPHER *EVP_idea_ecb(void);
EVP_CIPHER *EVP_idea_cfb(void);
EVP_CIPHER *EVP_idea_ofb(void);
EVP_CIPHER *EVP_idea_cbc(void);
EVP_CIPHER *EVP_rc2_ecb(void);
EVP_CIPHER *EVP_rc2_cbc(void);
+EVP_CIPHER *EVP_rc2_40_cbc(void);
EVP_CIPHER *EVP_rc2_cfb(void);
EVP_CIPHER *EVP_rc2_ofb(void);
EVP_CIPHER *EVP_bf_ecb(void);
EVP_CIPHER *EVP_bf_cbc(void);
EVP_CIPHER *EVP_bf_cfb(void);
EVP_CIPHER *EVP_bf_ofb(void);
+EVP_CIPHER *EVP_cast5_ecb(void);
+EVP_CIPHER *EVP_cast5_cbc(void);
+EVP_CIPHER *EVP_cast5_cfb(void);
+EVP_CIPHER *EVP_cast5_ofb(void);
+EVP_CIPHER *EVP_rc5_32_12_16_cbc(void);
+EVP_CIPHER *EVP_rc5_32_12_16_ecb(void);
+EVP_CIPHER *EVP_rc5_32_12_16_cfb(void);
+EVP_CIPHER *EVP_rc5_32_12_16_ofb(void);
void SSLeay_add_all_algorithms(void);
void SSLeay_add_all_ciphers(void);
@@ -531,7 +584,12 @@ EVP_CIPHER *EVP_get_cipherbyname(char *name);
EVP_MD *EVP_get_digestbyname(char *name);
void EVP_cleanup(void);
+int EVP_PKEY_decrypt(unsigned char *dec_key,unsigned char *enc_key,
+ int enc_key_len,EVP_PKEY *private_key);
+int EVP_PKEY_encrypt(unsigned char *enc_key,
+ unsigned char *key,int key_len,EVP_PKEY *pub_key);
int EVP_PKEY_type(int type);
+int EVP_PKEY_bits(EVP_PKEY *pkey);
int EVP_PKEY_size(EVP_PKEY *pkey);
int EVP_PKEY_assign(EVP_PKEY *pkey,int type,char *key);
EVP_PKEY * EVP_PKEY_new(void);
@@ -547,6 +605,15 @@ int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp);
int EVP_PKEY_copy_parameters(EVP_PKEY *to,EVP_PKEY *from);
int EVP_PKEY_missing_parameters(EVP_PKEY *pkey);
int EVP_PKEY_save_parameters(EVP_PKEY *pkey,int mode);
+int EVP_PKEY_cmp_parameters(EVP_PKEY *a,EVP_PKEY *b);
+
+/* calls methods */
+int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
+int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
+
+/* These are used by EVP_CIPHER methods */
+int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type);
+int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type);
#else
@@ -596,6 +663,7 @@ int EVP_DecodeBlock();
void ERR_load_EVP_strings();
+void EVP_CIPHER_CTX_init();
void EVP_CIPHER_CTX_cleanup();
#ifdef HEADER_BIO_H
@@ -629,18 +697,28 @@ EVP_CIPHER *EVP_des_ede_cbc();
EVP_CIPHER *EVP_des_ede3_cbc();
EVP_CIPHER *EVP_desx_cbc();
EVP_CIPHER *EVP_rc4();
+EVP_CIPHER *EVP_rc4_40();
EVP_CIPHER *EVP_idea_ecb();
EVP_CIPHER *EVP_idea_cfb();
EVP_CIPHER *EVP_idea_ofb();
EVP_CIPHER *EVP_idea_cbc();
EVP_CIPHER *EVP_rc2_ecb();
EVP_CIPHER *EVP_rc2_cbc();
+EVP_CIPHER *EVP_rc2_40_cbc();
EVP_CIPHER *EVP_rc2_cfb();
EVP_CIPHER *EVP_rc2_ofb();
EVP_CIPHER *EVP_bf_ecb();
EVP_CIPHER *EVP_bf_cbc();
EVP_CIPHER *EVP_bf_cfb();
EVP_CIPHER *EVP_bf_ofb();
+EVP_CIPHER *EVP_cast5_ecb();
+EVP_CIPHER *EVP_cast5_cbc();
+EVP_CIPHER *EVP_cast5_cfb();
+EVP_CIPHER *EVP_cast5_ofb();
+EVP_CIPHER *EVP_rc5_32_12_16_cbc();
+EVP_CIPHER *EVP_rc5_32_12_16_ecb();
+EVP_CIPHER *EVP_rc5_32_12_16_cfb();
+EVP_CIPHER *EVP_rc5_32_12_16_ofb();
void SSLeay_add_all_algorithms();
void SSLeay_add_all_ciphers();
@@ -655,7 +733,10 @@ EVP_CIPHER *EVP_get_cipherbyname();
EVP_MD *EVP_get_digestbyname();
void EVP_cleanup();
+int EVP_PKEY_decrypt();
+int EVP_PKEY_encrypt();
int EVP_PKEY_type();
+int EVP_PKEY_bits();
int EVP_PKEY_size();
int EVP_PKEY_assign();
EVP_PKEY * EVP_PKEY_new();
@@ -669,6 +750,13 @@ int i2d_PrivateKey();
int EVP_PKEY_copy_parameters();
int EVP_PKEY_missing_parameters();
int EVP_PKEY_save_parameters();
+int EVP_PKEY_cmp_parameters();
+
+int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
+int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
+
+int EVP_CIPHER_set_asn1_iv();
+int EVP_CIPHER_get_asn1_iv();
#endif
@@ -680,10 +768,11 @@ int EVP_PKEY_save_parameters();
#define EVP_F_EVP_DECRYPTFINAL 101
#define EVP_F_EVP_OPENINIT 102
#define EVP_F_EVP_PKEY_COPY_PARAMETERS 103
-#define EVP_F_EVP_PKEY_NEW 104
-#define EVP_F_EVP_SEALINIT 105
-#define EVP_F_EVP_SIGNFINAL 106
-#define EVP_F_EVP_VERIFYFINAL 107
+#define EVP_F_EVP_PKEY_DECRYPT 104
+#define EVP_F_EVP_PKEY_ENCRYPT 105
+#define EVP_F_EVP_PKEY_NEW 106
+#define EVP_F_EVP_SIGNFINAL 107
+#define EVP_F_EVP_VERIFYFINAL 108
/* Reason codes. */
#define EVP_R_BAD_DECRYPT 100
diff --git a/crypto/evp/evp_enc.c b/crypto/evp/evp_enc.c
index 2015b5f..93cc3a9 100644
--- a/crypto/evp/evp_enc.c
+++ b/crypto/evp/evp_enc.c
@@ -1,5 +1,5 @@
/* crypto/evp/evp_enc.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -60,7 +60,14 @@
#include "cryptlib.h"
#include "evp.h"
-char *EVP_version="EVP part of SSLeay 0.8.1b 29-Jun-1998";
+char *EVP_version="EVP part of SSLeay 0.9.0b 29-Jun-1998";
+
+void EVP_CIPHER_CTX_init(ctx)
+EVP_CIPHER_CTX *ctx;
+ {
+ memset(ctx,0,sizeof(EVP_CIPHER_CTX));
+ /* ctx->cipher=NULL; */
+ }
void EVP_CipherInit(ctx,data,key,iv,enc)
EVP_CIPHER_CTX *ctx;
diff --git a/crypto/evp/evp_err.c b/crypto/evp/evp_err.c
index 326da11..2b0a0ab 100644
--- a/crypto/evp/evp_err.c
+++ b/crypto/evp/evp_err.c
@@ -60,14 +60,16 @@
#include "evp.h"
/* BEGIN ERROR CODES */
+#ifndef NO_ERR
static ERR_STRING_DATA EVP_str_functs[]=
{
{ERR_PACK(0,EVP_F_D2I_PKEY,0), "D2I_PKEY"},
{ERR_PACK(0,EVP_F_EVP_DECRYPTFINAL,0), "EVP_DecryptFinal"},
{ERR_PACK(0,EVP_F_EVP_OPENINIT,0), "EVP_OpenInit"},
{ERR_PACK(0,EVP_F_EVP_PKEY_COPY_PARAMETERS,0), "EVP_PKEY_copy_parameters"},
+{ERR_PACK(0,EVP_F_EVP_PKEY_DECRYPT,0), "EVP_PKEY_decrypt"},
+{ERR_PACK(0,EVP_F_EVP_PKEY_ENCRYPT,0), "EVP_PKEY_encrypt"},
{ERR_PACK(0,EVP_F_EVP_PKEY_NEW,0), "EVP_PKEY_new"},
-{ERR_PACK(0,EVP_F_EVP_SEALINIT,0), "EVP_SealInit"},
{ERR_PACK(0,EVP_F_EVP_SIGNFINAL,0), "EVP_SignFinal"},
{ERR_PACK(0,EVP_F_EVP_VERIFYFINAL,0), "EVP_VerifyFinal"},
{0,NULL},
@@ -88,14 +90,19 @@ static ERR_STRING_DATA EVP_str_reasons[]=
{0,NULL},
};
+#endif
+
void ERR_load_EVP_strings()
{
static int init=1;
- if (init)
- {
+ if (init);
+ {;
init=0;
+#ifndef NO_ERR
ERR_load_strings(ERR_LIB_EVP,EVP_str_functs);
ERR_load_strings(ERR_LIB_EVP,EVP_str_reasons);
+#endif
+
}
}
diff --git a/crypto/evp/evp_key.c b/crypto/evp/evp_key.c
index 0aa1dbb..dafa686 100644
--- a/crypto/evp/evp_key.c
+++ b/crypto/evp/evp_key.c
@@ -1,5 +1,5 @@
/* crypto/evp/evp_key.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -82,6 +82,10 @@ char *EVP_get_pw_prompt()
return(prompt_string);
}
+#ifdef NO_DES
+int des_read_pw_string(char *buf,int len,char *prompt,int verify);
+#endif
+
int EVP_read_pw_string(buf,len,prompt,verify)
char *buf;
int len;
@@ -158,6 +162,6 @@ unsigned char *iv;
}
memset(&c,0,sizeof(c));
memset(&(md_buf[0]),0,EVP_MAX_MD_SIZE);
- return(nkey);
+ return(type->key_len);
}
diff --git a/crypto/evp/evp_lib.c b/crypto/evp/evp_lib.c
new file mode 100644
index 0000000..69784eb
--- /dev/null
+++ b/crypto/evp/evp_lib.c
@@ -0,0 +1,117 @@
+/* crypto/evp/evp_lib.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 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 acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS 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 AUTHOR OR 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#include <stdio.h>
+#include "cryptlib.h"
+#include "evp.h"
+#include "objects.h"
+
+int EVP_CIPHER_param_to_asn1(c,type)
+EVP_CIPHER_CTX *c;
+ASN1_TYPE *type;
+ {
+ int ret;
+
+ if (c->cipher->set_asn1_parameters != NULL)
+ ret=c->cipher->set_asn1_parameters(c,type);
+ else
+ ret=1;
+ return(ret);
+ }
+
+int EVP_CIPHER_asn1_to_param(c,type)
+EVP_CIPHER_CTX *c;
+ASN1_TYPE *type;
+ {
+ int ret;
+
+ if (c->cipher->get_asn1_parameters != NULL)
+ ret=c->cipher->get_asn1_parameters(c,type);
+ else
+ ret=1;
+ return(ret);
+ }
+
+int EVP_CIPHER_get_asn1_iv(c,type)
+EVP_CIPHER_CTX *c;
+ASN1_TYPE *type;
+ {
+ int i=0,l;
+
+ if (type != NULL)
+ {
+ l=EVP_CIPHER_CTX_iv_length(c);
+ i=ASN1_TYPE_get_octetstring(type,c->oiv,l);
+ memcpy(c->iv,c->oiv,l);
+ }
+ return(i);
+ }
+
+int EVP_CIPHER_set_asn1_iv(c,type)
+EVP_CIPHER_CTX *c;
+ASN1_TYPE *type;
+ {
+ int i=0,j;
+
+ if (type != NULL)
+ {
+ j=EVP_CIPHER_CTX_iv_length(c);
+ i=ASN1_TYPE_set_octetstring(type,c->oiv,j);
+ }
+ return(i);
+ }
diff --git a/crypto/evp/m_dss.c b/crypto/evp/m_dss.c
index 743beac..3549b16 100644
--- a/crypto/evp/m_dss.c
+++ b/crypto/evp/m_dss.c
@@ -1,5 +1,5 @@
/* crypto/evp/m_dss.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -67,10 +67,12 @@ static EVP_MD dsa_md=
NID_dsaWithSHA,
NID_dsaWithSHA,
SHA_DIGEST_LENGTH,
- SHA_Init,
- SHA_Update,
- SHA_Final,
+ SHA1_Init,
+ SHA1_Update,
+ SHA1_Final,
EVP_PKEY_DSA_method,
+ SHA_CBLOCK,
+ sizeof(EVP_MD *)+sizeof(SHA_CTX),
};
EVP_MD *EVP_dss()
diff --git a/crypto/evp/m_dss1.c b/crypto/evp/m_dss1.c
index a14e859..ff256b7 100644
--- a/crypto/evp/m_dss1.c
+++ b/crypto/evp/m_dss1.c
@@ -1,5 +1,5 @@
/* crypto/evp/m_dss1.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -71,6 +71,8 @@ static EVP_MD dss1_md=
SHA1_Update,
SHA1_Final,
EVP_PKEY_DSA_method,
+ SHA_CBLOCK,
+ sizeof(EVP_MD *)+sizeof(SHA_CTX),
};
EVP_MD *EVP_dss1()
diff --git a/crypto/evp/m_md2.c b/crypto/evp/m_md2.c
index 17360c1..2209416 100644
--- a/crypto/evp/m_md2.c
+++ b/crypto/evp/m_md2.c
@@ -1,5 +1,5 @@
/* crypto/evp/m_md2.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -71,6 +71,8 @@ static EVP_MD md2_md=
MD2_Update,
MD2_Final,
EVP_PKEY_RSA_method,
+ MD2_BLOCK,
+ sizeof(EVP_MD *)+sizeof(MD2_CTX),
};
EVP_MD *EVP_md2()
diff --git a/crypto/evp/m_md5.c b/crypto/evp/m_md5.c
index f7b4eb1..d65db9a 100644
--- a/crypto/evp/m_md5.c
+++ b/crypto/evp/m_md5.c
@@ -1,5 +1,5 @@
/* crypto/evp/m_md5.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -71,6 +71,8 @@ static EVP_MD md5_md=
MD5_Update,
MD5_Final,
EVP_PKEY_RSA_method,
+ MD5_CBLOCK,
+ sizeof(EVP_MD *)+sizeof(MD5_CTX),
};
EVP_MD *EVP_md5()
diff --git a/crypto/evp/m_mdc2.c b/crypto/evp/m_mdc2.c
index da70f68..64a853e 100644
--- a/crypto/evp/m_mdc2.c
+++ b/crypto/evp/m_mdc2.c
@@ -1,5 +1,5 @@
/* crypto/evp/m_mdc2.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -71,6 +71,8 @@ static EVP_MD mdc2_md=
MDC2_Update,
MDC2_Final,
EVP_PKEY_RSA_ASN1_OCTET_STRING_method,
+ MDC2_BLOCK,
+ sizeof(EVP_MD *)+sizeof(MDC2_CTX),
};
EVP_MD *EVP_mdc2()
diff --git a/crypto/evp/m_null.c b/crypto/evp/m_null.c
index 47db2c5..6d80560 100644
--- a/crypto/evp/m_null.c
+++ b/crypto/evp/m_null.c
@@ -1,5 +1,5 @@
/* crypto/evp/m_null.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -75,7 +75,9 @@ static EVP_MD null_md=
function,
function,
- EVP_PKEY_NULL_method
+ EVP_PKEY_NULL_method,
+ 0,
+ sizeof(EVP_MD *),
};
EVP_MD *EVP_md_null()
diff --git a/crypto/evp/m_ripemd.c b/crypto/evp/m_ripemd.c
new file mode 100644
index 0000000..04c5d88
--- /dev/null
+++ b/crypto/evp/m_ripemd.c
@@ -0,0 +1,81 @@
+/* crypto/evp/m_ripemd.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 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 acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS 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 AUTHOR OR 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#include <stdio.h>
+#include "cryptlib.h"
+#include "evp.h"
+#include "objects.h"
+#include "x509.h"
+
+static EVP_MD ripemd160_md=
+ {
+ NID_ripemd160,
+ NID_ripemd160WithRSA,
+ RIPEMD160_DIGEST_LENGTH,
+ RIPEMD160_Init,
+ RIPEMD160_Update,
+ RIPEMD160_Final,
+ EVP_PKEY_RSA_method,
+ RIPEMD160_CBLOCK,
+ sizeof(EVP_MD *)+sizeof(RIPEMD160_CTX),
+ };
+
+EVP_MD *EVP_ripemd160()
+ {
+ return(&ripemd160_md);
+ }
diff --git a/crypto/evp/m_sha.c b/crypto/evp/m_sha.c
index d723ac7..af4e434 100644
--- a/crypto/evp/m_sha.c
+++ b/crypto/evp/m_sha.c
@@ -1,5 +1,5 @@
/* crypto/evp/m_sha.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -71,6 +71,8 @@ static EVP_MD sha_md=
SHA_Update,
SHA_Final,
EVP_PKEY_RSA_method,
+ SHA_CBLOCK,
+ sizeof(EVP_MD *)+sizeof(SHA_CTX),
};
EVP_MD *EVP_sha()
diff --git a/crypto/evp/m_sha1.c b/crypto/evp/m_sha1.c
index 30037ff..87135a9 100644
--- a/crypto/evp/m_sha1.c
+++ b/crypto/evp/m_sha1.c
@@ -1,5 +1,5 @@
/* crypto/evp/m_sha1.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -71,6 +71,8 @@ static EVP_MD sha1_md=
SHA1_Update,
SHA1_Final,
EVP_PKEY_RSA_method,
+ SHA_CBLOCK,
+ sizeof(EVP_MD *)+sizeof(SHA_CTX),
};
EVP_MD *EVP_sha1()
diff --git a/crypto/evp/names.c b/crypto/evp/names.c
index 49fd34f..e0774da 100644
--- a/crypto/evp/names.c
+++ b/crypto/evp/names.c
@@ -1,5 +1,5 @@
/* crypto/evp/names.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -158,7 +158,9 @@ char *aname;
}
if ((i=sk_find(aliases,(char *)a)) >= 0)
+ {
Free(sk_delete(aliases,i));
+ }
if (!sk_push(aliases,(char *)a)) goto err;
return(1);
err:
@@ -207,6 +209,7 @@ char *name;
}
nid=OBJ_txt2nid(name);
+ if (nid == NID_undef) return(NULL);
c.nid=nid;
i=sk_find(ciphers,(char *)&c);
if (i >= 0)
@@ -245,6 +248,7 @@ char *name;
}
nid=OBJ_txt2nid(name);
+ if (nid == NID_undef) return(NULL);
c.pkey_type=nid;
i=sk_find(digests,(char *)&c);
if (i >= 0)
diff --git a/crypto/evp/p_dec.c b/crypto/evp/p_dec.c
new file mode 100644
index 0000000..e845ce7
--- /dev/null
+++ b/crypto/evp/p_dec.c
@@ -0,0 +1,84 @@
+/* crypto/evp/p_dec.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 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 acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS 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 AUTHOR OR 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#include <stdio.h>
+#include "cryptlib.h"
+#include "rand.h"
+#include "rsa.h"
+#include "evp.h"
+#include "objects.h"
+#include "x509.h"
+
+int EVP_PKEY_decrypt(key,ek,ekl,priv)
+unsigned char *key;
+unsigned char *ek;
+int ekl;
+EVP_PKEY *priv;
+ {
+ int ret= -1;
+
+ if (priv->type != EVP_PKEY_RSA)
+ {
+ EVPerr(EVP_F_EVP_PKEY_DECRYPT,EVP_R_PUBLIC_KEY_NOT_RSA);
+ goto err;
+ }
+
+ ret=RSA_private_decrypt(ekl,ek,key,priv->pkey.rsa,RSA_PKCS1_PADDING);
+err:
+ return(ret);
+ }
diff --git a/crypto/evp/p_enc.c b/crypto/evp/p_enc.c
new file mode 100644
index 0000000..a26bfad
--- /dev/null
+++ b/crypto/evp/p_enc.c
@@ -0,0 +1,83 @@
+/* crypto/evp/p_enc.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 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 acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS 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 AUTHOR OR 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#include <stdio.h>
+#include "cryptlib.h"
+#include "rand.h"
+#include "rsa.h"
+#include "evp.h"
+#include "objects.h"
+#include "x509.h"
+
+int EVP_PKEY_encrypt(ek,key,key_len,pubk)
+unsigned char *ek;
+unsigned char *key;
+int key_len;
+EVP_PKEY *pubk;
+ {
+ int ret=0;
+
+ if (pubk->type != EVP_PKEY_RSA)
+ {
+ EVPerr(EVP_F_EVP_PKEY_ENCRYPT,EVP_R_PUBLIC_KEY_NOT_RSA);
+ goto err;
+ }
+ ret=RSA_public_encrypt(key_len,key,ek,pubk->pkey.rsa,RSA_PKCS1_PADDING);
+err:
+ return(ret);
+ }
diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c
index 1136904..395351b 100644
--- a/crypto/evp/p_lib.c
+++ b/crypto/evp/p_lib.c
@@ -1,5 +1,5 @@
/* crypto/evp/p_lib.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -72,6 +72,21 @@ static void EVP_PKEY_free_it(EVP_PKEY *x);
static void EVP_PKEY_free_it();
#endif
+int EVP_PKEY_bits(pkey)
+EVP_PKEY *pkey;
+ {
+#ifndef NO_RSA
+ if (pkey->type == EVP_PKEY_RSA)
+ return(BN_num_bits(pkey->pkey.rsa->n));
+ else
+#endif
+#ifndef NO_DSA
+ if (pkey->type == EVP_PKEY_DSA)
+ return(BN_num_bits(pkey->pkey.dsa->p));
+#endif
+ return(0);
+ }
+
int EVP_PKEY_size(pkey)
EVP_PKEY *pkey;
{
@@ -110,13 +125,13 @@ EVP_PKEY *to,*from;
if (to->type != from->type)
{
EVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS,EVP_R_DIFFERENT_KEY_TYPES);
- return(0);
+ goto err;
}
if (EVP_PKEY_missing_parameters(from))
{
EVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS,EVP_R_MISSING_PARMATERS);
- return(0);
+ goto err;
}
#ifndef NO_DSA
if (to->type == EVP_PKEY_DSA)
@@ -157,6 +172,23 @@ EVP_PKEY *pkey;
return(0);
}
+int EVP_PKEY_cmp_parameters(a,b)
+EVP_PKEY *a,*b;
+ {
+#ifndef NO_DSA
+ if ((a->type == EVP_PKEY_DSA) && (b->type == EVP_PKEY_DSA))
+ {
+ if ( BN_cmp(a->pkey.dsa->p,b->pkey.dsa->p) ||
+ BN_cmp(a->pkey.dsa->q,b->pkey.dsa->q) ||
+ BN_cmp(a->pkey.dsa->g,b->pkey.dsa->g))
+ return(0);
+ else
+ return(1);
+ }
+#endif
+ return(-1);
+ }
+
EVP_PKEY *EVP_PKEY_new()
{
EVP_PKEY *ret;
@@ -198,8 +230,10 @@ int type;
case EVP_PKEY_RSA2:
return(EVP_PKEY_RSA);
case EVP_PKEY_DSA:
+ case EVP_PKEY_DSA1:
case EVP_PKEY_DSA2:
case EVP_PKEY_DSA3:
+ case EVP_PKEY_DSA4:
return(EVP_PKEY_DSA);
case EVP_PKEY_DH:
return(EVP_PKEY_DH);
@@ -216,6 +250,9 @@ EVP_PKEY *x;
if (x == NULL) return;
i=CRYPTO_add(&x->references,-1,CRYPTO_LOCK_EVP_PKEY);
+#ifdef REF_PRINT
+ REF_PRINT("EVP_PKEY",x);
+#endif
if (i > 0) return;
#ifdef REF_CHECK
if (i < 0)
@@ -243,6 +280,7 @@ EVP_PKEY *x;
case EVP_PKEY_DSA:
case EVP_PKEY_DSA2:
case EVP_PKEY_DSA3:
+ case EVP_PKEY_DSA4:
DSA_free(x->pkey.dsa);
break;
#endif
diff --git a/crypto/evp/p_open.c b/crypto/evp/p_open.c
index 4643405..28a8e02 100644
--- a/crypto/evp/p_open.c
+++ b/crypto/evp/p_open.c
@@ -1,5 +1,5 @@
/* crypto/evp/p_open.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -75,7 +75,7 @@ EVP_PKEY *priv;
if (priv->type != EVP_PKEY_RSA)
{
- EVPerr(EVP_F_EVP_OPENINIT,EVP_R_PUBLIC_KEY_NOT_RSA);
+ EVPerr(EVP_F_EVP_OPENINIT,EVP_R_PUBLIC_KEY_NOT_RSA);
ret= -1;
goto err;
}
@@ -90,13 +90,14 @@ EVP_PKEY *priv;
goto err;
}
- i=RSA_private_decrypt(ekl,ek,key,priv->pkey.rsa,RSA_PKCS1_PADDING);
+ i=EVP_PKEY_decrypt(key,ek,ekl,priv);
if (i != type->key_len)
{
/* ERROR */
goto err;
}
+ EVP_CIPHER_CTX_init(ctx);
EVP_DecryptInit(ctx,type,key,iv);
ret=1;
err:
diff --git a/crypto/evp/p_seal.c b/crypto/evp/p_seal.c
index b059c59..09a408d 100644
--- a/crypto/evp/p_seal.c
+++ b/crypto/evp/p_seal.c
@@ -1,5 +1,5 @@
/* crypto/evp/p_seal.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -74,30 +74,23 @@ EVP_PKEY **pubk;
int npubk;
{
unsigned char key[EVP_MAX_KEY_LENGTH];
- int i,ret=0,n;
+ int i;
if (npubk <= 0) return(0);
RAND_bytes(key,EVP_MAX_KEY_LENGTH);
if (type->iv_len > 0)
RAND_bytes(iv,type->iv_len);
+ EVP_CIPHER_CTX_init(ctx);
EVP_EncryptInit(ctx,type,key,iv);
+
for (i=0; i<npubk; i++)
{
- if (pubk[i]->type != EVP_PKEY_RSA)
- {
- EVPerr(EVP_F_EVP_SEALINIT,EVP_R_PUBLIC_KEY_NOT_RSA);
- goto err;
- }
- n=RSA_public_encrypt(type->key_len,key,ek[i],pubk[i]->pkey.rsa,
- RSA_PKCS1_PADDING);
- if (n <= 0) goto err;
- ekl[i]=n;
+ ekl[i]=EVP_PKEY_encrypt(ek[i],key,EVP_CIPHER_key_length(type),
+ pubk[i]);
+ if (ekl[i] <= 0) return(-1);
}
- ret=npubk;
-err:
- memset(key,0,EVP_MAX_KEY_LENGTH);
- return(ret);
+ return(npubk);
}
/* MACRO
diff --git a/crypto/evp/p_sign.c b/crypto/evp/p_sign.c
index ad5bcd8..073270c 100644
--- a/crypto/evp/p_sign.c
+++ b/crypto/evp/p_sign.c
@@ -1,5 +1,5 @@
/* crypto/evp/p_sign.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -88,9 +88,11 @@ EVP_PKEY *pkey;
unsigned char m[EVP_MAX_MD_SIZE];
unsigned int m_len;
int i,ok=0,v;
+ MS_STATIC EVP_MD_CTX tmp_ctx;
*siglen=0;
- EVP_DigestFinal(ctx,&(m[0]),&m_len);
+ memcpy(&tmp_ctx,ctx,sizeof(EVP_MD_CTX));
+ EVP_DigestFinal(&tmp_ctx,&(m[0]),&m_len);
for (i=0; i<4; i++)
{
v=ctx->digest->required_pkey_type[i];
diff --git a/crypto/evp/p_verify.c b/crypto/evp/p_verify.c
index 4dbaf1e..8d727d8 100644
--- a/crypto/evp/p_verify.c
+++ b/crypto/evp/p_verify.c
@@ -1,5 +1,5 @@
/* crypto/evp/p_verify.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
@@ -71,6 +71,7 @@ EVP_PKEY *pkey;
unsigned char m[EVP_MAX_MD_SIZE];
unsigned int m_len;
int i,ok=0,v;
+ MS_STATIC EVP_MD_CTX tmp_ctx;
for (i=0; i<4; i++)
{
@@ -87,7 +88,8 @@ EVP_PKEY *pkey;
EVPerr(EVP_F_EVP_VERIFYFINAL,EVP_R_WRONG_PUBLIC_KEY_TYPE);
return(-1);
}
- EVP_DigestFinal(ctx,&(m[0]),&m_len);
+ memcpy(&tmp_ctx,ctx,sizeof(EVP_MD_CTX));
+ EVP_DigestFinal(&tmp_ctx,&(m[0]),&m_len);
if (ctx->digest->verify == NULL)
{
EVPerr(EVP_F_EVP_VERIFYFINAL,EVP_R_NO_VERIFY_FUNCTION_CONFIGURED);
@@ -97,3 +99,4 @@ EVP_PKEY *pkey;
return(ctx->digest->verify(ctx->digest->type,m,m_len,
sigbuf,siglen,pkey->pkey.ptr));
}
+
diff --git a/crypto/evp/pk_lib.c b/crypto/evp/pk_lib.c
new file mode 100644
index 0000000..08f9fab
--- /dev/null
+++ b/crypto/evp/pk_lib.c
@@ -0,0 +1,82 @@
+/* crypto/evp/pk_lib.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * 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 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 acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS 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 AUTHOR OR 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.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+
+#include <stdio.h>
+#include "cryptlib.h"
+#include "evp.h"
+#include "objects.h"
+
+static LHASH *pk_md=NULL;
+
+static LHASH *pk_md=NULL;
+
+int EVP_add_pkey_md(oid,pkm,md)
+int oid;
+EVP_PKEY_METHOD *pkm;
+EVP_MD *md;
+ {
+ }
+
+EVP_add_pkey(pkm)
+EVP_PKEY_METHOD *pkm;
+ {
+ }
+
+EVP_PKEY_METHOD:q
+
+