Adapt to ndn-cxx security changes
refs: #4090, #4195, #3828
Change-Id: Ie1bf11d604af12d3b26fba24054ed67fe735ae7c
diff --git a/src/leaf-container.hpp b/src/leaf-container.hpp
index d116b55..e1d30bd 100644
--- a/src/leaf-container.hpp
+++ b/src/leaf-container.hpp
@@ -28,14 +28,12 @@
#include "mi-tag.hpp"
#include "leaf.hpp"
-#include <ndn-cxx/util/crypto.hpp>
-
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/mem_fun.hpp>
-
+#include <ndn-cxx/util/sha256.hpp>
namespace chronosync {
@@ -47,7 +45,7 @@
operator()(const Name& prefix) const
{
ndn::ConstBufferPtr buffer =
- ndn::crypto::computeSha256Digest(prefix.wireEncode().wire(), prefix.wireEncode().size());
+ ndn::util::Sha256::computeDigest(prefix.wireEncode().wire(), prefix.wireEncode().size());
BOOST_ASSERT(buffer->size() > sizeof(std::size_t));
diff --git a/src/leaf.hpp b/src/leaf.hpp
index b26b975..4c8223d 100644
--- a/src/leaf.hpp
+++ b/src/leaf.hpp
@@ -1,6 +1,6 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
- * Copyright (c) 2012-2014 University of California, Los Angeles
+ * Copyright (c) 2012-2017 University of California, Los Angeles
*
* This file is part of ChronoSync, synchronization library for distributed realtime
* applications for NDN.
@@ -26,7 +26,7 @@
#define CHRONOSYNC_LEAF_HPP
#include "common.hpp"
-#include <ndn-cxx/util/digest.hpp>
+#include <ndn-cxx/util/sha256.hpp>
namespace chronosync {
diff --git a/src/logic.cpp b/src/logic.cpp
index fc4aa83..df0fcd1 100644
--- a/src/logic.cpp
+++ b/src/logic.cpp
@@ -26,6 +26,8 @@
#include "logic.hpp"
#include "logger.hpp"
+#include <ndn-cxx/util/string-helper.hpp>
+
INIT_LOGGER(Logic);
#ifdef _DEBUG
@@ -94,7 +96,6 @@
, m_syncInterestLifetime(syncInterestLifetime)
, m_syncReplyFreshness(syncReplyFreshness)
, m_recoveryInterestLifetime(recoveryInterestLifetime)
- , m_defaultSigningId(defaultSigningId)
, m_validator(validator)
{
#ifdef _DEBUG
@@ -103,7 +104,7 @@
_LOG_DEBUG_ID(">> Logic::Logic");
- addUserNode(m_defaultUserPrefix, m_defaultSigningId);
+ addUserNode(m_defaultUserPrefix, defaultSigningId);
m_syncReset = m_syncPrefix;
@@ -159,7 +160,6 @@
if (defaultUserPrefix != EMPTY_NAME) {
if (m_nodeList.find(defaultUserPrefix) != m_nodeList.end()) {
m_defaultUserPrefix = defaultUserPrefix;
- m_defaultSigningId = m_nodeList[defaultUserPrefix].signingId;
}
}
}
@@ -171,7 +171,6 @@
return;
if (m_defaultUserPrefix == EMPTY_NAME) {
m_defaultUserPrefix = userPrefix;
- m_defaultSigningId = signingId;
}
if (m_nodeList.find(userPrefix) == m_nodeList.end()) {
m_nodeList[userPrefix].userPrefix = userPrefix;
@@ -193,11 +192,9 @@
if (m_defaultUserPrefix == userPrefix) {
if (!m_nodeList.empty()) {
m_defaultUserPrefix = m_nodeList.begin()->second.userPrefix;
- m_defaultSigningId = m_nodeList.begin()->second.signingId;
}
else {
m_defaultUserPrefix = EMPTY_NAME;
- m_defaultSigningId = DEFAULT_NAME;
}
}
reset(false);
@@ -256,11 +253,7 @@
_LOG_DEBUG_ID("updateSeqNo: not in Reset ");
ndn::ConstBufferPtr previousRoot = m_state.getRootDigest();
{
- using namespace CryptoPP;
-
- std::string hash;
- StringSource(previousRoot->buf(), previousRoot->size(), true,
- new HexEncoder(new StringSink(hash), false));
+ std::string hash = ndn::toHex(previousRoot->buf(), previousRoot->size(), false);
_LOG_DEBUG_ID("Hash: " << hash);
}
@@ -660,7 +653,7 @@
if (m_nodeList[nodePrefix].signingId.empty())
m_keyChain.sign(*syncReply);
else
- m_keyChain.signByIdentity(*syncReply, m_nodeList[nodePrefix].signingId);
+ m_keyChain.sign(*syncReply, security::signingByIdentity(m_nodeList[nodePrefix].signingId));
m_face.put(*syncReply);
@@ -700,11 +693,7 @@
void
Logic::printDigest(ndn::ConstBufferPtr digest)
{
- using namespace CryptoPP;
-
- std::string hash;
- StringSource(digest->buf(), digest->size(), true,
- new HexEncoder(new StringSink(hash), false));
+ std::string hash = ndn::toHex(digest->buf(), digest->size(), false);
_LOG_DEBUG_ID("Hash: " << hash);
}
@@ -811,7 +800,7 @@
if (m_nodeList[nodePrefix].signingId.empty())
m_keyChain.sign(*data);
else
- m_keyChain.signByIdentity(*data, m_nodeList[nodePrefix].signingId);
+ m_keyChain.sign(*data, security::signingByIdentity(m_nodeList[nodePrefix].signingId));
sendExcludeInterest(interest, *data);
diff --git a/src/logic.hpp b/src/logic.hpp
index 4f75085..78080ae 100644
--- a/src/logic.hpp
+++ b/src/logic.hpp
@@ -27,17 +27,18 @@
#define CHRONOSYNC_LOGIC_HPP
#include "boost-header.h"
+#include "diff-state-container.hpp"
+#include "interest-table.hpp"
+
#include <memory>
#include <unordered_map>
#include <ndn-cxx/face.hpp>
#include <ndn-cxx/util/scheduler.hpp>
#include <ndn-cxx/security/key-chain.hpp>
+#include <ndn-cxx/security/signing-helpers.hpp>
#include <ndn-cxx/security/validator.hpp>
-#include "interest-table.hpp"
-#include "diff-state-container.hpp"
-
namespace chronosync {
/**
@@ -515,7 +516,6 @@
time::milliseconds m_recoveryInterestLifetime;
// Security
- ndn::Name m_defaultSigningId;
ndn::KeyChain m_keyChain;
std::shared_ptr<ndn::Validator> m_validator;
diff --git a/src/socket.cpp b/src/socket.cpp
index 4a947d7..0fd5707 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -129,7 +129,7 @@
if (m_signingId.empty())
m_keyChain.sign(*data);
else
- m_keyChain.signByIdentity(*data, m_signingId);
+ m_keyChain.sign(*data, security::signingByIdentity(m_signingId));
m_ims.insert(*data);
@@ -152,7 +152,7 @@
if (m_signingId.empty())
m_keyChain.sign(*data);
else
- m_keyChain.signByIdentity(*data, m_signingId);
+ m_keyChain.sign(*data, security::signingByIdentity(m_signingId));
m_ims.insert(*data);
diff --git a/src/socket.hpp b/src/socket.hpp
index 356b212..6ec0aef 100644
--- a/src/socket.hpp
+++ b/src/socket.hpp
@@ -25,12 +25,12 @@
#ifndef CHRONOSYNC_SOCKET_HPP
#define CHRONOSYNC_SOCKET_HPP
-#include <ndn-cxx/face.hpp>
-#include <ndn-cxx/util/in-memory-storage-persistent.hpp>
-#include <unordered_map>
-
#include "logic.hpp"
+#include <ndn-cxx/face.hpp>
+#include <ndn-cxx/ims/in-memory-storage-persistent.hpp>
+#include <unordered_map>
+
namespace chronosync {
/**
@@ -235,12 +235,12 @@
ndn::Face& m_face;
Logic m_logic;
- ndn::Name m_signingId;
+ Name m_signingId;
ndn::KeyChain m_keyChain;
std::shared_ptr<ndn::Validator> m_validator;
RegisteredPrefixList m_registeredPrefixList;
- ndn::util::InMemoryStoragePersistent m_ims;
+ ndn::InMemoryStoragePersistent m_ims;
};
} // namespace chronosync
diff --git a/src/state.hpp b/src/state.hpp
index 4fa82e9..8713552 100644
--- a/src/state.hpp
+++ b/src/state.hpp
@@ -1,6 +1,6 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
- * Copyright (c) 2012-2014 University of California, Los Angeles
+ * Copyright (c) 2012-2017 University of California, Los Angeles
*
* This file is part of ChronoSync, synchronization library for distributed realtime
* applications for NDN.
@@ -27,7 +27,7 @@
#include "tlv.hpp"
#include "leaf-container.hpp"
-#include <ndn-cxx/util/digest.hpp>
+#include <ndn-cxx/util/sha256.hpp>
namespace chronosync {