diff libpurple/cipher.c @ 21015:787b3897ba9f

Patch from Andrew Gaul to constify a bunch of static variables to reduce the amount of writable memory +08108000 12K rwx-- /local/local/bin/pidgin -08107000 16K rwx-- /local/local/bin/pidgin +005bf000 20K rwx-- /local/local/lib/libpurple.so.0.2.1 -005be000 24K rwx-- /local/local/lib/libpurple.so.0.2.1
author Ka-Hing Cheung <khc@hxbc.us>
date Fri, 26 Oct 2007 04:59:23 +0000
parents 44b4e8bd759b
children 03463c52b9d7
line wrap: on
line diff
--- a/libpurple/cipher.c	Fri Oct 26 00:13:18 2007 +0000
+++ b/libpurple/cipher.c	Fri Oct 26 04:59:23 2007 +0000
@@ -616,7 +616,7 @@
 /*
  *  The s-box values are permuted according to the 'primitive function P'
  */
-static guint32 sbox1[64] =
+static const guint32 sbox1[64] =
 {
 	0x00808200, 0x00000000, 0x00008000, 0x00808202, 0x00808002, 0x00008202, 0x00000002, 0x00008000,
 	0x00000200, 0x00808200, 0x00808202, 0x00000200, 0x00800202, 0x00808002, 0x00800000, 0x00000002,
@@ -628,7 +628,7 @@
 	0x00000202, 0x00800200, 0x00800200, 0x00000000, 0x00008002, 0x00008200, 0x00000000, 0x00808002
 };
 
-static guint32 sbox2[64] =
+static const guint32 sbox2[64] =
 {
 	0x40084010, 0x40004000, 0x00004000, 0x00084010, 0x00080000, 0x00000010, 0x40080010, 0x40004010,
 	0x40000010, 0x40084010, 0x40084000, 0x40000000, 0x40004000, 0x00080000, 0x00000010, 0x40080010,
@@ -640,7 +640,7 @@
 	0x00084000, 0x00000000, 0x40004000, 0x00004010, 0x40000000, 0x40080010, 0x40084010, 0x00084000
 };
 
-static guint32 sbox3[64] =
+static const guint32 sbox3[64] =
 {
 	0x00000104, 0x04010100, 0x00000000, 0x04010004, 0x04000100, 0x00000000, 0x00010104, 0x04000100,
 	0x00010004, 0x04000004, 0x04000004, 0x00010000, 0x04010104, 0x00010004, 0x04010000, 0x00000104,
@@ -652,7 +652,7 @@
 	0x04010000, 0x04000104, 0x00000104, 0x04010000, 0x00010104, 0x00000004, 0x04010004, 0x00010100
 };
 
-static guint32 sbox4[64] =
+static const guint32 sbox4[64] =
 {
 	0x80401000, 0x80001040, 0x80001040, 0x00000040, 0x00401040, 0x80400040, 0x80400000, 0x80001000,
 	0x00000000, 0x00401000, 0x00401000, 0x80401040, 0x80000040, 0x00000000, 0x00400040, 0x80400000,
@@ -664,7 +664,7 @@
 	0x80001000, 0x00001040, 0x00400000, 0x80401000, 0x00000040, 0x00400000, 0x00001000, 0x00401040
 };
 
-static guint32 sbox5[64] =
+static const guint32 sbox5[64] =
 {
 	0x00000080, 0x01040080, 0x01040000, 0x21000080, 0x00040000, 0x00000080, 0x20000000, 0x01040000,
 	0x20040080, 0x00040000, 0x01000080, 0x20040080, 0x21000080, 0x21040000, 0x00040080, 0x20000000,
@@ -676,7 +676,7 @@
 	0x00040080, 0x01000080, 0x20000080, 0x00040000, 0x00000000, 0x20040000, 0x01040080, 0x20000080
 };
 
-static guint32 sbox6[64] =
+static const guint32 sbox6[64] =
 {
 	0x10000008, 0x10200000, 0x00002000, 0x10202008, 0x10200000, 0x00000008, 0x10202008, 0x00200000,
 	0x10002000, 0x00202008, 0x00200000, 0x10000008, 0x00200008, 0x10002000, 0x10000000, 0x00002008,
@@ -688,7 +688,7 @@
 	0x00002000, 0x00200008, 0x10002008, 0x00000000, 0x10202000, 0x10000000, 0x00200008, 0x10002008
 };
 
-static guint32 sbox7[64] =
+static const guint32 sbox7[64] =
 {
 	0x00100000, 0x02100001, 0x02000401, 0x00000000, 0x00000400, 0x02000401, 0x00100401, 0x02100400,
 	0x02100401, 0x00100000, 0x00000000, 0x02000001, 0x00000001, 0x02000000, 0x02100001, 0x00000401,
@@ -700,7 +700,7 @@
 	0x00000000, 0x00100401, 0x02100000, 0x00000400, 0x02000001, 0x02000400, 0x00000400, 0x00100001
 };
 
-static guint32 sbox8[64] =
+static const guint32 sbox8[64] =
 {
 	0x08000820, 0x00000800, 0x00020000, 0x08020820, 0x08000000, 0x08000820, 0x00000020, 0x08000000,
 	0x00020020, 0x08020000, 0x08020820, 0x00020800, 0x08020800, 0x00020820, 0x00000800, 0x00000020,
@@ -718,7 +718,7 @@
  *  * These two tables are part of the 'permuted choice 1' function.
  *   * In this implementation several speed improvements are done.
  *    */
-static guint32 leftkey_swap[16] =
+static const guint32 leftkey_swap[16] =
 {
 	0x00000000, 0x00000001, 0x00000100, 0x00000101,
 	0x00010000, 0x00010001, 0x00010100, 0x00010101,
@@ -726,7 +726,7 @@
 	0x01010000, 0x01010001, 0x01010100, 0x01010101
 };
 
-static guint32 rightkey_swap[16] =
+static const guint32 rightkey_swap[16] =
 {
 	0x00000000, 0x01000000, 0x00010000, 0x01010000,
 	0x00000100, 0x01000100, 0x00010100, 0x01010100,
@@ -742,7 +742,7 @@
  *  ordering of the subkeys so we can omit the table for decryption
  *  subkey schedule.
  */
-static guint8 encrypt_rotate_tab[16] =
+static const guint8 encrypt_rotate_tab[16] =
 {
 	1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1
 };