util: deprecate crypto::computeSha256Digest()
Use Sha256::computeDigest() instead.
Change-Id: I9db5b4839559c9c7930cdc24c78f35ca76b25b52
diff --git a/src/security/v1/key-chain.cpp b/src/security/v1/key-chain.cpp
index 1916532..9efcb4a 100644
--- a/src/security/v1/key-chain.cpp
+++ b/src/security/v1/key-chain.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).
@@ -24,8 +24,8 @@
#include "key-chain.hpp"
#include "../signing-helpers.hpp"
-#include "../../util/random.hpp"
#include "../../util/config-file.hpp"
+#include "../../util/digest.hpp"
#include "sec-public-info-sqlite3.hpp"
@@ -755,7 +755,7 @@
const Name& keyName, DigestAlgorithm digestAlgorithm) const
{
if (keyName == SigningInfo::getDigestSha256Identity())
- return Block(tlv::SignatureValue, crypto::computeSha256Digest(buf, size));
+ return Block(tlv::SignatureValue, util::Sha256::computeDigest(buf, size));
return m_tpm->signInTpm(buf, size, keyName, digestAlgorithm);
}
@@ -790,7 +790,7 @@
.append(sig.getInfo()); // signatureInfo
Block sigValue(tlv::SignatureValue,
- crypto::computeSha256Digest(signedName.wireEncode().value(),
+ util::Sha256::computeDigest(signedName.wireEncode().value(),
signedName.wireEncode().value_size()));
sigValue.encode();
diff --git a/src/security/v1/key-chain.hpp b/src/security/v1/key-chain.hpp
index 65821fa..3a84a47 100644
--- a/src/security/v1/key-chain.hpp
+++ b/src/security/v1/key-chain.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).
@@ -32,9 +32,7 @@
#include "../signature-sha256-with-ecdsa.hpp"
#include "../digest-sha256.hpp"
#include "../signing-info.hpp"
-
#include "../../interest.hpp"
-#include "../../util/crypto.hpp"
#include "../../util/random.hpp"
#include <initializer_list>
@@ -132,7 +130,7 @@
/**
* @brief KeyChain constructor
*
- * @sa http://redmine.named-data.net/issues/2260
+ * @sa https://redmine.named-data.net/issues/2260
*
* @param pibLocator PIB locator
* @param tpmLocator TPM locator
diff --git a/src/security/v1/public-key.cpp b/src/security/v1/public-key.cpp
index cef7295..7ada249 100644
--- a/src/security/v1/public-key.cpp
+++ b/src/security/v1/public-key.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).
@@ -25,7 +25,7 @@
#include "public-key.hpp"
#include "../../encoding/oid.hpp"
-#include "../../util/crypto.hpp"
+#include "../../util/digest.hpp"
#include "cryptopp.hpp"
namespace ndn {
@@ -53,7 +53,7 @@
if (m_digest.hasWire())
return m_digest;
else {
- m_digest = Block(tlv::KeyDigest, crypto::computeSha256Digest(m_key.buf(), m_key.size()));
+ m_digest = Block(tlv::KeyDigest, util::Sha256::computeDigest(m_key.buf(), m_key.size()));
m_digest.encode();
return m_digest;
}
@@ -119,7 +119,7 @@
m_key.assign(out.begin(), out.end());
}
- catch (CryptoPP::BERDecodeErr& err)
+ catch (const CryptoPP::BERDecodeErr& err)
{
m_type = KeyType::NONE;
BOOST_THROW_EXCEPTION(Error("PublicKey decoding error"));
diff --git a/src/security/v2/key-chain.cpp b/src/security/v2/key-chain.cpp
index 45d9277..c6e044c 100644
--- a/src/security/v2/key-chain.cpp
+++ b/src/security/v2/key-chain.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,6 +22,7 @@
#include "key-chain.hpp"
#include "../../util/config-file.hpp"
+#include "../../util/digest.hpp"
#include "../../util/logger.hpp"
#include "../pib/pib-sqlite3.hpp"
@@ -39,7 +40,6 @@
#include "../transform/private-key.hpp"
#include "../transform/verifier-filter.hpp"
#include "../../encoding/buffer-stream.hpp"
-#include "../../util/crypto.hpp"
#include <boost/lexical_cast.hpp>
@@ -685,7 +685,7 @@
const Name& keyName, DigestAlgorithm digestAlgorithm) const
{
if (keyName == SigningInfo::getDigestSha256Identity())
- return Block(tlv::SignatureValue, crypto::computeSha256Digest(buf, size));
+ return Block(tlv::SignatureValue, util::Sha256::computeDigest(buf, size));
return Block(tlv::SignatureValue, m_tpm->sign(buf, size, keyName, digestAlgorithm));
}
diff --git a/src/security/validator.cpp b/src/security/validator.cpp
index f0f87b7..4862d76 100644
--- a/src/security/validator.cpp
+++ b/src/security/validator.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).
@@ -20,7 +20,7 @@
*/
#include "validator.hpp"
-#include "../util/crypto.hpp"
+#include "../util/digest.hpp"
#include "../lp/tags.hpp"
#include "v1/cryptopp.hpp"
@@ -234,21 +234,20 @@
Validator::verifySignature(const uint8_t* buf, const size_t size, const DigestSha256& sig)
{
try {
- ConstBufferPtr buffer = crypto::computeSha256Digest(buf, size);
+ ConstBufferPtr buffer = util::Sha256::computeDigest(buf, size);
const Block& sigValue = sig.getValue();
- if (buffer != nullptr &&
- buffer->size() == sigValue.value_size() &&
- buffer->size() == crypto::SHA256_DIGEST_SIZE) {
+ if (buffer->size() == sigValue.value_size() &&
+ buffer->size() == util::Sha256::DIGEST_SIZE) {
const uint8_t* p1 = buffer->buf();
const uint8_t* p2 = sigValue.value();
- return 0 == memcmp(p1, p2, crypto::SHA256_DIGEST_SIZE);
+ return 0 == memcmp(p1, p2, util::Sha256::DIGEST_SIZE);
}
else
return false;
}
- catch (const CryptoPP::Exception& e) {
+ catch (const util::Sha256::Error&) {
return false;
}
}