Commit 231b2991 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[trac781] some mostly editorial cleanups: remove redudant whites, catch

exception by reference, indentation fixes.
parent 4d555337
......@@ -33,13 +33,14 @@ using namespace std;
using namespace isc::dns;
namespace {
Botan::HashFunction* getHash(const Name& hash_name) {
Botan::HashFunction*
getHash(const Name& hash_name) {
if (hash_name == TSIGKey::HMACMD5_NAME()) {
return Botan::get_hash("MD5");
return (Botan::get_hash("MD5"));
} else if (hash_name == TSIGKey::HMACSHA1_NAME()) {
return Botan::get_hash("SHA-1");
return (Botan::get_hash("SHA-1"));
} else if (hash_name == TSIGKey::HMACSHA256_NAME()) {
return Botan::get_hash("SHA-256");
return (Botan::get_hash("SHA-256"));
} else {
isc_throw(isc::crypto::UnsupportedAlgorithm,
"Unknown Hash type " + hash_name.toText());
......@@ -73,9 +74,9 @@ public:
hmac_->set_key(hashed_key.begin(), hashed_key.size());
} else {
hmac_->set_key(static_cast<const Botan::byte*>(key.getSecret()),
key.getSecretLength());
key.getSecretLength());
}
} catch (Botan::Invalid_Key_Length ikl) {
} catch (const Botan::Invalid_Key_Length& ikl) {
isc_throw(BadKey, ikl.what());
}
}
......@@ -90,11 +91,11 @@ public:
void sign(isc::dns::OutputBuffer& result) const {
// And generate the mac
Botan::SecureVector<Botan::byte> b_result(hmac_->final());
// write mac to result
result.writeData(b_result.begin(), b_result.size());
}
bool verify(const void* sig, const size_t len) const {
return (hmac_->verify_mac(static_cast<const Botan::byte*>(sig), len));
}
......
......@@ -66,7 +66,7 @@ public:
/// Notes: if the key is longer than the block size of its
/// algorithm, the constructor will run it through the hash
/// algorithm, and use the digest as a key for this HMAC operation
///
///
/// \param key The key to use
explicit HMAC(const isc::dns::TSIGKey& key);
......
......@@ -99,7 +99,7 @@ TSIGKey::TSIGKey(const std::string& str) : impl_(NULL) {
impl_ = new TSIGKeyImpl(key_name, algo_name, secret_b,
secret.size());
} catch (Exception e) {
} catch (const Exception& e) {
// 'reduce' the several types of exceptions name parsing and
// Base64 decoding can throw to just the InvalidParameter
isc_throw(InvalidParameter, e.what());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment