summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/des/cbc_enc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/des/cbc_enc.c')
-rw-r--r--src/lib/libcrypto/des/cbc_enc.c78
1 files changed, 2 insertions, 76 deletions
diff --git a/src/lib/libcrypto/des/cbc_enc.c b/src/lib/libcrypto/des/cbc_enc.c
index a84a53633c..677903ae4e 100644
--- a/src/lib/libcrypto/des/cbc_enc.c
+++ b/src/lib/libcrypto/des/cbc_enc.c
@@ -56,80 +56,6 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include "des_locl.h" 59#define CBC_ENC_C__DONT_UPDATE_IV
60
61void des_cbc_encrypt(input, output, length, schedule, ivec, enc)
62des_cblock (*input);
63des_cblock (*output);
64long length;
65des_key_schedule schedule;
66des_cblock (*ivec);
67int enc;
68 {
69 register DES_LONG tin0,tin1;
70 register DES_LONG tout0,tout1,xor0,xor1;
71 register unsigned char *in,*out;
72 register long l=length;
73 DES_LONG tin[2];
74 unsigned char *iv;
75
76 in=(unsigned char *)input;
77 out=(unsigned char *)output;
78 iv=(unsigned char *)ivec;
79
80 if (enc)
81 {
82 c2l(iv,tout0);
83 c2l(iv,tout1);
84 for (l-=8; l>=0; l-=8)
85 {
86 c2l(in,tin0);
87 c2l(in,tin1);
88 tin0^=tout0; tin[0]=tin0;
89 tin1^=tout1; tin[1]=tin1;
90 des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT);
91 tout0=tin[0]; l2c(tout0,out);
92 tout1=tin[1]; l2c(tout1,out);
93 }
94 if (l != -8)
95 {
96 c2ln(in,tin0,tin1,l+8);
97 tin0^=tout0; tin[0]=tin0;
98 tin1^=tout1; tin[1]=tin1;
99 des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT);
100 tout0=tin[0]; l2c(tout0,out);
101 tout1=tin[1]; l2c(tout1,out);
102 }
103 }
104 else
105 {
106 c2l(iv,xor0);
107 c2l(iv,xor1);
108 for (l-=8; l>=0; l-=8)
109 {
110 c2l(in,tin0); tin[0]=tin0;
111 c2l(in,tin1); tin[1]=tin1;
112 des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT);
113 tout0=tin[0]^xor0;
114 tout1=tin[1]^xor1;
115 l2c(tout0,out);
116 l2c(tout1,out);
117 xor0=tin0;
118 xor1=tin1;
119 }
120 if (l != -8)
121 {
122 c2l(in,tin0); tin[0]=tin0;
123 c2l(in,tin1); tin[1]=tin1;
124 des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT);
125 tout0=tin[0]^xor0;
126 tout1=tin[1]^xor1;
127 l2cn(tout0,tout1,out,l+8);
128 /* xor0=tin0;
129 xor1=tin1; */
130 }
131 }
132 tin0=tin1=tout0=tout1=xor0=xor1=0;
133 tin[0]=tin[1]=0;
134 }
135 60
61#include "ncbc_enc.c" /* des_cbc_encrypt */