Commit fb7877b0 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[trac781] minor editorial cleanup (basically along with the style guideline)

and constify one thing
parent 246e56b3
......@@ -39,7 +39,7 @@ namespace cryptolink {
// For Botan, we use the CryptoLink class object in RAII style
class CryptoLinkImpl {
private:
Botan::LibraryInitializer _botan_init;
Botan::LibraryInitializer botan_init_;
};
CryptoLink::~CryptoLink() {
......@@ -48,11 +48,11 @@ CryptoLink::~CryptoLink() {
CryptoLink&
CryptoLink::getCryptoLink() {
CryptoLink &c = getCryptoLinkInternal();
if (!c.impl_) {
CryptoLink& c = getCryptoLinkInternal();
if (c.impl_ == NULL) {
c.initialize();
}
return c;
return (c);
}
CryptoLink&
......@@ -64,7 +64,7 @@ CryptoLink::getCryptoLinkInternal() {
void
CryptoLink::initialize() {
CryptoLink& c = getCryptoLinkInternal();
if (!c.impl_) {
if (c.impl_ == NULL) {
try {
c.impl_ = new CryptoLinkImpl();
} catch (const Botan::Exception& ex) {
......@@ -75,7 +75,8 @@ CryptoLink::initialize() {
HMAC*
CryptoLink::createHMAC(const void* secret, size_t secret_len,
const HMAC::HashAlgorithm hash_algorithm) {
const HMAC::HashAlgorithm hash_algorithm)
{
return (new HMAC(secret, secret_len, hash_algorithm));
}
......
......@@ -153,7 +153,7 @@ private:
// To prevent people constructing their own, we make the constructor
// private too.
CryptoLink() : impl_(NULL) {};
CryptoLink() : impl_(NULL) {}
~CryptoLink();
CryptoLinkImpl* impl_;
......
......@@ -89,7 +89,7 @@ public:
void sign(isc::dns::OutputBuffer& result, size_t len) {
try {
Botan::SecureVector<Botan::byte> b_result(hmac_->final());
if (len == 0 || len > b_result.size()) {
len = b_result.size();
}
......
......@@ -107,7 +107,7 @@ namespace {
// whether verification fails then
hmac_sig.writeUint8At(~hmac_sig[0], 0);
EXPECT_FALSE(hmac_verify->verify(hmac_sig.getData(),
hmac_sig.getLength()));
hmac_sig.getLength()));
}
void doHMACTestVector(const std::string& data,
......@@ -428,7 +428,7 @@ namespace {
CryptoLink::getCryptoLink().createHMAC("asdf", 4, alg));
hmac_sign->update("asdf", 4);
const std::vector<uint8_t> sig = hmac_sign->sign(len);
return sig.size();
return (sig.size());
}
size_t
......@@ -438,12 +438,11 @@ namespace {
hmac_sign->update("asdf", 4);
OutputBuffer sig(0);
hmac_sign->sign(sig, len);
return sig.getLength();
return (sig.getLength());
}
}
TEST(CryptoLinkTest, HMACSigLengthArgument)
{
TEST(CryptoLinkTest, HMACSigLengthArgument) {
std::vector<uint8_t> sig;
EXPECT_EQ(16, sigVectorLength(HMAC::MD5, 0));
......@@ -507,7 +506,7 @@ TEST(CryptoLinkTest, BadKey) {
}
TEST(CryptoLinkTest, Singleton) {
CryptoLink& c1 = CryptoLink::getCryptoLink();
CryptoLink& c2 = CryptoLink::getCryptoLink();
const CryptoLink& c1 = CryptoLink::getCryptoLink();
const CryptoLink& c2 = CryptoLink::getCryptoLink();
ASSERT_EQ(&c1, &c2);
}
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