diff options
author | Bodo Möller <bodo@openssl.org> | 1999-12-03 20:24:21 +0000 |
---|---|---|
committer | Bodo Möller <bodo@openssl.org> | 1999-12-03 20:24:21 +0000 |
commit | cddfe788fbbc4726fcf9892963df3f3e823eb233 (patch) | |
tree | fe129b6f8b162a2053634fdfb62d17d9dad17a10 | |
parent | 21131f00d7ffcdac99334ce5704366c1cdd06fc4 (diff) | |
download | openssl-new-cddfe788fbbc4726fcf9892963df3f3e823eb233.tar.gz |
Add functions des_set_key_checked, des_set_key_unchecked.
Never use des_set_key (it depends on the global variable des_check_key),
but usually des_set_key_unchecked.
Only destest.c bothered to look at the return values of des_set_key,
but it did not set des_check_key -- if it had done so,
most checks would have failed because of wrong parity and
because of weak keys.
-rw-r--r-- | CHANGES | 8 | ||||
-rw-r--r-- | apps/speed.c | 6 | ||||
-rw-r--r-- | crypto/des/des.c | 6 | ||||
-rw-r--r-- | crypto/des/des.h | 5 | ||||
-rw-r--r-- | crypto/des/des_opts.c | 8 | ||||
-rw-r--r-- | crypto/des/destest.c | 59 | ||||
-rw-r--r-- | crypto/des/fcrypt.c | 2 | ||||
-rw-r--r-- | crypto/des/rand_key.c | 4 | ||||
-rw-r--r-- | crypto/des/rpc_enc.c | 2 | ||||
-rw-r--r-- | crypto/des/set_key.c | 35 | ||||
-rw-r--r-- | crypto/des/speed.c | 8 | ||||
-rw-r--r-- | crypto/des/str2key.c | 14 | ||||
-rw-r--r-- | crypto/evp/e_cbc_3d.c | 10 | ||||
-rw-r--r-- | crypto/evp/e_cfb_3d.c | 10 | ||||
-rw-r--r-- | crypto/evp/e_cfb_d.c | 2 | ||||
-rw-r--r-- | crypto/evp/e_ecb_3d.c | 10 | ||||
-rw-r--r-- | crypto/evp/e_ecb_d.c | 2 | ||||
-rw-r--r-- | crypto/evp/e_ofb_3d.c | 10 | ||||
-rw-r--r-- | crypto/evp/e_ofb_d.c | 2 | ||||
-rw-r--r-- | crypto/evp/e_xcbc_d.c | 2 | ||||
-rw-r--r-- | crypto/mdc2/mdc2dgst.c | 4 |
21 files changed, 106 insertions, 103 deletions
@@ -4,6 +4,14 @@ Changes between 0.9.4 and 0.9.5 [xx XXX 1999] + *) Add variants des_set_key_checked and des_set_key_unchecked of + des_set_key (aka des_key_sched). Global variable des_check_key + decides which of these is called by des_set_key; this way + des_check_key behaves as it always did, but applications and + the library itself, which was buggy for des_check_key == 1, + have a cleaner way to pick the version they need. + [Bodo Moeller] + *) New function PKCS12_newpass() which changes the password of a PKCS12 structure. [Steve Henson] diff --git a/apps/speed.c b/apps/speed.c index 779ee03a19..caf47e2277 100644 --- a/apps/speed.c +++ b/apps/speed.c @@ -590,9 +590,9 @@ int MAIN(int argc, char **argv) #endif #ifndef NO_DES - des_set_key(&key,sch); - des_set_key(&key2,sch2); - des_set_key(&key3,sch3); + des_set_key_unchecked(&key,sch); + des_set_key_unchecked(&key2,sch2); + des_set_key_unchecked(&key3,sch3); #endif #ifndef NO_IDEA idea_set_encrypt_key(key16,&idea_ks); diff --git a/crypto/des/des.c b/crypto/des/des.c index 206e3777a7..5cd337301a 100644 --- a/crypto/des/des.c +++ b/crypto/des/des.c @@ -425,7 +425,7 @@ void doencryption(void) else k2[i-8]=k; } - des_set_key(&k2,ks2); + des_set_key_unchecked(&k2,ks2); memset(k2,0,sizeof(k2)); } else if (longk || flag3) @@ -433,7 +433,7 @@ void doencryption(void) if (flag3) { des_string_to_2keys(key,&kk,&k2); - des_set_key(&k2,ks2); + des_set_key_unchecked(&k2,ks2); memset(k2,0,sizeof(k2)); } else @@ -455,7 +455,7 @@ void doencryption(void) kk[i]=key[i]|0x80; } - des_set_key(&kk,ks); + des_set_key_unchecked(&kk,ks); memset(key,0,sizeof(key)); memset(kk,0,sizeof(kk)); /* woops - A bug that does not showup under unix :-( */ diff --git a/crypto/des/des.h b/crypto/des/des.h index 67f90aaf17..b492002435 100644 --- a/crypto/des/des.h +++ b/crypto/des/des.h @@ -193,8 +193,13 @@ int des_read_2passwords(des_cblock *key1,des_cblock *key2, int des_read_pw_string(char *buf,int length,const char *prompt,int verify); void des_set_odd_parity(des_cblock *key); int des_is_weak_key(const_des_cblock *key); +/* des_set_key (= set_key = des_key_sched = key_sched) calls + * des_set_key_checked if global variable des_check_key is set, + * des_set_key_unchecked otherwise. */ int des_set_key(const_des_cblock *key,des_key_schedule schedule); int des_key_sched(const_des_cblock *key,des_key_schedule schedule); +int des_set_key_checked(const_des_cblock *key,des_key_schedule schedule); +void des_set_key_unchecked(const_des_cblock *key,des_key_schedule schedule); void des_string_to_key(const char *str,des_cblock *key); void des_string_to_2keys(const char *str,des_cblock *key1,des_cblock *key2); void des_cfb64_encrypt(const unsigned char *in,unsigned char *out,long length, diff --git a/crypto/des/des_opts.c b/crypto/des/des_opts.c index 746c456f8f..545075ce49 100644 --- a/crypto/des/des_opts.c +++ b/crypto/des/des_opts.c @@ -438,13 +438,13 @@ int main(int argc, char **argv) fprintf(stderr,"program when this computer is idle.\n"); #endif - des_set_key(&key,sch); - des_set_key(&key2,sch2); - des_set_key(&key3,sch3); + des_set_key_unchecked(&key,sch); + des_set_key_unchecked(&key2,sch2); + des_set_key_unchecked(&key3,sch3); #ifndef SIGALRM fprintf(stderr,"First we calculate the approximate speed ...\n"); - des_set_key(&key,sch); + des_set_key_unchecked(&key,sch); count=10; do { long i; diff --git a/crypto/des/destest.c b/crypto/des/destest.c index 69155eda12..7efd83dc30 100644 --- a/crypto/des/destest.c +++ b/crypto/des/destest.c @@ -234,7 +234,8 @@ static unsigned char cipher_ecb2[NUM_TESTS-1][8]={ {0x08,0xD7,0xB4,0xFB,0x62,0x9D,0x08,0x85}}; static unsigned char cbc_key [8]={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}; -static unsigned char cbc2_key[8]={0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87}; +/* static unsigned char cbc2_key[8]={0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87}; */ +static unsigned char cbc2_key[8]={0xf1,0xe0,0xd3,0xc2,0xb5,0xa4,0x97,0x86}; static unsigned char cbc3_key[8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10}; static unsigned char cbc_iv [8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10}; /* Changed the following text constant to binary so it will work on ebcdic @@ -331,17 +332,17 @@ int main(int argc, char *argv[]) #ifndef NO_DESCBCM printf("Doing cbcm\n"); - if ((j=des_key_sched(&cbc_key,ks)) != 0) + if ((j=des_set_key_checked(&cbc_key,ks)) != 0) { printf("Key error %d\n",j); err=1; } - if ((j=des_key_sched(&cbc2_key,ks2)) != 0) + if ((j=des_set_key_checked(&cbc2_key,ks2)) != 0) { printf("Key error %d\n",j); err=1; } - if ((j=des_key_sched(&cbc3_key,ks3)) != 0) + if ((j=des_set_key_checked(&cbc3_key,ks3)) != 0) { printf("Key error %d\n",j); err=1; @@ -385,11 +386,7 @@ int main(int argc, char *argv[]) printf("Doing ecb\n"); for (i=0; i<NUM_TESTS; i++) { - if ((j=des_key_sched(&key_data[i],ks)) != 0) - { - printf("Key error %2d:%d\n",i+1,j); - err=1; - } + des_set_key_unchecked(&key_data[i],ks); memcpy(in,plain_data[i],8); memset(out,0,8); memset(outin,0,8); @@ -415,21 +412,9 @@ int main(int argc, char *argv[]) printf("Doing ede ecb\n"); for (i=0; i<(NUM_TESTS-1); i++) { - if ((j=des_key_sched(&key_data[i],ks)) != 0) - { - err=1; - printf("Key error %2d:%d\n",i+1,j); - } - if ((j=des_key_sched(&key_data[i+1],ks2)) != 0) - { - printf("Key error %2d:%d\n",i+2,j); - err=1; - } - if ((j=des_key_sched(&key_data[i+2],ks3)) != 0) - { - printf("Key error %2d:%d\n",i+3,j); - err=1; - } + des_set_key_unchecked(&key_data[i],ks); + des_set_key_unchecked(&key_data[i+1],ks2); + des_set_key_unchecked(&key_data[i+2],ks3); memcpy(in,plain_data[i],8); memset(out,0,8); memset(outin,0,8); @@ -453,7 +438,7 @@ int main(int argc, char *argv[]) #endif printf("Doing cbc\n"); - if ((j=des_key_sched(&cbc_key,ks)) != 0) + if ((j=des_set_key_checked(&cbc_key,ks)) != 0) { printf("Key error %d\n",j); err=1; @@ -477,7 +462,7 @@ int main(int argc, char *argv[]) #ifndef LIBDES_LIT printf("Doing desx cbc\n"); - if ((j=des_key_sched(&cbc_key,ks)) != 0) + if ((j=des_set_key_checked(&cbc_key,ks)) != 0) { printf("Key error %d\n",j); err=1; @@ -502,17 +487,17 @@ int main(int argc, char *argv[]) #endif printf("Doing ede cbc\n"); - if ((j=des_key_sched(&cbc_key,ks)) != 0) + if ((j=des_set_key_checked(&cbc_key,ks)) != 0) { printf("Key error %d\n",j); err=1; } - if ((j=des_key_sched(&cbc2_key,ks2)) != 0) + if ((j=des_set_key_checked(&cbc2_key,ks2)) != 0) { printf("Key error %d\n",j); err=1; } - if ((j=des_key_sched(&cbc3_key,ks3)) != 0) + if ((j=des_set_key_checked(&cbc3_key,ks3)) != 0) { printf("Key error %d\n",j); err=1; @@ -543,7 +528,7 @@ int main(int argc, char *argv[]) #ifndef LIBDES_LIT printf("Doing pcbc\n"); - if ((j=des_key_sched(&cbc_key,ks)) != 0) + if ((j=des_set_key_checked(&cbc_key,ks)) != 0) { printf("Key error %d\n",j); err=1; @@ -606,7 +591,7 @@ int main(int argc, char *argv[]) printf("done\n"); printf("Doing ofb\n"); - des_key_sched(&ofb_key,ks); + des_set_key_checked(&ofb_key,ks); memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); des_ofb_encrypt(plain,ofb_buf1,64,sizeof(plain)/8,ks,&ofb_tmp); if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0) @@ -635,7 +620,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]); } printf("Doing ofb64\n"); - des_key_sched(&ofb_key,ks); + des_set_key_checked(&ofb_key,ks); memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); memset(ofb_buf1,0,sizeof(ofb_buf1)); memset(ofb_buf2,0,sizeof(ofb_buf1)); @@ -660,7 +645,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]); } printf("Doing ede_ofb64\n"); - des_key_sched(&ofb_key,ks); + des_set_key_checked(&ofb_key,ks); memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); memset(ofb_buf1,0,sizeof(ofb_buf1)); memset(ofb_buf2,0,sizeof(ofb_buf1)); @@ -686,7 +671,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]); } printf("Doing cbc_cksum\n"); - des_key_sched(&cbc_key,ks); + des_set_key_checked(&cbc_key,ks); cs=des_cbc_cksum(cbc_data,&cret,strlen((char *)cbc_data),ks,&cbc_iv); if (cs != cbc_cksum_ret) { @@ -825,7 +810,7 @@ static int cfb_test(int bits, unsigned char *cfb_cipher) des_key_schedule ks; int i,err=0; - des_key_sched(&cfb_key,ks); + des_set_key_checked(&cfb_key,ks); memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); des_cfb_encrypt(plain,cfb_buf1,bits,sizeof(plain),ks,&cfb_tmp, DES_ENCRYPT); @@ -854,7 +839,7 @@ static int cfb64_test(unsigned char *cfb_cipher) des_key_schedule ks; int err=0,i,n; - des_key_sched(&cfb_key,ks); + des_set_key_checked(&cfb_key,ks); memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); n=0; des_cfb64_encrypt(plain,cfb_buf1,12,ks,&cfb_tmp,&n,DES_ENCRYPT); @@ -887,7 +872,7 @@ static int ede_cfb64_test(unsigned char *cfb_cipher) des_key_schedule ks; int err=0,i,n; - des_key_sched(&cfb_key,ks); + des_set_key_checked(&cfb_key,ks); memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); n=0; des_ede3_cfb64_encrypt(plain,cfb_buf1,12,ks,ks,ks,&cfb_tmp,&n, diff --git a/crypto/des/fcrypt.c b/crypto/des/fcrypt.c index b59855c724..889715a746 100644 --- a/crypto/des/fcrypt.c +++ b/crypto/des/fcrypt.c @@ -151,7 +151,7 @@ r=(r+7)/8; for (; i<8; i++) key[i]=0; - des_set_key(&key,ks); + des_set_key_unchecked(&key,ks); fcrypt_body(&(out[0]),ks,Eswap0,Eswap1); ll=out[0]; l2c(ll,b); diff --git a/crypto/des/rand_key.c b/crypto/des/rand_key.c index fc11792cda..2032c59df6 100644 --- a/crypto/des/rand_key.c +++ b/crypto/des/rand_key.c @@ -100,11 +100,11 @@ void des_random_key(des_cblock *ret) l2c(t,p); des_set_odd_parity(&data); - des_set_key(&data,ks); + des_set_key_unchecked(&data,ks); des_cbc_cksum(key,&key,sizeof(key),ks,&data); des_set_odd_parity(&key); - des_set_key(&key,ks); + des_set_key_unchecked(&key,ks); des_cbc_cksum(key,&data,sizeof(key),ks,&key); memcpy(ret,data,sizeof(key)); diff --git a/crypto/des/rpc_enc.c b/crypto/des/rpc_enc.c index c96c204147..32d96d5cae 100644 --- a/crypto/des/rpc_enc.c +++ b/crypto/des/rpc_enc.c @@ -66,7 +66,7 @@ int _des_crypt(char *buf, int len, struct desparams *desp) des_key_schedule ks; int enc; - des_set_key(&desp->des_key,ks); + des_set_key_unchecked(&desp->des_key,ks); enc=(desp->des_dir == ENCRYPT)?DES_ENCRYPT:DES_DECRYPT; if (desp->des_mode == CBC) diff --git a/crypto/des/set_key.c b/crypto/des/set_key.c index 52553a4c16..eb64bd5292 100644 --- a/crypto/des/set_key.c +++ b/crypto/des/set_key.c @@ -145,11 +145,34 @@ int des_is_weak_key(const_des_cblock *key) #define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\ (a)=(a)^(t)^(t>>(16-(n)))) +int des_set_key(const_des_cblock *key, des_key_schedule schedule) + { + if (des_check_key) + { + return des_set_key_checked(key, schedule); + } + else + { + des_set_key_unchecked(key, schedule); + return 0; + } + } + /* return 0 if key parity is odd (correct), * return -1 if key parity error, * return -2 if illegal weak key. */ -int des_set_key(const_des_cblock *key, des_key_schedule schedule) +int des_set_key_checked(const_des_cblock *key, des_key_schedule schedule) + { + if (!check_parity(key)) + return(-1); + if (des_is_weak_key(key)) + return(-2); + des_set_key_unchecked(key, schedule); + return 0; + } + +void des_set_key_unchecked(const_des_cblock *key, des_key_schedule schedule) { static int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0}; register DES_LONG c,d,t,s,t2; @@ -157,15 +180,6 @@ int des_set_key(const_des_cblock *key, des_key_schedule schedule) register DES_LONG *k; register int i; - if (des_check_key) - { - if (!check_parity(key)) - return(-1); - - if (des_is_weak_key(key)) - return(-2); - } - k = &schedule->ks.deslong[0]; in = &(*key)[0]; @@ -225,7 +239,6 @@ int des_set_key(const_des_cblock *key, des_key_schedule schedule) t2=((s>>16L)|(t&0xffff0000L)); *(k++)=ROTATE(t2,26)&0xffffffffL; } - return(0); } int des_key_sched(const_des_cblock *key, des_key_schedule schedule) diff --git a/crypto/des/speed.c b/crypto/des/speed.c index da41abcb03..652cf5b03c 100644 --- a/crypto/des/speed.c +++ b/crypto/des/speed.c @@ -190,12 +190,12 @@ int main(int argc, char **argv) printf("program when this computer is idle.\n"); #endif - des_set_key(&key2,sch2); - des_set_key(&key3,sch3); + des_set_key_unchecked(&key2,sch2); + des_set_key_unchecked(&key3,sch3); #ifndef SIGALRM printf("First we calculate the approximate speed ...\n"); - des_set_key(&key,sch); + des_set_key_unchecked(&key,sch); count=10; do { long i; @@ -225,7 +225,7 @@ int main(int argc, char **argv) Time_F(START); for (count=0,run=1; COND(ca); count++) - des_set_key(&key,sch); + des_set_key_unchecked(&key,sch); d=Time_F(STOP); printf("%ld set_key's in %.2f seconds\n",count,d); a=((double)COUNT(ca))/d; diff --git a/crypto/des/str2key.c b/crypto/des/str2key.c index 24841452f1..5522824952 100644 --- a/crypto/des/str2key.c +++ b/crypto/des/str2key.c @@ -58,8 +58,6 @@ #include "des_locl.h" -OPENSSL_EXTERN int des_check_key; - void des_string_to_key(const char *str, des_cblock *key) { des_key_schedule ks; @@ -88,10 +86,7 @@ void des_string_to_key(const char *str, des_cblock *key) } #endif des_set_odd_parity(key); - i=des_check_key; - des_check_key=0; - des_set_key(key,ks); - des_check_key=i; + des_set_key_unchecked(key,ks); des_cbc_cksum((unsigned char*)str,key,length,ks,key); memset(ks,0,sizeof(ks)); des_set_odd_parity(key); @@ -150,13 +145,10 @@ void des_string_to_2keys(const char *str, des_cblock *key1, des_cblock *key2) #endif des_set_odd_parity(key1); des_set_odd_parity(key2); - i=des_check_key; - des_check_key=0; - des_set_key(key1,ks); + des_set_key_unchecked(key1,ks); des_cbc_cksum((unsigned char*)str,key1,length,ks,key1); - des_set_key(key2,ks); + des_set_key_unchecked(key2,ks); des_cbc_cksum((unsigned char*)str,key2,length,ks,key2); - des_check_key=i; memset(ks,0,sizeof(ks)); des_set_odd_parity(key1); des_set_odd_parity(key2); diff --git a/crypto/evp/e_cbc_3d.c b/crypto/evp/e_cbc_3d.c index 02ccc6dc90..5d16b865c5 100644 --- a/crypto/evp/e_cbc_3d.c +++ b/crypto/evp/e_cbc_3d.c @@ -115,8 +115,8 @@ static void des_cbc_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, if (deskey != NULL) { - des_set_key(&deskey[0],ctx->c.des_ede.ks1); - des_set_key(&deskey[1],ctx->c.des_ede.ks2); + des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1); + des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2); memcpy( (char *)ctx->c.des_ede.ks3, (char *)ctx->c.des_ede.ks1, sizeof(ctx->c.des_ede.ks1)); @@ -134,9 +134,9 @@ static void des_cbc_ede3_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, if (deskey != NULL) { - des_set_key(&deskey[0],ctx->c.des_ede.ks1); - des_set_key(&deskey[1],ctx->c.des_ede.ks2); - des_set_key(&deskey[2],ctx->c.des_ede.ks3); + des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1); + des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2); + des_set_key_unchecked(&deskey[2],ctx->c.des_ede.ks3); } } diff --git a/crypto/evp/e_cfb_3d.c b/crypto/evp/e_cfb_3d.c index bd32b072e2..b364bd4e31 100644 --- a/crypto/evp/e_cfb_3d.c +++ b/crypto/evp/e_cfb_3d.c @@ -116,8 +116,8 @@ static void des_ede_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); if (deskey != NULL) { - des_set_key(&deskey[0],ctx->c.des_ede.ks1); - des_set_key(&deskey[1],ctx->c.des_ede.ks2); + des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1); + des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2); memcpy( (char *)ctx->c.des_ede.ks3, (char *)ctx->c.des_ede.ks1, sizeof(ctx->c.des_ede.ks1)); @@ -136,9 +136,9 @@ static void des_ede3_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); if (deskey != NULL) { - des_set_key(&deskey[0],ctx->c.des_ede.ks1); - des_set_key(&deskey[1],ctx->c.des_ede.ks2); - des_set_key(&deskey[2],ctx->c.des_ede.ks3); + des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1); + des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2); + des_set_key_unchecked(&deskey[2],ctx->c.des_ede.ks3); } } diff --git a/crypto/evp/e_cfb_d.c b/crypto/evp/e_cfb_d.c index 6bdf20b646..9e1714bd15 100644 --- a/crypto/evp/e_cfb_d.c +++ b/crypto/evp/e_cfb_d.c @@ -95,7 +95,7 @@ static void des_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, memcpy(&(ctx->oiv[0]),iv,8); memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); if (deskey != NULL) - des_set_key(deskey,ctx->c.des_ks); + des_set_key_unchecked(deskey,ctx->c.des_ks); } static void des_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, diff --git a/crypto/evp/e_ecb_3d.c b/crypto/evp/e_ecb_3d.c index 354a8b79a7..806e971d36 100644 --- a/crypto/evp/e_ecb_3d.c +++ b/crypto/evp/e_ecb_3d.c @@ -110,8 +110,8 @@ static void des_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, if (deskey != NULL) { - des_set_key(&deskey[0],ctx->c.des_ede.ks1); - des_set_key(&deskey[1],ctx->c.des_ede.ks2); + des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1); + des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2); memcpy( (char *)ctx->c.des_ede.ks3, (char *)ctx->c.des_ede.ks1, sizeof(ctx->c.des_ede.ks1)); @@ -125,9 +125,9 @@ static void des_ede3_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, if (deskey != NULL) { - des_set_key(&deskey[0],ctx->c.des_ede.ks1); - des_set_key(&deskey[1],ctx->c.des_ede.ks2); - des_set_key(&deskey[2],ctx->c.des_ede.ks3); + des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1); + des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2); + des_set_key_unchecked(&deskey[2],ctx->c.des_ede.ks3); } } diff --git a/crypto/evp/e_ecb_d.c b/crypto/evp/e_ecb_d.c index 5fb4e64b1c..c11bef55ef 100644 --- a/crypto/evp/e_ecb_d.c +++ b/crypto/evp/e_ecb_d.c @@ -90,7 +90,7 @@ static void des_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, des_cblock *deskey = (des_cblock *)key; if (deskey != NULL) - des_set_key(deskey,ctx->c.des_ks); + des_set_key_unchecked(deskey,ctx->c.des_ks); } static void des_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, diff --git a/crypto/evp/e_ofb_3d.c b/crypto/evp/e_ofb_3d.c index 5233567c0c..d1a33e2ecd 100644 --- a/crypto/evp/e_ofb_3d.c +++ b/crypto/evp/e_ofb_3d.c @@ -116,8 +116,8 @@ static void des_ede_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); if (deskey != NULL) { - des_set_key(&deskey[0],ctx->c.des_ede.ks1); - des_set_key(&deskey[1],ctx->c.des_ede.ks2); + des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1); + des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2); memcpy( (char *)ctx->c.des_ede.ks3, (char *)ctx->c.des_ede.ks1, sizeof(ctx->c.des_ede.ks1)); @@ -136,9 +136,9 @@ static void des_ede3_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); if (deskey != NULL) { - des_set_key(&deskey[0],ctx->c.des_ede.ks1); - des_set_key(&deskey[1],ctx->c.des_ede.ks2); - des_set_key(&deskey[2],ctx->c.des_ede.ks3); + des_set_key_unchecked(&deskey[0],ctx->c.des_ede.ks1); + des_set_key_unchecked(&deskey[1],ctx->c.des_ede.ks2); + des_set_key_unchecked(&deskey[2],ctx->c.des_ede.ks3); } } diff --git a/crypto/evp/e_ofb_d.c b/crypto/evp/e_ofb_d.c index 398b3a002e..d51ce230f4 100644 --- a/crypto/evp/e_ofb_d.c +++ b/crypto/evp/e_ofb_d.c @@ -95,7 +95,7 @@ static void des_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, memcpy(&(ctx->oiv[0]),iv,8); memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); if (deskey != NULL) - des_set_key(deskey,ctx->c.des_ks); + des_set_key_unchecked(deskey,ctx->c.des_ks); } static void des_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, diff --git a/crypto/evp/e_xcbc_d.c b/crypto/evp/e_xcbc_d.c index 3a6628a75c..7568fad4ff 100644 --- a/crypto/evp/e_xcbc_d.c +++ b/crypto/evp/e_xcbc_d.c @@ -94,7 +94,7 @@ static void desx_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); if (deskey != NULL) { - des_set_key(deskey,ctx->c.desx_cbc.ks); + des_set_key_unchecked(deskey,ctx->c.desx_cbc.ks); memcpy(&(ctx->c.desx_cbc.inw[0]),&(key[8]),8); memcpy(&(ctx->c.desx_cbc.outw[0]),&(key[16]),8); } diff --git a/crypto/mdc2/mdc2dgst.c b/crypto/mdc2/mdc2dgst.c index 4fc39ed86c..aed715c69d 100644 --- a/crypto/mdc2/mdc2dgst.c +++ b/crypto/mdc2/mdc2dgst.c @@ -135,11 +135,11 @@ static void mdc2_body(MDC2_CTX *c, unsigned char *in, unsigned int len) c->hh[0]=(c->hh[0]&0x9f)|0x20; des_set_odd_parity(&c->h); - des_set_key(&c->h,k); + des_set_key_unchecked(&c->h,k); des_encrypt(d,k,1); des_set_odd_parity(&c->hh); - des_set_key(&c->hh,k); + des_set_key_unchecked(&c->hh,k); des_encrypt(dd,k,1); ttin0=tin0^dd[0]; |