]>
git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/des/fcrypt_b.c
2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (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
13 * This version of crypt has been developed from my MIT compatible DES
14 * library. The library is available at pub/Crypto/DES at ftp.psy.uq.oz.au
15 * Eric Young (eay@cryptsoft.com)
23 #define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\
28 #define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\
29 (a)=(a)^(t)^(t>>(16-(n))))\
31 void fcrypt_body(DES_LONG *out, DES_key_schedule *ks, DES_LONG Eswap0,
34 register DES_LONG l
, r
, t
, u
;
37 register DES_LONG E0
, E1
;
46 for (j
= 0; j
< 25; j
++) {
47 D_ENCRYPT(l
, r
, 0); /* 1 */
48 D_ENCRYPT(r
, l
, 2); /* 2 */
49 D_ENCRYPT(l
, r
, 4); /* 3 */
50 D_ENCRYPT(r
, l
, 6); /* 4 */
51 D_ENCRYPT(l
, r
, 8); /* 5 */
52 D_ENCRYPT(r
, l
, 10); /* 6 */
53 D_ENCRYPT(l
, r
, 12); /* 7 */
54 D_ENCRYPT(r
, l
, 14); /* 8 */
55 D_ENCRYPT(l
, r
, 16); /* 9 */
56 D_ENCRYPT(r
, l
, 18); /* 10 */
57 D_ENCRYPT(l
, r
, 20); /* 11 */
58 D_ENCRYPT(r
, l
, 22); /* 12 */
59 D_ENCRYPT(l
, r
, 24); /* 13 */
60 D_ENCRYPT(r
, l
, 26); /* 14 */
61 D_ENCRYPT(l
, r
, 28); /* 15 */
62 D_ENCRYPT(r
, l
, 30); /* 16 */
67 l
= ROTATE(l
, 3) & 0xffffffffL
;
68 r
= ROTATE(r
, 3) & 0xffffffffL
;
70 PERM_OP(l
, r
, t
, 1, 0x55555555L
);
71 PERM_OP(r
, l
, t
, 8, 0x00ff00ffL
);
72 PERM_OP(l
, r
, t
, 2, 0x33333333L
);
73 PERM_OP(r
, l
, t
, 16, 0x0000ffffL
);
74 PERM_OP(l
, r
, t
, 4, 0x0f0f0f0fL
);