File: | out/../deps/openssl/openssl/crypto/des/des_enc.c |
Warning: | line 152, column 5 Value stored to 'l' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* |
2 | * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. |
3 | * |
4 | * Licensed under the Apache License 2.0 (the "License"). You may not use |
5 | * this file except in compliance with the License. You can obtain a copy |
6 | * in the file LICENSE in the source distribution or at |
7 | * https://www.openssl.org/source/license.html |
8 | */ |
9 | |
10 | /* |
11 | * DES low level APIs are deprecated for public use, but still ok for internal |
12 | * use. |
13 | */ |
14 | #include "internal/deprecated.h" |
15 | |
16 | #include <openssl/crypto.h> |
17 | #include "des_local.h" |
18 | #include "spr.h" |
19 | |
20 | void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc) |
21 | { |
22 | register DES_LONG l, r, t, u; |
23 | register DES_LONG *s; |
24 | |
25 | r = data[0]; |
26 | l = data[1]; |
27 | |
28 | IP(r, l){ register DES_LONG tt; ((tt)=((((l)>>(4))^(r))&(0x0f0f0f0fL )), (r)^=(tt), (l)^=((tt)<<(4))); ((tt)=((((r)>>( 16))^(l))&(0x0000ffffL)), (l)^=(tt), (r)^=((tt)<<(16 ))); ((tt)=((((l)>>(2))^(r))&(0x33333333L)), (r)^=( tt), (l)^=((tt)<<(2))); ((tt)=((((r)>>(8))^(l))& (0x00ff00ffL)), (l)^=(tt), (r)^=((tt)<<(8))); ((tt)=((( (l)>>(1))^(r))&(0x55555555L)), (r)^=(tt), (l)^=((tt )<<(1))); }; |
29 | /* |
30 | * Things have been modified so that the initial rotate is done outside |
31 | * the loop. This required the DES_SPtrans values in sp.h to be rotated |
32 | * 1 bit to the right. One perl script later and things have a 5% speed |
33 | * up on a sparc2. Thanks to Richard Outerbridge for pointing this out. |
34 | */ |
35 | /* clear the top bits on machines with 8byte longs */ |
36 | /* shift left by 2 */ |
37 | r = ROTATE(r, 29)({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(29),"0"(r) : "cc"); ret; }) & 0xffffffffL; |
38 | l = ROTATE(l, 29)({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(29),"0"(l) : "cc"); ret; }) & 0xffffffffL; |
39 | |
40 | s = ks->ks->deslong; |
41 | /* |
42 | * I don't know if it is worth the effort of loop unrolling the inner |
43 | * loop |
44 | */ |
45 | if (enc) { |
46 | D_ENCRYPT(l, r, 0){ u=r^s[0 ]; t=r^s[0 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 1 */ |
47 | D_ENCRYPT(r, l, 2){ u=l^s[2 ]; t=l^s[2 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 2 */ |
48 | D_ENCRYPT(l, r, 4){ u=r^s[4 ]; t=r^s[4 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 3 */ |
49 | D_ENCRYPT(r, l, 6){ u=l^s[6 ]; t=l^s[6 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 4 */ |
50 | D_ENCRYPT(l, r, 8){ u=r^s[8 ]; t=r^s[8 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 5 */ |
51 | D_ENCRYPT(r, l, 10){ u=l^s[10 ]; t=l^s[10 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 6 */ |
52 | D_ENCRYPT(l, r, 12){ u=r^s[12 ]; t=r^s[12 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 7 */ |
53 | D_ENCRYPT(r, l, 14){ u=l^s[14 ]; t=l^s[14 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 8 */ |
54 | D_ENCRYPT(l, r, 16){ u=r^s[16 ]; t=r^s[16 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 9 */ |
55 | D_ENCRYPT(r, l, 18){ u=l^s[18 ]; t=l^s[18 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 10 */ |
56 | D_ENCRYPT(l, r, 20){ u=r^s[20 ]; t=r^s[20 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 11 */ |
57 | D_ENCRYPT(r, l, 22){ u=l^s[22 ]; t=l^s[22 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 12 */ |
58 | D_ENCRYPT(l, r, 24){ u=r^s[24 ]; t=r^s[24 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 13 */ |
59 | D_ENCRYPT(r, l, 26){ u=l^s[26 ]; t=l^s[26 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 14 */ |
60 | D_ENCRYPT(l, r, 28){ u=r^s[28 ]; t=r^s[28 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 15 */ |
61 | D_ENCRYPT(r, l, 30){ u=l^s[30 ]; t=l^s[30 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 16 */ |
62 | } else { |
63 | D_ENCRYPT(l, r, 30){ u=r^s[30 ]; t=r^s[30 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 16 */ |
64 | D_ENCRYPT(r, l, 28){ u=l^s[28 ]; t=l^s[28 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 15 */ |
65 | D_ENCRYPT(l, r, 26){ u=r^s[26 ]; t=r^s[26 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 14 */ |
66 | D_ENCRYPT(r, l, 24){ u=l^s[24 ]; t=l^s[24 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 13 */ |
67 | D_ENCRYPT(l, r, 22){ u=r^s[22 ]; t=r^s[22 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 12 */ |
68 | D_ENCRYPT(r, l, 20){ u=l^s[20 ]; t=l^s[20 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 11 */ |
69 | D_ENCRYPT(l, r, 18){ u=r^s[18 ]; t=r^s[18 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 10 */ |
70 | D_ENCRYPT(r, l, 16){ u=l^s[16 ]; t=l^s[16 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 9 */ |
71 | D_ENCRYPT(l, r, 14){ u=r^s[14 ]; t=r^s[14 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 8 */ |
72 | D_ENCRYPT(r, l, 12){ u=l^s[12 ]; t=l^s[12 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 7 */ |
73 | D_ENCRYPT(l, r, 10){ u=r^s[10 ]; t=r^s[10 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 6 */ |
74 | D_ENCRYPT(r, l, 8){ u=l^s[8 ]; t=l^s[8 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 5 */ |
75 | D_ENCRYPT(l, r, 6){ u=r^s[6 ]; t=r^s[6 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 4 */ |
76 | D_ENCRYPT(r, l, 4){ u=l^s[4 ]; t=l^s[4 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 3 */ |
77 | D_ENCRYPT(l, r, 2){ u=r^s[2 ]; t=r^s[2 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 2 */ |
78 | D_ENCRYPT(r, l, 0){ u=l^s[0 ]; t=l^s[0 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 1 */ |
79 | } |
80 | |
81 | /* rotate and clear the top bits on machines with 8byte longs */ |
82 | l = ROTATE(l, 3)({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(3),"0"(l) : "cc"); ret; }) & 0xffffffffL; |
83 | r = ROTATE(r, 3)({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(3),"0"(r) : "cc"); ret; }) & 0xffffffffL; |
84 | |
85 | FP(r, l){ register DES_LONG tt; ((tt)=((((r)>>(1))^(l))&(0x55555555L )), (l)^=(tt), (r)^=((tt)<<(1))); ((tt)=((((l)>>( 8))^(r))&(0x00ff00ffL)), (r)^=(tt), (l)^=((tt)<<(8) )); ((tt)=((((r)>>(2))^(l))&(0x33333333L)), (l)^=(tt ), (r)^=((tt)<<(2))); ((tt)=((((l)>>(16))^(r))& (0x0000ffffL)), (r)^=(tt), (l)^=((tt)<<(16))); ((tt)=(( ((r)>>(4))^(l))&(0x0f0f0f0fL)), (l)^=(tt), (r)^=((tt )<<(4))); }; |
86 | data[0] = l; |
87 | data[1] = r; |
88 | l = r = t = u = 0; |
89 | } |
90 | |
91 | void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc) |
92 | { |
93 | register DES_LONG l, r, t, u; |
94 | register DES_LONG *s; |
95 | |
96 | r = data[0]; |
97 | l = data[1]; |
98 | |
99 | /* |
100 | * Things have been modified so that the initial rotate is done outside |
101 | * the loop. This required the DES_SPtrans values in sp.h to be rotated |
102 | * 1 bit to the right. One perl script later and things have a 5% speed |
103 | * up on a sparc2. Thanks to Richard Outerbridge for pointing this out. |
104 | */ |
105 | /* clear the top bits on machines with 8byte longs */ |
106 | r = ROTATE(r, 29)({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(29),"0"(r) : "cc"); ret; }) & 0xffffffffL; |
107 | l = ROTATE(l, 29)({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(29),"0"(l) : "cc"); ret; }) & 0xffffffffL; |
108 | |
109 | s = ks->ks->deslong; |
110 | /* |
111 | * I don't know if it is worth the effort of loop unrolling the inner |
112 | * loop |
113 | */ |
114 | if (enc) { |
115 | D_ENCRYPT(l, r, 0){ u=r^s[0 ]; t=r^s[0 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 1 */ |
116 | D_ENCRYPT(r, l, 2){ u=l^s[2 ]; t=l^s[2 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 2 */ |
117 | D_ENCRYPT(l, r, 4){ u=r^s[4 ]; t=r^s[4 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 3 */ |
118 | D_ENCRYPT(r, l, 6){ u=l^s[6 ]; t=l^s[6 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 4 */ |
119 | D_ENCRYPT(l, r, 8){ u=r^s[8 ]; t=r^s[8 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 5 */ |
120 | D_ENCRYPT(r, l, 10){ u=l^s[10 ]; t=l^s[10 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 6 */ |
121 | D_ENCRYPT(l, r, 12){ u=r^s[12 ]; t=r^s[12 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 7 */ |
122 | D_ENCRYPT(r, l, 14){ u=l^s[14 ]; t=l^s[14 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 8 */ |
123 | D_ENCRYPT(l, r, 16){ u=r^s[16 ]; t=r^s[16 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 9 */ |
124 | D_ENCRYPT(r, l, 18){ u=l^s[18 ]; t=l^s[18 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 10 */ |
125 | D_ENCRYPT(l, r, 20){ u=r^s[20 ]; t=r^s[20 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 11 */ |
126 | D_ENCRYPT(r, l, 22){ u=l^s[22 ]; t=l^s[22 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 12 */ |
127 | D_ENCRYPT(l, r, 24){ u=r^s[24 ]; t=r^s[24 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 13 */ |
128 | D_ENCRYPT(r, l, 26){ u=l^s[26 ]; t=l^s[26 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 14 */ |
129 | D_ENCRYPT(l, r, 28){ u=r^s[28 ]; t=r^s[28 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 15 */ |
130 | D_ENCRYPT(r, l, 30){ u=l^s[30 ]; t=l^s[30 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 16 */ |
131 | } else { |
132 | D_ENCRYPT(l, r, 30){ u=r^s[30 ]; t=r^s[30 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 16 */ |
133 | D_ENCRYPT(r, l, 28){ u=l^s[28 ]; t=l^s[28 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 15 */ |
134 | D_ENCRYPT(l, r, 26){ u=r^s[26 ]; t=r^s[26 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 14 */ |
135 | D_ENCRYPT(r, l, 24){ u=l^s[24 ]; t=l^s[24 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 13 */ |
136 | D_ENCRYPT(l, r, 22){ u=r^s[22 ]; t=r^s[22 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 12 */ |
137 | D_ENCRYPT(r, l, 20){ u=l^s[20 ]; t=l^s[20 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 11 */ |
138 | D_ENCRYPT(l, r, 18){ u=r^s[18 ]; t=r^s[18 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 10 */ |
139 | D_ENCRYPT(r, l, 16){ u=l^s[16 ]; t=l^s[16 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 9 */ |
140 | D_ENCRYPT(l, r, 14){ u=r^s[14 ]; t=r^s[14 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 8 */ |
141 | D_ENCRYPT(r, l, 12){ u=l^s[12 ]; t=l^s[12 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 7 */ |
142 | D_ENCRYPT(l, r, 10){ u=r^s[10 ]; t=r^s[10 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 6 */ |
143 | D_ENCRYPT(r, l, 8){ u=l^s[8 ]; t=l^s[8 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 5 */ |
144 | D_ENCRYPT(l, r, 6){ u=r^s[6 ]; t=r^s[6 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 4 */ |
145 | D_ENCRYPT(r, l, 4){ u=l^s[4 ]; t=l^s[4 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 3 */ |
146 | D_ENCRYPT(l, r, 2){ u=r^s[2 ]; t=r^s[2 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); l ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 2 */ |
147 | D_ENCRYPT(r, l, 0){ u=l^s[0 ]; t=l^s[0 +1]; t=({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(4),"0"(t) : "cc"); ret; }); r ^= DES_SPtrans[0][(u>> 2L)&0x3f]^ DES_SPtrans[2][(u >>10L)&0x3f]^ DES_SPtrans[4][(u>>18L)&0x3f ]^ DES_SPtrans[6][(u>>26L)&0x3f]^ DES_SPtrans[1][(t >> 2L)&0x3f]^ DES_SPtrans[3][(t>>10L)&0x3f ]^ DES_SPtrans[5][(t>>18L)&0x3f]^ DES_SPtrans[7][(t >>26L)&0x3f]; }; /* 1 */ |
148 | } |
149 | /* rotate and clear the top bits on machines with 8byte longs */ |
150 | data[0] = ROTATE(l, 3)({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(3),"0"(l) : "cc"); ret; }) & 0xffffffffL; |
151 | data[1] = ROTATE(r, 3)({ register unsigned int ret; asm ("rorl %1,%0" : "=r"(ret) : "I"(3),"0"(r) : "cc"); ret; }) & 0xffffffffL; |
152 | l = r = t = u = 0; |
Value stored to 'l' is never read | |
153 | } |
154 | |
155 | void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1, |
156 | DES_key_schedule *ks2, DES_key_schedule *ks3) |
157 | { |
158 | register DES_LONG l, r; |
159 | |
160 | l = data[0]; |
161 | r = data[1]; |
162 | IP(l, r){ register DES_LONG tt; ((tt)=((((r)>>(4))^(l))&(0x0f0f0f0fL )), (l)^=(tt), (r)^=((tt)<<(4))); ((tt)=((((l)>>( 16))^(r))&(0x0000ffffL)), (r)^=(tt), (l)^=((tt)<<(16 ))); ((tt)=((((r)>>(2))^(l))&(0x33333333L)), (l)^=( tt), (r)^=((tt)<<(2))); ((tt)=((((l)>>(8))^(r))& (0x00ff00ffL)), (r)^=(tt), (l)^=((tt)<<(8))); ((tt)=((( (r)>>(1))^(l))&(0x55555555L)), (l)^=(tt), (r)^=((tt )<<(1))); }; |
163 | data[0] = l; |
164 | data[1] = r; |
165 | DES_encrypt2((DES_LONG *)data, ks1, DES_ENCRYPT1); |
166 | DES_encrypt2((DES_LONG *)data, ks2, DES_DECRYPT0); |
167 | DES_encrypt2((DES_LONG *)data, ks3, DES_ENCRYPT1); |
168 | l = data[0]; |
169 | r = data[1]; |
170 | FP(r, l){ register DES_LONG tt; ((tt)=((((r)>>(1))^(l))&(0x55555555L )), (l)^=(tt), (r)^=((tt)<<(1))); ((tt)=((((l)>>( 8))^(r))&(0x00ff00ffL)), (r)^=(tt), (l)^=((tt)<<(8) )); ((tt)=((((r)>>(2))^(l))&(0x33333333L)), (l)^=(tt ), (r)^=((tt)<<(2))); ((tt)=((((l)>>(16))^(r))& (0x0000ffffL)), (r)^=(tt), (l)^=((tt)<<(16))); ((tt)=(( ((r)>>(4))^(l))&(0x0f0f0f0fL)), (l)^=(tt), (r)^=((tt )<<(4))); }; |
171 | data[0] = l; |
172 | data[1] = r; |
173 | } |
174 | |
175 | void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1, |
176 | DES_key_schedule *ks2, DES_key_schedule *ks3) |
177 | { |
178 | register DES_LONG l, r; |
179 | |
180 | l = data[0]; |
181 | r = data[1]; |
182 | IP(l, r){ register DES_LONG tt; ((tt)=((((r)>>(4))^(l))&(0x0f0f0f0fL )), (l)^=(tt), (r)^=((tt)<<(4))); ((tt)=((((l)>>( 16))^(r))&(0x0000ffffL)), (r)^=(tt), (l)^=((tt)<<(16 ))); ((tt)=((((r)>>(2))^(l))&(0x33333333L)), (l)^=( tt), (r)^=((tt)<<(2))); ((tt)=((((l)>>(8))^(r))& (0x00ff00ffL)), (r)^=(tt), (l)^=((tt)<<(8))); ((tt)=((( (r)>>(1))^(l))&(0x55555555L)), (l)^=(tt), (r)^=((tt )<<(1))); }; |
183 | data[0] = l; |
184 | data[1] = r; |
185 | DES_encrypt2((DES_LONG *)data, ks3, DES_DECRYPT0); |
186 | DES_encrypt2((DES_LONG *)data, ks2, DES_ENCRYPT1); |
187 | DES_encrypt2((DES_LONG *)data, ks1, DES_DECRYPT0); |
188 | l = data[0]; |
189 | r = data[1]; |
190 | FP(r, l){ register DES_LONG tt; ((tt)=((((r)>>(1))^(l))&(0x55555555L )), (l)^=(tt), (r)^=((tt)<<(1))); ((tt)=((((l)>>( 8))^(r))&(0x00ff00ffL)), (r)^=(tt), (l)^=((tt)<<(8) )); ((tt)=((((r)>>(2))^(l))&(0x33333333L)), (l)^=(tt ), (r)^=((tt)<<(2))); ((tt)=((((l)>>(16))^(r))& (0x0000ffffL)), (r)^=(tt), (l)^=((tt)<<(16))); ((tt)=(( ((r)>>(4))^(l))&(0x0f0f0f0fL)), (l)^=(tt), (r)^=((tt )<<(4))); }; |
191 | data[0] = l; |
192 | data[1] = r; |
193 | } |
194 | |
195 | #ifndef DES_DEFAULT_OPTIONS |
196 | |
197 | # undef CBC_ENC_C__DONT_UPDATE_IV |
198 | # include "ncbc_enc.c" /* DES_ncbc_encrypt */ |
199 | |
200 | void DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output, |
201 | long length, DES_key_schedule *ks1, |
202 | DES_key_schedule *ks2, DES_key_schedule *ks3, |
203 | DES_cblock *ivec, int enc) |
204 | { |
205 | register DES_LONG tin0, tin1; |
206 | register DES_LONG tout0, tout1, xor0, xor1; |
207 | register const unsigned char *in; |
208 | unsigned char *out; |
209 | register long l = length; |
210 | DES_LONG tin[2]; |
211 | unsigned char *iv; |
212 | |
213 | in = input; |
214 | out = output; |
215 | iv = &(*ivec)[0]; |
216 | |
217 | if (enc) { |
218 | c2l(iv, tout0)(tout0 =((DES_LONG)(*((iv)++))) , tout0|=((DES_LONG)(*((iv)++ )))<< 8L, tout0|=((DES_LONG)(*((iv)++)))<<16L, tout0 |=((DES_LONG)(*((iv)++)))<<24L); |
219 | c2l(iv, tout1)(tout1 =((DES_LONG)(*((iv)++))) , tout1|=((DES_LONG)(*((iv)++ )))<< 8L, tout1|=((DES_LONG)(*((iv)++)))<<16L, tout1 |=((DES_LONG)(*((iv)++)))<<24L); |
220 | for (l -= 8; l >= 0; l -= 8) { |
221 | c2l(in, tin0)(tin0 =((DES_LONG)(*((in)++))) , tin0|=((DES_LONG)(*((in)++)) )<< 8L, tin0|=((DES_LONG)(*((in)++)))<<16L, tin0|= ((DES_LONG)(*((in)++)))<<24L); |
222 | c2l(in, tin1)(tin1 =((DES_LONG)(*((in)++))) , tin1|=((DES_LONG)(*((in)++)) )<< 8L, tin1|=((DES_LONG)(*((in)++)))<<16L, tin1|= ((DES_LONG)(*((in)++)))<<24L); |
223 | tin0 ^= tout0; |
224 | tin1 ^= tout1; |
225 | |
226 | tin[0] = tin0; |
227 | tin[1] = tin1; |
228 | DES_encrypt3((DES_LONG *)tin, ks1, ks2, ks3); |
229 | tout0 = tin[0]; |
230 | tout1 = tin[1]; |
231 | |
232 | l2c(tout0, out)(*((out)++)=(unsigned char)(((tout0) )&0xff), *((out)++)= (unsigned char)(((tout0)>> 8L)&0xff), *((out)++)=(unsigned char)(((tout0)>>16L)&0xff), *((out)++)=(unsigned char )(((tout0)>>24L)&0xff)); |
233 | l2c(tout1, out)(*((out)++)=(unsigned char)(((tout1) )&0xff), *((out)++)= (unsigned char)(((tout1)>> 8L)&0xff), *((out)++)=(unsigned char)(((tout1)>>16L)&0xff), *((out)++)=(unsigned char )(((tout1)>>24L)&0xff)); |
234 | } |
235 | if (l != -8) { |
236 | c2ln(in, tin0, tin1, l + 8){ in+=l + 8; tin0=tin1=0; switch (l + 8) { case 8: tin1 =((DES_LONG )(*(--(in))))<<24L; case 7: tin1|=((DES_LONG)(*(--(in)) ))<<16L; case 6: tin1|=((DES_LONG)(*(--(in))))<< 8L ; case 5: tin1|=((DES_LONG)(*(--(in)))); case 4: tin0 =((DES_LONG )(*(--(in))))<<24L; case 3: tin0|=((DES_LONG)(*(--(in)) ))<<16L; case 2: tin0|=((DES_LONG)(*(--(in))))<< 8L ; case 1: tin0|=((DES_LONG)(*(--(in)))); } }; |
237 | tin0 ^= tout0; |
238 | tin1 ^= tout1; |
239 | |
240 | tin[0] = tin0; |
241 | tin[1] = tin1; |
242 | DES_encrypt3((DES_LONG *)tin, ks1, ks2, ks3); |
243 | tout0 = tin[0]; |
244 | tout1 = tin[1]; |
245 | |
246 | l2c(tout0, out)(*((out)++)=(unsigned char)(((tout0) )&0xff), *((out)++)= (unsigned char)(((tout0)>> 8L)&0xff), *((out)++)=(unsigned char)(((tout0)>>16L)&0xff), *((out)++)=(unsigned char )(((tout0)>>24L)&0xff)); |
247 | l2c(tout1, out)(*((out)++)=(unsigned char)(((tout1) )&0xff), *((out)++)= (unsigned char)(((tout1)>> 8L)&0xff), *((out)++)=(unsigned char)(((tout1)>>16L)&0xff), *((out)++)=(unsigned char )(((tout1)>>24L)&0xff)); |
248 | } |
249 | iv = &(*ivec)[0]; |
250 | l2c(tout0, iv)(*((iv)++)=(unsigned char)(((tout0) )&0xff), *((iv)++)=(unsigned char)(((tout0)>> 8L)&0xff), *((iv)++)=(unsigned char )(((tout0)>>16L)&0xff), *((iv)++)=(unsigned char)(( (tout0)>>24L)&0xff)); |
251 | l2c(tout1, iv)(*((iv)++)=(unsigned char)(((tout1) )&0xff), *((iv)++)=(unsigned char)(((tout1)>> 8L)&0xff), *((iv)++)=(unsigned char )(((tout1)>>16L)&0xff), *((iv)++)=(unsigned char)(( (tout1)>>24L)&0xff)); |
252 | } else { |
253 | register DES_LONG t0, t1; |
254 | |
255 | c2l(iv, xor0)(xor0 =((DES_LONG)(*((iv)++))) , xor0|=((DES_LONG)(*((iv)++)) )<< 8L, xor0|=((DES_LONG)(*((iv)++)))<<16L, xor0|= ((DES_LONG)(*((iv)++)))<<24L); |
256 | c2l(iv, xor1)(xor1 =((DES_LONG)(*((iv)++))) , xor1|=((DES_LONG)(*((iv)++)) )<< 8L, xor1|=((DES_LONG)(*((iv)++)))<<16L, xor1|= ((DES_LONG)(*((iv)++)))<<24L); |
257 | for (l -= 8; l >= 0; l -= 8) { |
258 | c2l(in, tin0)(tin0 =((DES_LONG)(*((in)++))) , tin0|=((DES_LONG)(*((in)++)) )<< 8L, tin0|=((DES_LONG)(*((in)++)))<<16L, tin0|= ((DES_LONG)(*((in)++)))<<24L); |
259 | c2l(in, tin1)(tin1 =((DES_LONG)(*((in)++))) , tin1|=((DES_LONG)(*((in)++)) )<< 8L, tin1|=((DES_LONG)(*((in)++)))<<16L, tin1|= ((DES_LONG)(*((in)++)))<<24L); |
260 | |
261 | t0 = tin0; |
262 | t1 = tin1; |
263 | |
264 | tin[0] = tin0; |
265 | tin[1] = tin1; |
266 | DES_decrypt3((DES_LONG *)tin, ks1, ks2, ks3); |
267 | tout0 = tin[0]; |
268 | tout1 = tin[1]; |
269 | |
270 | tout0 ^= xor0; |
271 | tout1 ^= xor1; |
272 | l2c(tout0, out)(*((out)++)=(unsigned char)(((tout0) )&0xff), *((out)++)= (unsigned char)(((tout0)>> 8L)&0xff), *((out)++)=(unsigned char)(((tout0)>>16L)&0xff), *((out)++)=(unsigned char )(((tout0)>>24L)&0xff)); |
273 | l2c(tout1, out)(*((out)++)=(unsigned char)(((tout1) )&0xff), *((out)++)= (unsigned char)(((tout1)>> 8L)&0xff), *((out)++)=(unsigned char)(((tout1)>>16L)&0xff), *((out)++)=(unsigned char )(((tout1)>>24L)&0xff)); |
274 | xor0 = t0; |
275 | xor1 = t1; |
276 | } |
277 | if (l != -8) { |
278 | c2l(in, tin0)(tin0 =((DES_LONG)(*((in)++))) , tin0|=((DES_LONG)(*((in)++)) )<< 8L, tin0|=((DES_LONG)(*((in)++)))<<16L, tin0|= ((DES_LONG)(*((in)++)))<<24L); |
279 | c2l(in, tin1)(tin1 =((DES_LONG)(*((in)++))) , tin1|=((DES_LONG)(*((in)++)) )<< 8L, tin1|=((DES_LONG)(*((in)++)))<<16L, tin1|= ((DES_LONG)(*((in)++)))<<24L); |
280 | |
281 | t0 = tin0; |
282 | t1 = tin1; |
283 | |
284 | tin[0] = tin0; |
285 | tin[1] = tin1; |
286 | DES_decrypt3((DES_LONG *)tin, ks1, ks2, ks3); |
287 | tout0 = tin[0]; |
288 | tout1 = tin[1]; |
289 | |
290 | tout0 ^= xor0; |
291 | tout1 ^= xor1; |
292 | l2cn(tout0, tout1, out, l + 8){ out+=l + 8; switch (l + 8) { case 8: *(--(out))=(unsigned char )(((tout1)>>24L)&0xff); case 7: *(--(out))=(unsigned char)(((tout1)>>16L)&0xff); case 6: *(--(out))=(unsigned char)(((tout1)>> 8L)&0xff); case 5: *(--(out))=(unsigned char)(((tout1) )&0xff); case 4: *(--(out))=(unsigned char )(((tout0)>>24L)&0xff); case 3: *(--(out))=(unsigned char)(((tout0)>>16L)&0xff); case 2: *(--(out))=(unsigned char)(((tout0)>> 8L)&0xff); case 1: *(--(out))=(unsigned char)(((tout0) )&0xff); } }; |
293 | xor0 = t0; |
294 | xor1 = t1; |
295 | } |
296 | |
297 | iv = &(*ivec)[0]; |
298 | l2c(xor0, iv)(*((iv)++)=(unsigned char)(((xor0) )&0xff), *((iv)++)=(unsigned char)(((xor0)>> 8L)&0xff), *((iv)++)=(unsigned char )(((xor0)>>16L)&0xff), *((iv)++)=(unsigned char)((( xor0)>>24L)&0xff)); |
299 | l2c(xor1, iv)(*((iv)++)=(unsigned char)(((xor1) )&0xff), *((iv)++)=(unsigned char)(((xor1)>> 8L)&0xff), *((iv)++)=(unsigned char )(((xor1)>>16L)&0xff), *((iv)++)=(unsigned char)((( xor1)>>24L)&0xff)); |
300 | } |
301 | tin0 = tin1 = tout0 = tout1 = xor0 = xor1 = 0; |
302 | tin[0] = tin[1] = 0; |
303 | } |
304 | |
305 | #endif /* DES_DEFAULT_OPTIONS */ |