195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * All rights reserved. 395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * 495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * This package is an SSL implementation written 595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * by Eric Young (eay@cryptsoft.com). 695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * The implementation was written so as to conform with Netscapes SSL. 795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * 895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * This library is free for commercial and non-commercial use as long as 995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * the following conditions are aheared to. The following conditions 1095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * apply to all code found in this distribution, be it the RC4, RSA, 1195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * lhash, DES, etc., code; not just the SSL code. The SSL documentation 1295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * included with this distribution is covered by the same copyright terms 1395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * except that the holder is Tim Hudson (tjh@cryptsoft.com). 1495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * 1595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * Copyright remains Eric Young's, and as such any Copyright notices in 1695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * the code are not to be removed. 1795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * If this package is used in a product, Eric Young should be given attribution 1895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * as the author of the parts of the library used. 1995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * This can be in the form of a textual message at program startup or 2095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * in documentation (online or textual) provided with the package. 2195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * 2295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * Redistribution and use in source and binary forms, with or without 2395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * modification, are permitted provided that the following conditions 2495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * are met: 2595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * 1. Redistributions of source code must retain the copyright 2695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * notice, this list of conditions and the following disclaimer. 2795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * 2. Redistributions in binary form must reproduce the above copyright 2895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * notice, this list of conditions and the following disclaimer in the 2995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * documentation and/or other materials provided with the distribution. 3095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * 3. All advertising materials mentioning features or use of this software 3195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * must display the following acknowledgement: 3295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * "This product includes cryptographic software written by 3395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * Eric Young (eay@cryptsoft.com)" 3495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * The word 'cryptographic' can be left out if the rouines from the library 3595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * being used are not cryptographic related :-). 3695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * 4. If you include any Windows specific code (or a derivative thereof) from 3795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * the apps directory (application code) you must include an acknowledgement: 3895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 3995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * 4095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 4195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 4295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 4395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 4495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 4595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 4695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 4795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 4895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 4995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 5095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * SUCH DAMAGE. 5195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * 5295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * The licence and distribution terms for any publically available version or 5395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * derivative of this code cannot be changed. i.e. this code cannot simply be 5495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * copied and put under another distribution licence 5595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * [including the GNU Public Licence.] */ 5695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 5795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#ifndef OPENSSL_HEADER_DES_INTERNAL_H 5895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#define OPENSSL_HEADER_DES_INTERNAL_H 5995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 6095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#include <openssl/base.h> 6195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 6295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#if defined(__cplusplus) 6395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleyextern "C" { 6495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#endif 6595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 6695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 6795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#define c2l(c, l) \ 6895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley (l = ((uint32_t)(*((c)++))), l |= ((uint32_t)(*((c)++))) << 8L, \ 6995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley l |= ((uint32_t)(*((c)++))) << 16L, l |= ((uint32_t)(*((c)++))) << 24L) 7095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 7195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#define l2c(l, c) \ 7295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley (*((c)++) = (unsigned char)(((l)) & 0xff), \ 7395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley *((c)++) = (unsigned char)(((l) >> 8L) & 0xff), \ 7495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley *((c)++) = (unsigned char)(((l) >> 16L) & 0xff), \ 7595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley *((c)++) = (unsigned char)(((l) >> 24L) & 0xff)) 7695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 7795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley/* NOTE - c is not incremented as per c2l */ 7895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#define c2ln(c, l1, l2, n) \ 7995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley { \ 8095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley c += n; \ 8195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley l1 = l2 = 0; \ 8295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley switch (n) { \ 8395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley case 8: \ 8495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley l2 = ((uint32_t)(*(--(c)))) << 24L; \ 8595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley case 7: \ 8695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley l2 |= ((uint32_t)(*(--(c)))) << 16L; \ 8795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley case 6: \ 8895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley l2 |= ((uint32_t)(*(--(c)))) << 8L; \ 8995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley case 5: \ 9095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley l2 |= ((uint32_t)(*(--(c)))); \ 9195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley case 4: \ 9295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley l1 = ((uint32_t)(*(--(c)))) << 24L; \ 9395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley case 3: \ 9495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley l1 |= ((uint32_t)(*(--(c)))) << 16L; \ 9595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley case 2: \ 9695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley l1 |= ((uint32_t)(*(--(c)))) << 8L; \ 9795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley case 1: \ 9895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley l1 |= ((uint32_t)(*(--(c)))); \ 9995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley } \ 10095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley } 10195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 10295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley/* NOTE - c is not incremented as per l2c */ 10395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#define l2cn(l1, l2, c, n) \ 10495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley { \ 10595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley c += n; \ 10695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley switch (n) { \ 10795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley case 8: \ 10895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley *(--(c)) = (unsigned char)(((l2) >> 24L) & 0xff); \ 10995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley case 7: \ 11095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley *(--(c)) = (unsigned char)(((l2) >> 16L) & 0xff); \ 11195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley case 6: \ 11295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley *(--(c)) = (unsigned char)(((l2) >> 8L) & 0xff); \ 11395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley case 5: \ 11495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley *(--(c)) = (unsigned char)(((l2)) & 0xff); \ 11595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley case 4: \ 11695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley *(--(c)) = (unsigned char)(((l1) >> 24L) & 0xff); \ 11795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley case 3: \ 11895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley *(--(c)) = (unsigned char)(((l1) >> 16L) & 0xff); \ 11995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley case 2: \ 12095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley *(--(c)) = (unsigned char)(((l1) >> 8L) & 0xff); \ 12195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley case 1: \ 12295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley *(--(c)) = (unsigned char)(((l1)) & 0xff); \ 12395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley } \ 12495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley } 12595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 12695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley/* IP and FP 12795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley * The problem is more of a geometric problem that random bit fiddling. 12895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 0 1 2 3 4 5 6 7 62 54 46 38 30 22 14 6 12995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 8 9 10 11 12 13 14 15 60 52 44 36 28 20 12 4 13095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley16 17 18 19 20 21 22 23 58 50 42 34 26 18 10 2 13195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley24 25 26 27 28 29 30 31 to 56 48 40 32 24 16 8 0 13295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 13395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley32 33 34 35 36 37 38 39 63 55 47 39 31 23 15 7 13495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley40 41 42 43 44 45 46 47 61 53 45 37 29 21 13 5 13595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley48 49 50 51 52 53 54 55 59 51 43 35 27 19 11 3 13695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley56 57 58 59 60 61 62 63 57 49 41 33 25 17 9 1 13795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 13895c29f3cd1f6c08c6c0927868683392eea727ccAdam LangleyThe output has been subject to swaps of the form 13995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley0 1 -> 3 1 but the odd and even bits have been put into 14095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley2 3 2 0 14195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleydifferent words. The main trick is to remember that 14295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleyt=((l>>size)^r)&(mask); 14395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleyr^=t; 14495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleyl^=(t<<size); 14595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleycan be used to swap and move bits between words. 14695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 14795c29f3cd1f6c08c6c0927868683392eea727ccAdam LangleySo l = 0 1 2 3 r = 16 17 18 19 14895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 4 5 6 7 20 21 22 23 14995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 8 9 10 11 24 25 26 27 15095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 12 13 14 15 28 29 30 31 15195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleybecomes (for size == 2 and mask == 0x3333) 15295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley t = 2^16 3^17 -- -- l = 0 1 16 17 r = 2 3 18 19 15395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 6^20 7^21 -- -- 4 5 20 21 6 7 22 23 15495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 10^24 11^25 -- -- 8 9 24 25 10 11 24 25 15595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 14^28 15^29 -- -- 12 13 28 29 14 15 28 29 15695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 15795c29f3cd1f6c08c6c0927868683392eea727ccAdam LangleyThanks for hints from Richard Outerbridge - he told me IP&FP 15895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleycould be done in 15 xor, 10 shifts and 5 ands. 15995c29f3cd1f6c08c6c0927868683392eea727ccAdam LangleyWhen I finally started to think of the problem in 2D 16095c29f3cd1f6c08c6c0927868683392eea727ccAdam LangleyI first got ~42 operations without xors. When I remembered 16195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langleyhow to use xors :-) I got it to its final state. 16295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley*/ 16395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#define PERM_OP(a, b, t, n, m) \ 16495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley ((t) = ((((a) >> (n)) ^ (b)) & (m)), (b) ^= (t), (a) ^= ((t) << (n))) 16595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 16695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#define IP(l, r) \ 16795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley { \ 16895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley uint32_t tt; \ 16995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley PERM_OP(r, l, tt, 4, 0x0f0f0f0fL); \ 17095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley PERM_OP(l, r, tt, 16, 0x0000ffffL); \ 17195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley PERM_OP(r, l, tt, 2, 0x33333333L); \ 17295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley PERM_OP(l, r, tt, 8, 0x00ff00ffL); \ 17395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley PERM_OP(r, l, tt, 1, 0x55555555L); \ 17495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley } 17595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 17695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#define FP(l, r) \ 17795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley { \ 17895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley uint32_t tt; \ 17995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley PERM_OP(l, r, tt, 1, 0x55555555L); \ 18095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley PERM_OP(r, l, tt, 8, 0x00ff00ffL); \ 18195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley PERM_OP(l, r, tt, 2, 0x33333333L); \ 18295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley PERM_OP(r, l, tt, 16, 0x0000ffffL); \ 18395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley PERM_OP(l, r, tt, 4, 0x0f0f0f0fL); \ 18495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley } 18595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 18695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#define LOAD_DATA(R, S, u, t, E0, E1) \ 18795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley u = R ^ s[S]; \ 18895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley t = R ^ s[S + 1] 18995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 19095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#define D_ENCRYPT(LL, R, S) \ 19195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley { \ 19295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley LOAD_DATA(R, S, u, t, E0, E1); \ 19395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley t = ROTATE(t, 4); \ 19495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley LL ^= \ 19595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley DES_SPtrans[0][(u >> 2L) & 0x3f] ^ DES_SPtrans[2][(u >> 10L) & 0x3f] ^ \ 19695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley DES_SPtrans[4][(u >> 18L) & 0x3f] ^ \ 19795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley DES_SPtrans[6][(u >> 26L) & 0x3f] ^ DES_SPtrans[1][(t >> 2L) & 0x3f] ^ \ 19895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley DES_SPtrans[3][(t >> 10L) & 0x3f] ^ \ 19995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley DES_SPtrans[5][(t >> 18L) & 0x3f] ^ DES_SPtrans[7][(t >> 26L) & 0x3f]; \ 20095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley } 20195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 20295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#define ITERATIONS 16 20395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#define HALF_ITERATIONS 8 20495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 20595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#if defined(_MSC_VER) 20695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#define ROTATE(a, n) (_lrotr(a, n)) 20795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#elif defined(__ICC) 20895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#define ROTATE(a, n) (_rotr(a, n)) 20995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#elif defined(__GNUC__) && __GNUC__ >= 2 && !defined(OPENSSL_NO_ASM) && \ 21095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley !defined(__STRICT_ANSI__) && \ 21195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley (defined(OPENSSL_X86) || defined(OPENSSL_X86_64)) 21295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#define ROTATE(a, n) \ 21395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley ({ \ 21495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley unsigned int ret; \ 21595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley asm("rorl %1,%0" : "=r"(ret) : "I"(n), "0"(a) : "cc"); \ 21695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley ret; \ 21795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley }) 21895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#endif 21995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 22095c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#ifndef ROTATE 22195c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#define ROTATE(a, n) (((a) >> (n)) + ((a) << (32 - (n)))) 22295c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#endif 22395c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 22495c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 22595c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#if defined(__cplusplus) 22695c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley} /* extern C */ 22795c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#endif 22895c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley 22995c29f3cd1f6c08c6c0927868683392eea727ccAdam Langley#endif /* OPENSSL_HEADER_DES_INTERNAL_H */ 230