diff options
Diffstat (limited to 'src/lib/libcrypto/des/xcbc_enc.c')
-rw-r--r-- | src/lib/libcrypto/des/xcbc_enc.c | 57 |
1 files changed, 23 insertions, 34 deletions
diff --git a/src/lib/libcrypto/des/xcbc_enc.c b/src/lib/libcrypto/des/xcbc_enc.c index 031589bf50..47246eb466 100644 --- a/src/lib/libcrypto/des/xcbc_enc.c +++ b/src/lib/libcrypto/des/xcbc_enc.c | |||
@@ -79,18 +79,14 @@ static unsigned char desx_white_in2out[256]={ | |||
79 | 0xA7,0x1C,0xC9,0x09,0x69,0x9A,0x83,0xCF,0x29,0x39,0xB9,0xE9,0x4C,0xFF,0x43,0xAB, | 79 | 0xA7,0x1C,0xC9,0x09,0x69,0x9A,0x83,0xCF,0x29,0x39,0xB9,0xE9,0x4C,0xFF,0x43,0xAB, |
80 | }; | 80 | }; |
81 | 81 | ||
82 | void des_xwhite_in2out(des_key,in_white,out_white) | 82 | void DES_xwhite_in2out(const_DES_cblock *des_key, const_DES_cblock *in_white, |
83 | des_cblock (*des_key); | 83 | DES_cblock *out_white) |
84 | des_cblock (*in_white); | ||
85 | des_cblock (*out_white); | ||
86 | { | 84 | { |
87 | unsigned char *key,*in,*out; | ||
88 | int out0,out1; | 85 | int out0,out1; |
89 | int i; | 86 | int i; |
90 | 87 | const unsigned char *key = &(*des_key)[0]; | |
91 | key=(unsigned char *)des_key; | 88 | const unsigned char *in = &(*in_white)[0]; |
92 | in=(unsigned char *)in_white; | 89 | unsigned char *out = &(*out_white)[0]; |
93 | out=(unsigned char *)out_white; | ||
94 | 90 | ||
95 | out[0]=out[1]=out[2]=out[3]=out[4]=out[5]=out[6]=out[7]=0; | 91 | out[0]=out[1]=out[2]=out[3]=out[4]=out[5]=out[6]=out[7]=0; |
96 | out0=out1=0; | 92 | out0=out1=0; |
@@ -111,34 +107,27 @@ des_cblock (*out_white); | |||
111 | } | 107 | } |
112 | } | 108 | } |
113 | 109 | ||
114 | void des_xcbc_encrypt(input, output, length, schedule, ivec, inw,outw,enc) | 110 | void DES_xcbc_encrypt(const unsigned char *in, unsigned char *out, |
115 | des_cblock (*input); | 111 | long length, DES_key_schedule *schedule, |
116 | des_cblock (*output); | 112 | DES_cblock *ivec, const_DES_cblock *inw, |
117 | long length; | 113 | const_DES_cblock *outw, int enc) |
118 | des_key_schedule schedule; | ||
119 | des_cblock (*ivec); | ||
120 | des_cblock (*inw); | ||
121 | des_cblock (*outw); | ||
122 | int enc; | ||
123 | { | 114 | { |
124 | register DES_LONG tin0,tin1; | 115 | register DES_LONG tin0,tin1; |
125 | register DES_LONG tout0,tout1,xor0,xor1; | 116 | register DES_LONG tout0,tout1,xor0,xor1; |
126 | register DES_LONG inW0,inW1,outW0,outW1; | 117 | register DES_LONG inW0,inW1,outW0,outW1; |
127 | register unsigned char *in,*out; | 118 | register const unsigned char *in2; |
128 | register long l=length; | 119 | register long l=length; |
129 | DES_LONG tin[2]; | 120 | DES_LONG tin[2]; |
130 | unsigned char *iv; | 121 | unsigned char *iv; |
131 | 122 | ||
132 | in=(unsigned char *)inw; | 123 | in2 = &(*inw)[0]; |
133 | c2l(in,inW0); | 124 | c2l(in2,inW0); |
134 | c2l(in,inW1); | 125 | c2l(in2,inW1); |
135 | in=(unsigned char *)outw; | 126 | in2 = &(*outw)[0]; |
136 | c2l(in,outW0); | 127 | c2l(in2,outW0); |
137 | c2l(in,outW1); | 128 | c2l(in2,outW1); |
138 | 129 | ||
139 | in=(unsigned char *)input; | 130 | iv = &(*ivec)[0]; |
140 | out=(unsigned char *)output; | ||
141 | iv=(unsigned char *)ivec; | ||
142 | 131 | ||
143 | if (enc) | 132 | if (enc) |
144 | { | 133 | { |
@@ -150,7 +139,7 @@ int enc; | |||
150 | c2l(in,tin1); | 139 | c2l(in,tin1); |
151 | tin0^=tout0^inW0; tin[0]=tin0; | 140 | tin0^=tout0^inW0; tin[0]=tin0; |
152 | tin1^=tout1^inW1; tin[1]=tin1; | 141 | tin1^=tout1^inW1; tin[1]=tin1; |
153 | des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT); | 142 | DES_encrypt1(tin,schedule,DES_ENCRYPT); |
154 | tout0=tin[0]^outW0; l2c(tout0,out); | 143 | tout0=tin[0]^outW0; l2c(tout0,out); |
155 | tout1=tin[1]^outW1; l2c(tout1,out); | 144 | tout1=tin[1]^outW1; l2c(tout1,out); |
156 | } | 145 | } |
@@ -159,11 +148,11 @@ int enc; | |||
159 | c2ln(in,tin0,tin1,l+8); | 148 | c2ln(in,tin0,tin1,l+8); |
160 | tin0^=tout0^inW0; tin[0]=tin0; | 149 | tin0^=tout0^inW0; tin[0]=tin0; |
161 | tin1^=tout1^inW1; tin[1]=tin1; | 150 | tin1^=tout1^inW1; tin[1]=tin1; |
162 | des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT); | 151 | DES_encrypt1(tin,schedule,DES_ENCRYPT); |
163 | tout0=tin[0]^outW0; l2c(tout0,out); | 152 | tout0=tin[0]^outW0; l2c(tout0,out); |
164 | tout1=tin[1]^outW1; l2c(tout1,out); | 153 | tout1=tin[1]^outW1; l2c(tout1,out); |
165 | } | 154 | } |
166 | iv=(unsigned char *)ivec; | 155 | iv = &(*ivec)[0]; |
167 | l2c(tout0,iv); | 156 | l2c(tout0,iv); |
168 | l2c(tout1,iv); | 157 | l2c(tout1,iv); |
169 | } | 158 | } |
@@ -175,7 +164,7 @@ int enc; | |||
175 | { | 164 | { |
176 | c2l(in,tin0); tin[0]=tin0^outW0; | 165 | c2l(in,tin0); tin[0]=tin0^outW0; |
177 | c2l(in,tin1); tin[1]=tin1^outW1; | 166 | c2l(in,tin1); tin[1]=tin1^outW1; |
178 | des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT); | 167 | DES_encrypt1(tin,schedule,DES_DECRYPT); |
179 | tout0=tin[0]^xor0^inW0; | 168 | tout0=tin[0]^xor0^inW0; |
180 | tout1=tin[1]^xor1^inW1; | 169 | tout1=tin[1]^xor1^inW1; |
181 | l2c(tout0,out); | 170 | l2c(tout0,out); |
@@ -187,7 +176,7 @@ int enc; | |||
187 | { | 176 | { |
188 | c2l(in,tin0); tin[0]=tin0^outW0; | 177 | c2l(in,tin0); tin[0]=tin0^outW0; |
189 | c2l(in,tin1); tin[1]=tin1^outW1; | 178 | c2l(in,tin1); tin[1]=tin1^outW1; |
190 | des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT); | 179 | DES_encrypt1(tin,schedule,DES_DECRYPT); |
191 | tout0=tin[0]^xor0^inW0; | 180 | tout0=tin[0]^xor0^inW0; |
192 | tout1=tin[1]^xor1^inW1; | 181 | tout1=tin[1]^xor1^inW1; |
193 | l2cn(tout0,tout1,out,l+8); | 182 | l2cn(tout0,tout1,out,l+8); |
@@ -195,7 +184,7 @@ int enc; | |||
195 | xor1=tin1; | 184 | xor1=tin1; |
196 | } | 185 | } |
197 | 186 | ||
198 | iv=(unsigned char *)ivec; | 187 | iv = &(*ivec)[0]; |
199 | l2c(xor0,iv); | 188 | l2c(xor0,iv); |
200 | l2c(xor1,iv); | 189 | l2c(xor1,iv); |
201 | } | 190 | } |