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