From 155a54ba40f65d3f4e4bcfb5cb93478f7b21eba5 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Thu, 17 Jul 2014 10:49:05 +0200 Subject: [PATCH] add LTC prefix to most macros --- src/encauth/gcm/gcm_gf_mult.c | 2 +- src/headers/tomcrypt_cipher.h | 2 +- src/headers/tomcrypt_custom.h | 50 ++++++++++++++++---------------- src/headers/tomcrypt_mac.h | 2 +- src/headers/tomcrypt_pk.h | 2 +- src/math/multi.c | 2 +- src/misc/crypt/crypt.c | 8 ++--- src/misc/crypt/crypt_constants.c | 6 ++-- src/misc/crypt/crypt_sizes.c | 2 +- src/modes/lrw/lrw_process.c | 4 +-- src/modes/lrw/lrw_setiv.c | 4 +-- src/modes/lrw/lrw_start.c | 4 +-- src/pk/dh/dh_static.c | 18 ++++++------ src/pk/ecc/ecc.c | 18 ++++++------ src/pk/katja/katja_decrypt_key.c | 2 +- src/pk/katja/katja_encrypt_key.c | 2 +- src/pk/katja/katja_export.c | 2 +- src/pk/katja/katja_exptmod.c | 2 +- src/pk/katja/katja_free.c | 2 +- src/pk/katja/katja_import.c | 2 +- src/pk/katja/katja_make_key.c | 2 +- src/prngs/rng_get_bytes.c | 4 +-- testprof/katja_test.c | 2 +- testprof/x86_prof.c | 4 +-- 24 files changed, 74 insertions(+), 74 deletions(-) diff --git a/src/encauth/gcm/gcm_gf_mult.c b/src/encauth/gcm/gcm_gf_mult.c index 72e0624..37d8a57 100644 --- a/src/encauth/gcm/gcm_gf_mult.c +++ b/src/encauth/gcm/gcm_gf_mult.c @@ -15,7 +15,7 @@ */ #include "tomcrypt.h" -#if defined(LTC_GCM_TABLES) || defined(LRW_TABLES) || ((defined(LTC_GCM_MODE) || defined(LTC_GCM_MODE)) && defined(LTC_FAST)) +#if defined(LTC_GCM_TABLES) || defined(LTC_LRW_TABLES) || ((defined(LTC_GCM_MODE) || defined(LTC_GCM_MODE)) && defined(LTC_FAST)) /* this is x*2^128 mod p(x) ... the results are 16 bytes each stored in a packed format. Since only the * lower 16 bits are not zero'ed I removed the upper 14 bytes */ diff --git a/src/headers/tomcrypt_cipher.h b/src/headers/tomcrypt_cipher.h index f19ec86..a7142a0 100644 --- a/src/headers/tomcrypt_cipher.h +++ b/src/headers/tomcrypt_cipher.h @@ -310,7 +310,7 @@ typedef struct { /** The scheduled symmetric key */ symmetric_key key; -#ifdef LRW_TABLES +#ifdef LTC_LRW_TABLES /** The pre-computed multiplication table */ unsigned char PC[16][256][16]; #endif diff --git a/src/headers/tomcrypt_custom.h b/src/headers/tomcrypt_custom.h index 0494202..025fb81 100644 --- a/src/headers/tomcrypt_custom.h +++ b/src/headers/tomcrypt_custom.h @@ -108,7 +108,7 @@ #define LTC_SPRNG #define LTC_YARROW #define LTC_DEVRANDOM - #define TRY_URANDOM_FIRST + #define LTC_TRY_URANDOM_FIRST #define LTC_NO_PK #define LTC_MRSA @@ -212,7 +212,7 @@ /* like GCM mode this will enable 16 8x128 tables [64KB] that make * seeking very fast. */ - #define LRW_TABLES + #define LTC_LRW_TABLES #endif /* XTS mode */ @@ -304,7 +304,7 @@ /* the *nix style /dev/random device */ #define LTC_DEVRANDOM /* try /dev/urandom before trying /dev/random */ -#define TRY_URANDOM_FIRST +#define LTC_TRY_URANDOM_FIRST #endif /* LTC_NO_PRNGS */ @@ -324,23 +324,23 @@ /* is_prime fails for GMP */ #define LTC_MDH /* Supported Key Sizes */ -#define DH768 -#define DH1024 -#define DH1280 -#define DH1536 -#define DH1792 -#define DH2048 +#define LTC_DH768 +#define LTC_DH1024 +#define LTC_DH1280 +#define LTC_DH1536 +#define LTC_DH1792 +#define LTC_DH2048 #ifndef TFM_DESC /* tfm has a problem in fp_isprime for larger key sizes */ -#define DH2560 -#define DH3072 -#define DH4096 +#define LTC_DH2560 +#define LTC_DH3072 +#define LTC_DH4096 #endif #endif /* Include Katja (a Rabin variant like RSA) */ -/* #define MKAT */ +/* #define LTC_MKAT */ /* Digital Signature Algorithm */ #define LTC_MDSA @@ -398,20 +398,20 @@ #ifdef LTC_MECC /* Supported ECC Key Sizes */ #ifndef LTC_NO_CURVES - #define ECC112 - #define ECC128 - #define ECC160 - #define ECC192 - #define ECC224 - #define ECC256 - #define ECC384 - #define ECC521 + #define LTC_ECC112 + #define LTC_ECC128 + #define LTC_ECC160 + #define LTC_ECC192 + #define LTC_ECC224 + #define LTC_ECC256 + #define LTC_ECC384 + #define LTC_ECC521 #endif #endif -#if defined(LTC_MECC) || defined(LTC_MRSA) || defined(LTC_MDSA) || defined(MKATJA) +#if defined(LTC_MECC) || defined(LTC_MRSA) || defined(LTC_MDSA) || defined(LTC_MKAT) /* Include the MPI functionality? (required by the PK algorithms) */ - #define MPI + #define LTC_MPI #endif #ifdef LTC_MRSA @@ -435,11 +435,11 @@ #error LTC_YARROW requires LTC_CTR_MODE chaining mode to be defined! #endif -#if defined(LTC_DER) && !defined(MPI) +#if defined(LTC_DER) && !defined(LTC_MPI) #error ASN.1 DER requires MPI functionality #endif -#if (defined(LTC_MDSA) || defined(LTC_MRSA) || defined(LTC_MECC) || defined(MKATJA)) && !defined(LTC_DER) +#if (defined(LTC_MDSA) || defined(LTC_MRSA) || defined(LTC_MECC) || defined(LTC_MKAT)) && !defined(LTC_DER) #error PK requires ASN.1 DER functionality, make sure LTC_DER is enabled #endif diff --git a/src/headers/tomcrypt_mac.h b/src/headers/tomcrypt_mac.h index 7ec662a..5d71af6 100644 --- a/src/headers/tomcrypt_mac.h +++ b/src/headers/tomcrypt_mac.h @@ -292,7 +292,7 @@ void gcm_gf_mult(const unsigned char *a, const unsigned char *b, unsigned char * /* table shared between GCM and LRW */ -#if defined(LTC_GCM_TABLES) || defined(LRW_TABLES) || ((defined(LTC_GCM_MODE) || defined(LTC_GCM_MODE)) && defined(LTC_FAST)) +#if defined(LTC_GCM_TABLES) || defined(LTC_LRW_TABLES) || ((defined(LTC_GCM_MODE) || defined(LTC_GCM_MODE)) && defined(LTC_FAST)) extern const unsigned char gcm_shift_table[]; #endif diff --git a/src/headers/tomcrypt_pk.h b/src/headers/tomcrypt_pk.h index 2a8987b..ef0a5f9 100644 --- a/src/headers/tomcrypt_pk.h +++ b/src/headers/tomcrypt_pk.h @@ -111,7 +111,7 @@ int rsa_import(const unsigned char *in, unsigned long inlen, rsa_key *key); #endif /* ---- Katja ---- */ -#ifdef MKAT +#ifdef LTC_MKAT /* Min and Max KAT key sizes (in bits) */ #define MIN_KAT_SIZE 1024 diff --git a/src/math/multi.c b/src/math/multi.c index 6c6537c..f85e900 100644 --- a/src/math/multi.c +++ b/src/math/multi.c @@ -10,7 +10,7 @@ */ #include "tomcrypt.h" -#ifdef MPI +#ifdef LTC_MPI #include int ltc_init_multi(void **a, ...) diff --git a/src/misc/crypt/crypt.c b/src/misc/crypt/crypt.c index f7b83d1..a5fbbca 100644 --- a/src/misc/crypt/crypt.c +++ b/src/misc/crypt/crypt.c @@ -188,7 +188,7 @@ const char *crypt_build_settings = #endif #if defined(LTC_LRW_MODE) " LRW" -#if defined(LRW_TABLES) +#if defined(LTC_LRW_TABLES) " (tables) " #endif "\n" @@ -282,7 +282,7 @@ const char *crypt_build_settings = #if defined(LTC_MDSA) " DSA\n" #endif -#if defined(MKAT) +#if defined(LTC_MKAT) " Katja\n" #endif @@ -338,8 +338,8 @@ const char *crypt_build_settings = #if defined(MPI) " MPI " #endif -#if defined(TRY_URANDOM_FIRST) - " TRY_URANDOM_FIRST " +#if defined(LTC_TRY_URANDOM_FIRST) + " LTC_TRY_URANDOM_FIRST " #endif #if defined(LTC_TEST) " LTC_TEST " diff --git a/src/misc/crypt/crypt_constants.c b/src/misc/crypt/crypt_constants.c index adb6836..b0af4dd 100755 --- a/src/misc/crypt/crypt_constants.c +++ b/src/misc/crypt/crypt_constants.c @@ -56,12 +56,12 @@ static const crypt_constant _crypt_constants[] = { {"LTC_MRSA", 0}, #endif -#ifdef MKAT - {"MKAT", 1}, +#ifdef LTC_MKAT + {"LTC_MKAT", 1}, _C_STRINGIFY(MIN_KAT_SIZE), _C_STRINGIFY(MAX_KAT_SIZE), #else - {"MKAT", 0}, + {"LTC_MKAT", 0}, #endif #ifdef LTC_MECC diff --git a/src/misc/crypt/crypt_sizes.c b/src/misc/crypt/crypt_sizes.c index d7b1cb8..c758dbe 100755 --- a/src/misc/crypt/crypt_sizes.c +++ b/src/misc/crypt/crypt_sizes.c @@ -210,7 +210,7 @@ static const crypt_size _crypt_sizes[] = { _SZ_STRINGIFY_T(ecc_key), _SZ_STRINGIFY_T(ecc_point), #endif -#ifdef MKAT +#ifdef LTC_MKAT _SZ_STRINGIFY_T(katja_key), #endif diff --git a/src/modes/lrw/lrw_process.c b/src/modes/lrw/lrw_process.c index e7b567b..8a4fd1a 100644 --- a/src/modes/lrw/lrw_process.c +++ b/src/modes/lrw/lrw_process.c @@ -30,7 +30,7 @@ int lrw_process(const unsigned char *pt, unsigned char *ct, unsigned long len, i { unsigned char prod[16]; int x, err; -#ifdef LRW_TABLES +#ifdef LTC_LRW_TABLES int y; #endif @@ -55,7 +55,7 @@ int lrw_process(const unsigned char *pt, unsigned char *ct, unsigned long len, i } /* update pad */ -#ifdef LRW_TABLES +#ifdef LTC_LRW_TABLES /* for each byte changed we undo it's affect on the pad then add the new product */ for (; x < 16; x++) { #ifdef LTC_FAST diff --git a/src/modes/lrw/lrw_setiv.c b/src/modes/lrw/lrw_setiv.c index 8a2ff9a..d2e21d3 100644 --- a/src/modes/lrw/lrw_setiv.c +++ b/src/modes/lrw/lrw_setiv.c @@ -27,7 +27,7 @@ int lrw_setiv(const unsigned char *IV, unsigned long len, symmetric_LRW *lrw) { int err; -#ifdef LRW_TABLES +#ifdef LTC_LRW_TABLES unsigned char T[16]; int x, y; #endif @@ -51,7 +51,7 @@ int lrw_setiv(const unsigned char *IV, unsigned long len, symmetric_LRW *lrw) return CRYPT_OK; } -#ifdef LRW_TABLES +#ifdef LTC_LRW_TABLES XMEMCPY(T, &lrw->PC[0][IV[0]][0], 16); for (x = 1; x < 16; x++) { #ifdef LTC_FAST diff --git a/src/modes/lrw/lrw_start.c b/src/modes/lrw/lrw_start.c index f378789..bf9b275 100644 --- a/src/modes/lrw/lrw_start.c +++ b/src/modes/lrw/lrw_start.c @@ -36,7 +36,7 @@ int lrw_start( int cipher, symmetric_LRW *lrw) { int err; -#ifdef LRW_TABLES +#ifdef LTC_LRW_TABLES unsigned char B[16]; int x, y, z, t; #endif @@ -69,7 +69,7 @@ int lrw_start( int cipher, /* copy the IV and tweak */ XMEMCPY(lrw->tweak, tweak, 16); -#ifdef LRW_TABLES +#ifdef LTC_LRW_TABLES /* setup tables */ /* generate the first table as it has no shifting (from which we make the other tables) */ zeromem(B, 16); diff --git a/src/pk/dh/dh_static.c b/src/pk/dh/dh_static.c index 043d3b1..d154017 100644 --- a/src/pk/dh/dh_static.c +++ b/src/pk/dh/dh_static.c @@ -22,7 +22,7 @@ /* This holds the key settings. ***MUST*** be organized by size from smallest to largest. */ const dh_set sets[] = { -#ifdef DH768 +#ifdef LTC_DH768 { 96, "DH-768", @@ -32,7 +32,7 @@ const dh_set sets[] = { "//////m3wvV" }, #endif -#ifdef DH1024 +#ifdef LTC_DH1024 { 128, "DH-1024", @@ -42,7 +42,7 @@ const dh_set sets[] = { "////////////////////////////////////////////////m3C47" }, #endif -#ifdef DH1280 +#ifdef LTC_DH1280 { 160, "DH-1280", @@ -53,7 +53,7 @@ const dh_set sets[] = { "//////////////////////////////m4kSN" }, #endif -#ifdef DH1536 +#ifdef LTC_DH1536 { 192, "DH-1536", @@ -65,7 +65,7 @@ const dh_set sets[] = { "////////////m5uqd" }, #endif -#ifdef DH1792 +#ifdef LTC_DH1792 { 224, "DH-1792", @@ -77,7 +77,7 @@ const dh_set sets[] = { "//////////////////////////////////////////////////////mT/sd" }, #endif -#ifdef DH2048 +#ifdef LTC_DH2048 { 256, "DH-2048", @@ -90,7 +90,7 @@ const dh_set sets[] = { "/////////////////////////////////////////m8MPh" }, #endif -#ifdef DH2560 +#ifdef LTC_DH2560 { 320, "DH-2560", @@ -105,7 +105,7 @@ const dh_set sets[] = { "/////mKFpF" }, #endif -#ifdef DH3072 +#ifdef LTC_DH3072 { 384, "DH-3072", @@ -121,7 +121,7 @@ const dh_set sets[] = { "/////////////////////////////m32nN" }, #endif -#ifdef DH4096 +#ifdef LTC_DH4096 { 512, "DH-4096", diff --git a/src/pk/ecc/ecc.c b/src/pk/ecc/ecc.c index 56ed526..3cef4d3 100644 --- a/src/pk/ecc/ecc.c +++ b/src/pk/ecc/ecc.c @@ -19,13 +19,13 @@ /** @file ecc.c ECC Crypto, Tom St Denis -*/ +*/ #ifdef LTC_MECC /* This holds the key settings. ***MUST*** be organized by size from smallest to largest. */ const ltc_ecc_set_type ltc_ecc_sets[] = { -#ifdef ECC112 +#ifdef LTC_ECC112 { 14, "SECP112R1", @@ -36,7 +36,7 @@ const ltc_ecc_set_type ltc_ecc_sets[] = { "A89CE5AF8724C0A23E0E0FF77500" }, #endif -#ifdef ECC128 +#ifdef LTC_ECC128 { 16, "SECP128R1", @@ -47,7 +47,7 @@ const ltc_ecc_set_type ltc_ecc_sets[] = { "CF5AC8395BAFEB13C02DA292DDED7A83", }, #endif -#ifdef ECC160 +#ifdef LTC_ECC160 { 20, "SECP160R1", @@ -58,7 +58,7 @@ const ltc_ecc_set_type ltc_ecc_sets[] = { "23A628553168947D59DCC912042351377AC5FB32", }, #endif -#ifdef ECC192 +#ifdef LTC_ECC192 { 24, "ECC-192", @@ -69,7 +69,7 @@ const ltc_ecc_set_type ltc_ecc_sets[] = { "7192B95FFC8DA78631011ED6B24CDD573F977A11E794811", }, #endif -#ifdef ECC224 +#ifdef LTC_ECC224 { 28, "ECC-224", @@ -80,7 +80,7 @@ const ltc_ecc_set_type ltc_ecc_sets[] = { "BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34", }, #endif -#ifdef ECC256 +#ifdef LTC_ECC256 { 32, "ECC-256", @@ -91,7 +91,7 @@ const ltc_ecc_set_type ltc_ecc_sets[] = { "4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5", }, #endif -#ifdef ECC384 +#ifdef LTC_ECC384 { 48, "ECC-384", @@ -102,7 +102,7 @@ const ltc_ecc_set_type ltc_ecc_sets[] = { "3617DE4A96262C6F5D9E98BF9292DC29F8F41DBD289A147CE9DA3113B5F0B8C00A60B1CE1D7E819D7A431D7C90EA0E5F", }, #endif -#ifdef ECC521 +#ifdef LTC_ECC521 { 66, "ECC-521", diff --git a/src/pk/katja/katja_decrypt_key.c b/src/pk/katja/katja_decrypt_key.c index 4a33558..aae323d 100644 --- a/src/pk/katja/katja_decrypt_key.c +++ b/src/pk/katja/katja_decrypt_key.c @@ -15,7 +15,7 @@ Katja PKCS #1 OAEP Decryption, Tom St Denis */ -#ifdef MKAT +#ifdef LTC_MKAT /** (PKCS #1 v2.0) decrypt then OAEP depad diff --git a/src/pk/katja/katja_encrypt_key.c b/src/pk/katja/katja_encrypt_key.c index 08635eb..12ca1e2 100644 --- a/src/pk/katja/katja_encrypt_key.c +++ b/src/pk/katja/katja_encrypt_key.c @@ -15,7 +15,7 @@ Katja PKCS-style OAEP encryption, Tom St Denis */ -#ifdef MKAT +#ifdef LTC_MKAT /** (PKCS #1 v2.0) OAEP pad then encrypt diff --git a/src/pk/katja/katja_export.c b/src/pk/katja/katja_export.c index 97c63aa..2e0e7d3 100644 --- a/src/pk/katja/katja_export.c +++ b/src/pk/katja/katja_export.c @@ -15,7 +15,7 @@ Export Katja PKCS-style keys, Tom St Denis */ -#ifdef MKAT +#ifdef LTC_MKAT /** This will export either an KatjaPublicKey or KatjaPrivateKey diff --git a/src/pk/katja/katja_exptmod.c b/src/pk/katja/katja_exptmod.c index 7cf5604..c70eec9 100644 --- a/src/pk/katja/katja_exptmod.c +++ b/src/pk/katja/katja_exptmod.c @@ -15,7 +15,7 @@ Katja PKCS-style exptmod, Tom St Denis */ -#ifdef MKAT +#ifdef LTC_MKAT /** Compute an RSA modular exponentiation diff --git a/src/pk/katja/katja_free.c b/src/pk/katja/katja_free.c index c5a46af..767486a 100644 --- a/src/pk/katja/katja_free.c +++ b/src/pk/katja/katja_free.c @@ -15,7 +15,7 @@ Free an Katja key, Tom St Denis */ -#ifdef MKAT +#ifdef LTC_MKAT /** Free an Katja key from memory diff --git a/src/pk/katja/katja_import.c b/src/pk/katja/katja_import.c index 3ea6062..c306867 100644 --- a/src/pk/katja/katja_import.c +++ b/src/pk/katja/katja_import.c @@ -15,7 +15,7 @@ Import a PKCS-style Katja key, Tom St Denis */ -#ifdef MKAT +#ifdef LTC_MKAT /** Import an KatjaPublicKey or KatjaPrivateKey [two-prime only, only support >= 1024-bit keys, defined in PKCS #1 v2.1] diff --git a/src/pk/katja/katja_make_key.c b/src/pk/katja/katja_make_key.c index eec8e98..86b4c1a 100644 --- a/src/pk/katja/katja_make_key.c +++ b/src/pk/katja/katja_make_key.c @@ -15,7 +15,7 @@ Katja key generation, Tom St Denis */ -#ifdef MKAT +#ifdef LTC_MKAT /** Create a Katja key diff --git a/src/prngs/rng_get_bytes.c b/src/prngs/rng_get_bytes.c index 5604838..3839794 100644 --- a/src/prngs/rng_get_bytes.c +++ b/src/prngs/rng_get_bytes.c @@ -25,10 +25,10 @@ static unsigned long rng_nix(unsigned char *buf, unsigned long len, #else FILE *f; unsigned long x; -#ifdef TRY_URANDOM_FIRST +#ifdef LTC_TRY_URANDOM_FIRST f = fopen("/dev/urandom", "rb"); if (f == NULL) -#endif /* TRY_URANDOM_FIRST */ +#endif /* LTC_TRY_URANDOM_FIRST */ f = fopen("/dev/random", "rb"); if (f == NULL) { diff --git a/testprof/katja_test.c b/testprof/katja_test.c index 86fe6b0..a597892 100644 --- a/testprof/katja_test.c +++ b/testprof/katja_test.c @@ -1,6 +1,6 @@ #include -#ifdef MKAT +#ifdef LTC_MKAT int katja_test(void) { diff --git a/testprof/x86_prof.c b/testprof/x86_prof.c index 4dbaa71..70b130a 100644 --- a/testprof/x86_prof.c +++ b/testprof/x86_prof.c @@ -776,10 +776,10 @@ int time_hash(void) /*#warning you need an mp_rand!!!*/ #ifndef USE_LTM - #undef MPI + #undef LTC_MPI #endif -#ifdef MPI +#ifdef LTC_MPI void time_mult(void) { ulong64 t1, t2;