diff options
Diffstat (limited to 'src/lib/libcrypto/des')
-rw-r--r-- | src/lib/libcrypto/des/cfb64ede.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/des/cfb_enc.c | 71 | ||||
-rw-r--r-- | src/lib/libcrypto/des/des.h | 11 | ||||
-rw-r--r-- | src/lib/libcrypto/des/des_enc.c | 9 | ||||
-rw-r--r-- | src/lib/libcrypto/des/des_locl.h | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/des/des_old.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/des/des_old.h | 13 | ||||
-rw-r--r-- | src/lib/libcrypto/des/des_opts.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/des/des_ver.h | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/des/destest.c | 18 | ||||
-rw-r--r-- | src/lib/libcrypto/des/ecb3_enc.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/des/ecb_enc.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/des/ede_cbcm_enc.c | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/des/fcrypt.c | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/des/read2pwd.c | 1 | ||||
-rw-r--r-- | src/lib/libcrypto/des/set_key.c | 10 | ||||
-rw-r--r-- | src/lib/libcrypto/des/speed.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/des/str2key.c | 1 | ||||
-rw-r--r-- | src/lib/libcrypto/des/xcbc_enc.c | 4 |
19 files changed, 103 insertions, 70 deletions
diff --git a/src/lib/libcrypto/des/cfb64ede.c b/src/lib/libcrypto/des/cfb64ede.c index f3c6018528..de34ecceb9 100644 --- a/src/lib/libcrypto/des/cfb64ede.c +++ b/src/lib/libcrypto/des/cfb64ede.c | |||
@@ -152,8 +152,8 @@ void DES_ede3_cfb_encrypt(const unsigned char *in,unsigned char *out, | |||
152 | DES_cblock *ivec,int enc) | 152 | DES_cblock *ivec,int enc) |
153 | { | 153 | { |
154 | register DES_LONG d0,d1,v0,v1; | 154 | register DES_LONG d0,d1,v0,v1; |
155 | register long l=length; | 155 | register unsigned long l=length,n=((unsigned int)numbits+7)/8; |
156 | register int num=numbits,n=(numbits+7)/8,i; | 156 | register int num=numbits,i; |
157 | DES_LONG ti[2]; | 157 | DES_LONG ti[2]; |
158 | unsigned char *iv; | 158 | unsigned char *iv; |
159 | unsigned char ovec[16]; | 159 | unsigned char ovec[16]; |
diff --git a/src/lib/libcrypto/des/cfb_enc.c b/src/lib/libcrypto/des/cfb_enc.c index 03cabb223c..720f29a28e 100644 --- a/src/lib/libcrypto/des/cfb_enc.c +++ b/src/lib/libcrypto/des/cfb_enc.c | |||
@@ -58,6 +58,7 @@ | |||
58 | 58 | ||
59 | #include "e_os.h" | 59 | #include "e_os.h" |
60 | #include "des_locl.h" | 60 | #include "des_locl.h" |
61 | #include <assert.h> | ||
61 | 62 | ||
62 | /* The input and output are loaded in multiples of 8 bits. | 63 | /* The input and output are loaded in multiples of 8 bits. |
63 | * What this means is that if you hame numbits=12 and length=2 | 64 | * What this means is that if you hame numbits=12 and length=2 |
@@ -72,19 +73,29 @@ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, | |||
72 | int enc) | 73 | int enc) |
73 | { | 74 | { |
74 | register DES_LONG d0,d1,v0,v1; | 75 | register DES_LONG d0,d1,v0,v1; |
75 | register unsigned long l=length,n=(numbits+7)/8; | 76 | register unsigned long l=length; |
76 | register int num=numbits,i; | 77 | register int num=numbits/8,n=(numbits+7)/8,i,rem=numbits%8; |
77 | DES_LONG ti[2]; | 78 | DES_LONG ti[2]; |
78 | unsigned char *iv; | 79 | unsigned char *iv; |
80 | #ifndef L_ENDIAN | ||
79 | unsigned char ovec[16]; | 81 | unsigned char ovec[16]; |
82 | #else | ||
83 | unsigned int sh[4]; | ||
84 | unsigned char *ovec=(unsigned char *)sh; | ||
80 | 85 | ||
81 | if (num > 64) return; | 86 | /* I kind of count that compiler optimizes away this assertioni,*/ |
87 | assert (sizeof(sh[0])==4); /* as this holds true for all, */ | ||
88 | /* but 16-bit platforms... */ | ||
89 | |||
90 | #endif | ||
91 | |||
92 | if (numbits<=0 || numbits > 64) return; | ||
82 | iv = &(*ivec)[0]; | 93 | iv = &(*ivec)[0]; |
83 | c2l(iv,v0); | 94 | c2l(iv,v0); |
84 | c2l(iv,v1); | 95 | c2l(iv,v1); |
85 | if (enc) | 96 | if (enc) |
86 | { | 97 | { |
87 | while (l >= n) | 98 | while (l >= (unsigned long)n) |
88 | { | 99 | { |
89 | l-=n; | 100 | l-=n; |
90 | ti[0]=v0; | 101 | ti[0]=v0; |
@@ -98,35 +109,40 @@ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, | |||
98 | out+=n; | 109 | out+=n; |
99 | /* 30-08-94 - eay - changed because l>>32 and | 110 | /* 30-08-94 - eay - changed because l>>32 and |
100 | * l<<32 are bad under gcc :-( */ | 111 | * l<<32 are bad under gcc :-( */ |
101 | if (num == 32) | 112 | if (numbits == 32) |
102 | { v0=v1; v1=d0; } | 113 | { v0=v1; v1=d0; } |
103 | else if (num == 64) | 114 | else if (numbits == 64) |
104 | { v0=d0; v1=d1; } | 115 | { v0=d0; v1=d1; } |
105 | else | 116 | else |
106 | { | 117 | { |
118 | #ifndef L_ENDIAN | ||
107 | iv=&ovec[0]; | 119 | iv=&ovec[0]; |
108 | l2c(v0,iv); | 120 | l2c(v0,iv); |
109 | l2c(v1,iv); | 121 | l2c(v1,iv); |
110 | l2c(d0,iv); | 122 | l2c(d0,iv); |
111 | l2c(d1,iv); | 123 | l2c(d1,iv); |
112 | /* shift ovec left most of the bits... */ | 124 | #else |
113 | memmove(ovec,ovec+num/8,8+(num%8 ? 1 : 0)); | 125 | sh[0]=v0, sh[1]=v1, sh[2]=d0, sh[3]=d1; |
114 | /* now the remaining bits */ | 126 | #endif |
115 | if(num%8 != 0) | 127 | if (rem==0) |
128 | memmove(ovec,ovec+num,8); | ||
129 | else | ||
116 | for(i=0 ; i < 8 ; ++i) | 130 | for(i=0 ; i < 8 ; ++i) |
117 | { | 131 | ovec[i]=ovec[i+num]<<rem | |
118 | ovec[i]<<=num%8; | 132 | ovec[i+num+1]>>(8-rem); |
119 | ovec[i]|=ovec[i+1]>>(8-num%8); | 133 | #ifdef L_ENDIAN |
120 | } | 134 | v0=sh[0], v1=sh[1]; |
135 | #else | ||
121 | iv=&ovec[0]; | 136 | iv=&ovec[0]; |
122 | c2l(iv,v0); | 137 | c2l(iv,v0); |
123 | c2l(iv,v1); | 138 | c2l(iv,v1); |
139 | #endif | ||
124 | } | 140 | } |
125 | } | 141 | } |
126 | } | 142 | } |
127 | else | 143 | else |
128 | { | 144 | { |
129 | while (l >= n) | 145 | while (l >= (unsigned long)n) |
130 | { | 146 | { |
131 | l-=n; | 147 | l-=n; |
132 | ti[0]=v0; | 148 | ti[0]=v0; |
@@ -136,29 +152,34 @@ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, | |||
136 | in+=n; | 152 | in+=n; |
137 | /* 30-08-94 - eay - changed because l>>32 and | 153 | /* 30-08-94 - eay - changed because l>>32 and |
138 | * l<<32 are bad under gcc :-( */ | 154 | * l<<32 are bad under gcc :-( */ |
139 | if (num == 32) | 155 | if (numbits == 32) |
140 | { v0=v1; v1=d0; } | 156 | { v0=v1; v1=d0; } |
141 | else if (num == 64) | 157 | else if (numbits == 64) |
142 | { v0=d0; v1=d1; } | 158 | { v0=d0; v1=d1; } |
143 | else | 159 | else |
144 | { | 160 | { |
161 | #ifndef L_ENDIAN | ||
145 | iv=&ovec[0]; | 162 | iv=&ovec[0]; |
146 | l2c(v0,iv); | 163 | l2c(v0,iv); |
147 | l2c(v1,iv); | 164 | l2c(v1,iv); |
148 | l2c(d0,iv); | 165 | l2c(d0,iv); |
149 | l2c(d1,iv); | 166 | l2c(d1,iv); |
150 | /* shift ovec left most of the bits... */ | 167 | #else |
151 | memmove(ovec,ovec+num/8,8+(num%8 ? 1 : 0)); | 168 | sh[0]=v0, sh[1]=v1, sh[2]=d0, sh[3]=d1; |
152 | /* now the remaining bits */ | 169 | #endif |
153 | if(num%8 != 0) | 170 | if (rem==0) |
171 | memmove(ovec,ovec+num,8); | ||
172 | else | ||
154 | for(i=0 ; i < 8 ; ++i) | 173 | for(i=0 ; i < 8 ; ++i) |
155 | { | 174 | ovec[i]=ovec[i+num]<<rem | |
156 | ovec[i]<<=num%8; | 175 | ovec[i+num+1]>>(8-rem); |
157 | ovec[i]|=ovec[i+1]>>(8-num%8); | 176 | #ifdef L_ENDIAN |
158 | } | 177 | v0=sh[0], v1=sh[1]; |
178 | #else | ||
159 | iv=&ovec[0]; | 179 | iv=&ovec[0]; |
160 | c2l(iv,v0); | 180 | c2l(iv,v0); |
161 | c2l(iv,v1); | 181 | c2l(iv,v1); |
182 | #endif | ||
162 | } | 183 | } |
163 | d0^=ti[0]; | 184 | d0^=ti[0]; |
164 | d1^=ti[1]; | 185 | d1^=ti[1]; |
diff --git a/src/lib/libcrypto/des/des.h b/src/lib/libcrypto/des/des.h index 81bd874edd..7318593699 100644 --- a/src/lib/libcrypto/des/des.h +++ b/src/lib/libcrypto/des/des.h | |||
@@ -59,13 +59,13 @@ | |||
59 | #ifndef HEADER_DES_H | 59 | #ifndef HEADER_DES_H |
60 | #define HEADER_DES_H | 60 | #define HEADER_DES_H |
61 | 61 | ||
62 | #include <openssl/e_os2.h> /* OPENSSL_EXTERN, OPENSSL_NO_DES, | ||
63 | DES_LONG (via openssl/opensslconf.h */ | ||
64 | |||
62 | #ifdef OPENSSL_NO_DES | 65 | #ifdef OPENSSL_NO_DES |
63 | #error DES is disabled. | 66 | #error DES is disabled. |
64 | #endif | 67 | #endif |
65 | 68 | ||
66 | #include <openssl/opensslconf.h> /* DES_LONG */ | ||
67 | #include <openssl/e_os2.h> /* OPENSSL_EXTERN */ | ||
68 | |||
69 | #ifdef OPENSSL_BUILD_SHLIBCRYPTO | 69 | #ifdef OPENSSL_BUILD_SHLIBCRYPTO |
70 | # undef OPENSSL_EXTERN | 70 | # undef OPENSSL_EXTERN |
71 | # define OPENSSL_EXTERN OPENSSL_EXPORT | 71 | # define OPENSSL_EXTERN OPENSSL_EXPORT |
@@ -130,7 +130,7 @@ OPENSSL_DECLARE_GLOBAL(int,DES_rw_mode); /* defaults to DES_PCBC_MODE */ | |||
130 | #define DES_rw_mode OPENSSL_GLOBAL_REF(DES_rw_mode) | 130 | #define DES_rw_mode OPENSSL_GLOBAL_REF(DES_rw_mode) |
131 | 131 | ||
132 | const char *DES_options(void); | 132 | const char *DES_options(void); |
133 | void DES_ecb3_encrypt(const unsigned char *input, unsigned char *output, | 133 | void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output, |
134 | DES_key_schedule *ks1,DES_key_schedule *ks2, | 134 | DES_key_schedule *ks1,DES_key_schedule *ks2, |
135 | DES_key_schedule *ks3, int enc); | 135 | DES_key_schedule *ks3, int enc); |
136 | DES_LONG DES_cbc_cksum(const unsigned char *input,DES_cblock *output, | 136 | DES_LONG DES_cbc_cksum(const unsigned char *input,DES_cblock *output, |
@@ -197,9 +197,10 @@ void DES_ede3_ofb64_encrypt(const unsigned char *in,unsigned char *out, | |||
197 | long length,DES_key_schedule *ks1, | 197 | long length,DES_key_schedule *ks1, |
198 | DES_key_schedule *ks2,DES_key_schedule *ks3, | 198 | DES_key_schedule *ks2,DES_key_schedule *ks3, |
199 | DES_cblock *ivec,int *num); | 199 | DES_cblock *ivec,int *num); |
200 | 200 | #if 0 | |
201 | void DES_xwhite_in2out(const_DES_cblock *DES_key,const_DES_cblock *in_white, | 201 | void DES_xwhite_in2out(const_DES_cblock *DES_key,const_DES_cblock *in_white, |
202 | DES_cblock *out_white); | 202 | DES_cblock *out_white); |
203 | #endif | ||
203 | 204 | ||
204 | int DES_enc_read(int fd,void *buf,int len,DES_key_schedule *sched, | 205 | int DES_enc_read(int fd,void *buf,int len,DES_key_schedule *sched, |
205 | DES_cblock *iv); | 206 | DES_cblock *iv); |
diff --git a/src/lib/libcrypto/des/des_enc.c b/src/lib/libcrypto/des/des_enc.c index 6a49ec4a55..53705b9f5b 100644 --- a/src/lib/libcrypto/des/des_enc.c +++ b/src/lib/libcrypto/des/des_enc.c | |||
@@ -58,9 +58,6 @@ | |||
58 | 58 | ||
59 | #include "des_locl.h" | 59 | #include "des_locl.h" |
60 | 60 | ||
61 | #ifndef OPENSSL_FIPS | ||
62 | #ifndef OPENBSD_DES_ASM | ||
63 | |||
64 | void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc) | 61 | void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc) |
65 | { | 62 | { |
66 | register DES_LONG l,r,t,u; | 63 | register DES_LONG l,r,t,u; |
@@ -291,12 +288,8 @@ void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1, | |||
291 | data[1]=r; | 288 | data[1]=r; |
292 | } | 289 | } |
293 | 290 | ||
294 | #endif /* ndef OPENSSL_FIPS */ | ||
295 | |||
296 | #ifndef DES_DEFAULT_OPTIONS | 291 | #ifndef DES_DEFAULT_OPTIONS |
297 | 292 | ||
298 | #if !defined(OPENSSL_FIPS_DES_ASM) | ||
299 | |||
300 | #undef CBC_ENC_C__DONT_UPDATE_IV | 293 | #undef CBC_ENC_C__DONT_UPDATE_IV |
301 | #include "ncbc_enc.c" /* DES_ncbc_encrypt */ | 294 | #include "ncbc_enc.c" /* DES_ncbc_encrypt */ |
302 | 295 | ||
@@ -412,6 +405,4 @@ void DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output, | |||
412 | tin[0]=tin[1]=0; | 405 | tin[0]=tin[1]=0; |
413 | } | 406 | } |
414 | 407 | ||
415 | #endif /* !defined(OPENSSL_FIPS_DES_ASM) */ | ||
416 | |||
417 | #endif /* DES_DEFAULT_OPTIONS */ | 408 | #endif /* DES_DEFAULT_OPTIONS */ |
diff --git a/src/lib/libcrypto/des/des_locl.h b/src/lib/libcrypto/des/des_locl.h index 8f04b18c50..4b9ecff233 100644 --- a/src/lib/libcrypto/des/des_locl.h +++ b/src/lib/libcrypto/des/des_locl.h | |||
@@ -160,7 +160,7 @@ | |||
160 | } \ | 160 | } \ |
161 | } | 161 | } |
162 | 162 | ||
163 | #if defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER) | 163 | #if (defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER)) || defined(__ICC) |
164 | #define ROTATE(a,n) (_lrotr(a,n)) | 164 | #define ROTATE(a,n) (_lrotr(a,n)) |
165 | #elif defined(__GNUC__) && __GNUC__>=2 && !defined(__STRICT_ANSI__) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC) | 165 | #elif defined(__GNUC__) && __GNUC__>=2 && !defined(__STRICT_ANSI__) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC) |
166 | # if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) | 166 | # if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) |
diff --git a/src/lib/libcrypto/des/des_old.c b/src/lib/libcrypto/des/des_old.c index 88e9802aad..7c33ed7a93 100644 --- a/src/lib/libcrypto/des/des_old.c +++ b/src/lib/libcrypto/des/des_old.c | |||
@@ -84,7 +84,7 @@ void _ossl_old_des_ecb3_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock | |||
84 | des_key_schedule ks1,des_key_schedule ks2, | 84 | des_key_schedule ks1,des_key_schedule ks2, |
85 | des_key_schedule ks3, int enc) | 85 | des_key_schedule ks3, int enc) |
86 | { | 86 | { |
87 | DES_ecb3_encrypt((const unsigned char *)input, (unsigned char *)output, | 87 | DES_ecb3_encrypt((const_DES_cblock *)input, output, |
88 | (DES_key_schedule *)ks1, (DES_key_schedule *)ks2, | 88 | (DES_key_schedule *)ks1, (DES_key_schedule *)ks2, |
89 | (DES_key_schedule *)ks3, enc); | 89 | (DES_key_schedule *)ks3, enc); |
90 | } | 90 | } |
@@ -169,11 +169,13 @@ void _ossl_old_des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out, | |||
169 | (DES_key_schedule *)ks3, ivec, num); | 169 | (DES_key_schedule *)ks3, ivec, num); |
170 | } | 170 | } |
171 | 171 | ||
172 | #if 0 /* broken code, preserved just in case anyone specifically looks for this */ | ||
172 | void _ossl_old_des_xwhite_in2out(_ossl_old_des_cblock (*des_key), _ossl_old_des_cblock (*in_white), | 173 | void _ossl_old_des_xwhite_in2out(_ossl_old_des_cblock (*des_key), _ossl_old_des_cblock (*in_white), |
173 | _ossl_old_des_cblock (*out_white)) | 174 | _ossl_old_des_cblock (*out_white)) |
174 | { | 175 | { |
175 | DES_xwhite_in2out(des_key, in_white, out_white); | 176 | DES_xwhite_in2out(des_key, in_white, out_white); |
176 | } | 177 | } |
178 | #endif | ||
177 | 179 | ||
178 | int _ossl_old_des_enc_read(int fd,char *buf,int len,des_key_schedule sched, | 180 | int _ossl_old_des_enc_read(int fd,char *buf,int len,des_key_schedule sched, |
179 | _ossl_old_des_cblock *iv) | 181 | _ossl_old_des_cblock *iv) |
diff --git a/src/lib/libcrypto/des/des_old.h b/src/lib/libcrypto/des/des_old.h index 1d8bf65101..8665ba4e7e 100644 --- a/src/lib/libcrypto/des/des_old.h +++ b/src/lib/libcrypto/des/des_old.h | |||
@@ -91,6 +91,8 @@ | |||
91 | #ifndef HEADER_DES_OLD_H | 91 | #ifndef HEADER_DES_OLD_H |
92 | #define HEADER_DES_OLD_H | 92 | #define HEADER_DES_OLD_H |
93 | 93 | ||
94 | #include <openssl/e_os2.h> /* OPENSSL_EXTERN, OPENSSL_NO_DES, DES_LONG */ | ||
95 | |||
94 | #ifdef OPENSSL_NO_DES | 96 | #ifdef OPENSSL_NO_DES |
95 | #error DES is disabled. | 97 | #error DES is disabled. |
96 | #endif | 98 | #endif |
@@ -103,8 +105,6 @@ | |||
103 | #error <openssl/des_old.h> replaces <kerberos/des.h>. | 105 | #error <openssl/des_old.h> replaces <kerberos/des.h>. |
104 | #endif | 106 | #endif |
105 | 107 | ||
106 | #include <openssl/opensslconf.h> /* DES_LONG */ | ||
107 | #include <openssl/e_os2.h> /* OPENSSL_EXTERN */ | ||
108 | #include <openssl/symhacks.h> | 108 | #include <openssl/symhacks.h> |
109 | 109 | ||
110 | #ifdef OPENSSL_BUILD_SHLIBCRYPTO | 110 | #ifdef OPENSSL_BUILD_SHLIBCRYPTO |
@@ -116,6 +116,10 @@ | |||
116 | extern "C" { | 116 | extern "C" { |
117 | #endif | 117 | #endif |
118 | 118 | ||
119 | #ifdef _ | ||
120 | #undef _ | ||
121 | #endif | ||
122 | |||
119 | typedef unsigned char _ossl_old_des_cblock[8]; | 123 | typedef unsigned char _ossl_old_des_cblock[8]; |
120 | typedef struct _ossl_old_des_ks_struct | 124 | typedef struct _ossl_old_des_ks_struct |
121 | { | 125 | { |
@@ -171,9 +175,9 @@ typedef struct _ossl_old_des_ks_struct | |||
171 | DES_enc_write((f),(b),(l),&(k),(iv)) | 175 | DES_enc_write((f),(b),(l),&(k),(iv)) |
172 | #define des_fcrypt(b,s,r)\ | 176 | #define des_fcrypt(b,s,r)\ |
173 | DES_fcrypt((b),(s),(r)) | 177 | DES_fcrypt((b),(s),(r)) |
178 | #if 0 | ||
174 | #define des_crypt(b,s)\ | 179 | #define des_crypt(b,s)\ |
175 | DES_crypt((b),(s)) | 180 | DES_crypt((b),(s)) |
176 | #if 0 | ||
177 | #if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT) && !defined(__OpenBSD__) | 181 | #if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT) && !defined(__OpenBSD__) |
178 | #define crypt(b,s)\ | 182 | #define crypt(b,s)\ |
179 | DES_crypt((b),(s)) | 183 | DES_crypt((b),(s)) |
@@ -360,9 +364,10 @@ void _ossl_old_des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out, | |||
360 | void _ossl_old_des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out, | 364 | void _ossl_old_des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out, |
361 | long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2, | 365 | long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2, |
362 | _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num); | 366 | _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num); |
363 | 367 | #if 0 | |
364 | void _ossl_old_des_xwhite_in2out(_ossl_old_des_cblock (*des_key), _ossl_old_des_cblock (*in_white), | 368 | void _ossl_old_des_xwhite_in2out(_ossl_old_des_cblock (*des_key), _ossl_old_des_cblock (*in_white), |
365 | _ossl_old_des_cblock (*out_white)); | 369 | _ossl_old_des_cblock (*out_white)); |
370 | #endif | ||
366 | 371 | ||
367 | int _ossl_old_des_enc_read(int fd,char *buf,int len,_ossl_old_des_key_schedule sched, | 372 | int _ossl_old_des_enc_read(int fd,char *buf,int len,_ossl_old_des_key_schedule sched, |
368 | _ossl_old_des_cblock *iv); | 373 | _ossl_old_des_cblock *iv); |
diff --git a/src/lib/libcrypto/des/des_opts.c b/src/lib/libcrypto/des/des_opts.c index 79278b920e..2df82962c5 100644 --- a/src/lib/libcrypto/des/des_opts.c +++ b/src/lib/libcrypto/des/des_opts.c | |||
@@ -71,7 +71,11 @@ | |||
71 | #include <io.h> | 71 | #include <io.h> |
72 | extern void exit(); | 72 | extern void exit(); |
73 | #endif | 73 | #endif |
74 | |||
75 | #ifndef OPENSSL_SYS_NETWARE | ||
74 | #include <signal.h> | 76 | #include <signal.h> |
77 | #endif | ||
78 | |||
75 | #ifndef _IRIX | 79 | #ifndef _IRIX |
76 | #include <time.h> | 80 | #include <time.h> |
77 | #endif | 81 | #endif |
diff --git a/src/lib/libcrypto/des/des_ver.h b/src/lib/libcrypto/des/des_ver.h index 379bbadda2..d1ada258a6 100644 --- a/src/lib/libcrypto/des/des_ver.h +++ b/src/lib/libcrypto/des/des_ver.h | |||
@@ -67,5 +67,5 @@ | |||
67 | #define DES_version OSSL_DES_version | 67 | #define DES_version OSSL_DES_version |
68 | #define libdes_version OSSL_libdes_version | 68 | #define libdes_version OSSL_libdes_version |
69 | 69 | ||
70 | OPENSSL_EXTERN const char *OSSL_DES_version; /* SSLeay version string */ | 70 | OPENSSL_EXTERN const char OSSL_DES_version[]; /* SSLeay version string */ |
71 | OPENSSL_EXTERN const char *OSSL_libdes_version; /* old libdes version string */ | 71 | OPENSSL_EXTERN const char OSSL_libdes_version[]; /* old libdes version string */ |
diff --git a/src/lib/libcrypto/des/destest.c b/src/lib/libcrypto/des/destest.c index e3e9d77f14..64b92a34fe 100644 --- a/src/lib/libcrypto/des/destest.c +++ b/src/lib/libcrypto/des/destest.c | |||
@@ -84,7 +84,7 @@ int main(int argc, char *argv[]) | |||
84 | #else | 84 | #else |
85 | #include <openssl/des.h> | 85 | #include <openssl/des.h> |
86 | 86 | ||
87 | #define crypt(c,s) (des_crypt((c),(s))) | 87 | #define crypt(c,s) (DES_crypt((c),(s))) |
88 | 88 | ||
89 | /* tisk tisk - the test keys don't all have odd parity :-( */ | 89 | /* tisk tisk - the test keys don't all have odd parity :-( */ |
90 | /* test data */ | 90 | /* test data */ |
@@ -333,7 +333,8 @@ static int cfb64_test(unsigned char *cfb_cipher); | |||
333 | static int ede_cfb64_test(unsigned char *cfb_cipher); | 333 | static int ede_cfb64_test(unsigned char *cfb_cipher); |
334 | int main(int argc, char *argv[]) | 334 | int main(int argc, char *argv[]) |
335 | { | 335 | { |
336 | int i,j,err=0; | 336 | int j,err=0; |
337 | unsigned int i; | ||
337 | des_cblock in,out,outin,iv3,iv2; | 338 | des_cblock in,out,outin,iv3,iv2; |
338 | des_key_schedule ks,ks2,ks3; | 339 | des_key_schedule ks,ks2,ks3; |
339 | unsigned char cbc_in[40]; | 340 | unsigned char cbc_in[40]; |
@@ -391,7 +392,7 @@ int main(int argc, char *argv[]) | |||
391 | DES_ede3_cbcm_encrypt(cbc_out,cbc_in,i,&ks,&ks2,&ks3,&iv3,&iv2,DES_DECRYPT); | 392 | DES_ede3_cbcm_encrypt(cbc_out,cbc_in,i,&ks,&ks2,&ks3,&iv3,&iv2,DES_DECRYPT); |
392 | if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0) | 393 | if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0) |
393 | { | 394 | { |
394 | int n; | 395 | unsigned int n; |
395 | 396 | ||
396 | printf("des_ede3_cbcm_encrypt decrypt error\n"); | 397 | printf("des_ede3_cbcm_encrypt decrypt error\n"); |
397 | for(n=0 ; n < i ; ++n) | 398 | for(n=0 ; n < i ; ++n) |
@@ -439,8 +440,8 @@ int main(int argc, char *argv[]) | |||
439 | memcpy(in,plain_data[i],8); | 440 | memcpy(in,plain_data[i],8); |
440 | memset(out,0,8); | 441 | memset(out,0,8); |
441 | memset(outin,0,8); | 442 | memset(outin,0,8); |
442 | des_ecb2_encrypt(in,out,ks,ks2,DES_ENCRYPT); | 443 | des_ecb2_encrypt(&in,&out,ks,ks2,DES_ENCRYPT); |
443 | des_ecb2_encrypt(out,outin,ks,ks2,DES_DECRYPT); | 444 | des_ecb2_encrypt(&out,&outin,ks,ks2,DES_DECRYPT); |
444 | 445 | ||
445 | if (memcmp(out,cipher_ecb2[i],8) != 0) | 446 | if (memcmp(out,cipher_ecb2[i],8) != 0) |
446 | { | 447 | { |
@@ -540,7 +541,7 @@ int main(int argc, char *argv[]) | |||
540 | if (memcmp(cbc_out,cbc3_ok, | 541 | if (memcmp(cbc_out,cbc3_ok, |
541 | (unsigned int)(strlen((char *)cbc_data)+1+7)/8*8) != 0) | 542 | (unsigned int)(strlen((char *)cbc_data)+1+7)/8*8) != 0) |
542 | { | 543 | { |
543 | int n; | 544 | unsigned int n; |
544 | 545 | ||
545 | printf("des_ede3_cbc_encrypt encrypt error\n"); | 546 | printf("des_ede3_cbc_encrypt encrypt error\n"); |
546 | for(n=0 ; n < i ; ++n) | 547 | for(n=0 ; n < i ; ++n) |
@@ -556,7 +557,7 @@ int main(int argc, char *argv[]) | |||
556 | des_ede3_cbc_encrypt(cbc_out,cbc_in,i,ks,ks2,ks3,&iv3,DES_DECRYPT); | 557 | des_ede3_cbc_encrypt(cbc_out,cbc_in,i,ks,ks2,ks3,&iv3,DES_DECRYPT); |
557 | if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0) | 558 | if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0) |
558 | { | 559 | { |
559 | int n; | 560 | unsigned int n; |
560 | 561 | ||
561 | printf("des_ede3_cbc_encrypt decrypt error\n"); | 562 | printf("des_ede3_cbc_encrypt decrypt error\n"); |
562 | for(n=0 ; n < i ; ++n) | 563 | for(n=0 ; n < i ; ++n) |
@@ -820,6 +821,9 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]); | |||
820 | printf("fast crypt error, %s should be yA1Rp/1hZXIJk\n",str); | 821 | printf("fast crypt error, %s should be yA1Rp/1hZXIJk\n",str); |
821 | err=1; | 822 | err=1; |
822 | } | 823 | } |
824 | #ifdef OPENSSL_SYS_NETWARE | ||
825 | if (err) printf("ERROR: %d\n", err); | ||
826 | #endif | ||
823 | printf("\n"); | 827 | printf("\n"); |
824 | return(err); | 828 | return(err); |
825 | } | 829 | } |
diff --git a/src/lib/libcrypto/des/ecb3_enc.c b/src/lib/libcrypto/des/ecb3_enc.c index fa0c9c4d4f..c3437bc606 100644 --- a/src/lib/libcrypto/des/ecb3_enc.c +++ b/src/lib/libcrypto/des/ecb3_enc.c | |||
@@ -58,13 +58,15 @@ | |||
58 | 58 | ||
59 | #include "des_locl.h" | 59 | #include "des_locl.h" |
60 | 60 | ||
61 | void DES_ecb3_encrypt(const unsigned char *in, unsigned char *out, | 61 | void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output, |
62 | DES_key_schedule *ks1, DES_key_schedule *ks2, | 62 | DES_key_schedule *ks1, DES_key_schedule *ks2, |
63 | DES_key_schedule *ks3, | 63 | DES_key_schedule *ks3, |
64 | int enc) | 64 | int enc) |
65 | { | 65 | { |
66 | register DES_LONG l0,l1; | 66 | register DES_LONG l0,l1; |
67 | DES_LONG ll[2]; | 67 | DES_LONG ll[2]; |
68 | const unsigned char *in = &(*input)[0]; | ||
69 | unsigned char *out = &(*output)[0]; | ||
68 | 70 | ||
69 | c2l(in,l0); | 71 | c2l(in,l0); |
70 | c2l(in,l1); | 72 | c2l(in,l1); |
diff --git a/src/lib/libcrypto/des/ecb_enc.c b/src/lib/libcrypto/des/ecb_enc.c index 784aa5ba23..00d5b91e8c 100644 --- a/src/lib/libcrypto/des/ecb_enc.c +++ b/src/lib/libcrypto/des/ecb_enc.c | |||
@@ -62,8 +62,8 @@ | |||
62 | #include <openssl/opensslv.h> | 62 | #include <openssl/opensslv.h> |
63 | #include <openssl/bio.h> | 63 | #include <openssl/bio.h> |
64 | 64 | ||
65 | OPENSSL_GLOBAL const char *libdes_version="libdes" OPENSSL_VERSION_PTEXT; | 65 | OPENSSL_GLOBAL const char libdes_version[]="libdes" OPENSSL_VERSION_PTEXT; |
66 | OPENSSL_GLOBAL const char *DES_version="DES" OPENSSL_VERSION_PTEXT; | 66 | OPENSSL_GLOBAL const char DES_version[]="DES" OPENSSL_VERSION_PTEXT; |
67 | 67 | ||
68 | const char *DES_options(void) | 68 | const char *DES_options(void) |
69 | { | 69 | { |
diff --git a/src/lib/libcrypto/des/ede_cbcm_enc.c b/src/lib/libcrypto/des/ede_cbcm_enc.c index fa45aa272b..adfcb75cf3 100644 --- a/src/lib/libcrypto/des/ede_cbcm_enc.c +++ b/src/lib/libcrypto/des/ede_cbcm_enc.c | |||
@@ -68,6 +68,8 @@ http://www.cs.technion.ac.il/users/wwwb/cgi-bin/tr-get.cgi/1998/CS/CS0928.ps.gz | |||
68 | 68 | ||
69 | */ | 69 | */ |
70 | 70 | ||
71 | #include <openssl/opensslconf.h> /* To see if OPENSSL_NO_DESCBCM is defined */ | ||
72 | |||
71 | #ifndef OPENSSL_NO_DESCBCM | 73 | #ifndef OPENSSL_NO_DESCBCM |
72 | #include "des_locl.h" | 74 | #include "des_locl.h" |
73 | 75 | ||
diff --git a/src/lib/libcrypto/des/fcrypt.c b/src/lib/libcrypto/des/fcrypt.c index 2758c32656..ccbdff250f 100644 --- a/src/lib/libcrypto/des/fcrypt.c +++ b/src/lib/libcrypto/des/fcrypt.c | |||
@@ -58,9 +58,6 @@ static unsigned const char cov_2char[64]={ | |||
58 | 0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A | 58 | 0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A |
59 | }; | 59 | }; |
60 | 60 | ||
61 | void fcrypt_body(DES_LONG *out,DES_key_schedule *ks, | ||
62 | DES_LONG Eswap0, DES_LONG Eswap1); | ||
63 | |||
64 | char *DES_crypt(const char *buf, const char *salt) | 61 | char *DES_crypt(const char *buf, const char *salt) |
65 | { | 62 | { |
66 | static char buff[14]; | 63 | static char buff[14]; |
diff --git a/src/lib/libcrypto/des/read2pwd.c b/src/lib/libcrypto/des/read2pwd.c index 3a63c4016c..ee6969f76e 100644 --- a/src/lib/libcrypto/des/read2pwd.c +++ b/src/lib/libcrypto/des/read2pwd.c | |||
@@ -112,6 +112,7 @@ | |||
112 | #include <string.h> | 112 | #include <string.h> |
113 | #include <openssl/des.h> | 113 | #include <openssl/des.h> |
114 | #include <openssl/ui.h> | 114 | #include <openssl/ui.h> |
115 | #include <openssl/crypto.h> | ||
115 | 116 | ||
116 | int DES_read_password(DES_cblock *key, const char *prompt, int verify) | 117 | int DES_read_password(DES_cblock *key, const char *prompt, int verify) |
117 | { | 118 | { |
diff --git a/src/lib/libcrypto/des/set_key.c b/src/lib/libcrypto/des/set_key.c index 8881d46a7a..a43ef3c881 100644 --- a/src/lib/libcrypto/des/set_key.c +++ b/src/lib/libcrypto/des/set_key.c | |||
@@ -65,8 +65,6 @@ | |||
65 | */ | 65 | */ |
66 | #include "des_locl.h" | 66 | #include "des_locl.h" |
67 | 67 | ||
68 | #ifndef OPENSSL_FIPS | ||
69 | |||
70 | OPENSSL_IMPLEMENT_GLOBAL(int,DES_check_key); /* defaults to false */ | 68 | OPENSSL_IMPLEMENT_GLOBAL(int,DES_check_key); /* defaults to false */ |
71 | 69 | ||
72 | static const unsigned char odd_parity[256]={ | 70 | static const unsigned char odd_parity[256]={ |
@@ -89,7 +87,7 @@ static const unsigned char odd_parity[256]={ | |||
89 | 87 | ||
90 | void DES_set_odd_parity(DES_cblock *key) | 88 | void DES_set_odd_parity(DES_cblock *key) |
91 | { | 89 | { |
92 | int i; | 90 | unsigned int i; |
93 | 91 | ||
94 | for (i=0; i<DES_KEY_SZ; i++) | 92 | for (i=0; i<DES_KEY_SZ; i++) |
95 | (*key)[i]=odd_parity[(*key)[i]]; | 93 | (*key)[i]=odd_parity[(*key)[i]]; |
@@ -97,7 +95,7 @@ void DES_set_odd_parity(DES_cblock *key) | |||
97 | 95 | ||
98 | int DES_check_key_parity(const_DES_cblock *key) | 96 | int DES_check_key_parity(const_DES_cblock *key) |
99 | { | 97 | { |
100 | int i; | 98 | unsigned int i; |
101 | 99 | ||
102 | for (i=0; i<DES_KEY_SZ; i++) | 100 | for (i=0; i<DES_KEY_SZ; i++) |
103 | { | 101 | { |
@@ -117,7 +115,7 @@ int DES_check_key_parity(const_DES_cblock *key) | |||
117 | * (and actual cblock values). | 115 | * (and actual cblock values). |
118 | */ | 116 | */ |
119 | #define NUM_WEAK_KEY 16 | 117 | #define NUM_WEAK_KEY 16 |
120 | static DES_cblock weak_keys[NUM_WEAK_KEY]={ | 118 | static const DES_cblock weak_keys[NUM_WEAK_KEY]={ |
121 | /* weak keys */ | 119 | /* weak keys */ |
122 | {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01}, | 120 | {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01}, |
123 | {0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE}, | 121 | {0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE}, |
@@ -407,5 +405,3 @@ void des_fixup_key_parity(des_cblock *key) | |||
407 | des_set_odd_parity(key); | 405 | des_set_odd_parity(key); |
408 | } | 406 | } |
409 | */ | 407 | */ |
410 | |||
411 | #endif /* ndef OPENSSL_FIPS */ | ||
diff --git a/src/lib/libcrypto/des/speed.c b/src/lib/libcrypto/des/speed.c index 48fc1d49fc..1616f4b7c9 100644 --- a/src/lib/libcrypto/des/speed.c +++ b/src/lib/libcrypto/des/speed.c | |||
@@ -69,7 +69,11 @@ | |||
69 | #include OPENSSL_UNISTD_IO | 69 | #include OPENSSL_UNISTD_IO |
70 | OPENSSL_DECLARE_EXIT | 70 | OPENSSL_DECLARE_EXIT |
71 | 71 | ||
72 | #ifndef OPENSSL_SYS_NETWARE | ||
72 | #include <signal.h> | 73 | #include <signal.h> |
74 | #define crypt(c,s) (des_crypt((c),(s))) | ||
75 | #endif | ||
76 | |||
73 | #ifndef _IRIX | 77 | #ifndef _IRIX |
74 | #include <time.h> | 78 | #include <time.h> |
75 | #endif | 79 | #endif |
diff --git a/src/lib/libcrypto/des/str2key.c b/src/lib/libcrypto/des/str2key.c index 0373db469c..9c2054bda6 100644 --- a/src/lib/libcrypto/des/str2key.c +++ b/src/lib/libcrypto/des/str2key.c | |||
@@ -57,6 +57,7 @@ | |||
57 | */ | 57 | */ |
58 | 58 | ||
59 | #include "des_locl.h" | 59 | #include "des_locl.h" |
60 | #include <openssl/crypto.h> | ||
60 | 61 | ||
61 | void DES_string_to_key(const char *str, DES_cblock *key) | 62 | void DES_string_to_key(const char *str, DES_cblock *key) |
62 | { | 63 | { |
diff --git a/src/lib/libcrypto/des/xcbc_enc.c b/src/lib/libcrypto/des/xcbc_enc.c index 47246eb466..dc0c761b71 100644 --- a/src/lib/libcrypto/des/xcbc_enc.c +++ b/src/lib/libcrypto/des/xcbc_enc.c | |||
@@ -60,6 +60,7 @@ | |||
60 | 60 | ||
61 | /* RSA's DESX */ | 61 | /* RSA's DESX */ |
62 | 62 | ||
63 | #if 0 /* broken code, preserved just in case anyone specifically looks for this */ | ||
63 | static unsigned char desx_white_in2out[256]={ | 64 | static unsigned char desx_white_in2out[256]={ |
64 | 0xBD,0x56,0xEA,0xF2,0xA2,0xF1,0xAC,0x2A,0xB0,0x93,0xD1,0x9C,0x1B,0x33,0xFD,0xD0, | 65 | 0xBD,0x56,0xEA,0xF2,0xA2,0xF1,0xAC,0x2A,0xB0,0x93,0xD1,0x9C,0x1B,0x33,0xFD,0xD0, |
65 | 0x30,0x04,0xB6,0xDC,0x7D,0xDF,0x32,0x4B,0xF7,0xCB,0x45,0x9B,0x31,0xBB,0x21,0x5A, | 66 | 0x30,0x04,0xB6,0xDC,0x7D,0xDF,0x32,0x4B,0xF7,0xCB,0x45,0x9B,0x31,0xBB,0x21,0x5A, |
@@ -98,7 +99,7 @@ void DES_xwhite_in2out(const_DES_cblock *des_key, const_DES_cblock *in_white, | |||
98 | } | 99 | } |
99 | 100 | ||
100 | out0=out[0]; | 101 | out0=out[0]; |
101 | out1=out[i]; | 102 | out1=out[i]; /* BUG: out-of-bounds read */ |
102 | for (i=0; i<8; i++) | 103 | for (i=0; i<8; i++) |
103 | { | 104 | { |
104 | out[i]=in[i]^desx_white_in2out[out0^out1]; | 105 | out[i]=in[i]^desx_white_in2out[out0^out1]; |
@@ -106,6 +107,7 @@ void DES_xwhite_in2out(const_DES_cblock *des_key, const_DES_cblock *in_white, | |||
106 | out1=(int)out[i&0x07]; | 107 | out1=(int)out[i&0x07]; |
107 | } | 108 | } |
108 | } | 109 | } |
110 | #endif | ||
109 | 111 | ||
110 | void DES_xcbc_encrypt(const unsigned char *in, unsigned char *out, | 112 | void DES_xcbc_encrypt(const unsigned char *in, unsigned char *out, |
111 | long length, DES_key_schedule *schedule, | 113 | long length, DES_key_schedule *schedule, |