ReactOS 0.4.17-dev-1005-g171e1de
DesTables.c
Go to the documentation of this file.
1//
2// DesTables.c static lookup tables for DES
3//
4// Copyright (c) Microsoft Corporation. Licensed under the MIT license.
5//
6//
7// These tables were copies
8// from the RSA32 DES implementation. See 3des.c for details.
9//
10
11#include "precomp.h"
12
13//
14// Alignments are chosen to reduce side-channel attacks through the TLB cache.
15// We align each table to a multiple of the size within which we do data-dependent
16// lookups. For example, the table below is aligned to 256. It is not a secret
17// that the 8 sub-tables are accessed, but which value inside each sub-table is a secret.
18// Aligning to 256 still leaves the data cache line leakage, but avoids any TLB-related leakage.
19//
20SYMCRYPT_ALIGN_AT( 256 ) const UINT32 SymCryptDesSpbox[8][64] = {
210x02080800,0x00080000,0x02000002,0x02080802,
220x02000000,0x00080802,0x00080002,0x02000002,
230x00080802,0x02080800,0x02080000,0x00000802,
240x02000802,0x02000000,0x00000000,0x00080002,
250x00080000,0x00000002,0x02000800,0x00080800,
260x02080802,0x02080000,0x00000802,0x02000800,
270x00000002,0x00000800,0x00080800,0x02080002,
280x00000800,0x02000802,0x02080002,0x00000000,
290x00000000,0x02080802,0x02000800,0x00080002,
300x02080800,0x00080000,0x00000802,0x02000800,
310x02080002,0x00000800,0x00080800,0x02000002,
320x00080802,0x00000002,0x02000002,0x02080000,
330x02080802,0x00080800,0x02080000,0x02000802,
340x02000000,0x00000802,0x00080002,0x00000000,
350x00080000,0x02000000,0x02000802,0x02080800,
360x00000002,0x02080002,0x00000800,0x00080802,
370x40108010,0x00000000,0x00108000,0x40100000,
380x40000010,0x00008010,0x40008000,0x00108000,
390x00008000,0x40100010,0x00000010,0x40008000,
400x00100010,0x40108000,0x40100000,0x00000010,
410x00100000,0x40008010,0x40100010,0x00008000,
420x00108010,0x40000000,0x00000000,0x00100010,
430x40008010,0x00108010,0x40108000,0x40000010,
440x40000000,0x00100000,0x00008010,0x40108010,
450x00100010,0x40108000,0x40008000,0x00108010,
460x40108010,0x00100010,0x40000010,0x00000000,
470x40000000,0x00008010,0x00100000,0x40100010,
480x00008000,0x40000000,0x00108010,0x40008010,
490x40108000,0x00008000,0x00000000,0x40000010,
500x00000010,0x40108010,0x00108000,0x40100000,
510x40100010,0x00100000,0x00008010,0x40008000,
520x40008010,0x00000010,0x40100000,0x00108000,
530x04000001,0x04040100,0x00000100,0x04000101,
540x00040001,0x04000000,0x04000101,0x00040100,
550x04000100,0x00040000,0x04040000,0x00000001,
560x04040101,0x00000101,0x00000001,0x04040001,
570x00000000,0x00040001,0x04040100,0x00000100,
580x00000101,0x04040101,0x00040000,0x04000001,
590x04040001,0x04000100,0x00040101,0x04040000,
600x00040100,0x00000000,0x04000000,0x00040101,
610x04040100,0x00000100,0x00000001,0x00040000,
620x00000101,0x00040001,0x04040000,0x04000101,
630x00000000,0x04040100,0x00040100,0x04040001,
640x00040001,0x04000000,0x04040101,0x00000001,
650x00040101,0x04000001,0x04000000,0x04040101,
660x00040000,0x04000100,0x04000101,0x00040100,
670x04000100,0x00000000,0x04040001,0x00000101,
680x04000001,0x00040101,0x00000100,0x04040000,
690x00401008,0x10001000,0x00000008,0x10401008,
700x00000000,0x10400000,0x10001008,0x00400008,
710x10401000,0x10000008,0x10000000,0x00001008,
720x10000008,0x00401008,0x00400000,0x10000000,
730x10400008,0x00401000,0x00001000,0x00000008,
740x00401000,0x10001008,0x10400000,0x00001000,
750x00001008,0x00000000,0x00400008,0x10401000,
760x10001000,0x10400008,0x10401008,0x00400000,
770x10400008,0x00001008,0x00400000,0x10000008,
780x00401000,0x10001000,0x00000008,0x10400000,
790x10001008,0x00000000,0x00001000,0x00400008,
800x00000000,0x10400008,0x10401000,0x00001000,
810x10000000,0x10401008,0x00401008,0x00400000,
820x10401008,0x00000008,0x10001000,0x00401008,
830x00400008,0x00401000,0x10400000,0x10001008,
840x00001008,0x10000000,0x10000008,0x10401000,
850x08000000,0x00010000,0x00000400,0x08010420,
860x08010020,0x08000400,0x00010420,0x08010000,
870x00010000,0x00000020,0x08000020,0x00010400,
880x08000420,0x08010020,0x08010400,0x00000000,
890x00010400,0x08000000,0x00010020,0x00000420,
900x08000400,0x00010420,0x00000000,0x08000020,
910x00000020,0x08000420,0x08010420,0x00010020,
920x08010000,0x00000400,0x00000420,0x08010400,
930x08010400,0x08000420,0x00010020,0x08010000,
940x00010000,0x00000020,0x08000020,0x08000400,
950x08000000,0x00010400,0x08010420,0x00000000,
960x00010420,0x08000000,0x00000400,0x00010020,
970x08000420,0x00000400,0x00000000,0x08010420,
980x08010020,0x08010400,0x00000420,0x00010000,
990x00010400,0x08010020,0x08000400,0x00000420,
1000x00000020,0x00010420,0x08010000,0x08000020,
1010x80000040,0x00200040,0x00000000,0x80202000,
1020x00200040,0x00002000,0x80002040,0x00200000,
1030x00002040,0x80202040,0x00202000,0x80000000,
1040x80002000,0x80000040,0x80200000,0x00202040,
1050x00200000,0x80002040,0x80200040,0x00000000,
1060x00002000,0x00000040,0x80202000,0x80200040,
1070x80202040,0x80200000,0x80000000,0x00002040,
1080x00000040,0x00202000,0x00202040,0x80002000,
1090x00002040,0x80000000,0x80002000,0x00202040,
1100x80202000,0x00200040,0x00000000,0x80002000,
1110x80000000,0x00002000,0x80200040,0x00200000,
1120x00200040,0x80202040,0x00202000,0x00000040,
1130x80202040,0x00202000,0x00200000,0x80002040,
1140x80000040,0x80200000,0x00202040,0x00000000,
1150x00002000,0x80000040,0x80002040,0x80202000,
1160x80200000,0x00002040,0x00000040,0x80200040,
1170x00004000,0x00000200,0x01000200,0x01000004,
1180x01004204,0x00004004,0x00004200,0x00000000,
1190x01000000,0x01000204,0x00000204,0x01004000,
1200x00000004,0x01004200,0x01004000,0x00000204,
1210x01000204,0x00004000,0x00004004,0x01004204,
1220x00000000,0x01000200,0x01000004,0x00004200,
1230x01004004,0x00004204,0x01004200,0x00000004,
1240x00004204,0x01004004,0x00000200,0x01000000,
1250x00004204,0x01004000,0x01004004,0x00000204,
1260x00004000,0x00000200,0x01000000,0x01004004,
1270x01000204,0x00004204,0x00004200,0x00000000,
1280x00000200,0x01000004,0x00000004,0x01000200,
1290x00000000,0x01000204,0x01000200,0x00004200,
1300x00000204,0x00004000,0x01004204,0x01000000,
1310x01004200,0x00000004,0x00004004,0x01004204,
1320x01000004,0x01004200,0x01004000,0x00004004,
1330x20800080,0x20820000,0x00020080,0x00000000,
1340x20020000,0x00800080,0x20800000,0x20820080,
1350x00000080,0x20000000,0x00820000,0x00020080,
1360x00820080,0x20020080,0x20000080,0x20800000,
1370x00020000,0x00820080,0x00800080,0x20020000,
1380x20820080,0x20000080,0x00000000,0x00820000,
1390x20000000,0x00800000,0x20020080,0x20800080,
1400x00800000,0x00020000,0x20820000,0x00000080,
1410x00800000,0x00020000,0x20000080,0x20820080,
1420x00020080,0x20000000,0x00000000,0x00820000,
1430x20800080,0x20020080,0x20020000,0x00800080,
1440x20820000,0x00000080,0x00800080,0x20020000,
1450x20820080,0x00800000,0x20800000,0x20000080,
1460x00820000,0x00020080,0x20020080,0x20800000,
1470x00000080,0x20820000,0x00820080,0x00000000,
1480x20000000,0x20800080,0x00020000,0x00820080,
149};
150
151SYMCRYPT_ALIGN_AT(256) const UINT32 SymCryptDesKeySelect[8][64]={
1520x00000000,0x00000010,0x20000000,0x20000010,
1530x00010000,0x00010010,0x20010000,0x20010010,
1540x00000800,0x00000810,0x20000800,0x20000810,
1550x00010800,0x00010810,0x20010800,0x20010810,
1560x00000020,0x00000030,0x20000020,0x20000030,
1570x00010020,0x00010030,0x20010020,0x20010030,
1580x00000820,0x00000830,0x20000820,0x20000830,
1590x00010820,0x00010830,0x20010820,0x20010830,
1600x00080000,0x00080010,0x20080000,0x20080010,
1610x00090000,0x00090010,0x20090000,0x20090010,
1620x00080800,0x00080810,0x20080800,0x20080810,
1630x00090800,0x00090810,0x20090800,0x20090810,
1640x00080020,0x00080030,0x20080020,0x20080030,
1650x00090020,0x00090030,0x20090020,0x20090030,
1660x00080820,0x00080830,0x20080820,0x20080830,
1670x00090820,0x00090830,0x20090820,0x20090830,
1680x00000000,0x02000000,0x00002000,0x02002000,
1690x00200000,0x02200000,0x00202000,0x02202000,
1700x00000004,0x02000004,0x00002004,0x02002004,
1710x00200004,0x02200004,0x00202004,0x02202004,
1720x00000400,0x02000400,0x00002400,0x02002400,
1730x00200400,0x02200400,0x00202400,0x02202400,
1740x00000404,0x02000404,0x00002404,0x02002404,
1750x00200404,0x02200404,0x00202404,0x02202404,
1760x10000000,0x12000000,0x10002000,0x12002000,
1770x10200000,0x12200000,0x10202000,0x12202000,
1780x10000004,0x12000004,0x10002004,0x12002004,
1790x10200004,0x12200004,0x10202004,0x12202004,
1800x10000400,0x12000400,0x10002400,0x12002400,
1810x10200400,0x12200400,0x10202400,0x12202400,
1820x10000404,0x12000404,0x10002404,0x12002404,
1830x10200404,0x12200404,0x10202404,0x12202404,
1840x00000000,0x00000001,0x00040000,0x00040001,
1850x01000000,0x01000001,0x01040000,0x01040001,
1860x00000002,0x00000003,0x00040002,0x00040003,
1870x01000002,0x01000003,0x01040002,0x01040003,
1880x00000200,0x00000201,0x00040200,0x00040201,
1890x01000200,0x01000201,0x01040200,0x01040201,
1900x00000202,0x00000203,0x00040202,0x00040203,
1910x01000202,0x01000203,0x01040202,0x01040203,
1920x08000000,0x08000001,0x08040000,0x08040001,
1930x09000000,0x09000001,0x09040000,0x09040001,
1940x08000002,0x08000003,0x08040002,0x08040003,
1950x09000002,0x09000003,0x09040002,0x09040003,
1960x08000200,0x08000201,0x08040200,0x08040201,
1970x09000200,0x09000201,0x09040200,0x09040201,
1980x08000202,0x08000203,0x08040202,0x08040203,
1990x09000202,0x09000203,0x09040202,0x09040203,
2000x00000000,0x00100000,0x00000100,0x00100100,
2010x00000008,0x00100008,0x00000108,0x00100108,
2020x00001000,0x00101000,0x00001100,0x00101100,
2030x00001008,0x00101008,0x00001108,0x00101108,
2040x04000000,0x04100000,0x04000100,0x04100100,
2050x04000008,0x04100008,0x04000108,0x04100108,
2060x04001000,0x04101000,0x04001100,0x04101100,
2070x04001008,0x04101008,0x04001108,0x04101108,
2080x00020000,0x00120000,0x00020100,0x00120100,
2090x00020008,0x00120008,0x00020108,0x00120108,
2100x00021000,0x00121000,0x00021100,0x00121100,
2110x00021008,0x00121008,0x00021108,0x00121108,
2120x04020000,0x04120000,0x04020100,0x04120100,
2130x04020008,0x04120008,0x04020108,0x04120108,
2140x04021000,0x04121000,0x04021100,0x04121100,
2150x04021008,0x04121008,0x04021108,0x04121108,
2160x00000000,0x10000000,0x00010000,0x10010000,
2170x00000004,0x10000004,0x00010004,0x10010004,
2180x20000000,0x30000000,0x20010000,0x30010000,
2190x20000004,0x30000004,0x20010004,0x30010004,
2200x00100000,0x10100000,0x00110000,0x10110000,
2210x00100004,0x10100004,0x00110004,0x10110004,
2220x20100000,0x30100000,0x20110000,0x30110000,
2230x20100004,0x30100004,0x20110004,0x30110004,
2240x00001000,0x10001000,0x00011000,0x10011000,
2250x00001004,0x10001004,0x00011004,0x10011004,
2260x20001000,0x30001000,0x20011000,0x30011000,
2270x20001004,0x30001004,0x20011004,0x30011004,
2280x00101000,0x10101000,0x00111000,0x10111000,
2290x00101004,0x10101004,0x00111004,0x10111004,
2300x20101000,0x30101000,0x20111000,0x30111000,
2310x20101004,0x30101004,0x20111004,0x30111004,
2320x00000000,0x08000000,0x00000008,0x08000008,
2330x00000400,0x08000400,0x00000408,0x08000408,
2340x00020000,0x08020000,0x00020008,0x08020008,
2350x00020400,0x08020400,0x00020408,0x08020408,
2360x00000001,0x08000001,0x00000009,0x08000009,
2370x00000401,0x08000401,0x00000409,0x08000409,
2380x00020001,0x08020001,0x00020009,0x08020009,
2390x00020401,0x08020401,0x00020409,0x08020409,
2400x02000000,0x0A000000,0x02000008,0x0A000008,
2410x02000400,0x0A000400,0x02000408,0x0A000408,
2420x02020000,0x0A020000,0x02020008,0x0A020008,
2430x02020400,0x0A020400,0x02020408,0x0A020408,
2440x02000001,0x0A000001,0x02000009,0x0A000009,
2450x02000401,0x0A000401,0x02000409,0x0A000409,
2460x02020001,0x0A020001,0x02020009,0x0A020009,
2470x02020401,0x0A020401,0x02020409,0x0A020409,
2480x00000000,0x00000100,0x00080000,0x00080100,
2490x01000000,0x01000100,0x01080000,0x01080100,
2500x00000010,0x00000110,0x00080010,0x00080110,
2510x01000010,0x01000110,0x01080010,0x01080110,
2520x00200000,0x00200100,0x00280000,0x00280100,
2530x01200000,0x01200100,0x01280000,0x01280100,
2540x00200010,0x00200110,0x00280010,0x00280110,
2550x01200010,0x01200110,0x01280010,0x01280110,
2560x00000200,0x00000300,0x00080200,0x00080300,
2570x01000200,0x01000300,0x01080200,0x01080300,
2580x00000210,0x00000310,0x00080210,0x00080310,
2590x01000210,0x01000310,0x01080210,0x01080310,
2600x00200200,0x00200300,0x00280200,0x00280300,
2610x01200200,0x01200300,0x01280200,0x01280300,
2620x00200210,0x00200310,0x00280210,0x00280310,
2630x01200210,0x01200310,0x01280210,0x01280310,
2640x00000000,0x04000000,0x00040000,0x04040000,
2650x00000002,0x04000002,0x00040002,0x04040002,
2660x00002000,0x04002000,0x00042000,0x04042000,
2670x00002002,0x04002002,0x00042002,0x04042002,
2680x00000020,0x04000020,0x00040020,0x04040020,
2690x00000022,0x04000022,0x00040022,0x04040022,
2700x00002020,0x04002020,0x00042020,0x04042020,
2710x00002022,0x04002022,0x00042022,0x04042022,
2720x00000800,0x04000800,0x00040800,0x04040800,
2730x00000802,0x04000802,0x00040802,0x04040802,
2740x00002800,0x04002800,0x00042800,0x04042800,
2750x00002802,0x04002802,0x00042802,0x04042802,
2760x00000820,0x04000820,0x00040820,0x04040820,
2770x00000822,0x04000822,0x00040822,0x04040822,
2780x00002820,0x04002820,0x00042820,0x04042820,
2790x00002822,0x04002822,0x00042822,0x04042822,
280};
#define SYMCRYPT_ALIGN_AT(alignment)
uint32_t UINT32
Definition: typedefs.h:59
#define const
Definition: zconf.h:233