From: Ken Raeburn Date: Sat, 22 Jan 2000 02:42:19 +0000 (+0000) Subject: Avoid non-const static data, and gcc warnings Solaris, except afsstring2key.c: X-Git-Tag: krb5-1.2-beta1~160 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=de23b5a700246d5a6c112ba3cbf02ce12e3de2d3;p=krb5.git Avoid non-const static data, and gcc warnings Solaris, except afsstring2key.c: * 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. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@11957 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/crypto/des/ChangeLog b/src/lib/crypto/des/ChangeLog index f5b88409e..8d76259d4 100644 --- a/src/lib/crypto/des/ChangeLog +++ b/src/lib/crypto/des/ChangeLog @@ -1,3 +1,11 @@ +2000-01-21 Ken Raeburn + + * 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 * Makefile.in: Clean up usage of CFLAGS, CPPFLAGS, DEFS, DEFINES, diff --git a/src/lib/crypto/des/f_sched.c b/src/lib/crypto/des/f_sched.c index 9abbcfdc3..eeea4f8b5 100644 --- a/src/lib/crypto/des/f_sched.c +++ b/src/lib/crypto/des/f_sched.c @@ -65,6 +65,7 @@ static const unsigned DES_INT32 PC1_DR[8] = { * 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, @@ -81,7 +82,8 @@ static const unsigned DES_INT32 PC2_C[4][64] = { 0x01020400, 0x01020404, 0x01030400, 0x01030404, 0x01020020, 0x01020024, 0x01030020, 0x01030024, 0x01020420, 0x01020424, 0x01030420, 0x01030424, - + }, + { 0x00000000, 0x02000000, 0x00000800, 0x02000800, 0x00080000, 0x02080000, 0x00080800, 0x02080800, 0x00000001, 0x02000001, 0x00000801, 0x02000801, @@ -98,7 +100,8 @@ static const unsigned DES_INT32 PC2_C[4][64] = { 0x10080100, 0x12080100, 0x10080900, 0x12080900, 0x10000101, 0x12000101, 0x10000901, 0x12000901, 0x10080101, 0x12080101, 0x10080901, 0x12080901, - + }, + { 0x00000000, 0x00040000, 0x00002000, 0x00042000, 0x00100000, 0x00140000, 0x00102000, 0x00142000, 0x20000000, 0x20040000, 0x20002000, 0x20042000, @@ -115,7 +118,8 @@ static const unsigned DES_INT32 PC2_C[4][64] = { 0x00300008, 0x00340008, 0x00302008, 0x00342008, 0x20200008, 0x20240008, 0x20202008, 0x20242008, 0x20300008, 0x20340008, 0x20302008, 0x20342008, - + }, + { 0x00000000, 0x00000010, 0x08000000, 0x08000010, 0x00000200, 0x00000210, 0x08000200, 0x08000210, 0x00000002, 0x00000012, 0x08000002, 0x08000012, @@ -132,9 +136,11 @@ static const unsigned DES_INT32 PC2_C[4][64] = { 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, @@ -151,7 +157,8 @@ static const unsigned DES_INT32 PC2_D[4][64] = { 0x00200300, 0x02200300, 0x00220300, 0x02220300, 0x00200208, 0x02200208, 0x00220208, 0x02220208, 0x00200308, 0x02200308, 0x00220308, 0x02220308, - + }, + { 0x00000000, 0x00001000, 0x00000020, 0x00001020, 0x00100000, 0x00101000, 0x00100020, 0x00101020, 0x08000000, 0x08001000, 0x08000020, 0x08001020, @@ -168,7 +175,8 @@ static const unsigned DES_INT32 PC2_D[4][64] = { 0x00100404, 0x00101404, 0x00100424, 0x00101424, 0x08000404, 0x08001404, 0x08000424, 0x08001424, 0x08100404, 0x08101404, 0x08100424, 0x08101424, - + }, + { 0x00000000, 0x10000000, 0x00010000, 0x10010000, 0x00000002, 0x10000002, 0x00010002, 0x10010002, 0x00002000, 0x10002000, 0x00012000, 0x10012000, @@ -185,7 +193,8 @@ static const unsigned DES_INT32 PC2_D[4][64] = { 0x20040002, 0x30040002, 0x20050002, 0x30050002, 0x20042000, 0x30042000, 0x20052000, 0x30052000, 0x20042002, 0x30042002, 0x20052002, 0x30052002, - + }, + { 0x00000000, 0x04000000, 0x00000001, 0x04000001, 0x01000000, 0x05000000, 0x01000001, 0x05000001, 0x00000010, 0x04000010, 0x00000011, 0x04000011, @@ -202,6 +211,7 @@ static const unsigned DES_INT32 PC2_D[4][64] = { 0x01080800, 0x05080800, 0x01080801, 0x05080801, 0x00080810, 0x04080810, 0x00080811, 0x04080811, 0x01080810, 0x05080810, 0x01080811, 0x05080811 + }, }; diff --git a/src/lib/crypto/des/f_tables.c b/src/lib/crypto/des/f_tables.c index 2fd5341da..f84ade538 100644 --- a/src/lib/crypto/des/f_tables.c +++ b/src/lib/crypto/des/f_tables.c @@ -204,6 +204,7 @@ const unsigned DES_INT32 des_FP_table[256] = { * 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, @@ -220,7 +221,8 @@ const unsigned DES_INT32 des_SP_table[8][64] = { 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, @@ -237,7 +239,8 @@ const unsigned DES_INT32 des_SP_table[8][64] = { 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, @@ -254,7 +257,8 @@ const unsigned DES_INT32 des_SP_table[8][64] = { 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, @@ -271,7 +275,8 @@ const unsigned DES_INT32 des_SP_table[8][64] = { 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, @@ -288,7 +293,8 @@ const unsigned DES_INT32 des_SP_table[8][64] = { 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, @@ -305,7 +311,8 @@ const unsigned DES_INT32 des_SP_table[8][64] = { 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, @@ -322,7 +329,8 @@ const unsigned DES_INT32 des_SP_table[8][64] = { 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, @@ -339,4 +347,5 @@ const unsigned DES_INT32 des_SP_table[8][64] = { 0x00080010, 0x40004010, 0x40000010, 0x00080010, 0x00084000, 0x00000000, 0x40004000, 0x00004010, 0x40000000, 0x40080010, 0x40084010, 0x00084000 + }, }; diff --git a/src/lib/crypto/des/weak_key.c b/src/lib/crypto/des/weak_key.c index a64b2f5ad..293c25e22 100644 --- a/src/lib/crypto/des/weak_key.c +++ b/src/lib/crypto/des/weak_key.c @@ -38,7 +38,7 @@ /* * 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}, @@ -75,7 +75,7 @@ mit_des_is_weak_key(key) 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)))