summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/des/des_enc.c
diff options
context:
space:
mode:
authorbeck <>2002-05-15 02:29:21 +0000
committerbeck <>2002-05-15 02:29:21 +0000
commitb64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9 (patch)
treefa27cf82a1250b64ed3bf5f4a18c7354d470bbcc /src/lib/libcrypto/des/des_enc.c
parente471e1ea98d673597b182ea85f29e30c97cd08b5 (diff)
downloadopenbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.gz
openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.bz2
openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.zip
OpenSSL 0.9.7 stable 2002 05 08 merge
Diffstat (limited to 'src/lib/libcrypto/des/des_enc.c')
-rw-r--r--src/lib/libcrypto/des/des_enc.c53
1 files changed, 27 insertions, 26 deletions
diff --git a/src/lib/libcrypto/des/des_enc.c b/src/lib/libcrypto/des/des_enc.c
index 0bd9fa39bc..1c37ab96d3 100644
--- a/src/lib/libcrypto/des/des_enc.c
+++ b/src/lib/libcrypto/des/des_enc.c
@@ -58,11 +58,11 @@
58 58
59#include "des_locl.h" 59#include "des_locl.h"
60 60
61void des_encrypt1(DES_LONG *data, des_key_schedule ks, int enc) 61void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc)
62 { 62 {
63 register DES_LONG l,r,t,u; 63 register DES_LONG l,r,t,u;
64#ifdef DES_PTR 64#ifdef DES_PTR
65 register const unsigned char *des_SP=(const unsigned char *)des_SPtrans; 65 register const unsigned char *des_SP=(const unsigned char *)DES_SPtrans;
66#endif 66#endif
67#ifndef DES_UNROLL 67#ifndef DES_UNROLL
68 register int i; 68 register int i;
@@ -75,7 +75,7 @@ void des_encrypt1(DES_LONG *data, des_key_schedule ks, int enc)
75 IP(r,l); 75 IP(r,l);
76 /* Things have been modified so that the initial rotate is 76 /* Things have been modified so that the initial rotate is
77 * done outside the loop. This required the 77 * done outside the loop. This required the
78 * des_SPtrans values in sp.h to be rotated 1 bit to the right. 78 * DES_SPtrans values in sp.h to be rotated 1 bit to the right.
79 * One perl script later and things have a 5% speed up on a sparc2. 79 * One perl script later and things have a 5% speed up on a sparc2.
80 * Thanks to Richard Outerbridge <71755.204@CompuServe.COM> 80 * Thanks to Richard Outerbridge <71755.204@CompuServe.COM>
81 * for pointing this out. */ 81 * for pointing this out. */
@@ -84,7 +84,7 @@ void des_encrypt1(DES_LONG *data, des_key_schedule ks, int enc)
84 r=ROTATE(r,29)&0xffffffffL; 84 r=ROTATE(r,29)&0xffffffffL;
85 l=ROTATE(l,29)&0xffffffffL; 85 l=ROTATE(l,29)&0xffffffffL;
86 86
87 s=ks->ks.deslong; 87 s=ks->ks->deslong;
88 /* I don't know if it is worth the effort of loop unrolling the 88 /* I don't know if it is worth the effort of loop unrolling the
89 * inner loop */ 89 * inner loop */
90 if (enc) 90 if (enc)
@@ -156,11 +156,11 @@ void des_encrypt1(DES_LONG *data, des_key_schedule ks, int enc)
156 l=r=t=u=0; 156 l=r=t=u=0;
157 } 157 }
158 158
159void des_encrypt2(DES_LONG *data, des_key_schedule ks, int enc) 159void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc)
160 { 160 {
161 register DES_LONG l,r,t,u; 161 register DES_LONG l,r,t,u;
162#ifdef DES_PTR 162#ifdef DES_PTR
163 register const unsigned char *des_SP=(const unsigned char *)des_SPtrans; 163 register const unsigned char *des_SP=(const unsigned char *)DES_SPtrans;
164#endif 164#endif
165#ifndef DES_UNROLL 165#ifndef DES_UNROLL
166 register int i; 166 register int i;
@@ -172,7 +172,7 @@ void des_encrypt2(DES_LONG *data, des_key_schedule ks, int enc)
172 172
173 /* Things have been modified so that the initial rotate is 173 /* Things have been modified so that the initial rotate is
174 * done outside the loop. This required the 174 * done outside the loop. This required the
175 * des_SPtrans values in sp.h to be rotated 1 bit to the right. 175 * DES_SPtrans values in sp.h to be rotated 1 bit to the right.
176 * One perl script later and things have a 5% speed up on a sparc2. 176 * One perl script later and things have a 5% speed up on a sparc2.
177 * Thanks to Richard Outerbridge <71755.204@CompuServe.COM> 177 * Thanks to Richard Outerbridge <71755.204@CompuServe.COM>
178 * for pointing this out. */ 178 * for pointing this out. */
@@ -180,7 +180,7 @@ void des_encrypt2(DES_LONG *data, des_key_schedule ks, int enc)
180 r=ROTATE(r,29)&0xffffffffL; 180 r=ROTATE(r,29)&0xffffffffL;
181 l=ROTATE(l,29)&0xffffffffL; 181 l=ROTATE(l,29)&0xffffffffL;
182 182
183 s=ks->ks.deslong; 183 s=ks->ks->deslong;
184 /* I don't know if it is worth the effort of loop unrolling the 184 /* I don't know if it is worth the effort of loop unrolling the
185 * inner loop */ 185 * inner loop */
186 if (enc) 186 if (enc)
@@ -247,8 +247,8 @@ void des_encrypt2(DES_LONG *data, des_key_schedule ks, int enc)
247 l=r=t=u=0; 247 l=r=t=u=0;
248 } 248 }
249 249
250void des_encrypt3(DES_LONG *data, des_key_schedule ks1, des_key_schedule ks2, 250void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1,
251 des_key_schedule ks3) 251 DES_key_schedule *ks2, DES_key_schedule *ks3)
252 { 252 {
253 register DES_LONG l,r; 253 register DES_LONG l,r;
254 254
@@ -257,9 +257,9 @@ void des_encrypt3(DES_LONG *data, des_key_schedule ks1, des_key_schedule ks2,
257 IP(l,r); 257 IP(l,r);
258 data[0]=l; 258 data[0]=l;
259 data[1]=r; 259 data[1]=r;
260 des_encrypt2((DES_LONG *)data,ks1,DES_ENCRYPT); 260 DES_encrypt2((DES_LONG *)data,ks1,DES_ENCRYPT);
261 des_encrypt2((DES_LONG *)data,ks2,DES_DECRYPT); 261 DES_encrypt2((DES_LONG *)data,ks2,DES_DECRYPT);
262 des_encrypt2((DES_LONG *)data,ks3,DES_ENCRYPT); 262 DES_encrypt2((DES_LONG *)data,ks3,DES_ENCRYPT);
263 l=data[0]; 263 l=data[0];
264 r=data[1]; 264 r=data[1];
265 FP(r,l); 265 FP(r,l);
@@ -267,8 +267,8 @@ void des_encrypt3(DES_LONG *data, des_key_schedule ks1, des_key_schedule ks2,
267 data[1]=r; 267 data[1]=r;
268 } 268 }
269 269
270void des_decrypt3(DES_LONG *data, des_key_schedule ks1, des_key_schedule ks2, 270void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1,
271 des_key_schedule ks3) 271 DES_key_schedule *ks2, DES_key_schedule *ks3)
272 { 272 {
273 register DES_LONG l,r; 273 register DES_LONG l,r;
274 274
@@ -277,9 +277,9 @@ void des_decrypt3(DES_LONG *data, des_key_schedule ks1, des_key_schedule ks2,
277 IP(l,r); 277 IP(l,r);
278 data[0]=l; 278 data[0]=l;
279 data[1]=r; 279 data[1]=r;
280 des_encrypt2((DES_LONG *)data,ks3,DES_DECRYPT); 280 DES_encrypt2((DES_LONG *)data,ks3,DES_DECRYPT);
281 des_encrypt2((DES_LONG *)data,ks2,DES_ENCRYPT); 281 DES_encrypt2((DES_LONG *)data,ks2,DES_ENCRYPT);
282 des_encrypt2((DES_LONG *)data,ks1,DES_DECRYPT); 282 DES_encrypt2((DES_LONG *)data,ks1,DES_DECRYPT);
283 l=data[0]; 283 l=data[0];
284 r=data[1]; 284 r=data[1];
285 FP(r,l); 285 FP(r,l);
@@ -290,11 +290,12 @@ void des_decrypt3(DES_LONG *data, des_key_schedule ks1, des_key_schedule ks2,
290#ifndef DES_DEFAULT_OPTIONS 290#ifndef DES_DEFAULT_OPTIONS
291 291
292#undef CBC_ENC_C__DONT_UPDATE_IV 292#undef CBC_ENC_C__DONT_UPDATE_IV
293#include "ncbc_enc.c" /* des_ncbc_encrypt */ 293#include "ncbc_enc.c" /* DES_ncbc_encrypt */
294 294
295void des_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output, 295void DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,
296 long length, des_key_schedule ks1, des_key_schedule ks2, 296 long length, DES_key_schedule *ks1,
297 des_key_schedule ks3, des_cblock *ivec, int enc) 297 DES_key_schedule *ks2, DES_key_schedule *ks3,
298 DES_cblock *ivec, int enc)
298 { 299 {
299 register DES_LONG tin0,tin1; 300 register DES_LONG tin0,tin1;
300 register DES_LONG tout0,tout1,xor0,xor1; 301 register DES_LONG tout0,tout1,xor0,xor1;
@@ -321,7 +322,7 @@ void des_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,
321 322
322 tin[0]=tin0; 323 tin[0]=tin0;
323 tin[1]=tin1; 324 tin[1]=tin1;
324 des_encrypt3((DES_LONG *)tin,ks1,ks2,ks3); 325 DES_encrypt3((DES_LONG *)tin,ks1,ks2,ks3);
325 tout0=tin[0]; 326 tout0=tin[0];
326 tout1=tin[1]; 327 tout1=tin[1];
327 328
@@ -336,7 +337,7 @@ void des_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,
336 337
337 tin[0]=tin0; 338 tin[0]=tin0;
338 tin[1]=tin1; 339 tin[1]=tin1;
339 des_encrypt3((DES_LONG *)tin,ks1,ks2,ks3); 340 DES_encrypt3((DES_LONG *)tin,ks1,ks2,ks3);
340 tout0=tin[0]; 341 tout0=tin[0];
341 tout1=tin[1]; 342 tout1=tin[1];
342 343
@@ -363,7 +364,7 @@ void des_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,
363 364
364 tin[0]=tin0; 365 tin[0]=tin0;
365 tin[1]=tin1; 366 tin[1]=tin1;
366 des_decrypt3((DES_LONG *)tin,ks1,ks2,ks3); 367 DES_decrypt3((DES_LONG *)tin,ks1,ks2,ks3);
367 tout0=tin[0]; 368 tout0=tin[0];
368 tout1=tin[1]; 369 tout1=tin[1];
369 370
@@ -384,7 +385,7 @@ void des_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,
384 385
385 tin[0]=tin0; 386 tin[0]=tin0;
386 tin[1]=tin1; 387 tin[1]=tin1;
387 des_decrypt3((DES_LONG *)tin,ks1,ks2,ks3); 388 DES_decrypt3((DES_LONG *)tin,ks1,ks2,ks3);
388 tout0=tin[0]; 389 tout0=tin[0];
389 tout1=tin[1]; 390 tout1=tin[1];
390 391