+2000-01-21 Ken Raeburn <raeburn@mit.edu>
+
+ * f_sched.c (PC2_C, PC2_D): Put braces around sub-arrays.
+ * f_tables.c (des_SP_table): Ditto.
+
+ * weak_key.c (weak): Now const.
+ (mit_des_is_weak_key): Adjust pointer type accordingly.
+
1999-10-26 Tom Yu <tlyu@mit.edu>
* Makefile.in: Clean up usage of CFLAGS, CPPFLAGS, DEFS, DEFINES,
* in in the des code.
*/
static const unsigned DES_INT32 PC2_C[4][64] = {
+ {
0x00000000, 0x00000004, 0x00010000, 0x00010004,
0x00000400, 0x00000404, 0x00010400, 0x00010404,
0x00000020, 0x00000024, 0x00010020, 0x00010024,
0x01020400, 0x01020404, 0x01030400, 0x01030404,
0x01020020, 0x01020024, 0x01030020, 0x01030024,
0x01020420, 0x01020424, 0x01030420, 0x01030424,
-
+ },
+ {
0x00000000, 0x02000000, 0x00000800, 0x02000800,
0x00080000, 0x02080000, 0x00080800, 0x02080800,
0x00000001, 0x02000001, 0x00000801, 0x02000801,
0x10080100, 0x12080100, 0x10080900, 0x12080900,
0x10000101, 0x12000101, 0x10000901, 0x12000901,
0x10080101, 0x12080101, 0x10080901, 0x12080901,
-
+ },
+ {
0x00000000, 0x00040000, 0x00002000, 0x00042000,
0x00100000, 0x00140000, 0x00102000, 0x00142000,
0x20000000, 0x20040000, 0x20002000, 0x20042000,
0x00300008, 0x00340008, 0x00302008, 0x00342008,
0x20200008, 0x20240008, 0x20202008, 0x20242008,
0x20300008, 0x20340008, 0x20302008, 0x20342008,
-
+ },
+ {
0x00000000, 0x00000010, 0x08000000, 0x08000010,
0x00000200, 0x00000210, 0x08000200, 0x08000210,
0x00000002, 0x00000012, 0x08000002, 0x08000012,
0x04001200, 0x04001210, 0x0c001200, 0x0c001210,
0x04001002, 0x04001012, 0x0c001002, 0x0c001012,
0x04001202, 0x04001212, 0x0c001202, 0x0c001212
+ },
};
static const unsigned DES_INT32 PC2_D[4][64] = {
+ {
0x00000000, 0x02000000, 0x00020000, 0x02020000,
0x00000100, 0x02000100, 0x00020100, 0x02020100,
0x00000008, 0x02000008, 0x00020008, 0x02020008,
0x00200300, 0x02200300, 0x00220300, 0x02220300,
0x00200208, 0x02200208, 0x00220208, 0x02220208,
0x00200308, 0x02200308, 0x00220308, 0x02220308,
-
+ },
+ {
0x00000000, 0x00001000, 0x00000020, 0x00001020,
0x00100000, 0x00101000, 0x00100020, 0x00101020,
0x08000000, 0x08001000, 0x08000020, 0x08001020,
0x00100404, 0x00101404, 0x00100424, 0x00101424,
0x08000404, 0x08001404, 0x08000424, 0x08001424,
0x08100404, 0x08101404, 0x08100424, 0x08101424,
-
+ },
+ {
0x00000000, 0x10000000, 0x00010000, 0x10010000,
0x00000002, 0x10000002, 0x00010002, 0x10010002,
0x00002000, 0x10002000, 0x00012000, 0x10012000,
0x20040002, 0x30040002, 0x20050002, 0x30050002,
0x20042000, 0x30042000, 0x20052000, 0x30052000,
0x20042002, 0x30042002, 0x20052002, 0x30052002,
-
+ },
+ {
0x00000000, 0x04000000, 0x00000001, 0x04000001,
0x01000000, 0x05000000, 0x01000001, 0x05000001,
0x00000010, 0x04000010, 0x00000011, 0x04000011,
0x01080800, 0x05080800, 0x01080801, 0x05080801,
0x00080810, 0x04080810, 0x00080811, 0x04080811,
0x01080810, 0x05080810, 0x01080811, 0x05080811
+ },
};
* spec, to match the order of key application we follow.
*/
const unsigned DES_INT32 des_SP_table[8][64] = {
+ {
0x00100000, 0x02100001, 0x02000401, 0x00000000, /* 7 */
0x00000400, 0x02000401, 0x00100401, 0x02100400,
0x02100401, 0x00100000, 0x00000000, 0x02000001,
0x00100400, 0x00000000, 0x00000001, 0x02100401,
0x00000000, 0x00100401, 0x02100000, 0x00000400,
0x02000001, 0x02000400, 0x00000400, 0x00100001,
-
+ },
+ {
0x00808200, 0x00000000, 0x00008000, 0x00808202, /* 1 */
0x00808002, 0x00008202, 0x00000002, 0x00008000,
0x00000200, 0x00808200, 0x00808202, 0x00000200,
0x00800002, 0x00000202, 0x00008202, 0x00808200,
0x00000202, 0x00800200, 0x00800200, 0x00000000,
0x00008002, 0x00008200, 0x00000000, 0x00808002,
-
+ },
+ {
0x00000104, 0x04010100, 0x00000000, 0x04010004, /* 3 */
0x04000100, 0x00000000, 0x00010104, 0x04000100,
0x00010004, 0x04000004, 0x04000004, 0x00010000,
0x00000004, 0x00010104, 0x00010100, 0x04000004,
0x04010000, 0x04000104, 0x00000104, 0x04010000,
0x00010104, 0x00000004, 0x04010004, 0x00010100,
-
+ },
+ {
0x00000080, 0x01040080, 0x01040000, 0x21000080, /* 5 */
0x00040000, 0x00000080, 0x20000000, 0x01040000,
0x20040080, 0x00040000, 0x01000080, 0x20040080,
0x01040000, 0x00000000, 0x20040000, 0x21000000,
0x00040080, 0x01000080, 0x20000080, 0x00040000,
0x00000000, 0x20040000, 0x01040080, 0x20000080,
-
+ },
+ {
0x80401000, 0x80001040, 0x80001040, 0x00000040, /* 4 */
0x00401040, 0x80400040, 0x80400000, 0x80001000,
0x00000000, 0x00401000, 0x00401000, 0x80401040,
0x80400000, 0x80001000, 0x00401040, 0x80400040,
0x80001000, 0x00001040, 0x00400000, 0x80401000,
0x00000040, 0x00400000, 0x00001000, 0x00401040,
-
+ },
+ {
0x10000008, 0x10200000, 0x00002000, 0x10202008, /* 6 */
0x10200000, 0x00000008, 0x10202008, 0x00200000,
0x10002000, 0x00202008, 0x00200000, 0x10000008,
0x00000008, 0x00002000, 0x10200000, 0x00202008,
0x00002000, 0x00200008, 0x10002008, 0x00000000,
0x10202000, 0x10000000, 0x00200008, 0x10002008,
-
+ },
+ {
0x08000820, 0x00000800, 0x00020000, 0x08020820, /* 8 */
0x08000000, 0x08000820, 0x00000020, 0x08000000,
0x00020020, 0x08020000, 0x08020820, 0x00020800,
0x08020000, 0x08000800, 0x08000820, 0x00000000,
0x08020820, 0x00020800, 0x00020800, 0x00000820,
0x00000820, 0x00020020, 0x08000000, 0x08020800,
-
+ },
+ {
0x40084010, 0x40004000, 0x00004000, 0x00084010, /* 2 */
0x00080000, 0x00000010, 0x40080010, 0x40004010,
0x40000010, 0x40084010, 0x40084000, 0x40000000,
0x00080010, 0x40004010, 0x40000010, 0x00080010,
0x00084000, 0x00000000, 0x40004000, 0x00004010,
0x40000000, 0x40080010, 0x40084010, 0x00084000
+ },
};
/*
* The following are the weak DES keys:
*/
-static mit_des_cblock weak[16] = {
+static const mit_des_cblock weak[16] = {
/* weak keys */
{0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01},
{0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe},
mit_des_cblock key;
{
int i;
- mit_des_cblock *weak_p = weak;
+ const mit_des_cblock *weak_p = weak;
for (i = 0; i < (sizeof(weak)/sizeof(mit_des_cblock)); i++) {
if (!memcmp((char *)weak_p++,(char *)key,sizeof(mit_des_cblock)))