Wraphelp.c revision 862f5301
1ff559fabSmrg#ifdef HAVE_CONFIG_H 2ff559fabSmrg#include <config.h> 3ff559fabSmrg#endif 4ff559fabSmrg#include <sys/types.h> 5ff559fabSmrg#include <X11/Xmd.h> 6ff559fabSmrg#include "Wrap.h" 7ff559fabSmrg 8ff559fabSmrg/* des routines for non-usa - eay 10/9/1991 eay@psych.psy.uq.oz.au 9ff559fabSmrg * These routines were written for speed not size so they are bigger than 10ff559fabSmrg * needed. I have removed some of the loop unrolling, this will reduce 11ff559fabSmrg * code size at the expense of some speed. 12ff559fabSmrg * 25/9/1991 eay - much faster _XdmcpAuthSetup (4 times faster). 13ff559fabSmrg * 19/9/1991 eay - cleaned up the IP and FP code. 14ff559fabSmrg * 10/9/1991 eay - first release. 15ff559fabSmrg * The des routines this file has been made from can be found in 16ff559fabSmrg * ftp.psy.uq.oz.au /pub/DES 17ff559fabSmrg * This particular version derived from OpenBSD Revsion 1.3. 18ff559fabSmrg */ 19ff559fabSmrg 20ff559fabSmrg/* 21ff559fabSmrg * 22ff559fabSmrg * Export Requirements. 23ff559fabSmrg * You may not export or re-export this software or any copy or 24ff559fabSmrg * adaptation in violation of any applicable laws or regulations. 25ff559fabSmrg * 26ff559fabSmrg * Without limiting the generality of the foregoing, hardware, software, 27ff559fabSmrg * technology or services provided under this license agreement may not 28ff559fabSmrg * be exported, reexported, transferred or downloaded to or within (or to 29ff559fabSmrg * a national resident of) countries under U.S. economic embargo 30ff559fabSmrg * including the following countries: 31ff559fabSmrg * 32ff559fabSmrg * Cuba, Iran, Libya, North Korea, Sudan and Syria. This list is subject 33ff559fabSmrg * to change. 34ff559fabSmrg * 35ff559fabSmrg * Hardware, software, technology or services may not be exported, 36ff559fabSmrg * reexported, transferred or downloaded to persons or entities listed on 37ff559fabSmrg * the U.S. Department of Commerce Denied Persons List, Entity List of 38ff559fabSmrg * proliferation concern or on any U.S. Treasury Department Designated 39ff559fabSmrg * Nationals exclusion list, or to parties directly or indirectly 40ff559fabSmrg * involved in the development or production of nuclear, chemical, 41ff559fabSmrg * biological weapons or in missile technology programs as specified in 42ff559fabSmrg * the U.S. Export Administration Regulations (15 CFR 744). 43ff559fabSmrg * 44ff559fabSmrg * By accepting this license agreement you confirm that you are not 45ff559fabSmrg * located in (or a national resident of) any country under U.S. economic 46ff559fabSmrg * embargo, not identified on any U.S. Department of Commerce Denied 47ff559fabSmrg * Persons List, Entity List or Treasury Department Designated Nationals 48ff559fabSmrg * exclusion list, and not directly or indirectly involved in the 49ff559fabSmrg * development or production of nuclear, chemical, biological weapons or 50ff559fabSmrg * in missile technology programs as specified in the U.S. Export 51ff559fabSmrg * Administration Regulations. 52862f5301Smrg * 53862f5301Smrg * 54ff559fabSmrg * Local Country Import Requirements. The software you are about to 55ff559fabSmrg * download contains cryptography technology. Some countries regulate the 56ff559fabSmrg * import, use and/or export of certain products with cryptography. The 57ff559fabSmrg * X.org Foundation makes no claims as to the applicability of local 58ff559fabSmrg * country import, use and/or export regulations in relation to the 59ff559fabSmrg * download of this product. If you are located outside the U.S. and 60ff559fabSmrg * Canada you are advised to consult your local country regulations to 61ff559fabSmrg * insure compliance. 62ff559fabSmrg */ 63ff559fabSmrg 64ff559fabSmrgstatic const CARD32 skb[8][64] = { 65ff559fabSmrg /* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ 66ff559fabSmrg { 0x00000000,0x00000010,0x20000000,0x20000010, 67ff559fabSmrg 0x00010000,0x00010010,0x20010000,0x20010010, 68ff559fabSmrg 0x00000800,0x00000810,0x20000800,0x20000810, 69ff559fabSmrg 0x00010800,0x00010810,0x20010800,0x20010810, 70ff559fabSmrg 0x00000020,0x00000030,0x20000020,0x20000030, 71ff559fabSmrg 0x00010020,0x00010030,0x20010020,0x20010030, 72ff559fabSmrg 0x00000820,0x00000830,0x20000820,0x20000830, 73ff559fabSmrg 0x00010820,0x00010830,0x20010820,0x20010830, 74ff559fabSmrg 0x00080000,0x00080010,0x20080000,0x20080010, 75ff559fabSmrg 0x00090000,0x00090010,0x20090000,0x20090010, 76ff559fabSmrg 0x00080800,0x00080810,0x20080800,0x20080810, 77ff559fabSmrg 0x00090800,0x00090810,0x20090800,0x20090810, 78ff559fabSmrg 0x00080020,0x00080030,0x20080020,0x20080030, 79ff559fabSmrg 0x00090020,0x00090030,0x20090020,0x20090030, 80ff559fabSmrg 0x00080820,0x00080830,0x20080820,0x20080830, 81ff559fabSmrg 0x00090820,0x00090830,0x20090820,0x20090830 }, 82ff559fabSmrg /* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */ 83ff559fabSmrg { 0x00000000,0x02000000,0x00002000,0x02002000, 84ff559fabSmrg 0x00200000,0x02200000,0x00202000,0x02202000, 85ff559fabSmrg 0x00000004,0x02000004,0x00002004,0x02002004, 86ff559fabSmrg 0x00200004,0x02200004,0x00202004,0x02202004, 87ff559fabSmrg 0x00000400,0x02000400,0x00002400,0x02002400, 88ff559fabSmrg 0x00200400,0x02200400,0x00202400,0x02202400, 89ff559fabSmrg 0x00000404,0x02000404,0x00002404,0x02002404, 90ff559fabSmrg 0x00200404,0x02200404,0x00202404,0x02202404, 91ff559fabSmrg 0x10000000,0x12000000,0x10002000,0x12002000, 92ff559fabSmrg 0x10200000,0x12200000,0x10202000,0x12202000, 93ff559fabSmrg 0x10000004,0x12000004,0x10002004,0x12002004, 94ff559fabSmrg 0x10200004,0x12200004,0x10202004,0x12202004, 95ff559fabSmrg 0x10000400,0x12000400,0x10002400,0x12002400, 96ff559fabSmrg 0x10200400,0x12200400,0x10202400,0x12202400, 97ff559fabSmrg 0x10000404,0x12000404,0x10002404,0x12002404, 98ff559fabSmrg 0x10200404,0x12200404,0x10202404,0x12202404 }, 99ff559fabSmrg /* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */ 100ff559fabSmrg { 0x00000000,0x00000001,0x00040000,0x00040001, 101ff559fabSmrg 0x01000000,0x01000001,0x01040000,0x01040001, 102ff559fabSmrg 0x00000002,0x00000003,0x00040002,0x00040003, 103ff559fabSmrg 0x01000002,0x01000003,0x01040002,0x01040003, 104ff559fabSmrg 0x00000200,0x00000201,0x00040200,0x00040201, 105ff559fabSmrg 0x01000200,0x01000201,0x01040200,0x01040201, 106ff559fabSmrg 0x00000202,0x00000203,0x00040202,0x00040203, 107ff559fabSmrg 0x01000202,0x01000203,0x01040202,0x01040203, 108ff559fabSmrg 0x08000000,0x08000001,0x08040000,0x08040001, 109ff559fabSmrg 0x09000000,0x09000001,0x09040000,0x09040001, 110ff559fabSmrg 0x08000002,0x08000003,0x08040002,0x08040003, 111ff559fabSmrg 0x09000002,0x09000003,0x09040002,0x09040003, 112ff559fabSmrg 0x08000200,0x08000201,0x08040200,0x08040201, 113ff559fabSmrg 0x09000200,0x09000201,0x09040200,0x09040201, 114ff559fabSmrg 0x08000202,0x08000203,0x08040202,0x08040203, 115ff559fabSmrg 0x09000202,0x09000203,0x09040202,0x09040203 }, 116ff559fabSmrg /* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */ 117ff559fabSmrg { 0x00000000,0x00100000,0x00000100,0x00100100, 118ff559fabSmrg 0x00000008,0x00100008,0x00000108,0x00100108, 119ff559fabSmrg 0x00001000,0x00101000,0x00001100,0x00101100, 120ff559fabSmrg 0x00001008,0x00101008,0x00001108,0x00101108, 121ff559fabSmrg 0x04000000,0x04100000,0x04000100,0x04100100, 122ff559fabSmrg 0x04000008,0x04100008,0x04000108,0x04100108, 123ff559fabSmrg 0x04001000,0x04101000,0x04001100,0x04101100, 124ff559fabSmrg 0x04001008,0x04101008,0x04001108,0x04101108, 125ff559fabSmrg 0x00020000,0x00120000,0x00020100,0x00120100, 126ff559fabSmrg 0x00020008,0x00120008,0x00020108,0x00120108, 127ff559fabSmrg 0x00021000,0x00121000,0x00021100,0x00121100, 128ff559fabSmrg 0x00021008,0x00121008,0x00021108,0x00121108, 129ff559fabSmrg 0x04020000,0x04120000,0x04020100,0x04120100, 130ff559fabSmrg 0x04020008,0x04120008,0x04020108,0x04120108, 131ff559fabSmrg 0x04021000,0x04121000,0x04021100,0x04121100, 132ff559fabSmrg 0x04021008,0x04121008,0x04021108,0x04121108 }, 133ff559fabSmrg /* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ 134ff559fabSmrg { 0x00000000,0x10000000,0x00010000,0x10010000, 135ff559fabSmrg 0x00000004,0x10000004,0x00010004,0x10010004, 136ff559fabSmrg 0x20000000,0x30000000,0x20010000,0x30010000, 137ff559fabSmrg 0x20000004,0x30000004,0x20010004,0x30010004, 138ff559fabSmrg 0x00100000,0x10100000,0x00110000,0x10110000, 139ff559fabSmrg 0x00100004,0x10100004,0x00110004,0x10110004, 140ff559fabSmrg 0x20100000,0x30100000,0x20110000,0x30110000, 141ff559fabSmrg 0x20100004,0x30100004,0x20110004,0x30110004, 142ff559fabSmrg 0x00001000,0x10001000,0x00011000,0x10011000, 143ff559fabSmrg 0x00001004,0x10001004,0x00011004,0x10011004, 144ff559fabSmrg 0x20001000,0x30001000,0x20011000,0x30011000, 145ff559fabSmrg 0x20001004,0x30001004,0x20011004,0x30011004, 146ff559fabSmrg 0x00101000,0x10101000,0x00111000,0x10111000, 147ff559fabSmrg 0x00101004,0x10101004,0x00111004,0x10111004, 148ff559fabSmrg 0x20101000,0x30101000,0x20111000,0x30111000, 149ff559fabSmrg 0x20101004,0x30101004,0x20111004,0x30111004 }, 150ff559fabSmrg /* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */ 151ff559fabSmrg { 0x00000000,0x08000000,0x00000008,0x08000008, 152ff559fabSmrg 0x00000400,0x08000400,0x00000408,0x08000408, 153ff559fabSmrg 0x00020000,0x08020000,0x00020008,0x08020008, 154ff559fabSmrg 0x00020400,0x08020400,0x00020408,0x08020408, 155ff559fabSmrg 0x00000001,0x08000001,0x00000009,0x08000009, 156ff559fabSmrg 0x00000401,0x08000401,0x00000409,0x08000409, 157ff559fabSmrg 0x00020001,0x08020001,0x00020009,0x08020009, 158ff559fabSmrg 0x00020401,0x08020401,0x00020409,0x08020409, 159ff559fabSmrg 0x02000000,0x0A000000,0x02000008,0x0A000008, 160ff559fabSmrg 0x02000400,0x0A000400,0x02000408,0x0A000408, 161ff559fabSmrg 0x02020000,0x0A020000,0x02020008,0x0A020008, 162ff559fabSmrg 0x02020400,0x0A020400,0x02020408,0x0A020408, 163ff559fabSmrg 0x02000001,0x0A000001,0x02000009,0x0A000009, 164ff559fabSmrg 0x02000401,0x0A000401,0x02000409,0x0A000409, 165ff559fabSmrg 0x02020001,0x0A020001,0x02020009,0x0A020009, 166ff559fabSmrg 0x02020401,0x0A020401,0x02020409,0x0A020409 }, 167ff559fabSmrg /* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */ 168ff559fabSmrg { 0x00000000,0x00000100,0x00080000,0x00080100, 169ff559fabSmrg 0x01000000,0x01000100,0x01080000,0x01080100, 170ff559fabSmrg 0x00000010,0x00000110,0x00080010,0x00080110, 171ff559fabSmrg 0x01000010,0x01000110,0x01080010,0x01080110, 172ff559fabSmrg 0x00200000,0x00200100,0x00280000,0x00280100, 173ff559fabSmrg 0x01200000,0x01200100,0x01280000,0x01280100, 174ff559fabSmrg 0x00200010,0x00200110,0x00280010,0x00280110, 175ff559fabSmrg 0x01200010,0x01200110,0x01280010,0x01280110, 176ff559fabSmrg 0x00000200,0x00000300,0x00080200,0x00080300, 177ff559fabSmrg 0x01000200,0x01000300,0x01080200,0x01080300, 178ff559fabSmrg 0x00000210,0x00000310,0x00080210,0x00080310, 179ff559fabSmrg 0x01000210,0x01000310,0x01080210,0x01080310, 180ff559fabSmrg 0x00200200,0x00200300,0x00280200,0x00280300, 181ff559fabSmrg 0x01200200,0x01200300,0x01280200,0x01280300, 182ff559fabSmrg 0x00200210,0x00200310,0x00280210,0x00280310, 183ff559fabSmrg 0x01200210,0x01200310,0x01280210,0x01280310 }, 184ff559fabSmrg /* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */ 185ff559fabSmrg { 0x00000000,0x04000000,0x00040000,0x04040000, 186ff559fabSmrg 0x00000002,0x04000002,0x00040002,0x04040002, 187ff559fabSmrg 0x00002000,0x04002000,0x00042000,0x04042000, 188ff559fabSmrg 0x00002002,0x04002002,0x00042002,0x04042002, 189ff559fabSmrg 0x00000020,0x04000020,0x00040020,0x04040020, 190ff559fabSmrg 0x00000022,0x04000022,0x00040022,0x04040022, 191ff559fabSmrg 0x00002020,0x04002020,0x00042020,0x04042020, 192ff559fabSmrg 0x00002022,0x04002022,0x00042022,0x04042022, 193ff559fabSmrg 0x00000800,0x04000800,0x00040800,0x04040800, 194ff559fabSmrg 0x00000802,0x04000802,0x00040802,0x04040802, 195ff559fabSmrg 0x00002800,0x04002800,0x00042800,0x04042800, 196ff559fabSmrg 0x00002802,0x04002802,0x00042802,0x04042802, 197ff559fabSmrg 0x00000820,0x04000820,0x00040820,0x04040820, 198ff559fabSmrg 0x00000822,0x04000822,0x00040822,0x04040822, 199ff559fabSmrg 0x00002820,0x04002820,0x00042820,0x04042820, 200ff559fabSmrg 0x00002822,0x04002822,0x00042822,0x04042822 } 201ff559fabSmrg}; 202ff559fabSmrg 203ff559fabSmrg 204ff559fabSmrgstatic const CARD32 SPtrans[8][64] = { 205ff559fabSmrg /* nibble 0 */ 206ff559fabSmrg { 0x00410100, 0x00010000, 0x40400000, 0x40410100, 207ff559fabSmrg 0x00400000, 0x40010100, 0x40010000, 0x40400000, 208ff559fabSmrg 0x40010100, 0x00410100, 0x00410000, 0x40000100, 209ff559fabSmrg 0x40400100, 0x00400000, 0x00000000, 0x40010000, 210ff559fabSmrg 0x00010000, 0x40000000, 0x00400100, 0x00010100, 211ff559fabSmrg 0x40410100, 0x00410000, 0x40000100, 0x00400100, 212ff559fabSmrg 0x40000000, 0x00000100, 0x00010100, 0x40410000, 213ff559fabSmrg 0x00000100, 0x40400100, 0x40410000, 0x00000000, 214ff559fabSmrg 0x00000000, 0x40410100, 0x00400100, 0x40010000, 215ff559fabSmrg 0x00410100, 0x00010000, 0x40000100, 0x00400100, 216ff559fabSmrg 0x40410000, 0x00000100, 0x00010100, 0x40400000, 217ff559fabSmrg 0x40010100, 0x40000000, 0x40400000, 0x00410000, 218ff559fabSmrg 0x40410100, 0x00010100, 0x00410000, 0x40400100, 219ff559fabSmrg 0x00400000, 0x40000100, 0x40010000, 0x00000000, 220ff559fabSmrg 0x00010000, 0x00400000, 0x40400100, 0x00410100, 221ff559fabSmrg 0x40000000, 0x40410000, 0x00000100, 0x40010100 }, 222ff559fabSmrg 223ff559fabSmrg /* nibble 1 */ 224ff559fabSmrg { 0x08021002, 0x00000000, 0x00021000, 0x08020000, 225ff559fabSmrg 0x08000002, 0x00001002, 0x08001000, 0x00021000, 226ff559fabSmrg 0x00001000, 0x08020002, 0x00000002, 0x08001000, 227ff559fabSmrg 0x00020002, 0x08021000, 0x08020000, 0x00000002, 228ff559fabSmrg 0x00020000, 0x08001002, 0x08020002, 0x00001000, 229ff559fabSmrg 0x00021002, 0x08000000, 0x00000000, 0x00020002, 230ff559fabSmrg 0x08001002, 0x00021002, 0x08021000, 0x08000002, 231ff559fabSmrg 0x08000000, 0x00020000, 0x00001002, 0x08021002, 232ff559fabSmrg 0x00020002, 0x08021000, 0x08001000, 0x00021002, 233ff559fabSmrg 0x08021002, 0x00020002, 0x08000002, 0x00000000, 234ff559fabSmrg 0x08000000, 0x00001002, 0x00020000, 0x08020002, 235ff559fabSmrg 0x00001000, 0x08000000, 0x00021002, 0x08001002, 236ff559fabSmrg 0x08021000, 0x00001000, 0x00000000, 0x08000002, 237ff559fabSmrg 0x00000002, 0x08021002, 0x00021000, 0x08020000, 238ff559fabSmrg 0x08020002, 0x00020000, 0x00001002, 0x08001000, 239ff559fabSmrg 0x08001002, 0x00000002, 0x08020000, 0x00021000 }, 240ff559fabSmrg 241ff559fabSmrg /* nibble 2 */ 242ff559fabSmrg { 0x20800000, 0x00808020, 0x00000020, 0x20800020, 243ff559fabSmrg 0x20008000, 0x00800000, 0x20800020, 0x00008020, 244ff559fabSmrg 0x00800020, 0x00008000, 0x00808000, 0x20000000, 245ff559fabSmrg 0x20808020, 0x20000020, 0x20000000, 0x20808000, 246ff559fabSmrg 0x00000000, 0x20008000, 0x00808020, 0x00000020, 247ff559fabSmrg 0x20000020, 0x20808020, 0x00008000, 0x20800000, 248ff559fabSmrg 0x20808000, 0x00800020, 0x20008020, 0x00808000, 249ff559fabSmrg 0x00008020, 0x00000000, 0x00800000, 0x20008020, 250ff559fabSmrg 0x00808020, 0x00000020, 0x20000000, 0x00008000, 251ff559fabSmrg 0x20000020, 0x20008000, 0x00808000, 0x20800020, 252ff559fabSmrg 0x00000000, 0x00808020, 0x00008020, 0x20808000, 253ff559fabSmrg 0x20008000, 0x00800000, 0x20808020, 0x20000000, 254ff559fabSmrg 0x20008020, 0x20800000, 0x00800000, 0x20808020, 255ff559fabSmrg 0x00008000, 0x00800020, 0x20800020, 0x00008020, 256ff559fabSmrg 0x00800020, 0x00000000, 0x20808000, 0x20000020, 257ff559fabSmrg 0x20800000, 0x20008020, 0x00000020, 0x00808000 }, 258ff559fabSmrg 259ff559fabSmrg /* nibble 3 */ 260ff559fabSmrg { 0x00080201, 0x02000200, 0x00000001, 0x02080201, 261ff559fabSmrg 0x00000000, 0x02080000, 0x02000201, 0x00080001, 262ff559fabSmrg 0x02080200, 0x02000001, 0x02000000, 0x00000201, 263ff559fabSmrg 0x02000001, 0x00080201, 0x00080000, 0x02000000, 264ff559fabSmrg 0x02080001, 0x00080200, 0x00000200, 0x00000001, 265ff559fabSmrg 0x00080200, 0x02000201, 0x02080000, 0x00000200, 266ff559fabSmrg 0x00000201, 0x00000000, 0x00080001, 0x02080200, 267ff559fabSmrg 0x02000200, 0x02080001, 0x02080201, 0x00080000, 268ff559fabSmrg 0x02080001, 0x00000201, 0x00080000, 0x02000001, 269ff559fabSmrg 0x00080200, 0x02000200, 0x00000001, 0x02080000, 270ff559fabSmrg 0x02000201, 0x00000000, 0x00000200, 0x00080001, 271ff559fabSmrg 0x00000000, 0x02080001, 0x02080200, 0x00000200, 272ff559fabSmrg 0x02000000, 0x02080201, 0x00080201, 0x00080000, 273ff559fabSmrg 0x02080201, 0x00000001, 0x02000200, 0x00080201, 274ff559fabSmrg 0x00080001, 0x00080200, 0x02080000, 0x02000201, 275ff559fabSmrg 0x00000201, 0x02000000, 0x02000001, 0x02080200 }, 276ff559fabSmrg 277ff559fabSmrg /* nibble 4 */ 278ff559fabSmrg { 0x01000000, 0x00002000, 0x00000080, 0x01002084, 279ff559fabSmrg 0x01002004, 0x01000080, 0x00002084, 0x01002000, 280ff559fabSmrg 0x00002000, 0x00000004, 0x01000004, 0x00002080, 281ff559fabSmrg 0x01000084, 0x01002004, 0x01002080, 0x00000000, 282ff559fabSmrg 0x00002080, 0x01000000, 0x00002004, 0x00000084, 283ff559fabSmrg 0x01000080, 0x00002084, 0x00000000, 0x01000004, 284ff559fabSmrg 0x00000004, 0x01000084, 0x01002084, 0x00002004, 285ff559fabSmrg 0x01002000, 0x00000080, 0x00000084, 0x01002080, 286ff559fabSmrg 0x01002080, 0x01000084, 0x00002004, 0x01002000, 287ff559fabSmrg 0x00002000, 0x00000004, 0x01000004, 0x01000080, 288ff559fabSmrg 0x01000000, 0x00002080, 0x01002084, 0x00000000, 289ff559fabSmrg 0x00002084, 0x01000000, 0x00000080, 0x00002004, 290ff559fabSmrg 0x01000084, 0x00000080, 0x00000000, 0x01002084, 291ff559fabSmrg 0x01002004, 0x01002080, 0x00000084, 0x00002000, 292ff559fabSmrg 0x00002080, 0x01002004, 0x01000080, 0x00000084, 293ff559fabSmrg 0x00000004, 0x00002084, 0x01002000, 0x01000004 }, 294ff559fabSmrg 295ff559fabSmrg /* nibble 5 */ 296ff559fabSmrg { 0x10000008, 0x00040008, 0x00000000, 0x10040400, 297ff559fabSmrg 0x00040008, 0x00000400, 0x10000408, 0x00040000, 298ff559fabSmrg 0x00000408, 0x10040408, 0x00040400, 0x10000000, 299ff559fabSmrg 0x10000400, 0x10000008, 0x10040000, 0x00040408, 300ff559fabSmrg 0x00040000, 0x10000408, 0x10040008, 0x00000000, 301ff559fabSmrg 0x00000400, 0x00000008, 0x10040400, 0x10040008, 302ff559fabSmrg 0x10040408, 0x10040000, 0x10000000, 0x00000408, 303ff559fabSmrg 0x00000008, 0x00040400, 0x00040408, 0x10000400, 304ff559fabSmrg 0x00000408, 0x10000000, 0x10000400, 0x00040408, 305ff559fabSmrg 0x10040400, 0x00040008, 0x00000000, 0x10000400, 306ff559fabSmrg 0x10000000, 0x00000400, 0x10040008, 0x00040000, 307ff559fabSmrg 0x00040008, 0x10040408, 0x00040400, 0x00000008, 308ff559fabSmrg 0x10040408, 0x00040400, 0x00040000, 0x10000408, 309ff559fabSmrg 0x10000008, 0x10040000, 0x00040408, 0x00000000, 310ff559fabSmrg 0x00000400, 0x10000008, 0x10000408, 0x10040400, 311ff559fabSmrg 0x10040000, 0x00000408, 0x00000008, 0x10040008 }, 312ff559fabSmrg 313ff559fabSmrg /* nibble 6 */ 314ff559fabSmrg { 0x00000800, 0x00000040, 0x00200040, 0x80200000, 315ff559fabSmrg 0x80200840, 0x80000800, 0x00000840, 0x00000000, 316ff559fabSmrg 0x00200000, 0x80200040, 0x80000040, 0x00200800, 317ff559fabSmrg 0x80000000, 0x00200840, 0x00200800, 0x80000040, 318ff559fabSmrg 0x80200040, 0x00000800, 0x80000800, 0x80200840, 319ff559fabSmrg 0x00000000, 0x00200040, 0x80200000, 0x00000840, 320ff559fabSmrg 0x80200800, 0x80000840, 0x00200840, 0x80000000, 321ff559fabSmrg 0x80000840, 0x80200800, 0x00000040, 0x00200000, 322ff559fabSmrg 0x80000840, 0x00200800, 0x80200800, 0x80000040, 323ff559fabSmrg 0x00000800, 0x00000040, 0x00200000, 0x80200800, 324ff559fabSmrg 0x80200040, 0x80000840, 0x00000840, 0x00000000, 325ff559fabSmrg 0x00000040, 0x80200000, 0x80000000, 0x00200040, 326ff559fabSmrg 0x00000000, 0x80200040, 0x00200040, 0x00000840, 327ff559fabSmrg 0x80000040, 0x00000800, 0x80200840, 0x00200000, 328ff559fabSmrg 0x00200840, 0x80000000, 0x80000800, 0x80200840, 329ff559fabSmrg 0x80200000, 0x00200840, 0x00200800, 0x80000800 }, 330ff559fabSmrg 331ff559fabSmrg /* nibble 7 */ 332ff559fabSmrg { 0x04100010, 0x04104000, 0x00004010, 0x00000000, 333ff559fabSmrg 0x04004000, 0x00100010, 0x04100000, 0x04104010, 334ff559fabSmrg 0x00000010, 0x04000000, 0x00104000, 0x00004010, 335ff559fabSmrg 0x00104010, 0x04004010, 0x04000010, 0x04100000, 336ff559fabSmrg 0x00004000, 0x00104010, 0x00100010, 0x04004000, 337ff559fabSmrg 0x04104010, 0x04000010, 0x00000000, 0x00104000, 338ff559fabSmrg 0x04000000, 0x00100000, 0x04004010, 0x04100010, 339ff559fabSmrg 0x00100000, 0x00004000, 0x04104000, 0x00000010, 340ff559fabSmrg 0x00100000, 0x00004000, 0x04000010, 0x04104010, 341ff559fabSmrg 0x00004010, 0x04000000, 0x00000000, 0x00104000, 342ff559fabSmrg 0x04100010, 0x04004010, 0x04004000, 0x00100010, 343ff559fabSmrg 0x04104000, 0x00000010, 0x00100010, 0x04004000, 344ff559fabSmrg 0x04104010, 0x00100000, 0x04100000, 0x04000010, 345ff559fabSmrg 0x00104000, 0x00004010, 0x04004010, 0x04100000, 346ff559fabSmrg 0x00000010, 0x04104000, 0x00104010, 0x00000000, 347ff559fabSmrg 0x04000000, 0x04100010, 0x00004000, 0x00104010} 348ff559fabSmrg}; 349ff559fabSmrg 350ff559fabSmrg#define ITERATIONS 16 351ff559fabSmrg#define HALF_ITERATIONS 8 352ff559fabSmrg 353ff559fabSmrg#define c2l(c,l) (l =((CARD32)(*((c)++))) , \ 354ff559fabSmrg l|=((CARD32)(*((c)++)))<< 8, \ 355ff559fabSmrg l|=((CARD32)(*((c)++)))<<16, \ 356ff559fabSmrg l|=((CARD32)(*((c)++)))<<24) 357ff559fabSmrg 358ff559fabSmrg#define l2c(l,c) (*((c)++)=(CARD8)(((l) )&0xff), \ 359ff559fabSmrg *((c)++)=(CARD8)(((l)>> 8)&0xff), \ 360ff559fabSmrg *((c)++)=(CARD8)(((l)>>16)&0xff), \ 361ff559fabSmrg *((c)++)=(CARD8)(((l)>>24)&0xff)) 362ff559fabSmrg 363ff559fabSmrg#define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\ 364ff559fabSmrg (b)^=(t),\ 365ff559fabSmrg (a)^=((t)<<(n))) 366ff559fabSmrg 367ff559fabSmrg#define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\ 368ff559fabSmrg (a)=(a)^(t)^(t>>(16-(n))))\ 369ff559fabSmrg 370ff559fabSmrgstatic const char shifts2[16] = {0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0}; 371ff559fabSmrg 372ff559fabSmrgvoid _XdmcpAuthSetup(auth_cblock key, auth_wrapper_schedule schedule) 373ff559fabSmrg{ 374ff559fabSmrg CARD32 c,d,t,s; 375ff559fabSmrg CARD8 *in; 376ff559fabSmrg CARD32 *k; 377ff559fabSmrg int i; 378ff559fabSmrg 379ff559fabSmrg k=(CARD32 *)schedule; 380ff559fabSmrg in=(CARD8 *)key; 381ff559fabSmrg 382ff559fabSmrg c2l(in,c); 383ff559fabSmrg c2l(in,d); 384ff559fabSmrg 385ff559fabSmrg /* do PC1 in 60 simple operations */ 386ff559fabSmrg PERM_OP(d,c,t,4,0x0f0f0f0f); 387ff559fabSmrg HPERM_OP(c,t,-2, 0xcccc0000); 388ff559fabSmrg HPERM_OP(c,t,-1, 0xaaaa0000); 389ff559fabSmrg HPERM_OP(c,t, 8, 0x00ff0000); 390ff559fabSmrg HPERM_OP(c,t,-1, 0xaaaa0000); 391ff559fabSmrg HPERM_OP(d,t,-8, 0xff000000); 392ff559fabSmrg HPERM_OP(d,t, 8, 0x00ff0000); 393ff559fabSmrg HPERM_OP(d,t, 2, 0x33330000); 394ff559fabSmrg d=((d&0x00aa00aa)<<7)|((d&0x55005500)>>7)|(d&0xaa55aa55); 395ff559fabSmrg d=(d>>8)|((c&0xf0000000)>>4); 396ff559fabSmrg c&=0x0fffffff; 397ff559fabSmrg 398ff559fabSmrg for (i=0; i<ITERATIONS; i++) { 399ff559fabSmrg if (shifts2[i]) { 400ff559fabSmrg c=((c>>2)|(c<<26)); d=((d>>2)|(d<<26)); 401ff559fabSmrg } else { 402ff559fabSmrg c=((c>>1)|(c<<27)); d=((d>>1)|(d<<27)); 403ff559fabSmrg } 404ff559fabSmrg c&=0x0fffffff; 405ff559fabSmrg d&=0x0fffffff; 406ff559fabSmrg /* could be a few less shifts but I am to lazy at this 407ff559fabSmrg * point in time to investigate */ 408ff559fabSmrg s= skb[0][ (c )&0x3f ]| 409ff559fabSmrg skb[1][((c>> 6)&0x03)|((c>> 7)&0x3c)]| 410ff559fabSmrg skb[2][((c>>13)&0x0f)|((c>>14)&0x30)]| 411ff559fabSmrg skb[3][((c>>20)&0x01)|((c>>21)&0x06) | 412ff559fabSmrg ((c>>22)&0x38)]; 413ff559fabSmrg t= skb[4][ (d )&0x3f ]| 414ff559fabSmrg skb[5][((d>> 7)&0x03)|((d>> 8)&0x3c)]| 415ff559fabSmrg skb[6][ (d>>15)&0x3f ]| 416ff559fabSmrg skb[7][((d>>21)&0x0f)|((d>>22)&0x30)]; 417ff559fabSmrg 418ff559fabSmrg /* table contained 0213 4657 */ 419ff559fabSmrg *(k++)=((t<<16)|(s&0x0000ffff)); 420ff559fabSmrg s= ((s>>16)|(t&0xffff0000)); 421ff559fabSmrg 422ff559fabSmrg s=(s<<4)|(s>>28); 423ff559fabSmrg *(k++)=s; 424ff559fabSmrg } 425ff559fabSmrg return; 426ff559fabSmrg} 427ff559fabSmrg 428ff559fabSmrg#define D_ENCRYPT(L,R,S) \ 429ff559fabSmrg t=(R<<1)|(R>>31); \ 430ff559fabSmrg u=(t^s[S ]); \ 431ff559fabSmrg t=(t^s[S+1]); \ 432ff559fabSmrg t=(t>>4)|(t<<28); \ 433ff559fabSmrg L^= SPtrans[1][(t )&0x3f]| \ 434ff559fabSmrg SPtrans[3][(t>> 8)&0x3f]| \ 435ff559fabSmrg SPtrans[5][(t>>16)&0x3f]| \ 436ff559fabSmrg SPtrans[7][(t>>24)&0x3f]| \ 437ff559fabSmrg SPtrans[0][(u )&0x3f]| \ 438ff559fabSmrg SPtrans[2][(u>> 8)&0x3f]| \ 439ff559fabSmrg SPtrans[4][(u>>16)&0x3f]| \ 440ff559fabSmrg SPtrans[6][(u>>24)&0x3f]; 441ff559fabSmrg 442ff559fabSmrg 443ff559fabSmrgvoid _XdmcpAuthDoIt(auth_cblock input, auth_cblock output, 444ff559fabSmrg auth_wrapper_schedule ks, int encrypt) 445ff559fabSmrg{ 446ff559fabSmrg CARD32 l,r,t,u; 447ff559fabSmrg CARD32 *s; 448ff559fabSmrg CARD8 *in,*out; 449ff559fabSmrg int i; 450ff559fabSmrg 451ff559fabSmrg in=(CARD8 *)input; 452ff559fabSmrg out=(CARD8 *)output; 453ff559fabSmrg c2l(in,l); 454ff559fabSmrg c2l(in,r); 455ff559fabSmrg 456ff559fabSmrg /* do IP */ 457ff559fabSmrg PERM_OP(r,l,t, 4,0x0f0f0f0f); 458ff559fabSmrg PERM_OP(l,r,t,16,0x0000ffff); 459ff559fabSmrg PERM_OP(r,l,t, 2,0x33333333); 460ff559fabSmrg PERM_OP(l,r,t, 8,0x00ff00ff); 461ff559fabSmrg PERM_OP(r,l,t, 1,0x55555555); 462ff559fabSmrg /* r and l are reversed - remember that :-) */ 463ff559fabSmrg t=l; 464ff559fabSmrg l=r; 465ff559fabSmrg r=t; 466ff559fabSmrg 467ff559fabSmrg s=(CARD32 *)ks; 468ff559fabSmrg 469ff559fabSmrg if (encrypt) { 470ff559fabSmrg for (i=0; i<(ITERATIONS*2); i+=4) { 471ff559fabSmrg D_ENCRYPT(l,r, i); /* 1 */ 472ff559fabSmrg D_ENCRYPT(r,l, i+2); /* 2 */ 473ff559fabSmrg } 474ff559fabSmrg } else { 475ff559fabSmrg for (i=(ITERATIONS*2)-2; i >= 0; i-=4) { 476ff559fabSmrg D_ENCRYPT(l,r, i); /* 1 */ 477ff559fabSmrg D_ENCRYPT(r,l, i-2); /* 2 */ 478ff559fabSmrg } 479ff559fabSmrg } 480ff559fabSmrg 481ff559fabSmrg /* swap l and r 482ff559fabSmrg * we will not do the swap so just remember they are 483ff559fabSmrg * reversed for the rest of the subroutine 484ff559fabSmrg * luckily by FP fixes this problem :-) */ 485ff559fabSmrg 486ff559fabSmrg PERM_OP(r,l,t, 1,0x55555555); 487ff559fabSmrg PERM_OP(l,r,t, 8,0x00ff00ff); 488ff559fabSmrg PERM_OP(r,l,t, 2,0x33333333); 489ff559fabSmrg PERM_OP(l,r,t,16,0x0000ffff); 490ff559fabSmrg PERM_OP(r,l,t, 4,0x0f0f0f0f); 491ff559fabSmrg 492ff559fabSmrg l2c(l,out); 493ff559fabSmrg l2c(r,out); 494ff559fabSmrg return; 495ff559fabSmrg} 496