diff options
author | beck <> | 1999-09-29 04:37:45 +0000 |
---|---|---|
committer | beck <> | 1999-09-29 04:37:45 +0000 |
commit | de8f24ea083384bb66b32ec105dc4743c5663cdf (patch) | |
tree | 1412176ae62a3cab2cf2b0b92150fcbceaac6092 /src/lib/libcrypto/des/ncbc_enc.c | |
parent | cb929d29896bcb87c2a97417fbd03e50078fc178 (diff) | |
download | openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.gz openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.bz2 openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.zip |
OpenSSL 0.9.4 merge
Diffstat (limited to 'src/lib/libcrypto/des/ncbc_enc.c')
-rw-r--r-- | src/lib/libcrypto/des/ncbc_enc.c | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/src/lib/libcrypto/des/ncbc_enc.c b/src/lib/libcrypto/des/ncbc_enc.c index 1d1a368c22..e0e67a417d 100644 --- a/src/lib/libcrypto/des/ncbc_enc.c +++ b/src/lib/libcrypto/des/ncbc_enc.c | |||
@@ -58,24 +58,21 @@ | |||
58 | 58 | ||
59 | #include "des_locl.h" | 59 | #include "des_locl.h" |
60 | 60 | ||
61 | void des_ncbc_encrypt(input, output, length, schedule, ivec, enc) | 61 | #ifdef CBC_ENC_C__DONT_UPDATE_IV |
62 | des_cblock (*input); | 62 | void des_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, |
63 | des_cblock (*output); | 63 | des_key_schedule schedule, des_cblock *ivec, int enc) |
64 | long length; | 64 | #else |
65 | des_key_schedule schedule; | 65 | void des_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length, |
66 | des_cblock (*ivec); | 66 | des_key_schedule schedule, des_cblock *ivec, int enc) |
67 | int enc; | 67 | #endif |
68 | { | 68 | { |
69 | register DES_LONG tin0,tin1; | 69 | register DES_LONG tin0,tin1; |
70 | register DES_LONG tout0,tout1,xor0,xor1; | 70 | register DES_LONG tout0,tout1,xor0,xor1; |
71 | register unsigned char *in,*out; | ||
72 | register long l=length; | 71 | register long l=length; |
73 | DES_LONG tin[2]; | 72 | DES_LONG tin[2]; |
74 | unsigned char *iv; | 73 | unsigned char *iv; |
75 | 74 | ||
76 | in=(unsigned char *)input; | 75 | iv = &(*ivec)[0]; |
77 | out=(unsigned char *)output; | ||
78 | iv=(unsigned char *)ivec; | ||
79 | 76 | ||
80 | if (enc) | 77 | if (enc) |
81 | { | 78 | { |
@@ -100,9 +97,11 @@ int enc; | |||
100 | tout0=tin[0]; l2c(tout0,out); | 97 | tout0=tin[0]; l2c(tout0,out); |
101 | tout1=tin[1]; l2c(tout1,out); | 98 | tout1=tin[1]; l2c(tout1,out); |
102 | } | 99 | } |
103 | iv=(unsigned char *)ivec; | 100 | #ifndef CBC_ENC_C__DONT_UPDATE_IV |
101 | iv = &(*ivec)[0]; | ||
104 | l2c(tout0,iv); | 102 | l2c(tout0,iv); |
105 | l2c(tout1,iv); | 103 | l2c(tout1,iv); |
104 | #endif | ||
106 | } | 105 | } |
107 | else | 106 | else |
108 | { | 107 | { |
@@ -120,11 +119,25 @@ int enc; | |||
120 | xor0=tin0; | 119 | xor0=tin0; |
121 | xor1=tin1; | 120 | xor1=tin1; |
122 | } | 121 | } |
123 | iv=(unsigned char *)ivec; | 122 | if (l != -8) |
123 | { | ||
124 | c2l(in,tin0); tin[0]=tin0; | ||
125 | c2l(in,tin1); tin[1]=tin1; | ||
126 | des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT); | ||
127 | tout0=tin[0]^xor0; | ||
128 | tout1=tin[1]^xor1; | ||
129 | l2cn(tout0,tout1,out,l+8); | ||
130 | #ifndef CBC_ENC_C__DONT_UPDATE_IV | ||
131 | xor0=tin0; | ||
132 | xor1=tin1; | ||
133 | #endif | ||
134 | } | ||
135 | #ifndef CBC_ENC_C__DONT_UPDATE_IV | ||
136 | iv = &(*ivec)[0]; | ||
124 | l2c(xor0,iv); | 137 | l2c(xor0,iv); |
125 | l2c(xor1,iv); | 138 | l2c(xor1,iv); |
139 | #endif | ||
126 | } | 140 | } |
127 | tin0=tin1=tout0=tout1=xor0=xor1=0; | 141 | tin0=tin1=tout0=tout1=xor0=xor1=0; |
128 | tin[0]=tin[1]=0; | 142 | tin[0]=tin[1]=0; |
129 | } | 143 | } |
130 | |||