From dfa938a4f630ee3690fb694def9a75c33944748e Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Sun, 15 Feb 2015 17:25:45 +0100 Subject: [PATCH] verify outcome when defining LTC_NOTHING check that LTC_NOTHING really creates nothing but the libraries' basic API functions --- src/hashes/helper/hash_memory.c | 2 ++ src/hashes/helper/hash_memory_multi.c | 9 ++++++--- src/headers/tomcrypt_custom.h | 10 ++++++++++ src/math/rand_bn.c | 2 ++ src/misc/pk_get_oid.c | 2 ++ src/prngs/rng_get_bytes.c | 2 ++ src/prngs/rng_make_prng.c | 10 ++++++---- 7 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/hashes/helper/hash_memory.c b/src/hashes/helper/hash_memory.c index 853183a..53caa5d 100644 --- a/src/hashes/helper/hash_memory.c +++ b/src/hashes/helper/hash_memory.c @@ -10,6 +10,7 @@ */ #include "tomcrypt.h" +#ifdef LTC_HASH_HELPERS /** @file hash_memory.c Hash memory helper, Tom St Denis @@ -63,6 +64,7 @@ LBL_ERR: return err; } +#endif /* #ifdef LTC_HASH_HELPERS */ /* $Source$ */ /* $Revision$ */ diff --git a/src/hashes/helper/hash_memory_multi.c b/src/hashes/helper/hash_memory_multi.c index ef39646..560d6f6 100644 --- a/src/hashes/helper/hash_memory_multi.c +++ b/src/hashes/helper/hash_memory_multi.c @@ -10,13 +10,15 @@ */ #include "tomcrypt.h" #include + +#ifdef LTC_HASH_HELPERS /** @file hash_memory_multi.c Hash (multiple buffers) memory helper, Tom St Denis */ /** - Hash multiple (non-adjacent) blocks of memory at once. + Hash multiple (non-adjacent) blocks of memory at once. @param hash The index of the hash you wish to use @param out [out] Where to store the digest @param outlen [in/out] Max size and resulting size of the digest @@ -24,7 +26,7 @@ @param inlen The length of the data to hash (octets) @param ... tuples of (data,len) pairs to hash, terminated with a (NULL,x) (x=don't care) @return CRYPT_OK if successful -*/ +*/ int hash_memory_multi(int hash, unsigned char *out, unsigned long *outlen, const unsigned char *in, unsigned long inlen, ...) { @@ -57,7 +59,7 @@ int hash_memory_multi(int hash, unsigned char *out, unsigned long *outlen, } va_start(args, inlen); - curptr = in; + curptr = in; curlen = inlen; for (;;) { /* process buf */ @@ -81,6 +83,7 @@ LBL_ERR: va_end(args); return err; } +#endif /* #ifdef LTC_HASH_HELPERS */ /* $Source$ */ /* $Revision$ */ diff --git a/src/headers/tomcrypt_custom.h b/src/headers/tomcrypt_custom.h index bf3e8f4..3a2b0dd 100644 --- a/src/headers/tomcrypt_custom.h +++ b/src/headers/tomcrypt_custom.h @@ -77,6 +77,7 @@ #define LTC_NO_PK #define LTC_NO_PKCS #define LTC_NO_MISC + #define LTC_NO_FILE #endif /* LTC_NOTHING */ /* Easy button? */ @@ -98,6 +99,7 @@ #define LTC_SHA384 #define LTC_SHA256 #define LTC_SHA224 + #define LTC_HASH_HELPERS #define LTC_NO_MACS #define LTC_HMAC @@ -109,6 +111,8 @@ #define LTC_YARROW #define LTC_DEVRANDOM #define LTC_TRY_URANDOM_FIRST + #define LTC_RNG_GET_BYTES + #define LTC_RNG_MAKE_PRNG #define LTC_NO_PK #define LTC_MRSA @@ -241,6 +245,8 @@ #define LTC_RIPEMD256 #define LTC_RIPEMD320 +#define LTC_HASH_HELPERS + #endif /* LTC_NO_HASHES */ /* ---> MAC functions <--- */ @@ -307,6 +313,10 @@ #define LTC_DEVRANDOM /* try /dev/urandom before trying /dev/random */ #define LTC_TRY_URANDOM_FIRST +/* rng_get_bytes() */ +#define LTC_RNG_GET_BYTES +/* rng_make_prng() */ +#define LTC_RNG_MAKE_PRNG #endif /* LTC_NO_PRNGS */ diff --git a/src/math/rand_bn.c b/src/math/rand_bn.c index 39ff73c..e7bddd9 100755 --- a/src/math/rand_bn.c +++ b/src/math/rand_bn.c @@ -9,6 +9,7 @@ */ #include "tomcrypt.h" +#ifdef LTC_MDSA /** Generate a random number N with given bitlength (note: MSB can be 0) */ @@ -67,3 +68,4 @@ int rand_bn_range(void *N, void *limit, prng_state *prng, int wprng) return CRYPT_OK; } +#endif diff --git a/src/misc/pk_get_oid.c b/src/misc/pk_get_oid.c index c48049e..7d3a186 100644 --- a/src/misc/pk_get_oid.c +++ b/src/misc/pk_get_oid.c @@ -9,6 +9,7 @@ */ #include "tomcrypt.h" +#ifdef LTC_DER static const oid_st rsa_oid = { { 1, 2, 840, 113549, 1, 1, 1 }, 7, @@ -37,3 +38,4 @@ int pk_get_oid(int pk, oid_st *st) } return CRYPT_OK; } +#endif diff --git a/src/prngs/rng_get_bytes.c b/src/prngs/rng_get_bytes.c index 90338cb..becb5bd 100644 --- a/src/prngs/rng_get_bytes.c +++ b/src/prngs/rng_get_bytes.c @@ -10,6 +10,7 @@ */ #include "tomcrypt.h" +#ifdef LTC_RNG_GET_BYTES /** @file rng_get_bytes.c portable way to get secure random bits to feed a PRNG (Tom St Denis) @@ -150,6 +151,7 @@ unsigned long rng_get_bytes(unsigned char *out, unsigned long outlen, #endif return 0; } +#endif /* #ifdef LTC_RNG_GET_BYTES */ /* $Source$ */ /* $Revision$ */ diff --git a/src/prngs/rng_make_prng.c b/src/prngs/rng_make_prng.c index 6ba2cbe..05af405 100644 --- a/src/prngs/rng_make_prng.c +++ b/src/prngs/rng_make_prng.c @@ -10,7 +10,8 @@ */ #include "tomcrypt.h" -/** +#ifdef LTC_RNG_MAKE_PRNG +/** @file rng_make_prng.c portable way to get secure random bits to feed a PRNG (Tom St Denis) */ @@ -22,13 +23,13 @@ @param prng [out] PRNG state to initialize @param callback A pointer to a void function for when the RNG is slow, this can be NULL @return CRYPT_OK if successful -*/ -int rng_make_prng(int bits, int wprng, prng_state *prng, +*/ +int rng_make_prng(int bits, int wprng, prng_state *prng, void (*callback)(void)) { unsigned char buf[256]; int err; - + LTC_ARGCHK(prng != NULL); /* check parameter */ @@ -62,6 +63,7 @@ int rng_make_prng(int bits, int wprng, prng_state *prng, #endif return CRYPT_OK; } +#endif /* #ifdef LTC_RNG_MAKE_PRNG */ /* $Source$ */