summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/des/xcbc_enc.c
diff options
context:
space:
mode:
authorbeck <>1999-09-29 04:37:45 +0000
committerbeck <>1999-09-29 04:37:45 +0000
commitde8f24ea083384bb66b32ec105dc4743c5663cdf (patch)
tree1412176ae62a3cab2cf2b0b92150fcbceaac6092 /src/lib/libcrypto/des/xcbc_enc.c
parentcb929d29896bcb87c2a97417fbd03e50078fc178 (diff)
downloadopenbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.gz
openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.bz2
openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.zip
OpenSSL 0.9.4 merge
Diffstat (limited to 'src/lib/libcrypto/des/xcbc_enc.c')
-rw-r--r--src/lib/libcrypto/des/xcbc_enc.c56
1 files changed, 22 insertions, 34 deletions
diff --git a/src/lib/libcrypto/des/xcbc_enc.c b/src/lib/libcrypto/des/xcbc_enc.c
index 031589bf50..51e17e6b8a 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]={
790xA7,0x1C,0xC9,0x09,0x69,0x9A,0x83,0xCF,0x29,0x39,0xB9,0xE9,0x4C,0xFF,0x43,0xAB, 790xA7,0x1C,0xC9,0x09,0x69,0x9A,0x83,0xCF,0x29,0x39,0xB9,0xE9,0x4C,0xFF,0x43,0xAB,
80 }; 80 };
81 81
82void des_xwhite_in2out(des_key,in_white,out_white) 82void des_xwhite_in2out(const_des_cblock *des_key, const_des_cblock *in_white,
83des_cblock (*des_key); 83 des_cblock *out_white)
84des_cblock (*in_white);
85des_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,26 @@ des_cblock (*out_white);
111 } 107 }
112 } 108 }
113 109
114void des_xcbc_encrypt(input, output, length, schedule, ivec, inw,outw,enc) 110void des_xcbc_encrypt(const unsigned char *in, unsigned char *out,
115des_cblock (*input); 111 long length, des_key_schedule schedule, des_cblock *ivec,
116des_cblock (*output); 112 const_des_cblock *inw, const_des_cblock *outw, int enc)
117long length;
118des_key_schedule schedule;
119des_cblock (*ivec);
120des_cblock (*inw);
121des_cblock (*outw);
122int enc;
123 { 113 {
124 register DES_LONG tin0,tin1; 114 register DES_LONG tin0,tin1;
125 register DES_LONG tout0,tout1,xor0,xor1; 115 register DES_LONG tout0,tout1,xor0,xor1;
126 register DES_LONG inW0,inW1,outW0,outW1; 116 register DES_LONG inW0,inW1,outW0,outW1;
127 register unsigned char *in,*out; 117 register const unsigned char *in2;
128 register long l=length; 118 register long l=length;
129 DES_LONG tin[2]; 119 DES_LONG tin[2];
130 unsigned char *iv; 120 unsigned char *iv;
131 121
132 in=(unsigned char *)inw; 122 in2 = &(*inw)[0];
133 c2l(in,inW0); 123 c2l(in2,inW0);
134 c2l(in,inW1); 124 c2l(in2,inW1);
135 in=(unsigned char *)outw; 125 in2 = &(*outw)[0];
136 c2l(in,outW0); 126 c2l(in2,outW0);
137 c2l(in,outW1); 127 c2l(in2,outW1);
138 128
139 in=(unsigned char *)input; 129 iv = &(*ivec)[0];
140 out=(unsigned char *)output;
141 iv=(unsigned char *)ivec;
142 130
143 if (enc) 131 if (enc)
144 { 132 {
@@ -150,7 +138,7 @@ int enc;
150 c2l(in,tin1); 138 c2l(in,tin1);
151 tin0^=tout0^inW0; tin[0]=tin0; 139 tin0^=tout0^inW0; tin[0]=tin0;
152 tin1^=tout1^inW1; tin[1]=tin1; 140 tin1^=tout1^inW1; tin[1]=tin1;
153 des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT); 141 des_encrypt(tin,schedule,DES_ENCRYPT);
154 tout0=tin[0]^outW0; l2c(tout0,out); 142 tout0=tin[0]^outW0; l2c(tout0,out);
155 tout1=tin[1]^outW1; l2c(tout1,out); 143 tout1=tin[1]^outW1; l2c(tout1,out);
156 } 144 }
@@ -159,11 +147,11 @@ int enc;
159 c2ln(in,tin0,tin1,l+8); 147 c2ln(in,tin0,tin1,l+8);
160 tin0^=tout0^inW0; tin[0]=tin0; 148 tin0^=tout0^inW0; tin[0]=tin0;
161 tin1^=tout1^inW1; tin[1]=tin1; 149 tin1^=tout1^inW1; tin[1]=tin1;
162 des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT); 150 des_encrypt(tin,schedule,DES_ENCRYPT);
163 tout0=tin[0]^outW0; l2c(tout0,out); 151 tout0=tin[0]^outW0; l2c(tout0,out);
164 tout1=tin[1]^outW1; l2c(tout1,out); 152 tout1=tin[1]^outW1; l2c(tout1,out);
165 } 153 }
166 iv=(unsigned char *)ivec; 154 iv = &(*ivec)[0];
167 l2c(tout0,iv); 155 l2c(tout0,iv);
168 l2c(tout1,iv); 156 l2c(tout1,iv);
169 } 157 }
@@ -175,7 +163,7 @@ int enc;
175 { 163 {
176 c2l(in,tin0); tin[0]=tin0^outW0; 164 c2l(in,tin0); tin[0]=tin0^outW0;
177 c2l(in,tin1); tin[1]=tin1^outW1; 165 c2l(in,tin1); tin[1]=tin1^outW1;
178 des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT); 166 des_encrypt(tin,schedule,DES_DECRYPT);
179 tout0=tin[0]^xor0^inW0; 167 tout0=tin[0]^xor0^inW0;
180 tout1=tin[1]^xor1^inW1; 168 tout1=tin[1]^xor1^inW1;
181 l2c(tout0,out); 169 l2c(tout0,out);
@@ -187,7 +175,7 @@ int enc;
187 { 175 {
188 c2l(in,tin0); tin[0]=tin0^outW0; 176 c2l(in,tin0); tin[0]=tin0^outW0;
189 c2l(in,tin1); tin[1]=tin1^outW1; 177 c2l(in,tin1); tin[1]=tin1^outW1;
190 des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT); 178 des_encrypt(tin,schedule,DES_DECRYPT);
191 tout0=tin[0]^xor0^inW0; 179 tout0=tin[0]^xor0^inW0;
192 tout1=tin[1]^xor1^inW1; 180 tout1=tin[1]^xor1^inW1;
193 l2cn(tout0,tout1,out,l+8); 181 l2cn(tout0,tout1,out,l+8);
@@ -195,7 +183,7 @@ int enc;
195 xor1=tin1; 183 xor1=tin1;
196 } 184 }
197 185
198 iv=(unsigned char *)ivec; 186 iv = &(*ivec)[0];
199 l2c(xor0,iv); 187 l2c(xor0,iv);
200 l2c(xor1,iv); 188 l2c(xor1,iv);
201 } 189 }