xref: /titanic_51/usr/src/common/crypto/des/des_ks.c (revision 694c35faa87b858ecdadfe4fc592615f4eefbb07)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
23*4cc1ac68Skrishna  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #include <sys/types.h>
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate static uint64_t pc1_table[2][128]=
307c478bd9Sstevel@tonic-gate {
31*4cc1ac68Skrishna /* BEGIN CSTYLED */
327c478bd9Sstevel@tonic-gate {
33*4cc1ac68Skrishna 0x0000000000000000ULL, 0x0000000000100000ULL, 0x0000000000001000ULL, 0x0000000000101000ULL,
34*4cc1ac68Skrishna 0x0000000000000010ULL, 0x0000000000100010ULL, 0x0000000000001010ULL, 0x0000000000101010ULL,
35*4cc1ac68Skrishna 0x0000000000000001ULL, 0x0000000000100001ULL, 0x0000000000001001ULL, 0x0000000000101001ULL,
36*4cc1ac68Skrishna 0x0000000000000011ULL, 0x0000000000100011ULL, 0x0000000000001011ULL, 0x0000000000101011ULL,
37*4cc1ac68Skrishna 0x0000000100000000ULL, 0x0000000100100000ULL, 0x0000000100001000ULL, 0x0000000100101000ULL,
38*4cc1ac68Skrishna 0x0000000100000010ULL, 0x0000000100100010ULL, 0x0000000100001010ULL, 0x0000000100101010ULL,
39*4cc1ac68Skrishna 0x0000000100000001ULL, 0x0000000100100001ULL, 0x0000000100001001ULL, 0x0000000100101001ULL,
40*4cc1ac68Skrishna 0x0000000100000011ULL, 0x0000000100100011ULL, 0x0000000100001011ULL, 0x0000000100101011ULL,
41*4cc1ac68Skrishna 0x0000010000000000ULL, 0x0000010000100000ULL, 0x0000010000001000ULL, 0x0000010000101000ULL,
42*4cc1ac68Skrishna 0x0000010000000010ULL, 0x0000010000100010ULL, 0x0000010000001010ULL, 0x0000010000101010ULL,
43*4cc1ac68Skrishna 0x0000010000000001ULL, 0x0000010000100001ULL, 0x0000010000001001ULL, 0x0000010000101001ULL,
44*4cc1ac68Skrishna 0x0000010000000011ULL, 0x0000010000100011ULL, 0x0000010000001011ULL, 0x0000010000101011ULL,
45*4cc1ac68Skrishna 0x0000010100000000ULL, 0x0000010100100000ULL, 0x0000010100001000ULL, 0x0000010100101000ULL,
46*4cc1ac68Skrishna 0x0000010100000010ULL, 0x0000010100100010ULL, 0x0000010100001010ULL, 0x0000010100101010ULL,
47*4cc1ac68Skrishna 0x0000010100000001ULL, 0x0000010100100001ULL, 0x0000010100001001ULL, 0x0000010100101001ULL,
48*4cc1ac68Skrishna 0x0000010100000011ULL, 0x0000010100100011ULL, 0x0000010100001011ULL, 0x0000010100101011ULL,
49*4cc1ac68Skrishna 0x0001000000000000ULL, 0x0001000000100000ULL, 0x0001000000001000ULL, 0x0001000000101000ULL,
50*4cc1ac68Skrishna 0x0001000000000010ULL, 0x0001000000100010ULL, 0x0001000000001010ULL, 0x0001000000101010ULL,
51*4cc1ac68Skrishna 0x0001000000000001ULL, 0x0001000000100001ULL, 0x0001000000001001ULL, 0x0001000000101001ULL,
52*4cc1ac68Skrishna 0x0001000000000011ULL, 0x0001000000100011ULL, 0x0001000000001011ULL, 0x0001000000101011ULL,
53*4cc1ac68Skrishna 0x0001000100000000ULL, 0x0001000100100000ULL, 0x0001000100001000ULL, 0x0001000100101000ULL,
54*4cc1ac68Skrishna 0x0001000100000010ULL, 0x0001000100100010ULL, 0x0001000100001010ULL, 0x0001000100101010ULL,
55*4cc1ac68Skrishna 0x0001000100000001ULL, 0x0001000100100001ULL, 0x0001000100001001ULL, 0x0001000100101001ULL,
56*4cc1ac68Skrishna 0x0001000100000011ULL, 0x0001000100100011ULL, 0x0001000100001011ULL, 0x0001000100101011ULL,
57*4cc1ac68Skrishna 0x0001010000000000ULL, 0x0001010000100000ULL, 0x0001010000001000ULL, 0x0001010000101000ULL,
58*4cc1ac68Skrishna 0x0001010000000010ULL, 0x0001010000100010ULL, 0x0001010000001010ULL, 0x0001010000101010ULL,
59*4cc1ac68Skrishna 0x0001010000000001ULL, 0x0001010000100001ULL, 0x0001010000001001ULL, 0x0001010000101001ULL,
60*4cc1ac68Skrishna 0x0001010000000011ULL, 0x0001010000100011ULL, 0x0001010000001011ULL, 0x0001010000101011ULL,
61*4cc1ac68Skrishna 0x0001010100000000ULL, 0x0001010100100000ULL, 0x0001010100001000ULL, 0x0001010100101000ULL,
62*4cc1ac68Skrishna 0x0001010100000010ULL, 0x0001010100100010ULL, 0x0001010100001010ULL, 0x0001010100101010ULL,
63*4cc1ac68Skrishna 0x0001010100000001ULL, 0x0001010100100001ULL, 0x0001010100001001ULL, 0x0001010100101001ULL,
64*4cc1ac68Skrishna 0x0001010100000011ULL, 0x0001010100100011ULL, 0x0001010100001011ULL, 0x0001010100101011ULL
657c478bd9Sstevel@tonic-gate },
667c478bd9Sstevel@tonic-gate {
67*4cc1ac68Skrishna 0x0000000000000000ULL, 0x0000000001000000ULL, 0x0000000000010000ULL, 0x0000000001010000ULL,
68*4cc1ac68Skrishna 0x0000000000000100ULL, 0x0000000001000100ULL, 0x0000000000010100ULL, 0x0000000001010100ULL,
69*4cc1ac68Skrishna 0x0000000010000000ULL, 0x0000000011000000ULL, 0x0000000010010000ULL, 0x0000000011010000ULL,
70*4cc1ac68Skrishna 0x0000000010000100ULL, 0x0000000011000100ULL, 0x0000000010010100ULL, 0x0000000011010100ULL,
71*4cc1ac68Skrishna 0x0000001000000000ULL, 0x0000001001000000ULL, 0x0000001000010000ULL, 0x0000001001010000ULL,
72*4cc1ac68Skrishna 0x0000001000000100ULL, 0x0000001001000100ULL, 0x0000001000010100ULL, 0x0000001001010100ULL,
73*4cc1ac68Skrishna 0x0000001010000000ULL, 0x0000001011000000ULL, 0x0000001010010000ULL, 0x0000001011010000ULL,
74*4cc1ac68Skrishna 0x0000001010000100ULL, 0x0000001011000100ULL, 0x0000001010010100ULL, 0x0000001011010100ULL,
75*4cc1ac68Skrishna 0x0000100000000000ULL, 0x0000100001000000ULL, 0x0000100000010000ULL, 0x0000100001010000ULL,
76*4cc1ac68Skrishna 0x0000100000000100ULL, 0x0000100001000100ULL, 0x0000100000010100ULL, 0x0000100001010100ULL,
77*4cc1ac68Skrishna 0x0000100010000000ULL, 0x0000100011000000ULL, 0x0000100010010000ULL, 0x0000100011010000ULL,
78*4cc1ac68Skrishna 0x0000100010000100ULL, 0x0000100011000100ULL, 0x0000100010010100ULL, 0x0000100011010100ULL,
79*4cc1ac68Skrishna 0x0000101000000000ULL, 0x0000101001000000ULL, 0x0000101000010000ULL, 0x0000101001010000ULL,
80*4cc1ac68Skrishna 0x0000101000000100ULL, 0x0000101001000100ULL, 0x0000101000010100ULL, 0x0000101001010100ULL,
81*4cc1ac68Skrishna 0x0000101010000000ULL, 0x0000101011000000ULL, 0x0000101010010000ULL, 0x0000101011010000ULL,
82*4cc1ac68Skrishna 0x0000101010000100ULL, 0x0000101011000100ULL, 0x0000101010010100ULL, 0x0000101011010100ULL,
83*4cc1ac68Skrishna 0x0010000000000000ULL, 0x0010000001000000ULL, 0x0010000000010000ULL, 0x0010000001010000ULL,
84*4cc1ac68Skrishna 0x0010000000000100ULL, 0x0010000001000100ULL, 0x0010000000010100ULL, 0x0010000001010100ULL,
85*4cc1ac68Skrishna 0x0010000010000000ULL, 0x0010000011000000ULL, 0x0010000010010000ULL, 0x0010000011010000ULL,
86*4cc1ac68Skrishna 0x0010000010000100ULL, 0x0010000011000100ULL, 0x0010000010010100ULL, 0x0010000011010100ULL,
87*4cc1ac68Skrishna 0x0010001000000000ULL, 0x0010001001000000ULL, 0x0010001000010000ULL, 0x0010001001010000ULL,
88*4cc1ac68Skrishna 0x0010001000000100ULL, 0x0010001001000100ULL, 0x0010001000010100ULL, 0x0010001001010100ULL,
89*4cc1ac68Skrishna 0x0010001010000000ULL, 0x0010001011000000ULL, 0x0010001010010000ULL, 0x0010001011010000ULL,
90*4cc1ac68Skrishna 0x0010001010000100ULL, 0x0010001011000100ULL, 0x0010001010010100ULL, 0x0010001011010100ULL,
91*4cc1ac68Skrishna 0x0010100000000000ULL, 0x0010100001000000ULL, 0x0010100000010000ULL, 0x0010100001010000ULL,
92*4cc1ac68Skrishna 0x0010100000000100ULL, 0x0010100001000100ULL, 0x0010100000010100ULL, 0x0010100001010100ULL,
93*4cc1ac68Skrishna 0x0010100010000000ULL, 0x0010100011000000ULL, 0x0010100010010000ULL, 0x0010100011010000ULL,
94*4cc1ac68Skrishna 0x0010100010000100ULL, 0x0010100011000100ULL, 0x0010100010010100ULL, 0x0010100011010100ULL,
95*4cc1ac68Skrishna 0x0010101000000000ULL, 0x0010101001000000ULL, 0x0010101000010000ULL, 0x0010101001010000ULL,
96*4cc1ac68Skrishna 0x0010101000000100ULL, 0x0010101001000100ULL, 0x0010101000010100ULL, 0x0010101001010100ULL,
97*4cc1ac68Skrishna 0x0010101010000000ULL, 0x0010101011000000ULL, 0x0010101010010000ULL, 0x0010101011010000ULL,
98*4cc1ac68Skrishna 0x0010101010000100ULL, 0x0010101011000100ULL, 0x0010101010010100ULL, 0x0010101011010100ULL
997c478bd9Sstevel@tonic-gate }
100*4cc1ac68Skrishna /* END CSTYLED */
1017c478bd9Sstevel@tonic-gate };
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate static uint32_t pc2_1_table[4][64] =
1057c478bd9Sstevel@tonic-gate {
1067c478bd9Sstevel@tonic-gate {
1077c478bd9Sstevel@tonic-gate 0x00000000, 0x00004000, 0x04000000, 0x04004000,
1087c478bd9Sstevel@tonic-gate 0x00000100, 0x00004100, 0x04000100, 0x04004100,
1097c478bd9Sstevel@tonic-gate 0x00020000, 0x00024000, 0x04020000, 0x04024000,
1107c478bd9Sstevel@tonic-gate 0x00020100, 0x00024100, 0x04020100, 0x04024100,
1117c478bd9Sstevel@tonic-gate 0x00000001, 0x00004001, 0x04000001, 0x04004001,
1127c478bd9Sstevel@tonic-gate 0x00000101, 0x00004101, 0x04000101, 0x04004101,
1137c478bd9Sstevel@tonic-gate 0x00020001, 0x00024001, 0x04020001, 0x04024001,
1147c478bd9Sstevel@tonic-gate 0x00020101, 0x00024101, 0x04020101, 0x04024101,
1157c478bd9Sstevel@tonic-gate 0x08000000, 0x08004000, 0x0c000000, 0x0c004000,
1167c478bd9Sstevel@tonic-gate 0x08000100, 0x08004100, 0x0c000100, 0x0c004100,
1177c478bd9Sstevel@tonic-gate 0x08020000, 0x08024000, 0x0c020000, 0x0c024000,
1187c478bd9Sstevel@tonic-gate 0x08020100, 0x08024100, 0x0c020100, 0x0c024100,
1197c478bd9Sstevel@tonic-gate 0x08000001, 0x08004001, 0x0c000001, 0x0c004001,
1207c478bd9Sstevel@tonic-gate 0x08000101, 0x08004101, 0x0c000101, 0x0c004101,
1217c478bd9Sstevel@tonic-gate 0x08020001, 0x08024001, 0x0c020001, 0x0c024001,
1227c478bd9Sstevel@tonic-gate 0x08020101, 0x08024101, 0x0c020101, 0x0c024101
1237c478bd9Sstevel@tonic-gate },
1247c478bd9Sstevel@tonic-gate {
1257c478bd9Sstevel@tonic-gate 0x00000000, 0x00000200, 0x20000000, 0x20000200,
1267c478bd9Sstevel@tonic-gate 0x00001000, 0x00001200, 0x20001000, 0x20001200,
1277c478bd9Sstevel@tonic-gate 0x00000000, 0x00000200, 0x20000000, 0x20000200,
1287c478bd9Sstevel@tonic-gate 0x00001000, 0x00001200, 0x20001000, 0x20001200,
1297c478bd9Sstevel@tonic-gate 0x00000040, 0x00000240, 0x20000040, 0x20000240,
1307c478bd9Sstevel@tonic-gate 0x00001040, 0x00001240, 0x20001040, 0x20001240,
1317c478bd9Sstevel@tonic-gate 0x00000040, 0x00000240, 0x20000040, 0x20000240,
1327c478bd9Sstevel@tonic-gate 0x00001040, 0x00001240, 0x20001040, 0x20001240,
1337c478bd9Sstevel@tonic-gate 0x00000010, 0x00000210, 0x20000010, 0x20000210,
1347c478bd9Sstevel@tonic-gate 0x00001010, 0x00001210, 0x20001010, 0x20001210,
1357c478bd9Sstevel@tonic-gate 0x00000010, 0x00000210, 0x20000010, 0x20000210,
1367c478bd9Sstevel@tonic-gate 0x00001010, 0x00001210, 0x20001010, 0x20001210,
1377c478bd9Sstevel@tonic-gate 0x00000050, 0x00000250, 0x20000050, 0x20000250,
1387c478bd9Sstevel@tonic-gate 0x00001050, 0x00001250, 0x20001050, 0x20001250,
1397c478bd9Sstevel@tonic-gate 0x00000050, 0x00000250, 0x20000050, 0x20000250,
1407c478bd9Sstevel@tonic-gate 0x00001050, 0x00001250, 0x20001050, 0x20001250
1417c478bd9Sstevel@tonic-gate },
1427c478bd9Sstevel@tonic-gate {
1437c478bd9Sstevel@tonic-gate 0x00000000, 0x00000000, 0x40000000, 0x40000000,
1447c478bd9Sstevel@tonic-gate 0x00000020, 0x00000020, 0x40000020, 0x40000020,
1457c478bd9Sstevel@tonic-gate 0x00008000, 0x00008000, 0x40008000, 0x40008000,
1467c478bd9Sstevel@tonic-gate 0x00008020, 0x00008020, 0x40008020, 0x40008020,
1477c478bd9Sstevel@tonic-gate 0x80000000, 0x80000000, 0xc0000000, 0xc0000000,
1487c478bd9Sstevel@tonic-gate 0x80000020, 0x80000020, 0xc0000020, 0xc0000020,
1497c478bd9Sstevel@tonic-gate 0x80008000, 0x80008000, 0xc0008000, 0xc0008000,
1507c478bd9Sstevel@tonic-gate 0x80008020, 0x80008020, 0xc0008020, 0xc0008020,
1517c478bd9Sstevel@tonic-gate 0x00000002, 0x00000002, 0x40000002, 0x40000002,
1527c478bd9Sstevel@tonic-gate 0x00000022, 0x00000022, 0x40000022, 0x40000022,
1537c478bd9Sstevel@tonic-gate 0x00008002, 0x00008002, 0x40008002, 0x40008002,
1547c478bd9Sstevel@tonic-gate 0x00008022, 0x00008022, 0x40008022, 0x40008022,
1557c478bd9Sstevel@tonic-gate 0x80000002, 0x80000002, 0xc0000002, 0xc0000002,
1567c478bd9Sstevel@tonic-gate 0x80000022, 0x80000022, 0xc0000022, 0xc0000022,
1577c478bd9Sstevel@tonic-gate 0x80008002, 0x80008002, 0xc0008002, 0xc0008002,
1587c478bd9Sstevel@tonic-gate 0x80008022, 0x80008022, 0xc0008022, 0xc0008022
1597c478bd9Sstevel@tonic-gate },
1607c478bd9Sstevel@tonic-gate {
1617c478bd9Sstevel@tonic-gate 0x00000000, 0x10000000, 0x00000800, 0x10000800,
1627c478bd9Sstevel@tonic-gate 0x00000000, 0x10000000, 0x00000800, 0x10000800,
1637c478bd9Sstevel@tonic-gate 0x00002000, 0x10002000, 0x00002800, 0x10002800,
1647c478bd9Sstevel@tonic-gate 0x00002000, 0x10002000, 0x00002800, 0x10002800,
1657c478bd9Sstevel@tonic-gate 0x00000004, 0x10000004, 0x00000804, 0x10000804,
1667c478bd9Sstevel@tonic-gate 0x00000004, 0x10000004, 0x00000804, 0x10000804,
1677c478bd9Sstevel@tonic-gate 0x00002004, 0x10002004, 0x00002804, 0x10002804,
1687c478bd9Sstevel@tonic-gate 0x00002004, 0x10002004, 0x00002804, 0x10002804,
1697c478bd9Sstevel@tonic-gate 0x00000400, 0x10000400, 0x00000c00, 0x10000c00,
1707c478bd9Sstevel@tonic-gate 0x00000400, 0x10000400, 0x00000c00, 0x10000c00,
1717c478bd9Sstevel@tonic-gate 0x00002400, 0x10002400, 0x00002c00, 0x10002c00,
1727c478bd9Sstevel@tonic-gate 0x00002400, 0x10002400, 0x00002c00, 0x10002c00,
1737c478bd9Sstevel@tonic-gate 0x00000404, 0x10000404, 0x00000c04, 0x10000c04,
1747c478bd9Sstevel@tonic-gate 0x00000404, 0x10000404, 0x00000c04, 0x10000c04,
1757c478bd9Sstevel@tonic-gate 0x00002404, 0x10002404, 0x00002c04, 0x10002c04,
1767c478bd9Sstevel@tonic-gate 0x00002404, 0x10002404, 0x00002c04, 0x10002c04
1777c478bd9Sstevel@tonic-gate }
1787c478bd9Sstevel@tonic-gate };
1797c478bd9Sstevel@tonic-gate 
1807c478bd9Sstevel@tonic-gate static uint32_t pc2_1_tail_table[8] =
1817c478bd9Sstevel@tonic-gate {
1827c478bd9Sstevel@tonic-gate 0x00000000, 0x00010000, 0x00000008, 0x00010008,
1837c478bd9Sstevel@tonic-gate 0x00000080, 0x00010080, 0x00000088, 0x00010088
1847c478bd9Sstevel@tonic-gate };
1857c478bd9Sstevel@tonic-gate 
1867c478bd9Sstevel@tonic-gate static uint32_t pc2_2_table[5][32] =
1877c478bd9Sstevel@tonic-gate {
1887c478bd9Sstevel@tonic-gate {
1897c478bd9Sstevel@tonic-gate 0x00000000, 0x00010000, 0x00000008, 0x00010008,
1907c478bd9Sstevel@tonic-gate 0x20000000, 0x20010000, 0x20000008, 0x20010008,
1917c478bd9Sstevel@tonic-gate 0x00100000, 0x00110000, 0x00100008, 0x00110008,
1927c478bd9Sstevel@tonic-gate 0x20100000, 0x20110000, 0x20100008, 0x20110008,
1937c478bd9Sstevel@tonic-gate 0x00000010, 0x00010010, 0x00000018, 0x00010018,
1947c478bd9Sstevel@tonic-gate 0x20000010, 0x20010010, 0x20000018, 0x20010018,
1957c478bd9Sstevel@tonic-gate 0x00100010, 0x00110010, 0x00100018, 0x00110018,
1967c478bd9Sstevel@tonic-gate 0x20100010, 0x20110010, 0x20100018, 0x20110018
1977c478bd9Sstevel@tonic-gate },
1987c478bd9Sstevel@tonic-gate {
1997c478bd9Sstevel@tonic-gate 0x00000000, 0x00000000, 0x10000000, 0x10000000,
2007c478bd9Sstevel@tonic-gate 0x00000020, 0x00000020, 0x10000020, 0x10000020,
2017c478bd9Sstevel@tonic-gate 0x00000000, 0x00000000, 0x10000000, 0x10000000,
2027c478bd9Sstevel@tonic-gate 0x00000020, 0x00000020, 0x10000020, 0x10000020,
2037c478bd9Sstevel@tonic-gate 0x00000400, 0x00000400, 0x10000400, 0x10000400,
2047c478bd9Sstevel@tonic-gate 0x00000420, 0x00000420, 0x10000420, 0x10000420,
2057c478bd9Sstevel@tonic-gate 0x00000400, 0x00000400, 0x10000400, 0x10000400,
2067c478bd9Sstevel@tonic-gate 0x00000420, 0x00000420, 0x10000420, 0x10000420
2077c478bd9Sstevel@tonic-gate },
2087c478bd9Sstevel@tonic-gate {
2097c478bd9Sstevel@tonic-gate 0x00000000, 0x00000000, 0x00000080, 0x00000080,
2107c478bd9Sstevel@tonic-gate 0x80000000, 0x80000000, 0x80000080, 0x80000080,
2117c478bd9Sstevel@tonic-gate 0x00080000, 0x00080000, 0x00080080, 0x00080080,
2127c478bd9Sstevel@tonic-gate 0x80080000, 0x80080000, 0x80080080, 0x80080080,
2137c478bd9Sstevel@tonic-gate 0x00001000, 0x00001000, 0x00001080, 0x00001080,
2147c478bd9Sstevel@tonic-gate 0x80001000, 0x80001000, 0x80001080, 0x80001080,
2157c478bd9Sstevel@tonic-gate 0x00081000, 0x00081000, 0x00081080, 0x00081080,
2167c478bd9Sstevel@tonic-gate 0x80081000, 0x80081000, 0x80081080, 0x80081080
2177c478bd9Sstevel@tonic-gate },
2187c478bd9Sstevel@tonic-gate {
2197c478bd9Sstevel@tonic-gate 0x00000000, 0x00008000, 0x08000000, 0x08008000,
2207c478bd9Sstevel@tonic-gate 0x00000100, 0x00008100, 0x08000100, 0x08008100,
2217c478bd9Sstevel@tonic-gate 0x00020000, 0x00028000, 0x08020000, 0x08028000,
2227c478bd9Sstevel@tonic-gate 0x00020100, 0x00028100, 0x08020100, 0x08028100,
2237c478bd9Sstevel@tonic-gate 0x00004000, 0x0000c000, 0x08004000, 0x0800c000,
2247c478bd9Sstevel@tonic-gate 0x00004100, 0x0000c100, 0x08004100, 0x0800c100,
2257c478bd9Sstevel@tonic-gate 0x00024000, 0x0002c000, 0x08024000, 0x0802c000,
2267c478bd9Sstevel@tonic-gate 0x00024100, 0x0002c100, 0x08024100, 0x0802c100
2277c478bd9Sstevel@tonic-gate },
2287c478bd9Sstevel@tonic-gate {
2297c478bd9Sstevel@tonic-gate 0x00000000, 0x00000200, 0x40000000, 0x40000200,
2307c478bd9Sstevel@tonic-gate 0x00040000, 0x00040200, 0x40040000, 0x40040200,
2317c478bd9Sstevel@tonic-gate 0x00000040, 0x00000240, 0x40000040, 0x40000240,
2327c478bd9Sstevel@tonic-gate 0x00040040, 0x00040240, 0x40040040, 0x40040240,
2337c478bd9Sstevel@tonic-gate 0x00002000, 0x00002200, 0x40002000, 0x40002200,
2347c478bd9Sstevel@tonic-gate 0x00042000, 0x00042200, 0x40042000, 0x40042200,
2357c478bd9Sstevel@tonic-gate 0x00002040, 0x00002240, 0x40002040, 0x40002240,
2367c478bd9Sstevel@tonic-gate 0x00042040, 0x00042240, 0x40042040, 0x40042240
2377c478bd9Sstevel@tonic-gate }
2387c478bd9Sstevel@tonic-gate };
2397c478bd9Sstevel@tonic-gate 
2407c478bd9Sstevel@tonic-gate static uint32_t pc2_2_tail_table[4] =
2417c478bd9Sstevel@tonic-gate {
2427c478bd9Sstevel@tonic-gate 0x00000000, 0x00000800, 0x04000000, 0x04000800
2437c478bd9Sstevel@tonic-gate };
2447c478bd9Sstevel@tonic-gate 
2457c478bd9Sstevel@tonic-gate static int ss[16] = {1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1};
2467c478bd9Sstevel@tonic-gate 
2477c478bd9Sstevel@tonic-gate 
2487c478bd9Sstevel@tonic-gate /*
2497c478bd9Sstevel@tonic-gate  * This routine initializes the key schedule.
2507c478bd9Sstevel@tonic-gate  */
2517c478bd9Sstevel@tonic-gate void
2527c478bd9Sstevel@tonic-gate des_ks(uint64_t *ks, uint64_t key)
2537c478bd9Sstevel@tonic-gate {
2547c478bd9Sstevel@tonic-gate 	int i;
2557c478bd9Sstevel@tonic-gate 	uint32_t upper, lower;
2567c478bd9Sstevel@tonic-gate 	uint64_t c, d;
2577c478bd9Sstevel@tonic-gate 
2587c478bd9Sstevel@tonic-gate 	c = pc1_table[0][key >> 57] |
259*4cc1ac68Skrishna 		((pc1_table[0][(key >> 49) & 127ULL]) << 1) |
260*4cc1ac68Skrishna 		((pc1_table[0][(key >> 41) & 127ULL]) << 2) |
261*4cc1ac68Skrishna 		((pc1_table[0][(key >> 33) & 127ULL]) << 3) |
262*4cc1ac68Skrishna 		pc1_table[1][(key >> 25) & 127ULL] |
263*4cc1ac68Skrishna 		((pc1_table[1][(key >> 17) & 127ULL]) << 1) |
264*4cc1ac68Skrishna 		((pc1_table[1][(key >> 9) & 127ULL]) << 2) |
265*4cc1ac68Skrishna 		((pc1_table[1][(key >> 1) & 127ULL]) << 3);
2667c478bd9Sstevel@tonic-gate 
267*4cc1ac68Skrishna 	d = (c & 0xfffffffULL) | ((c & 0xfffffffULL) << 28);
268*4cc1ac68Skrishna 	c = (c & 0xfffffff0000000ULL) | ((c & 0xfffffff0000000ULL) >> 28);
2697c478bd9Sstevel@tonic-gate 
2707c478bd9Sstevel@tonic-gate 	for (i = 0; i < 16; i++) {
2717c478bd9Sstevel@tonic-gate 		c = c << ss[i];
2727c478bd9Sstevel@tonic-gate 		d = d << ss[i];
2737c478bd9Sstevel@tonic-gate 
2747c478bd9Sstevel@tonic-gate 		upper = pc2_1_table[0][(c >> 50) & 63] |
2757c478bd9Sstevel@tonic-gate 			pc2_1_table[1][(c >> 44) & 63] |
2767c478bd9Sstevel@tonic-gate 			pc2_1_table[2][(c >> 38) & 63] |
2777c478bd9Sstevel@tonic-gate 			pc2_1_table[3][(c >> 32) & 63] |
2787c478bd9Sstevel@tonic-gate 			pc2_1_tail_table[(c >> 28) & 7];
2797c478bd9Sstevel@tonic-gate 
2807c478bd9Sstevel@tonic-gate 		lower = pc2_2_table[0][(d >> 51) & 31] |
2817c478bd9Sstevel@tonic-gate 			pc2_2_table[1][(d >> 46) & 31] |
2827c478bd9Sstevel@tonic-gate 			pc2_2_table[2][(d >> 41) & 31] |
2837c478bd9Sstevel@tonic-gate 			pc2_2_table[3][(d >> 36) & 31] |
2847c478bd9Sstevel@tonic-gate 			pc2_2_table[4][(d >> 31) & 31] |
2857c478bd9Sstevel@tonic-gate 			pc2_2_tail_table[(d >> 28) & 3];
2867c478bd9Sstevel@tonic-gate 		ks[i] = ((uint64_t)upper)<<32 | ((uint64_t)lower);
2877c478bd9Sstevel@tonic-gate 	}
2887c478bd9Sstevel@tonic-gate }
289