diff options
Diffstat (limited to 'src/lib/cryptolink/crypto_hmac.cc')
-rw-r--r-- | src/lib/cryptolink/crypto_hmac.cc | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/lib/cryptolink/crypto_hmac.cc b/src/lib/cryptolink/crypto_hmac.cc index 576471b0c9..2f41e5d127 100644 --- a/src/lib/cryptolink/crypto_hmac.cc +++ b/src/lib/cryptolink/crypto_hmac.cc @@ -19,13 +19,12 @@ #include <boost/scoped_ptr.hpp> +#include <botan/version.h> #include <botan/botan.h> #include <botan/hmac.h> #include <botan/hash.h> #include <botan/types.h> -// [XX] remove -#include <iostream> namespace { const char* getBotanHashAlgorithmName(isc::cryptolink::HashAlgorithm algorithm) { @@ -76,17 +75,15 @@ public: try { // use a temp var so we don't have blocks spanning // preprocessor directives - size_t block_length; -#if (BOTAN_API_VERSION >= 100900) - block_length = hash->hash_block_size(); -#elif (BOTAN_API_VERSION >= 100800) - block_length = hash->HASH_BLOCK_SIZE; +#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,0) + size_t block_length = hash->hash_block_size(); +#elif BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,8,0) + size_t block_length = hash->HASH_BLOCK_SIZE; #else -#error "Unsupported BOTAN_API_VERSION" +#error "Unsupported BOTAN_API_VERSION (need 1.8 or higher)" // added to suppress irrelevant compiler errors - block_length = 0; + size_t block_length = 0; #endif - if (secret_len > block_length) { Botan::SecureVector<Botan::byte> hashed_key = hash->process(static_cast<const Botan::byte*>(secret), @@ -95,7 +92,7 @@ public: } else { // Apparently 1.9 considers 0 a valid secret length. // We do not. -#if (BOTAN_API_VERSION >= 100900) +#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,0) if (secret_len == 0) { isc_throw(BadKey, "Bad HMAC secret length: 0"); } @@ -113,12 +110,12 @@ public: ~HMACImpl() { } size_t getOutputLength() const { -#if (BOTAN_API_VERSION >= 100900) +#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,0) return (hmac_->output_length()); -#elif (BOTAN_API_VERSION >= 100800) +#elif BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,8,0) return (hmac_->OUTPUT_LENGTH); #else -#error "Unsupported BOTAN_API_VERSION" +#error "Unsupported BOTAN_API_VERSION (need 1.8 or higher)" // added to suppress irrelevant compiler errors return 0; #endif |