1 /* |
|
2 * ==================================================================== |
|
3 * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved. |
|
4 * |
|
5 * Redistribution and use in source and binary forms, with or without |
|
6 * modification, are permitted provided that the following conditions |
|
7 * are met: |
|
8 * |
|
9 * 1. Redistributions of source code must retain the above copyright |
|
10 * notice, this list of conditions and the following disclaimer. |
|
11 * |
|
12 * 2. Redistributions in binary form must reproduce the above copyright |
|
13 * notice, this list of conditions and the following disclaimer in |
|
14 * the documentation and/or other materials provided with the |
|
15 * distribution. |
|
16 * |
|
17 * 3. All advertising materials mentioning features or use of this |
|
18 * software must display the following acknowledgment: |
|
19 * "This product includes software developed by the OpenSSL Project |
|
20 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" |
|
21 * |
|
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to |
|
23 * endorse or promote products derived from this software without |
|
24 * prior written permission. For written permission, please contact |
|
25 * [email protected]. |
|
26 * |
|
27 * 5. Products derived from this software may not be called "OpenSSL" |
|
28 * nor may "OpenSSL" appear in their names without prior written |
|
29 * permission of the OpenSSL Project. |
|
30 * |
|
31 * 6. Redistributions of any form whatsoever must retain the following |
|
32 * acknowledgment: |
|
33 * "This product includes software developed by the OpenSSL Project |
|
34 * for use in the OpenSSL Toolkit (http://www.openssl.org/)" |
|
35 * |
|
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY |
|
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR |
|
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
|
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
|
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
|
47 * OF THE POSSIBILITY OF SUCH DAMAGE. |
|
48 * ==================================================================== |
|
49 */ |
|
50 |
|
51 /* |
|
52 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
|
53 */ |
|
54 |
|
55 /*LINTLIBRARY*/ |
|
56 |
|
57 #if defined(lint) || defined(__lint) |
|
58 |
|
59 #include <sys/types.h> |
|
60 #include "../engine/eng_t4_des_asm.h" |
|
61 |
|
62 /*ARGSUSED*/ |
|
63 void t4_des_expand(uint64_t *rk, const uint32_t *key) |
|
64 { return; } |
|
65 |
|
66 /*ARGSUSED*/ |
|
67 void t4_des_encrypt(const uint64_t *rk, const uint64_t *pt, uint64_t *ct) |
|
68 { return; } |
|
69 |
|
70 |
|
71 /*ARGSUSED*/ |
|
72 void t4_des_load_keys(uint64_t *ks) |
|
73 { return; } |
|
74 |
|
75 /*ARGSUSED*/ |
|
76 void t4_des_ecb_crypt(uint64_t *ks, uint64_t *asm_in, |
|
77 uint64_t *asm_out, size_t amount_to_crypt, uint64_t *iv) |
|
78 { return; } |
|
79 |
|
80 /*ARGSUSED*/ |
|
81 void t4_des_cbc_encrypt(uint64_t *ks, uint64_t *asm_in, |
|
82 uint64_t *asm_out, size_t amount_to_crypt, uint64_t *iv) |
|
83 { return; } |
|
84 |
|
85 /*ARGSUSED*/ |
|
86 void t4_des_cbc_decrypt(uint64_t *ks, uint64_t *asm_in, |
|
87 uint64_t *asm_out, size_t amount_to_crypt, uint64_t *iv) |
|
88 { return; } |
|
89 |
|
90 /*ARGSUSED*/ |
|
91 void t4_des3_load_keys(uint64_t *ks) |
|
92 { return; } |
|
93 |
|
94 /*ARGSUSED*/ |
|
95 void t4_des3_ecb_crypt(uint64_t *ks, uint64_t *asm_in, |
|
96 uint64_t *asm_out, size_t amount_to_crypt, uint64_t *iv) |
|
97 { return; } |
|
98 |
|
99 /*ARGSUSED*/ |
|
100 void t4_des3_cbc_encrypt(uint64_t *ks, uint64_t *asm_in, |
|
101 uint64_t *asm_out, size_t amount_to_crypt, uint64_t *iv) |
|
102 { return; } |
|
103 |
|
104 /*ARGSUSED*/ |
|
105 void t4_des3_cbc_decrypt(uint64_t *ks, uint64_t *asm_in, |
|
106 uint64_t *asm_out, size_t amount_to_crypt, uint64_t *iv) |
|
107 { return; } |
|
108 |
|
109 #else /* lint || __lint */ |
|
110 |
|
111 #include <sys/asm_linkage.h> |
|
112 |
|
113 |
|
114 ENTRY(t4_des_expand) |
|
115 |
|
116 !load key |
|
117 ld [%o1], %f0 |
|
118 ld [%o1 + 0x4], %f1 |
|
119 |
|
120 !expand the key |
|
121 !des_kexpand %f0, 0, %f0 |
|
122 !des_kexpand %f0, 1, %f2 |
|
123 !des_kexpand %f2, 3, %f6 |
|
124 !des_kexpand %f2, 2, %f4 |
|
125 !des_kexpand %f6, 3, %f10 |
|
126 !des_kexpand %f6, 2, %f8 |
|
127 !des_kexpand %f10, 3, %f14 |
|
128 !des_kexpand %f10, 2, %f12 |
|
129 !des_kexpand %f14, 1, %f16 |
|
130 !des_kexpand %f16, 3, %f20 |
|
131 !des_kexpand %f16, 2, %f18 |
|
132 !des_kexpand %f20, 3, %f24 |
|
133 !des_kexpand %f20, 2, %f22 |
|
134 !des_kexpand %f24, 3, %f28 |
|
135 !des_kexpand %f24, 2, %f26 |
|
136 !des_kexpand %f28, 1, %f30 |
|
137 .byte 0x81, 0xb0, 0x26, 0xc0 |
|
138 .byte 0x85, 0xb0, 0x26, 0xc1 |
|
139 .byte 0x8d, 0xb0, 0xa6, 0xc3 |
|
140 .byte 0x89, 0xb0, 0xa6, 0xc2 |
|
141 .byte 0x95, 0xb1, 0xa6, 0xc3 |
|
142 .byte 0x91, 0xb1, 0xa6, 0xc2 |
|
143 .byte 0x9d, 0xb2, 0xa6, 0xc3 |
|
144 .byte 0x99, 0xb2, 0xa6, 0xc2 |
|
145 .byte 0xa1, 0xb3, 0xa6, 0xc1 |
|
146 .byte 0xa9, 0xb4, 0x26, 0xc3 |
|
147 .byte 0xa5, 0xb4, 0x26, 0xc2 |
|
148 .byte 0xb1, 0xb5, 0x26, 0xc3 |
|
149 .byte 0xad, 0xb5, 0x26, 0xc2 |
|
150 .byte 0xb9, 0xb6, 0x26, 0xc3 |
|
151 .byte 0xb5, 0xb6, 0x26, 0xc2 |
|
152 .byte 0xbd, 0xb7, 0x26, 0xc1 |
|
153 |
|
154 !copy expanded key back into array |
|
155 std %f0, [%o0] |
|
156 std %f2, [%o0 + 0x8] |
|
157 std %f4, [%o0 + 0x10] |
|
158 std %f6, [%o0 + 0x18] |
|
159 std %f8, [%o0 + 0x20] |
|
160 std %f10, [%o0 + 0x28] |
|
161 std %f12, [%o0 + 0x30] |
|
162 std %f14, [%o0 + 0x38] |
|
163 std %f16, [%o0 + 0x40] |
|
164 std %f18, [%o0 + 0x48] |
|
165 std %f20, [%o0 + 0x50] |
|
166 std %f22, [%o0 + 0x58] |
|
167 std %f24, [%o0 + 0x60] |
|
168 std %f26, [%o0 + 0x68] |
|
169 std %f28, [%o0 + 0x70] |
|
170 retl |
|
171 std %f30, [%o0 + 0x78] |
|
172 |
|
173 SET_SIZE(t4_des_expand) |
|
174 |
|
175 |
|
176 ENTRY(t4_des_encrypt) |
|
177 |
|
178 !load expanded key |
|
179 ldd [%o0], %f0 |
|
180 ldd [%o0 + 0x8], %f2 |
|
181 ldd [%o0 + 0x10], %f4 |
|
182 ldd [%o0 + 0x18], %f6 |
|
183 ldd [%o0 + 0x20], %f8 |
|
184 ldd [%o0 + 0x28], %f10 |
|
185 ldd [%o0 + 0x30], %f12 |
|
186 ldd [%o0 + 0x38], %f14 |
|
187 ldd [%o0 + 0x40], %f16 |
|
188 ldd [%o0 + 0x48], %f18 |
|
189 ldd [%o0 + 0x50], %f20 |
|
190 ldd [%o0 + 0x58], %f22 |
|
191 ldd [%o0 + 0x60], %f24 |
|
192 ldd [%o0 + 0x68], %f26 |
|
193 ldd [%o0 + 0x70], %f28 |
|
194 ldd [%o0 + 0x78], %f30 |
|
195 |
|
196 !load input |
|
197 ldd [%o1], %f32 |
|
198 |
|
199 !perform the cipher transformation |
|
200 !des_ip %f32, %f32 |
|
201 !des_round %f0, %f2, %f32, %f32 |
|
202 !des_round %f4, %f6, %f32, %f32 |
|
203 !des_round %f8, %f10, %f32, %f32 |
|
204 !des_round %f12, %f14, %f32, %f32 |
|
205 !des_round %f16, %f18, %f32, %f32 |
|
206 !des_round %f20, %f22, %f32, %f32 |
|
207 !des_round %f24, %f26, %f32, %f32 |
|
208 !des_round %f28, %f30, %f32, %f32 |
|
209 !des_iip %f32, %f32 |
|
210 .byte 0x83, 0xb0, 0x66, 0x80 |
|
211 .byte 0x82, 0xc8, 0x03, 0x22 |
|
212 .byte 0x82, 0xc9, 0x03, 0x26 |
|
213 .byte 0x82, 0xca, 0x03, 0x2a |
|
214 .byte 0x82, 0xcb, 0x03, 0x2e |
|
215 .byte 0x82, 0xcc, 0x03, 0x32 |
|
216 .byte 0x82, 0xcd, 0x03, 0x36 |
|
217 .byte 0x82, 0xce, 0x03, 0x3a |
|
218 .byte 0x82, 0xcf, 0x03, 0x3e |
|
219 .byte 0x83, 0xb0, 0x66, 0xa0 |
|
220 |
|
221 !copy output back to array |
|
222 retl |
|
223 std %f32, [%o2] |
|
224 |
|
225 SET_SIZE(t4_des_encrypt) |
|
226 |
|
227 ENTRY(t4_des_load_keys) |
|
228 |
|
229 !load expanded key |
|
230 ldd [%o0], %f0 |
|
231 ldd [%o0 + 0x8], %f2 |
|
232 ldd [%o0 + 0x10], %f4 |
|
233 ldd [%o0 + 0x18], %f6 |
|
234 ldd [%o0 + 0x20], %f8 |
|
235 ldd [%o0 + 0x28], %f10 |
|
236 ldd [%o0 + 0x30], %f12 |
|
237 ldd [%o0 + 0x38], %f14 |
|
238 ldd [%o0 + 0x40], %f16 |
|
239 ldd [%o0 + 0x48], %f18 |
|
240 ldd [%o0 + 0x50], %f20 |
|
241 ldd [%o0 + 0x58], %f22 |
|
242 ldd [%o0 + 0x60], %f24 |
|
243 ldd [%o0 + 0x68], %f26 |
|
244 ldd [%o0 + 0x70], %f28 |
|
245 retl |
|
246 ldd [%o0 + 0x78], %f30 |
|
247 |
|
248 SET_SIZE(t4_des_load_keys) |
|
249 |
|
250 ENTRY(t4_des3_load_keys) |
|
251 |
|
252 !load first 30 pieces of the expanded key |
|
253 ldd [%o0], %f0 |
|
254 ldd [%o0 + 0x8], %f2 |
|
255 ldd [%o0 + 0x10], %f4 |
|
256 ldd [%o0 + 0x18], %f6 |
|
257 ldd [%o0 + 0x20], %f8 |
|
258 ldd [%o0 + 0x28], %f10 |
|
259 ldd [%o0 + 0x30], %f12 |
|
260 ldd [%o0 + 0x38], %f14 |
|
261 ldd [%o0 + 0x40], %f16 |
|
262 ldd [%o0 + 0x48], %f18 |
|
263 ldd [%o0 + 0x50], %f20 |
|
264 ldd [%o0 + 0x58], %f22 |
|
265 ldd [%o0 + 0x60], %f24 |
|
266 ldd [%o0 + 0x68], %f26 |
|
267 ldd [%o0 + 0x70], %f28 |
|
268 ldd [%o0 + 0x78], %f30 |
|
269 ldd [%o0 + 0x80], %f32 |
|
270 ldd [%o0 + 0x88], %f34 |
|
271 ldd [%o0 + 0x90], %f36 |
|
272 ldd [%o0 + 0x98], %f38 |
|
273 ldd [%o0 + 0xa0], %f40 |
|
274 ldd [%o0 + 0xa8], %f42 |
|
275 ldd [%o0 + 0xb0], %f44 |
|
276 ldd [%o0 + 0xb8], %f46 |
|
277 ldd [%o0 + 0xc0], %f48 |
|
278 ldd [%o0 + 0xc8], %f50 |
|
279 ldd [%o0 + 0xd0], %f52 |
|
280 ldd [%o0 + 0xd8], %f54 |
|
281 ldd [%o0 + 0xe0], %f56 |
|
282 retl |
|
283 ldd [%o0 + 0xe8], %f58 |
|
284 |
|
285 SET_SIZE(t4_des3_load_keys) |
|
286 |
|
287 ENTRY(t4_des_ecb_crypt) |
|
288 |
|
289 des_ecb_loop: |
|
290 !load input |
|
291 ldd [%o1], %f62 |
|
292 |
|
293 !perform the cipher transformation |
|
294 !des_ip %f62, %f62 |
|
295 !des_round %f0, %f2, %f62, %f62 |
|
296 !des_round %f4, %f6, %f62, %f62 |
|
297 !des_round %f8, %f10, %f62, %f62 |
|
298 !des_round %f12, %f14, %f62, %f62 |
|
299 !des_round %f16, %f18, %f62, %f62 |
|
300 !des_round %f20, %f22, %f62, %f62 |
|
301 !des_round %f24, %f26, %f62, %f62 |
|
302 !des_round %f28, %f30, %f62, %f62 |
|
303 !des_iip %f62, %f62 |
|
304 .byte 0xbf, 0xb7, 0xe6, 0x80 |
|
305 .byte 0xbe, 0xc8, 0x3f, 0x22 |
|
306 .byte 0xbe, 0xc9, 0x3f, 0x26 |
|
307 .byte 0xbe, 0xca, 0x3f, 0x2a |
|
308 .byte 0xbe, 0xcb, 0x3f, 0x2e |
|
309 .byte 0xbe, 0xcc, 0x3f, 0x32 |
|
310 .byte 0xbe, 0xcd, 0x3f, 0x36 |
|
311 .byte 0xbe, 0xce, 0x3f, 0x3a |
|
312 .byte 0xbe, 0xcf, 0x3f, 0x3e |
|
313 .byte 0xbf, 0xb7, 0xe6, 0xa0 |
|
314 |
|
315 !copy output back to array |
|
316 std %f62, [%o2] |
|
317 sub %o3, 8, %o3 |
|
318 add %o1, 8, %o1 |
|
319 brnz %o3, des_ecb_loop |
|
320 add %o2, 8, %o2 |
|
321 |
|
322 retl |
|
323 nop |
|
324 |
|
325 SET_SIZE(t4_des_ecb_crypt) |
|
326 |
|
327 |
|
328 ENTRY(t4_des_cbc_encrypt) |
|
329 |
|
330 ldd [%o4], %f60 |
|
331 des_cbc_encrypt_loop: |
|
332 !load input |
|
333 ldd [%o1], %f58 |
|
334 fxor %f58, %f60, %f62 |
|
335 |
|
336 !perform the cipher transformation |
|
337 !des_ip %f62, %f62 |
|
338 !des_round %f0, %f2, %f62, %f62 |
|
339 !des_round %f4, %f6, %f62, %f62 |
|
340 !des_round %f8, %f10, %f62, %f62 |
|
341 !des_round %f12, %f14, %f62, %f62 |
|
342 !des_round %f16, %f18, %f62, %f62 |
|
343 !des_round %f20, %f22, %f62, %f62 |
|
344 !des_round %f24, %f26, %f62, %f62 |
|
345 !des_round %f28, %f30, %f62, %f62 |
|
346 !des_iip %f62, %f60 |
|
347 .byte 0xbf, 0xb7, 0xe6, 0x80 |
|
348 .byte 0xbe, 0xc8, 0x3f, 0x22 |
|
349 .byte 0xbe, 0xc9, 0x3f, 0x26 |
|
350 .byte 0xbe, 0xca, 0x3f, 0x2a |
|
351 .byte 0xbe, 0xcb, 0x3f, 0x2e |
|
352 .byte 0xbe, 0xcc, 0x3f, 0x32 |
|
353 .byte 0xbe, 0xcd, 0x3f, 0x36 |
|
354 .byte 0xbe, 0xce, 0x3f, 0x3a |
|
355 .byte 0xbe, 0xcf, 0x3f, 0x3e |
|
356 .byte 0xbb, 0xb7, 0xe6, 0xa0 |
|
357 |
|
358 !copy output back to array |
|
359 std %f60, [%o2] |
|
360 sub %o3, 8, %o3 |
|
361 add %o1, 8, %o1 |
|
362 brnz %o3, des_cbc_encrypt_loop |
|
363 add %o2, 8, %o2 |
|
364 |
|
365 retl |
|
366 std %f60, [%o4] |
|
367 |
|
368 SET_SIZE(t4_des_cbc_encrypt) |
|
369 |
|
370 |
|
371 |
|
372 ENTRY(t4_des_cbc_decrypt) |
|
373 |
|
374 ldd [%o4], %f60 |
|
375 des_cbc_decrypt_loop: |
|
376 !load input |
|
377 ldd [%o1], %f62 |
|
378 ldx [%o1], %o5 |
|
379 |
|
380 !perform the cipher transformation |
|
381 !des_ip %f62, %f62 |
|
382 !des_round %f0, %f2, %f62, %f62 |
|
383 !des_round %f4, %f6, %f62, %f62 |
|
384 !des_round %f8, %f10, %f62, %f62 |
|
385 !des_round %f12, %f14, %f62, %f62 |
|
386 !des_round %f16, %f18, %f62, %f62 |
|
387 !des_round %f20, %f22, %f62, %f62 |
|
388 !des_round %f24, %f26, %f62, %f62 |
|
389 !des_round %f28, %f30, %f62, %f62 |
|
390 !des_iip %f62, %f62 |
|
391 .byte 0xbf, 0xb7, 0xe6, 0x80 |
|
392 .byte 0xbe, 0xc8, 0x3f, 0x22 |
|
393 .byte 0xbe, 0xc9, 0x3f, 0x26 |
|
394 .byte 0xbe, 0xca, 0x3f, 0x2a |
|
395 .byte 0xbe, 0xcb, 0x3f, 0x2e |
|
396 .byte 0xbe, 0xcc, 0x3f, 0x32 |
|
397 .byte 0xbe, 0xcd, 0x3f, 0x36 |
|
398 .byte 0xbe, 0xce, 0x3f, 0x3a |
|
399 .byte 0xbe, 0xcf, 0x3f, 0x3e |
|
400 .byte 0xbf, 0xb7, 0xe6, 0xa0 |
|
401 fxor %f60, %f62, %f62 |
|
402 movxtod %o5, %f60 |
|
403 |
|
404 !copy output back to array |
|
405 std %f62, [%o2] |
|
406 sub %o3, 8, %o3 |
|
407 add %o1, 8, %o1 |
|
408 brnz %o3, des_cbc_decrypt_loop |
|
409 add %o2, 8, %o2 |
|
410 |
|
411 retl |
|
412 std %f60, [%o4] |
|
413 |
|
414 SET_SIZE(t4_des_cbc_decrypt) |
|
415 |
|
416 |
|
417 |
|
418 ENTRY(t4_des3_ecb_crypt) |
|
419 |
|
420 des3_ecb_loop: |
|
421 !load input |
|
422 ldd [%o1], %f62 |
|
423 |
|
424 !perform the cipher transformation |
|
425 !des_ip %f62, %f62 |
|
426 !des_round %f0, %f2, %f62, %f62 |
|
427 !des_round %f4, %f6, %f62, %f62 |
|
428 !des_round %f8, %f10, %f62, %f62 |
|
429 !des_round %f12, %f14, %f62, %f62 |
|
430 !des_round %f16, %f18, %f62, %f62 |
|
431 .byte 0xbf, 0xb7, 0xe6, 0x80 |
|
432 .byte 0xbe, 0xc8, 0x3f, 0x22 |
|
433 .byte 0xbe, 0xc9, 0x3f, 0x26 |
|
434 .byte 0xbe, 0xca, 0x3f, 0x2a |
|
435 .byte 0xbe, 0xcb, 0x3f, 0x2e |
|
436 .byte 0xbe, 0xcc, 0x3f, 0x32 |
|
437 |
|
438 ldd [%o0 + 0xf0], %f16 |
|
439 ldd [%o0 + 0xf8], %f18 |
|
440 !des_round %f20, %f22, %f62, %f62 |
|
441 .byte 0xbe, 0xcd, 0x3f, 0x36 |
|
442 ldd [%o0 + 0x100], %f20 |
|
443 ldd [%o0 + 0x108], %f22 |
|
444 !des_round %f24, %f26, %f62, %f62 |
|
445 .byte 0xbe, 0xce, 0x3f, 0x3a |
|
446 ldd [%o0 + 0x110], %f24 |
|
447 ldd [%o0 + 0x118], %f26 |
|
448 !des_round %f28, %f30, %f62, %f62 |
|
449 .byte 0xbe, 0xcf, 0x3f, 0x3e |
|
450 ldd [%o0 + 0x120], %f28 |
|
451 ldd [%o0 + 0x128], %f30 |
|
452 |
|
453 !des_iip %f62, %f62 |
|
454 !des_ip %f62, %f62 |
|
455 .byte 0xbf, 0xb7, 0xe6, 0xa0 |
|
456 .byte 0xbf, 0xb7, 0xe6, 0x80 |
|
457 |
|
458 !des_round %f32, %f34, %f62, %f62 |
|
459 .byte 0xbe, 0xc8, 0x7f, 0x23 |
|
460 ldd [%o0 + 0x130], %f0 |
|
461 ldd [%o0 + 0x138], %f2 |
|
462 !des_round %f36, %f38, %f62, %f62 |
|
463 .byte 0xbe, 0xc9, 0x7f, 0x27 |
|
464 ldd [%o0 + 0x140], %f4 |
|
465 ldd [%o0 + 0x148], %f6 |
|
466 !des_round %f40, %f42, %f62, %f62 |
|
467 .byte 0xbe, 0xca, 0x7f, 0x2b |
|
468 ldd [%o0 + 0x150], %f8 |
|
469 ldd [%o0 + 0x158], %f10 |
|
470 !des_round %f44, %f46, %f62, %f62 |
|
471 .byte 0xbe, 0xcb, 0x7f, 0x2f |
|
472 ldd [%o0 + 0x160], %f12 |
|
473 ldd [%o0 + 0x168], %f14 |
|
474 !des_round %f48, %f50, %f62, %f62 |
|
475 !des_round %f52, %f54, %f62, %f62 |
|
476 !des_round %f56, %f58, %f62, %f62 |
|
477 !des_round %f16, %f18, %f62, %f62 |
|
478 .byte 0xbe, 0xcc, 0x7f, 0x33 |
|
479 .byte 0xbe, 0xcd, 0x7f, 0x37 |
|
480 .byte 0xbe, 0xce, 0x7f, 0x3b |
|
481 .byte 0xbe, 0xcc, 0x3f, 0x32 |
|
482 ldd [%o0 + 0x170], %f16 |
|
483 ldd [%o0 + 0x178], %f18 |
|
484 |
|
485 !des_iip %f62, %f62 |
|
486 !des_ip %f62, %f62 |
|
487 .byte 0xbf, 0xb7, 0xe6, 0xa0 |
|
488 .byte 0xbf, 0xb7, 0xe6, 0x80 |
|
489 |
|
490 !des_round %f20, %f22, %f62, %f62 |
|
491 .byte 0xbe, 0xcd, 0x3f, 0x36 |
|
492 ldd [%o0 + 0x50], %f20 |
|
493 ldd [%o0 + 0x58], %f22 |
|
494 !des_round %f24, %f26, %f62, %f62 |
|
495 .byte 0xbe, 0xce, 0x3f, 0x3a |
|
496 ldd [%o0 + 0x60], %f24 |
|
497 ldd [%o0 + 0x68], %f26 |
|
498 !des_round %f28, %f30, %f62, %f62 |
|
499 .byte 0xbe, 0xcf, 0x3f, 0x3e |
|
500 ldd [%o0 + 0x70], %f28 |
|
501 ldd [%o0 + 0x78], %f30 |
|
502 !des_round %f0, %f2, %f62, %f62 |
|
503 .byte 0xbe, 0xc8, 0x3f, 0x22 |
|
504 ldd [%o0], %f0 |
|
505 ldd [%o0 + 0x8], %f2 |
|
506 !des_round %f4, %f6, %f62, %f62 |
|
507 .byte 0xbe, 0xc9, 0x3f, 0x26 |
|
508 |
|
509 ldd [%o0 + 0x10], %f4 |
|
510 ldd [%o0 + 0x18], %f6 |
|
511 !des_round %f8, %f10, %f62, %f62 |
|
512 .byte 0xbe, 0xca, 0x3f, 0x2a |
|
513 ldd [%o0 + 0x20], %f8 |
|
514 ldd [%o0 + 0x28], %f10 |
|
515 !des_round %f12, %f14, %f62, %f62 |
|
516 .byte 0xbe, 0xcb, 0x3f, 0x2e |
|
517 ldd [%o0 + 0x30], %f12 |
|
518 ldd [%o0 + 0x38], %f14 |
|
519 !des_round %f16, %f18, %f62, %f62 |
|
520 .byte 0xbe, 0xcc, 0x3f, 0x32 |
|
521 ldd [%o0 + 0x40], %f16 |
|
522 ldd [%o0 + 0x48], %f18 |
|
523 |
|
524 !des_iip %f62, %f62 |
|
525 .byte 0xbf, 0xb7, 0xe6, 0xa0 |
|
526 |
|
527 !copy output back to array |
|
528 std %f62, [%o2] |
|
529 sub %o3, 8, %o3 |
|
530 add %o1, 8, %o1 |
|
531 brnz %o3, des3_ecb_loop |
|
532 add %o2, 8, %o2 |
|
533 |
|
534 retl |
|
535 nop |
|
536 |
|
537 SET_SIZE(t4_des3_ecb_crypt) |
|
538 |
|
539 |
|
540 ENTRY(t4_des3_cbc_encrypt) |
|
541 |
|
542 ldd [%o4], %f62 |
|
543 des3_cbc_encrypt_loop: |
|
544 !load input |
|
545 ldd [%o1], %f60 |
|
546 fxor %f60, %f62, %f62 |
|
547 |
|
548 !perform the cipher transformation |
|
549 !des_ip %f62, %f62 |
|
550 .byte 0xbf, 0xb7, 0xe6, 0x80 |
|
551 !des_round %f0, %f2, %f62, %f62 |
|
552 !des_round %f4, %f6, %f62, %f62 |
|
553 !des_round %f8, %f10, %f62, %f62 |
|
554 !des_round %f12, %f14, %f62, %f62 |
|
555 !des_round %f16, %f18, %f62, %f62 |
|
556 .byte 0xbe, 0xc8, 0x3f, 0x22 |
|
557 .byte 0xbe, 0xc9, 0x3f, 0x26 |
|
558 .byte 0xbe, 0xca, 0x3f, 0x2a |
|
559 .byte 0xbe, 0xcb, 0x3f, 0x2e |
|
560 .byte 0xbe, 0xcc, 0x3f, 0x32 |
|
561 ldd [%o0 + 0xf0], %f16 |
|
562 ldd [%o0 + 0xf8], %f18 |
|
563 !des_round %f20, %f22, %f62, %f62 |
|
564 .byte 0xbe, 0xcd, 0x3f, 0x36 |
|
565 ldd [%o0 + 0x100], %f20 |
|
566 ldd [%o0 + 0x108], %f22 |
|
567 !des_round %f24, %f26, %f62, %f62 |
|
568 .byte 0xbe, 0xce, 0x3f, 0x3a |
|
569 ldd [%o0 + 0x110], %f24 |
|
570 ldd [%o0 + 0x118], %f26 |
|
571 !des_round %f28, %f30, %f62, %f62 |
|
572 .byte 0xbe, 0xcf, 0x3f, 0x3e |
|
573 ldd [%o0 + 0x120], %f28 |
|
574 ldd [%o0 + 0x128], %f30 |
|
575 |
|
576 !des_iip %f62, %f62 |
|
577 !des_ip %f62, %f62 |
|
578 .byte 0xbf, 0xb7, 0xe6, 0xa0 |
|
579 .byte 0xbf, 0xb7, 0xe6, 0x80 |
|
580 |
|
581 !des_round %f32, %f34, %f62, %f62 |
|
582 .byte 0xbe, 0xc8, 0x7f, 0x23 |
|
583 ldd [%o0 + 0x130], %f0 |
|
584 ldd [%o0 + 0x138], %f2 |
|
585 !des_round %f36, %f38, %f62, %f62 |
|
586 .byte 0xbe, 0xc9, 0x7f, 0x27 |
|
587 ldd [%o0 + 0x140], %f4 |
|
588 ldd [%o0 + 0x148], %f6 |
|
589 !des_round %f40, %f42, %f62, %f62 |
|
590 .byte 0xbe, 0xca, 0x7f, 0x2b |
|
591 ldd [%o0 + 0x150], %f8 |
|
592 ldd [%o0 + 0x158], %f10 |
|
593 !des_round %f44, %f46, %f62, %f62 |
|
594 .byte 0xbe, 0xcb, 0x7f, 0x2f |
|
595 ldd [%o0 + 0x160], %f12 |
|
596 ldd [%o0 + 0x168], %f14 |
|
597 !des_round %f48, %f50, %f62, %f62 |
|
598 !des_round %f52, %f54, %f62, %f62 |
|
599 !des_round %f56, %f58, %f62, %f62 |
|
600 !des_round %f16, %f18, %f62, %f62 |
|
601 .byte 0xbe, 0xcc, 0x7f, 0x33 |
|
602 .byte 0xbe, 0xcd, 0x7f, 0x37 |
|
603 .byte 0xbe, 0xce, 0x7f, 0x3b |
|
604 .byte 0xbe, 0xcc, 0x3f, 0x32 |
|
605 ldd [%o0 + 0x170], %f16 |
|
606 ldd [%o0 + 0x178], %f18 |
|
607 |
|
608 !des_iip %f62, %f62 |
|
609 !des_ip %f62, %f62 |
|
610 .byte 0xbf, 0xb7, 0xe6, 0xa0 |
|
611 .byte 0xbf, 0xb7, 0xe6, 0x80 |
|
612 |
|
613 !des_round %f20, %f22, %f62, %f62 |
|
614 .byte 0xbe, 0xcd, 0x3f, 0x36 |
|
615 ldd [%o0 + 0x50], %f20 |
|
616 ldd [%o0 + 0x58], %f22 |
|
617 !des_round %f24, %f26, %f62, %f62 |
|
618 .byte 0xbe, 0xce, 0x3f, 0x3a |
|
619 ldd [%o0 + 0x60], %f24 |
|
620 ldd [%o0 + 0x68], %f26 |
|
621 !des_round %f28, %f30, %f62, %f62 |
|
622 .byte 0xbe, 0xcf, 0x3f, 0x3e |
|
623 ldd [%o0 + 0x70], %f28 |
|
624 ldd [%o0 + 0x78], %f30 |
|
625 !des_round %f0, %f2, %f62, %f62 |
|
626 .byte 0xbe, 0xc8, 0x3f, 0x22 |
|
627 ldd [%o0], %f0 |
|
628 ldd [%o0 + 0x8], %f2 |
|
629 !des_round %f4, %f6, %f62, %f62 |
|
630 .byte 0xbe, 0xc9, 0x3f, 0x26 |
|
631 ldd [%o0 + 0x10], %f4 |
|
632 ldd [%o0 + 0x18], %f6 |
|
633 !des_round %f8, %f10, %f62, %f62 |
|
634 .byte 0xbe, 0xca, 0x3f, 0x2a |
|
635 ldd [%o0 + 0x20], %f8 |
|
636 ldd [%o0 + 0x28], %f10 |
|
637 !des_round %f12, %f14, %f62, %f62 |
|
638 .byte 0xbe, 0xcb, 0x3f, 0x2e |
|
639 ldd [%o0 + 0x30], %f12 |
|
640 ldd [%o0 + 0x38], %f14 |
|
641 !des_round %f16, %f18, %f62, %f62 |
|
642 .byte 0xbe, 0xcc, 0x3f, 0x32 |
|
643 ldd [%o0 + 0x40], %f16 |
|
644 ldd [%o0 + 0x48], %f18 |
|
645 |
|
646 !des_iip %f62, %f62 |
|
647 .byte 0xbf, 0xb7, 0xe6, 0xa0 |
|
648 |
|
649 !copy output back to array |
|
650 std %f62, [%o2] |
|
651 sub %o3, 8, %o3 |
|
652 add %o1, 8, %o1 |
|
653 brnz %o3, des3_cbc_encrypt_loop |
|
654 add %o2, 8, %o2 |
|
655 |
|
656 retl |
|
657 std %f62, [%o4] |
|
658 |
|
659 SET_SIZE(t4_des3_cbc_encrypt) |
|
660 |
|
661 |
|
662 ENTRY(t4_des3_cbc_decrypt) |
|
663 |
|
664 ldd [%o4], %f60 |
|
665 des3_cbc_decrypt_loop: |
|
666 !load input |
|
667 ldx [%o1], %o5 |
|
668 movxtod %o5, %f62 |
|
669 |
|
670 !perform the cipher transformation |
|
671 !des_ip %f62, %f62 |
|
672 .byte 0xbf, 0xb7, 0xe6, 0x80 |
|
673 !des_round %f0, %f2, %f62, %f62 |
|
674 !des_round %f4, %f6, %f62, %f62 |
|
675 !des_round %f8, %f10, %f62, %f62 |
|
676 !des_round %f12, %f14, %f62, %f62 |
|
677 !des_round %f16, %f18, %f62, %f62 |
|
678 .byte 0xbe, 0xc8, 0x3f, 0x22 |
|
679 .byte 0xbe, 0xc9, 0x3f, 0x26 |
|
680 .byte 0xbe, 0xca, 0x3f, 0x2a |
|
681 .byte 0xbe, 0xcb, 0x3f, 0x2e |
|
682 .byte 0xbe, 0xcc, 0x3f, 0x32 |
|
683 ldd [%o0 + 0xf0], %f16 |
|
684 ldd [%o0 + 0xf8], %f18 |
|
685 !des_round %f20, %f22, %f62, %f62 |
|
686 .byte 0xbe, 0xcd, 0x3f, 0x36 |
|
687 ldd [%o0 + 0x100], %f20 |
|
688 ldd [%o0 + 0x108], %f22 |
|
689 !des_round %f24, %f26, %f62, %f62 |
|
690 .byte 0xbe, 0xce, 0x3f, 0x3a |
|
691 ldd [%o0 + 0x110], %f24 |
|
692 ldd [%o0 + 0x118], %f26 |
|
693 !des_round %f28, %f30, %f62, %f62 |
|
694 .byte 0xbe, 0xcf, 0x3f, 0x3e |
|
695 ldd [%o0 + 0x120], %f28 |
|
696 ldd [%o0 + 0x128], %f30 |
|
697 |
|
698 !des_iip %f62, %f62 |
|
699 !des_ip %f62, %f62 |
|
700 .byte 0xbf, 0xb7, 0xe6, 0xa0 |
|
701 .byte 0xbf, 0xb7, 0xe6, 0x80 |
|
702 |
|
703 !des_round %f32, %f34, %f62, %f62 |
|
704 .byte 0xbe, 0xc8, 0x7f, 0x23 |
|
705 ldd [%o0 + 0x130], %f0 |
|
706 ldd [%o0 + 0x138], %f2 |
|
707 !des_round %f36, %f38, %f62, %f62 |
|
708 .byte 0xbe, 0xc9, 0x7f, 0x27 |
|
709 ldd [%o0 + 0x140], %f4 |
|
710 ldd [%o0 + 0x148], %f6 |
|
711 !des_round %f40, %f42, %f62, %f62 |
|
712 .byte 0xbe, 0xca, 0x7f, 0x2b |
|
713 ldd [%o0 + 0x150], %f8 |
|
714 ldd [%o0 + 0x158], %f10 |
|
715 !des_round %f44, %f46, %f62, %f62 |
|
716 .byte 0xbe, 0xcb, 0x7f, 0x2f |
|
717 ldd [%o0 + 0x160], %f12 |
|
718 ldd [%o0 + 0x168], %f14 |
|
719 !des_round %f48, %f50, %f62, %f62 |
|
720 !des_round %f52, %f54, %f62, %f62 |
|
721 !des_round %f56, %f58, %f62, %f62 |
|
722 !des_round %f16, %f18, %f62, %f62 |
|
723 .byte 0xbe, 0xcc, 0x7f, 0x33 |
|
724 .byte 0xbe, 0xcd, 0x7f, 0x37 |
|
725 .byte 0xbe, 0xce, 0x7f, 0x3b |
|
726 .byte 0xbe, 0xcc, 0x3f, 0x32 |
|
727 ldd [%o0 + 0x170], %f16 |
|
728 ldd [%o0 + 0x178], %f18 |
|
729 |
|
730 !des_iip %f62, %f62 |
|
731 !des_ip %f62, %f62 |
|
732 .byte 0xbf, 0xb7, 0xe6, 0xa0 |
|
733 .byte 0xbf, 0xb7, 0xe6, 0x80 |
|
734 |
|
735 !des_round %f20, %f22, %f62, %f62 |
|
736 .byte 0xbe, 0xcd, 0x3f, 0x36 |
|
737 ldd [%o0 + 0x50], %f20 |
|
738 ldd [%o0 + 0x58], %f22 |
|
739 !des_round %f24, %f26, %f62, %f62 |
|
740 .byte 0xbe, 0xce, 0x3f, 0x3a |
|
741 ldd [%o0 + 0x60], %f24 |
|
742 ldd [%o0 + 0x68], %f26 |
|
743 !des_round %f28, %f30, %f62, %f62 |
|
744 .byte 0xbe, 0xcf, 0x3f, 0x3e |
|
745 ldd [%o0 + 0x70], %f28 |
|
746 ldd [%o0 + 0x78], %f30 |
|
747 !des_round %f0, %f2, %f62, %f62 |
|
748 .byte 0xbe, 0xc8, 0x3f, 0x22 |
|
749 ldd [%o0], %f0 |
|
750 ldd [%o0 + 0x8], %f2 |
|
751 !des_round %f4, %f6, %f62, %f62 |
|
752 .byte 0xbe, 0xc9, 0x3f, 0x26 |
|
753 ldd [%o0 + 0x10], %f4 |
|
754 ldd [%o0 + 0x18], %f6 |
|
755 !des_round %f8, %f10, %f62, %f62 |
|
756 .byte 0xbe, 0xca, 0x3f, 0x2a |
|
757 ldd [%o0 + 0x20], %f8 |
|
758 ldd [%o0 + 0x28], %f10 |
|
759 !des_round %f12, %f14, %f62, %f62 |
|
760 .byte 0xbe, 0xcb, 0x3f, 0x2e |
|
761 ldd [%o0 + 0x30], %f12 |
|
762 ldd [%o0 + 0x38], %f14 |
|
763 !des_round %f16, %f18, %f62, %f62 |
|
764 .byte 0xbe, 0xcc, 0x3f, 0x32 |
|
765 ldd [%o0 + 0x40], %f16 |
|
766 ldd [%o0 + 0x48], %f18 |
|
767 |
|
768 !des_iip %f62, %f62 |
|
769 .byte 0xbf, 0xb7, 0xe6, 0xa0 |
|
770 fxor %f60, %f62, %f62 |
|
771 movxtod %o5, %f60 |
|
772 |
|
773 !copy output back to array |
|
774 std %f62, [%o2] |
|
775 sub %o3, 8, %o3 |
|
776 add %o1, 8, %o1 |
|
777 brnz %o3, des3_cbc_decrypt_loop |
|
778 add %o2, 8, %o2 |
|
779 |
|
780 retl |
|
781 stx %o5, [%o4] |
|
782 |
|
783 SET_SIZE(t4_des3_cbc_decrypt) |
|
784 |
|
785 |
|
786 #endif /* lint || __lint */ |
|