mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-10-23 14:56:19 +00:00
[trac781] minor editorial cleanup (basically along with the style guideline)
and constify one thing
This commit is contained in:
@@ -39,7 +39,7 @@ namespace cryptolink {
|
|||||||
// For Botan, we use the CryptoLink class object in RAII style
|
// For Botan, we use the CryptoLink class object in RAII style
|
||||||
class CryptoLinkImpl {
|
class CryptoLinkImpl {
|
||||||
private:
|
private:
|
||||||
Botan::LibraryInitializer _botan_init;
|
Botan::LibraryInitializer botan_init_;
|
||||||
};
|
};
|
||||||
|
|
||||||
CryptoLink::~CryptoLink() {
|
CryptoLink::~CryptoLink() {
|
||||||
@@ -48,11 +48,11 @@ CryptoLink::~CryptoLink() {
|
|||||||
|
|
||||||
CryptoLink&
|
CryptoLink&
|
||||||
CryptoLink::getCryptoLink() {
|
CryptoLink::getCryptoLink() {
|
||||||
CryptoLink &c = getCryptoLinkInternal();
|
CryptoLink& c = getCryptoLinkInternal();
|
||||||
if (!c.impl_) {
|
if (c.impl_ == NULL) {
|
||||||
c.initialize();
|
c.initialize();
|
||||||
}
|
}
|
||||||
return c;
|
return (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
CryptoLink&
|
CryptoLink&
|
||||||
@@ -64,7 +64,7 @@ CryptoLink::getCryptoLinkInternal() {
|
|||||||
void
|
void
|
||||||
CryptoLink::initialize() {
|
CryptoLink::initialize() {
|
||||||
CryptoLink& c = getCryptoLinkInternal();
|
CryptoLink& c = getCryptoLinkInternal();
|
||||||
if (!c.impl_) {
|
if (c.impl_ == NULL) {
|
||||||
try {
|
try {
|
||||||
c.impl_ = new CryptoLinkImpl();
|
c.impl_ = new CryptoLinkImpl();
|
||||||
} catch (const Botan::Exception& ex) {
|
} catch (const Botan::Exception& ex) {
|
||||||
@@ -75,7 +75,8 @@ CryptoLink::initialize() {
|
|||||||
|
|
||||||
HMAC*
|
HMAC*
|
||||||
CryptoLink::createHMAC(const void* secret, size_t secret_len,
|
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));
|
return (new HMAC(secret, secret_len, hash_algorithm));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ private:
|
|||||||
|
|
||||||
// To prevent people constructing their own, we make the constructor
|
// To prevent people constructing their own, we make the constructor
|
||||||
// private too.
|
// private too.
|
||||||
CryptoLink() : impl_(NULL) {};
|
CryptoLink() : impl_(NULL) {}
|
||||||
~CryptoLink();
|
~CryptoLink();
|
||||||
|
|
||||||
CryptoLinkImpl* impl_;
|
CryptoLinkImpl* impl_;
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ public:
|
|||||||
void sign(isc::dns::OutputBuffer& result, size_t len) {
|
void sign(isc::dns::OutputBuffer& result, size_t len) {
|
||||||
try {
|
try {
|
||||||
Botan::SecureVector<Botan::byte> b_result(hmac_->final());
|
Botan::SecureVector<Botan::byte> b_result(hmac_->final());
|
||||||
|
|
||||||
if (len == 0 || len > b_result.size()) {
|
if (len == 0 || len > b_result.size()) {
|
||||||
len = b_result.size();
|
len = b_result.size();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ namespace {
|
|||||||
// whether verification fails then
|
// whether verification fails then
|
||||||
hmac_sig.writeUint8At(~hmac_sig[0], 0);
|
hmac_sig.writeUint8At(~hmac_sig[0], 0);
|
||||||
EXPECT_FALSE(hmac_verify->verify(hmac_sig.getData(),
|
EXPECT_FALSE(hmac_verify->verify(hmac_sig.getData(),
|
||||||
hmac_sig.getLength()));
|
hmac_sig.getLength()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void doHMACTestVector(const std::string& data,
|
void doHMACTestVector(const std::string& data,
|
||||||
@@ -428,7 +428,7 @@ namespace {
|
|||||||
CryptoLink::getCryptoLink().createHMAC("asdf", 4, alg));
|
CryptoLink::getCryptoLink().createHMAC("asdf", 4, alg));
|
||||||
hmac_sign->update("asdf", 4);
|
hmac_sign->update("asdf", 4);
|
||||||
const std::vector<uint8_t> sig = hmac_sign->sign(len);
|
const std::vector<uint8_t> sig = hmac_sign->sign(len);
|
||||||
return sig.size();
|
return (sig.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
@@ -438,12 +438,11 @@ namespace {
|
|||||||
hmac_sign->update("asdf", 4);
|
hmac_sign->update("asdf", 4);
|
||||||
OutputBuffer sig(0);
|
OutputBuffer sig(0);
|
||||||
hmac_sign->sign(sig, len);
|
hmac_sign->sign(sig, len);
|
||||||
return sig.getLength();
|
return (sig.getLength());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CryptoLinkTest, HMACSigLengthArgument)
|
TEST(CryptoLinkTest, HMACSigLengthArgument) {
|
||||||
{
|
|
||||||
std::vector<uint8_t> sig;
|
std::vector<uint8_t> sig;
|
||||||
|
|
||||||
EXPECT_EQ(16, sigVectorLength(HMAC::MD5, 0));
|
EXPECT_EQ(16, sigVectorLength(HMAC::MD5, 0));
|
||||||
@@ -507,7 +506,7 @@ TEST(CryptoLinkTest, BadKey) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(CryptoLinkTest, Singleton) {
|
TEST(CryptoLinkTest, Singleton) {
|
||||||
CryptoLink& c1 = CryptoLink::getCryptoLink();
|
const CryptoLink& c1 = CryptoLink::getCryptoLink();
|
||||||
CryptoLink& c2 = CryptoLink::getCryptoLink();
|
const CryptoLink& c2 = CryptoLink::getCryptoLink();
|
||||||
ASSERT_EQ(&c1, &c2);
|
ASSERT_EQ(&c1, &c2);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user