BIND 10 trac781, updated. 817462f1ea1f1e9b4e05b2da90b8d311a7b59843 [trac781] remove unused code, some style changes
BIND 10 source code commits
bind10-changes at lists.isc.org
Sun Apr 10 20:50:00 UTC 2011
The branch, trac781 has been updated
via 817462f1ea1f1e9b4e05b2da90b8d311a7b59843 (commit)
from 30ab4cfbd7f0744653248efc5635c68930359eea (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 817462f1ea1f1e9b4e05b2da90b8d311a7b59843
Author: Jelte Jansen <Tjebbe at kanariepiet.com>
Date: Sun Apr 10 22:48:39 2011 +0200
[trac781] remove unused code, some style changes
-----------------------------------------------------------------------
Summary of changes:
src/lib/crypto/crypto.cc | 37 +++++++++++++----------------
src/lib/crypto/crypto.h | 35 ++++++---------------------
src/lib/crypto/crypto_botan.h | 7 -----
src/lib/crypto/tests/crypto_unittests.cc | 2 +-
4 files changed, 26 insertions(+), 55 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/crypto/crypto.cc b/src/lib/crypto/crypto.cc
index f6cc4b1..3409167 100644
--- a/src/lib/crypto/crypto.cc
+++ b/src/lib/crypto/crypto.cc
@@ -46,41 +46,43 @@ HashFunction* getHash(const Name& hash_name) {
}
}
+ // Library needs to have been inited during the entire program
+ // should we make this a singleton? (for hsm we'll need more
+ // initialization, and dynamic loading)
+ LibraryInitializer init;
+
} // local namespace
namespace isc {
namespace crypto {
-void doHMAC(const OutputBuffer& data, TSIGKey key, isc::dns::OutputBuffer& result) {
-
- // needs to be in global scope; can we make a generalized
- // subclassable singleton? (for hsm we'll need more initialization)
- LibraryInitializer init;
-
- // not used here, but we'd need a ctx
-
+void
+signHMAC(const OutputBuffer& data, TSIGKey key,
+ isc::dns::OutputBuffer& result)
+{
// get algorithm from key, then 'translate' to Botan-specific algo
HashFunction* hash = getHash(key.getAlgorithmName());
HMAC::HMAC hmac(hash);
// Take the 'secret' from the key
- hmac.set_key(static_cast<const byte*>(key.getSecret()), key.getSecretLength());
+ hmac.set_key(static_cast<const byte*>(key.getSecret()),
+ key.getSecretLength());
// update the data from whatever we get (probably as a buffer)
- hmac.update(static_cast<const byte*>(data.getData()), data.getLength());
+ hmac.update(static_cast<const byte*>(data.getData()),
+ data.getLength());
// And generate the mac
SecureVector<byte> b_result(hmac.final());
-
// write mac to result
result.writeData(b_result.begin(), b_result.size());
-
- //std::cout << "HMAC SIG LEN: " << b_result.size() << std::endl;
- //std::cout << "HMAC SIG LEN2: " << result.getLength() << std::endl;
}
-bool verifyHMAC(const OutputBuffer& data, TSIGKey key, const isc::dns::OutputBuffer& result) {
+bool
+verifyHMAC(const OutputBuffer& data, TSIGKey key,
+ const isc::dns::OutputBuffer& result)
+{
HashFunction* hash = getHash(key.getAlgorithmName());
HMAC::HMAC hmac(hash);
hmac.set_key(static_cast<const byte*>(key.getSecret()), key.getSecretLength());
@@ -113,11 +115,6 @@ TSIGKeyFromString(const std::string& str) {
std::string secret_str = str.substr(pos + 1, pos2 - pos - 1);
- /*
- std::cout << "[XX] KEY NAME: " << key_name << std::endl;
- std::cout << "[XX] KEY ALGO: " << algo_name << std::endl;
- std::cout << "[XX] SECRET: " << secret_str << std::endl;
- */
vector<uint8_t> secret;
decodeBase64(secret_str, secret);
unsigned char secret_b[secret.size()];
diff --git a/src/lib/crypto/crypto.h b/src/lib/crypto/crypto.h
index 122da7a..b5b823d 100644
--- a/src/lib/crypto/crypto.h
+++ b/src/lib/crypto/crypto.h
@@ -35,37 +35,18 @@
namespace isc {
namespace crypto {
-void doHMAC(const isc::dns::OutputBuffer& data, isc::dns::TSIGKey key, isc::dns::OutputBuffer& result);
-bool verifyHMAC(const isc::dns::OutputBuffer& data, isc::dns::TSIGKey key, const isc::dns::OutputBuffer& mac);
-isc::dns::TSIGKey TSIGKeyFromString(const std::string& str);
-std::string TSIGKeyToString(const isc::dns::TSIGKey& key);
+void signHMAC(const isc::dns::OutputBuffer& data,
+ isc::dns::TSIGKey key,
+ isc::dns::OutputBuffer& result);
-class Crypto {
- static Crypto& getInstance();
- virtual void init() = 0;
- virtual void cleanup() = 0;
-};
+bool verifyHMAC(const isc::dns::OutputBuffer& data,
+ isc::dns::TSIGKey key,
+ const isc::dns::OutputBuffer& mac);
-/*
-class TSIGKeyImpl;
+isc::dns::TSIGKey TSIGKeyFromString(const std::string& str);
-class TSIGKey {
-public:
- enum algorithms {
- TSIG_HMAC_MD5 = 1,
- TSIG_HMAC_SHA256 = 2
- };
+std::string TSIGKeyToString(const isc::dns::TSIGKey& key);
- TSIGKey(const std::string& str);
- ~TSIGKey();
- algorithms getAlgorithm();
- const char* getSecret();
- size_t getSecretLength();
-
-private:
- TSIGKeyImpl* impl_;
-};
-*/
} // namespace crypto
} // namespace isc
diff --git a/src/lib/crypto/crypto_botan.h b/src/lib/crypto/crypto_botan.h
index 0978bae..0f4ae17 100644
--- a/src/lib/crypto/crypto_botan.h
+++ b/src/lib/crypto/crypto_botan.h
@@ -22,13 +22,6 @@
namespace isc {
namespace crypto {
-class CryptoBotan : public Crypto {
- void init() {};
- void cleanup() {};
-};
-
-
-
} // namespace crypto
} // namespace isc
diff --git a/src/lib/crypto/tests/crypto_unittests.cc b/src/lib/crypto/tests/crypto_unittests.cc
index 815a4c4..2e5f80b 100644
--- a/src/lib/crypto/tests/crypto_unittests.cc
+++ b/src/lib/crypto/tests/crypto_unittests.cc
@@ -41,7 +41,7 @@ namespace {
TSIGKey key = TSIGKeyFromString(key_str);
- doHMAC(data_buf, key, hmac_sig);
+ signHMAC(data_buf, key, hmac_sig);
checkBuffer(hmac_sig, expected_hmac, hmac_len);
}
}
More information about the bind10-changes
mailing list