diff options
author | Jelte Jansen <jelte@isc.org> | 2011-05-18 18:15:22 +0200 |
---|---|---|
committer | Jelte Jansen <jelte@isc.org> | 2011-05-18 18:15:22 +0200 |
commit | 77def12e8d0d957d9fe587816b27b6df4f88ce90 (patch) | |
tree | 8b189d8fbad52d01bb00e35d7a34c50a686a62b3 /src/lib/cryptolink | |
parent | [trac936] check for botan API version, and use appropriate calls in cryptolink (diff) | |
download | kea-77def12e8d0d957d9fe587816b27b6df4f88ce90.tar.xz kea-77def12e8d0d957d9fe587816b27b6df4f88ce90.zip |
[trac936] use botan-provided version macro
turns out botan had a check for exactly this, so we don't need to reinvent our own
Diffstat (limited to 'src/lib/cryptolink')
-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 |