security: add missing out-of-line destructors for transform classes
Change-Id: I8306b8e10953e55e056b4eb5fcb76ec8f395f5c4
diff --git a/src/security/tpm/back-end.cpp b/src/security/tpm/back-end.cpp
index 72ef5fd..364b8bb 100644
--- a/src/security/tpm/back-end.cpp
+++ b/src/security/tpm/back-end.cpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -22,10 +22,12 @@
#include "back-end.hpp"
#include "key-handle.hpp"
#include "tpm.hpp"
-#include "../transform.hpp"
+#include "../pib/key.hpp"
+#include "../transform/buffer-source.hpp"
+#include "../transform/digest-filter.hpp"
+#include "../transform/stream-sink.hpp"
#include "../../encoding/buffer-stream.hpp"
#include "../../util/random.hpp"
-#include "../pib/key.hpp"
namespace ndn {
namespace security {
diff --git a/src/security/transform.hpp b/src/security/transform.hpp
index 8ecfed5..bc38619 100644
--- a/src/security/transform.hpp
+++ b/src/security/transform.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -23,20 +23,23 @@
#define NDN_CXX_SECURITY_TRANSFORM_HPP
#include "transform/buffer-source.hpp"
-#include "transform/stream-source.hpp"
#include "transform/step-source.hpp"
+#include "transform/stream-source.hpp"
#include "transform/bool-sink.hpp"
#include "transform/stream-sink.hpp"
-#include "transform/strip-space.hpp"
-#include "transform/hex-encode.hpp"
-#include "transform/hex-decode.hpp"
-#include "transform/base64-encode.hpp"
#include "transform/base64-decode.hpp"
+#include "transform/base64-encode.hpp"
+#include "transform/hex-decode.hpp"
+#include "transform/hex-encode.hpp"
+#include "transform/strip-space.hpp"
+
+#include "transform/block-cipher.hpp"
#include "transform/digest-filter.hpp"
#include "transform/hmac-filter.hpp"
-#include "transform/block-cipher.hpp"
+#include "transform/private-key.hpp"
+#include "transform/public-key.hpp"
#include "transform/signer-filter.hpp"
#include "transform/verifier-filter.hpp"
diff --git a/src/security/transform/base64-decode.cpp b/src/security/transform/base64-decode.cpp
index 8b047bc..5033b63 100644
--- a/src/security/transform/base64-decode.cpp
+++ b/src/security/transform/base64-decode.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -20,7 +20,6 @@
*/
#include "base64-decode.hpp"
-#include "../../encoding/buffer.hpp"
#include "../detail/openssl.hpp"
namespace ndn {
@@ -59,12 +58,14 @@
static const size_t BUFFER_LENGTH = 1024;
Base64Decode::Base64Decode(bool expectNewlineEvery64Bytes)
- : m_impl(new Impl)
+ : m_impl(make_unique<Impl>())
{
if (!expectNewlineEvery64Bytes)
BIO_set_flags(m_impl->m_base64, BIO_FLAGS_BASE64_NO_NL);
}
+Base64Decode::~Base64Decode() = default;
+
void
Base64Decode::preTransform()
{
@@ -114,7 +115,7 @@
// OpenSSL base64 BIO cannot give us the number bytes of partial decoded result,
// so we just try to read a chunk.
auto buffer = make_unique<OBuffer>(BUFFER_LENGTH);
- int rLen = BIO_read(m_impl->m_base64, &(*buffer)[0], buffer->size());
+ int rLen = BIO_read(m_impl->m_base64, buffer->data(), buffer->size());
if (rLen <= 0)
return;
diff --git a/src/security/transform/base64-decode.hpp b/src/security/transform/base64-decode.hpp
index ea69b8d..203716f 100644
--- a/src/security/transform/base64-decode.hpp
+++ b/src/security/transform/base64-decode.hpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -44,8 +44,9 @@
explicit
Base64Decode(bool expectNewlineEvery64Bytes = true);
-private:
+ ~Base64Decode();
+private:
/**
* @brief Read partial transformation results into output buffer and write them into next module.
*/
diff --git a/src/security/transform/base64-encode.cpp b/src/security/transform/base64-encode.cpp
index 60bc25f..d9a8a7a 100644
--- a/src/security/transform/base64-encode.cpp
+++ b/src/security/transform/base64-encode.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -20,7 +20,6 @@
*/
#include "base64-encode.hpp"
-#include "../../encoding/buffer.hpp"
#include "../detail/openssl.hpp"
namespace ndn {
@@ -53,12 +52,14 @@
};
Base64Encode::Base64Encode(bool needBreak)
- : m_impl(new Impl)
+ : m_impl(make_unique<Impl>())
{
if (!needBreak)
BIO_set_flags(m_impl->m_base64, BIO_FLAGS_BASE64_NO_NL);
}
+Base64Encode::~Base64Encode() = default;
+
void
Base64Encode::preTransform()
{
@@ -109,7 +110,7 @@
// there is something to read from BIO
auto buffer = make_unique<OBuffer>(nRead);
- int rLen = BIO_read(m_impl->m_sink, &(*buffer)[0], nRead);
+ int rLen = BIO_read(m_impl->m_sink, buffer->data(), nRead);
if (rLen < 0)
return;
diff --git a/src/security/transform/base64-encode.hpp b/src/security/transform/base64-encode.hpp
index d62b5d8..34ad577 100644
--- a/src/security/transform/base64-encode.hpp
+++ b/src/security/transform/base64-encode.hpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -42,6 +42,8 @@
explicit
Base64Encode(bool needBreak = true);
+ ~Base64Encode();
+
private:
/**
* @brief Read partial transformation result (if exists) from BIO
diff --git a/src/security/transform/block-cipher.cpp b/src/security/transform/block-cipher.cpp
index 327aba6..b1bb091 100644
--- a/src/security/transform/block-cipher.cpp
+++ b/src/security/transform/block-cipher.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -48,21 +48,24 @@
BIO* m_sink; // BIO_f_cipher alone does not work without a sink
};
+
BlockCipher::BlockCipher(BlockCipherAlgorithm algo, CipherOperator op,
const uint8_t* key, size_t keyLen,
const uint8_t* iv, size_t ivLen)
- : m_impl(new Impl)
+ : m_impl(make_unique<Impl>())
{
switch (algo) {
case BlockCipherAlgorithm::AES_CBC:
initializeAesCbc(key, keyLen, iv, ivLen, op);
break;
default:
- BOOST_THROW_EXCEPTION(Error(getIndex(), "Cipher algorithm " +
- boost::lexical_cast<std::string>(algo) + " is not supported"));
+ BOOST_THROW_EXCEPTION(Error(getIndex(), "Unsupported block cipher algorithm " +
+ boost::lexical_cast<std::string>(algo)));
}
}
+BlockCipher::~BlockCipher() = default;
+
void
BlockCipher::preTransform()
{
@@ -113,7 +116,7 @@
// there is something to read from BIO
auto buffer = make_unique<OBuffer>(nRead);
- int rLen = BIO_read(m_impl->m_sink, &(*buffer)[0], nRead);
+ int rLen = BIO_read(m_impl->m_sink, buffer->data(), nRead);
if (rLen < 0)
return;
diff --git a/src/security/transform/block-cipher.hpp b/src/security/transform/block-cipher.hpp
index 320e184..ee56682 100644
--- a/src/security/transform/block-cipher.hpp
+++ b/src/security/transform/block-cipher.hpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -52,6 +52,8 @@
const uint8_t* key, size_t keyLen,
const uint8_t* iv, size_t ivLen);
+ ~BlockCipher();
+
private:
/**
* @brief Read partial transformation result (if exists) from BIO
diff --git a/src/security/transform/digest-filter.cpp b/src/security/transform/digest-filter.cpp
index 862d784..44fe429 100644
--- a/src/security/transform/digest-filter.cpp
+++ b/src/security/transform/digest-filter.cpp
@@ -71,6 +71,8 @@
boost::lexical_cast<std::string>(algo)));
}
+DigestFilter::~DigestFilter() = default;
+
size_t
DigestFilter::convert(const uint8_t* buf, size_t size)
{
diff --git a/src/security/transform/digest-filter.hpp b/src/security/transform/digest-filter.hpp
index 0ccc81b..a9c023e 100644
--- a/src/security/transform/digest-filter.hpp
+++ b/src/security/transform/digest-filter.hpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -41,6 +41,8 @@
explicit
DigestFilter(DigestAlgorithm algo);
+ ~DigestFilter();
+
private:
/**
* @brief Append data @p buf into digest calculation
diff --git a/src/security/transform/hmac-filter.cpp b/src/security/transform/hmac-filter.cpp
index e150a79..07a1796 100644
--- a/src/security/transform/hmac-filter.cpp
+++ b/src/security/transform/hmac-filter.cpp
@@ -68,8 +68,9 @@
#endif // OPENSSL_VERSION_NUMBER < 0x1010000fL
};
+
HmacFilter::HmacFilter(DigestAlgorithm algo, const uint8_t* key, size_t keyLen)
- : m_impl(new Impl)
+ : m_impl(make_unique<Impl>())
{
BOOST_ASSERT(key != nullptr);
BOOST_ASSERT(keyLen > 0);
@@ -82,6 +83,8 @@
BOOST_THROW_EXCEPTION(Error(getIndex(), "Cannot initialize HMAC"));
}
+HmacFilter::~HmacFilter() = default;
+
size_t
HmacFilter::convert(const uint8_t* buf, size_t size)
{
@@ -97,7 +100,7 @@
auto buffer = make_unique<OBuffer>(EVP_MAX_MD_SIZE);
unsigned int mdLen = 0;
- if (HMAC_Final(*m_impl, &(*buffer)[0], &mdLen) == 0)
+ if (HMAC_Final(*m_impl, buffer->data(), &mdLen) == 0)
BOOST_THROW_EXCEPTION(Error(getIndex(), "Failed to finalize HMAC"));
buffer->erase(buffer->begin() + mdLen, buffer->end());
diff --git a/src/security/transform/hmac-filter.hpp b/src/security/transform/hmac-filter.hpp
index 002fda8..d0770b3 100644
--- a/src/security/transform/hmac-filter.hpp
+++ b/src/security/transform/hmac-filter.hpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -35,13 +35,14 @@
class HmacFilter : public Transform
{
public:
-
/**
* @brief Create a HMAC module to generate HMAC using algorithm @p algo and @p key
* @pre @p key must not be nullptr, and @p size must be a positive integer.
*/
HmacFilter(DigestAlgorithm algo, const uint8_t* key, size_t keyLen);
+ ~HmacFilter();
+
private:
/**
* @brief write data @p buf into HMAC signer
diff --git a/src/security/transform/verifier-filter.cpp b/src/security/transform/verifier-filter.cpp
index 1a7eebe..6e54c34 100644
--- a/src/security/transform/verifier-filter.cpp
+++ b/src/security/transform/verifier-filter.cpp
@@ -20,6 +20,7 @@
*/
#include "verifier-filter.hpp"
+#include "public-key.hpp"
#include "../detail/openssl-helper.hpp"
#include <boost/lexical_cast.hpp>
@@ -56,9 +57,10 @@
size_t m_sigLen;
};
+
VerifierFilter::VerifierFilter(DigestAlgorithm algo, const PublicKey& key,
const uint8_t* sig, size_t sigLen)
- : m_impl(new Impl(key, sig, sigLen))
+ : m_impl(make_unique<Impl>(key, sig, sigLen))
{
const EVP_MD* md = detail::digestAlgorithmToEvpMd(algo);
if (md == nullptr)
@@ -70,6 +72,8 @@
boost::lexical_cast<std::string>(algo)));
}
+VerifierFilter::~VerifierFilter() = default;
+
size_t
VerifierFilter::convert(const uint8_t* buf, size_t size)
{
diff --git a/src/security/transform/verifier-filter.hpp b/src/security/transform/verifier-filter.hpp
index 4bc63e3..e08cc7d 100644
--- a/src/security/transform/verifier-filter.hpp
+++ b/src/security/transform/verifier-filter.hpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -23,26 +23,29 @@
#define NDN_CXX_SECURITY_TRANSFORM_VERIFIER_FILTER_HPP
#include "transform-base.hpp"
-#include "public-key.hpp"
#include "../security-common.hpp"
namespace ndn {
namespace security {
namespace transform {
+class PublicKey;
+
/**
- * @brief The module to verify signature.
+ * @brief The module to verify signatures.
*
- * The next module is usually SinkBool.
+ * The next module in the chain is usually BoolSink.
*/
class VerifierFilter : public Transform
{
public:
/**
- * @brief Create a verifier module to verify signature @p sig using algorithm @p algo and @p key
+ * @brief Create a verifier module to verify signature @p sig using algorithm @p algo and key @p key
*/
VerifierFilter(DigestAlgorithm algo, const PublicKey& key, const uint8_t* sig, size_t sigLen);
+ ~VerifierFilter();
+
private:
/**
* @brief Write data @p buf into verifier
diff --git a/src/security/v2/key-chain.cpp b/src/security/v2/key-chain.cpp
index 2e5e4ad..b63287d 100644
--- a/src/security/v2/key-chain.cpp
+++ b/src/security/v2/key-chain.cpp
@@ -38,6 +38,7 @@
#include "../transform/bool-sink.hpp"
#include "../transform/buffer-source.hpp"
#include "../transform/private-key.hpp"
+#include "../transform/public-key.hpp"
#include "../transform/verifier-filter.hpp"
#include "../../encoding/buffer-stream.hpp"
diff --git a/src/security/verification-helpers.cpp b/src/security/verification-helpers.cpp
index f8fd3d2..1d22373 100644
--- a/src/security/verification-helpers.cpp
+++ b/src/security/verification-helpers.cpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -21,14 +21,18 @@
#include "verification-helpers.hpp"
-#include "data.hpp"
-#include "interest.hpp"
-#include "encoding/buffer-stream.hpp"
-#include "security/pib/key.hpp"
-#include "security/pib/key.hpp"
-#include "security/transform.hpp"
-#include "security/v2/certificate.hpp"
-#include "security/detail/openssl.hpp"
+#include "detail/openssl.hpp"
+#include "pib/key.hpp"
+#include "transform/bool-sink.hpp"
+#include "transform/buffer-source.hpp"
+#include "transform/digest-filter.hpp"
+#include "transform/public-key.hpp"
+#include "transform/stream-sink.hpp"
+#include "transform/verifier-filter.hpp"
+#include "v2/certificate.hpp"
+#include "../data.hpp"
+#include "../interest.hpp"
+#include "../encoding/buffer-stream.hpp"
namespace ndn {
namespace security {