From c9414460b36428a3d5f29b9ee943052bdebc1528 Mon Sep 17 00:00:00 2001 From: Marc Cannon Date: Thu, 24 Jan 2013 06:35:24 -0500 Subject: [PATCH] Fix up LTC macro inclusions: don't pull in tab files or algorithms unless we're actually using them --- src/libtomcrypt/src/ciphers/aes/aes_tab.c | 5 +++++ src/libtomcrypt/src/ciphers/safer/safer_tab.c | 2 +- src/libtomcrypt/src/ciphers/twofish/twofish_tab.c | 1 + src/libtomcrypt/src/hashes/sha2/sha224.c | 5 +++++ src/libtomcrypt/src/hashes/sha2/sha384.c | 9 +++++---- src/libtomcrypt/src/hashes/whirl/whirltab.c | 5 +++++ src/libtomcrypt/src/prngs/sober128tab.c | 6 ++++++ 7 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/libtomcrypt/src/ciphers/aes/aes_tab.c b/src/libtomcrypt/src/ciphers/aes/aes_tab.c index ca7008d5..9057af51 100644 --- a/src/libtomcrypt/src/ciphers/aes/aes_tab.c +++ b/src/libtomcrypt/src/ciphers/aes/aes_tab.c @@ -23,6 +23,9 @@ Td3[x] = Si[x].[09, 0d, 0b, 0e]; Td4[x] = Si[x].[01, 01, 01, 01]; */ +#ifdef LTC_RIJNDAEL +#include "tomcrypt_macros.h" + /** @file aes_tab.c AES tables @@ -1023,6 +1026,8 @@ static const ulong32 rcon[] = { 0x1B000000UL, 0x36000000UL, /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */ }; +#endif /* LTC_RIJNDAEL */ + /* $Source$ */ /* $Revision$ */ /* $Date$ */ diff --git a/src/libtomcrypt/src/ciphers/safer/safer_tab.c b/src/libtomcrypt/src/ciphers/safer/safer_tab.c index 9a515ff5..6ed6ff68 100644 --- a/src/libtomcrypt/src/ciphers/safer/safer_tab.c +++ b/src/libtomcrypt/src/ciphers/safer/safer_tab.c @@ -14,9 +14,9 @@ Tables for LTC_SAFER block ciphers */ -#include "tomcrypt.h" #if defined(LTC_SAFERP) || defined(LTC_SAFER) +#include "tomcrypt.h" /* This is the box defined by ebox[x] = 45^x mod 257. * Its assumed that the value "256" corresponds to zero. */ diff --git a/src/libtomcrypt/src/ciphers/twofish/twofish_tab.c b/src/libtomcrypt/src/ciphers/twofish/twofish_tab.c index ea3eb21b..cba52dd0 100644 --- a/src/libtomcrypt/src/ciphers/twofish/twofish_tab.c +++ b/src/libtomcrypt/src/ciphers/twofish/twofish_tab.c @@ -14,6 +14,7 @@ Twofish tables, Tom St Denis */ #ifdef LTC_TWOFISH_TABLES +#include "tomcrypt_macros.h" /* pre generated 8x8 tables from the four 4x4s */ static const unsigned char SBOX[2][256] = { diff --git a/src/libtomcrypt/src/hashes/sha2/sha224.c b/src/libtomcrypt/src/hashes/sha2/sha224.c index 5d7dfb23..655e203d 100644 --- a/src/libtomcrypt/src/hashes/sha2/sha224.c +++ b/src/libtomcrypt/src/hashes/sha2/sha224.c @@ -8,6 +8,10 @@ * * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ +#include "tomcrypt.h" + +#ifdef LTC_SHA224 + /** @param sha224.c LTC_SHA-224 new NIST standard based off of LTC_SHA-256 truncated to 224 bits (Tom St Denis) @@ -119,6 +123,7 @@ int sha224_test(void) #endif } +#endif /* LTC_SHA224 */ /* $Source$ */ /* $Revision$ */ diff --git a/src/libtomcrypt/src/hashes/sha2/sha384.c b/src/libtomcrypt/src/hashes/sha2/sha384.c index cf4d7dc3..2a67df68 100644 --- a/src/libtomcrypt/src/hashes/sha2/sha384.c +++ b/src/libtomcrypt/src/hashes/sha2/sha384.c @@ -8,6 +8,10 @@ * * Tom St Denis, tomstdenis@gmail.com, http://libtom.org */ +#include "tomcrypt.h" + +#ifdef LTC_SHA384 + /** @param sha384.c LTC_SHA384 hash included in sha512.c, Tom St Denis @@ -125,10 +129,7 @@ int sha384_test(void) #endif } - - - - +#endif /* LTC_SHA384 */ /* $Source$ */ /* $Revision$ */ diff --git a/src/libtomcrypt/src/hashes/whirl/whirltab.c b/src/libtomcrypt/src/hashes/whirl/whirltab.c index 85ba3122..a99778e9 100644 --- a/src/libtomcrypt/src/hashes/whirl/whirltab.c +++ b/src/libtomcrypt/src/hashes/whirl/whirltab.c @@ -2,6 +2,10 @@ @file whirltab.c LTC_WHIRLPOOL tables, Tom St Denis */ + +#if defined(LTC_WHIRLPOOL) || 1 +#include "tomcrypt_macros.h" + static const ulong64 sbox0[] = { CONST64(0x18186018c07830d8), CONST64(0x23238c2305af4626), CONST64(0xc6c63fc67ef991b8), CONST64(0xe8e887e8136fcdfb), CONST64(0x878726874ca113cb), CONST64(0xb8b8dab8a9626d11), CONST64(0x0101040108050209), CONST64(0x4f4f214f426e9e0d), @@ -577,6 +581,7 @@ CONST64(0xca2dbf07ad5a8333), CONST64(0x6302aa71c81949d9), }; +#endif /* LTC_WHIRLPOOL */ /* $Source$ */ /* $Revision$ */ diff --git a/src/libtomcrypt/src/prngs/sober128tab.c b/src/libtomcrypt/src/prngs/sober128tab.c index a5754c72..a4462665 100644 --- a/src/libtomcrypt/src/prngs/sober128tab.c +++ b/src/libtomcrypt/src/prngs/sober128tab.c @@ -5,6 +5,10 @@ /* $ID$ */ /* @(#)TuringMultab.h 1.3 (QUALCOMM) 02/09/03 */ /* Multiplication table for Turing using 0xD02B4367 */ + +#ifdef LTC_SOBER128 +#include "tomcrypt_macros.h" + static const ulong32 Multab[256] = { 0x00000000, 0xD02B4367, 0xED5686CE, 0x3D7DC5A9, 0x97AC41D1, 0x478702B6, 0x7AFAC71F, 0xAAD18478, @@ -157,6 +161,8 @@ static const ulong32 Sbox[256] = { 0xf9e6053f, 0xa4b0d300, 0xd499cbcc, 0xb95e3d40, }; +#endif /* LTC_SOBER128 */ + /* $Source$ */ /* $Revision$ */ /* $Date$ */ -- 2.11.0