Switch to new KeyChain where possible
signed_interest::POS_RANDOM_VAL and signed_interest::POS_TIMESTAMP
constants are deprecated. Use command_interest:: equivalents instead.
This commit also includes fix for the backward compatibility regression
due to move of deprecated TPM/PublicInfo header files.
Change-Id: Ic3b008fc6758f3ac83f191158b6ac0789483f90d
Refs: #3098
diff --git a/src/security/command-interest-validator.cpp b/src/security/command-interest-validator.cpp
index f877f41..73358bf 100644
--- a/src/security/command-interest-validator.cpp
+++ b/src/security/command-interest-validator.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).
*
@@ -118,11 +118,11 @@
uint64_t& timestamp) const
{
const Name& name = interest.getName();
- if (name.size() < signed_interest::MIN_LENGTH) {
+ if (name.size() < command_interest::MIN_SIZE) {
return ErrorCode::NAME_TOO_SHORT;
}
- const name::Component& timestampComp = name[signed_interest::POS_TIMESTAMP];
+ const name::Component& timestampComp = name.at(command_interest::POS_TIMESTAMP);
if (!timestampComp.isNumber()) {
return ErrorCode::BAD_TIMESTAMP;
}
diff --git a/src/security/conf/checker.hpp b/src/security/conf/checker.hpp
index 0bed1a9..b928906 100644
--- a/src/security/conf/checker.hpp
+++ b/src/security/conf/checker.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).
*
@@ -48,12 +48,6 @@
typedef function<void(const shared_ptr<const Data>&)> OnDataChecked;
typedef function<void(const shared_ptr<const Data>&, const std::string&)> OnDataCheckFailed;
- enum {
- INTEREST_SIG_VALUE = -1,
- INTEREST_SIG_INFO = -2
- };
-
-
virtual
~Checker()
{
@@ -115,8 +109,8 @@
{
try {
const Name& interestName = interest.getName();
- Signature signature(interestName[Checker::INTEREST_SIG_INFO].blockFromValue(),
- interestName[Checker::INTEREST_SIG_VALUE].blockFromValue());
+ Signature signature(interestName[command_interest::POS_SIG_INFO].blockFromValue(),
+ interestName[command_interest::POS_SIG_VALUE].blockFromValue());
return check(interest, signature);
}
catch (const Signature::Error& e) {
@@ -222,8 +216,8 @@
{
try {
const Name& interestName = interest.getName();
- Signature signature(interestName[Checker::INTEREST_SIG_INFO].blockFromValue(),
- interestName[Checker::INTEREST_SIG_VALUE].blockFromValue());
+ Signature signature(interestName[command_interest::POS_SIG_INFO].blockFromValue(),
+ interestName[command_interest::POS_SIG_VALUE].blockFromValue());
return check(interest, signature);
}
catch (const Signature::Error& e) {
diff --git a/src/security/conf/filter.hpp b/src/security/conf/filter.hpp
index d191b1b..2ebc4e6 100644
--- a/src/security/conf/filter.hpp
+++ b/src/security/conf/filter.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 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).
*
@@ -63,10 +63,10 @@
bool
match(const Interest& interest)
{
- if (interest.getName().size() < signed_interest::MIN_LENGTH)
+ if (interest.getName().size() < command_interest::MIN_SIZE)
return false;
- Name unsignedName = interest.getName().getPrefix(-signed_interest::MIN_LENGTH);
+ Name unsignedName = interest.getName().getPrefix(-command_interest::MIN_SIZE);
return matchName(unsignedName);
}
diff --git a/src/security/conf/key-locator-checker.hpp b/src/security/conf/key-locator-checker.hpp
index 7a9ff0b..04f43e0 100644
--- a/src/security/conf/key-locator-checker.hpp
+++ b/src/security/conf/key-locator-checker.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 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).
*
@@ -75,13 +75,13 @@
const KeyLocator& keyLocator,
std::string& failInfo)
{
- if (interest.getName().size() < signed_interest::MIN_LENGTH)
+ if (interest.getName().size() < command_interest::MIN_SIZE)
{
failInfo = "No Signature";
return false;
}
- Name signedName = interest.getName().getPrefix(-signed_interest::MIN_LENGTH);
+ Name signedName = interest.getName().getPrefix(-command_interest::MIN_SIZE);
return check(signedName, keyLocator, failInfo);
}
diff --git a/src/security/sec-public-info-sqlite3.hpp b/src/security/sec-public-info-sqlite3.hpp
new file mode 100644
index 0000000..e5b061f
--- /dev/null
+++ b/src/security/sec-public-info-sqlite3.hpp
@@ -0,0 +1,33 @@
+/* -*- 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).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+/**
+ * @file security/sec-public-info-sqlite3.hpp
+ * @deprecated Use new PIB backed routines
+ */
+
+#include "security-common.hpp"
+
+#ifdef NDN_CXX_KEEP_SECURITY_V1_ALIASES
+#include "v1/sec-public-info-sqlite3.hpp"
+#else
+#error "Deprecated. Use the new PIB backed routines"
+#endif // NDN_CXX_KEEP_SECURITY_V1_ALIASES
diff --git a/src/security/sec-public-info.hpp b/src/security/sec-public-info.hpp
new file mode 100644
index 0000000..5101df5
--- /dev/null
+++ b/src/security/sec-public-info.hpp
@@ -0,0 +1,33 @@
+/* -*- 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).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+/**
+ * @file security/sec-public-info.hpp
+ * @deprecated Use new PIB backed routines
+ */
+
+#include "security-common.hpp"
+
+#ifdef NDN_CXX_KEEP_SECURITY_V1_ALIASES
+#include "v1/sec-public-info.hpp"
+#else
+#error "Deprecated. Use the new PIB backed routines"
+#endif // NDN_CXX_KEEP_SECURITY_V1_ALIASES
diff --git a/src/security/sec-tpm-file.hpp b/src/security/sec-tpm-file.hpp
new file mode 100644
index 0000000..d30e492
--- /dev/null
+++ b/src/security/sec-tpm-file.hpp
@@ -0,0 +1,33 @@
+/* -*- 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).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+/**
+ * @file security/sec-tpm-file.hpp
+ * @deprecated Use new TPM backed routines
+ */
+
+#include "security-common.hpp"
+
+#ifdef NDN_CXX_KEEP_SECURITY_V1_ALIASES
+#include "v1/sec-tpm-file.hpp"
+#else
+#error "Deprecated. Use the new TPM backed routines"
+#endif // NDN_CXX_KEEP_SECURITY_V1_ALIASES
diff --git a/src/security/sec-tpm-osx.hpp b/src/security/sec-tpm-osx.hpp
new file mode 100644
index 0000000..478e8cf
--- /dev/null
+++ b/src/security/sec-tpm-osx.hpp
@@ -0,0 +1,33 @@
+/* -*- 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).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+/**
+ * @file security/sec-tpm-osx.hpp
+ * @deprecated Use new TPM backed routines
+ */
+
+#include "security-common.hpp"
+
+#ifdef NDN_CXX_KEEP_SECURITY_V1_ALIASES
+#include "v1/sec-tpm-osx.hpp"
+#else
+#error "Deprecated. Use the new TPM backed routines"
+#endif // NDN_CXX_KEEP_SECURITY_V1_ALIASES
diff --git a/src/security/sec-tpm.hpp b/src/security/sec-tpm.hpp
new file mode 100644
index 0000000..a5fcb8b
--- /dev/null
+++ b/src/security/sec-tpm.hpp
@@ -0,0 +1,33 @@
+/* -*- 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).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+/**
+ * @file security/sec-tpm.hpp
+ * @deprecated Use new TPM backed routines
+ */
+
+#include "security-common.hpp"
+
+#ifdef NDN_CXX_KEEP_SECURITY_V1_ALIASES
+#include "v1/sec-tpm.hpp"
+#else
+#error "Deprecated. Use the new TPM backed routines"
+#endif // NDN_CXX_KEEP_SECURITY_V1_ALIASES
diff --git a/src/security/security-common.hpp b/src/security/security-common.hpp
index 7fec50b..04d2691 100644
--- a/src/security/security-common.hpp
+++ b/src/security/security-common.hpp
@@ -32,18 +32,48 @@
const ssize_t POS_SIG_VALUE = -1;
const ssize_t POS_SIG_INFO = -2;
+
+/** \brief minimal number of components for Signed Interest
+ * \sa https://redmine.named-data.net/projects/ndn-cxx/wiki/SignedInterest
+ */
+const size_t MIN_SIZE = 2;
+
+/** \deprecated To avoid a potentially breaking change, this value is kept based on the Command
+ * Interest definition. This value will be eliminated in favor of `MIN_SIZE=2`.
+ */
+const size_t MIN_LENGTH = 4;
+
+/** \deprecated Use `MIN_SIZE`
+ */
+const size_t MIN_LENGTH_SIG_ONLY = 2;
+
+} // namespace signed_interest
+
+namespace command_interest {
+
+using signed_interest::POS_SIG_VALUE;
+using signed_interest::POS_SIG_INFO;
const ssize_t POS_RANDOM_VAL = -3;
const ssize_t POS_TIMESTAMP = -4;
/** \brief minimal number of components for Command Interest
* \sa https://redmine.named-data.net/projects/ndn-cxx/wiki/CommandInterest
*/
-const size_t MIN_LENGTH = 4;
+const size_t MIN_SIZE = 4;
-/** \brief minimal number of components for Signed Interest
- * \sa https://redmine.named-data.net/projects/ndn-cxx/wiki/SignedInterest
+} // namespace command_interest
+
+namespace signed_interest {
+
+/**
+ * @deprecated Use command_interest::POS_RANDOM_VAL
*/
-const size_t MIN_LENGTH_SIG_ONLY = 2;
+using command_interest::POS_RANDOM_VAL;
+
+/**
+ * @deprecated Use command_interest::POS_TIMESTAMP
+ */
+using command_interest::POS_TIMESTAMP;
} // namespace signed_interest
diff --git a/src/security/validator-config.cpp b/src/security/validator-config.cpp
index 64c0187..f267377 100644
--- a/src/security/validator-config.cpp
+++ b/src/security/validator-config.cpp
@@ -482,14 +482,14 @@
// If interestName has less than 4 name components,
// it is definitely not a signed interest.
- if (interest.getName().size() < signed_interest::MIN_LENGTH)
+ if (interest.getName().size() < command_interest::MIN_SIZE)
return onValidationFailed(interest.shared_from_this(),
"Interest is not signed: " + interest.getName().toUri());
try {
const Name& interestName = interest.getName();
- Signature signature(interestName[signed_interest::POS_SIG_INFO].blockFromValue(),
- interestName[signed_interest::POS_SIG_VALUE].blockFromValue());
+ Signature signature(interestName[command_interest::POS_SIG_INFO].blockFromValue(),
+ interestName[command_interest::POS_SIG_VALUE].blockFromValue());
if (!signature.hasKeyLocator())
return onValidationFailed(interest.shared_from_this(), "No valid KeyLocator");
@@ -552,7 +552,7 @@
try {
interestTime =
- time::fromUnixTimestamp(time::milliseconds(interestName.get(-signed_interest::MIN_LENGTH).toNumber()));
+ time::fromUnixTimestamp(time::milliseconds(interestName.at(command_interest::POS_TIMESTAMP).toNumber()));
}
catch (const tlv::Error& e) {
return onValidationFailed(interest,
diff --git a/src/security/validator.cpp b/src/security/validator.cpp
index d3af387..f0f87b7 100644
--- a/src/security/validator.cpp
+++ b/src/security/validator.cpp
@@ -117,7 +117,7 @@
{
const Name& name = interest.getName();
- if (name.size() < signed_interest::MIN_LENGTH_SIG_ONLY)
+ if (name.size() < signed_interest::MIN_SIZE)
return false;
Signature sig;