summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJINMEI Tatuya <jinmei@isc.org>2011-04-15 11:33:26 +0200
committerJINMEI Tatuya <jinmei@isc.org>2011-04-15 11:33:26 +0200
commit231b29911894b0f5ddbd0d1444d9dfdf9cb5abb3 (patch)
tree2ea0304c19819076734cc0993ea3bff32c3ca679 /src
parent[trac781] test both 'direct' and convenience methods (diff)
downloadkea-231b29911894b0f5ddbd0d1444d9dfdf9cb5abb3.tar.xz
kea-231b29911894b0f5ddbd0d1444d9dfdf9cb5abb3.zip
[trac781] some mostly editorial cleanups: remove redudant whites, catch
exception by reference, indentation fixes.
Diffstat (limited to 'src')
-rw-r--r--src/lib/crypto/crypto.cc17
-rw-r--r--src/lib/crypto/crypto.h2
-rw-r--r--src/lib/dns/tsigkey.cc2
3 files changed, 11 insertions, 10 deletions
diff --git a/src/lib/crypto/crypto.cc b/src/lib/crypto/crypto.cc
index 1e5cecbffd..214eddfea0 100644
--- a/src/lib/crypto/crypto.cc
+++ b/src/lib/crypto/crypto.cc
@@ -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));
}
diff --git a/src/lib/crypto/crypto.h b/src/lib/crypto/crypto.h
index 8597c236ba..3f326158cf 100644
--- a/src/lib/crypto/crypto.h
+++ b/src/lib/crypto/crypto.h
@@ -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);
diff --git a/src/lib/dns/tsigkey.cc b/src/lib/dns/tsigkey.cc
index 550c2a2041..d35fde3d32 100644
--- a/src/lib/dns/tsigkey.cc
+++ b/src/lib/dns/tsigkey.cc
@@ -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());