interest: remove deprecated setDefaultCanBePrefix()

Change-Id: Ifaffb7cc7772a31c3b396c60b816e783d70b7041
This commit is contained in:
Davide Pesavento committed 2022-02-18 14:43:02 -05:00
1 parent 778ad714f0
commit aee2ada5f0
23 files changed
+25 -192

No files matched your search

+2 -2
View File
@@ -18,7 +18,7 @@ callbacks to be called when Data/Nack is retrieved or Interest times out.
.. literalinclude:: ../examples/consumer.cpp
:language: c++
:linenos:
:emphasize-lines: 43-49,52-55,63,77,83
:emphasize-lines: 43-48,51-54,62,76,82
Trivial producer
----------------
@@ -64,4 +64,4 @@ Interest approximately 3 seconds after the first one.
.. literalinclude:: ../examples/consumer-with-timer.cpp
:language: c++
:linenos:
:emphasize-lines: 37-38,54-57,60,91,104-107,112-114
:emphasize-lines: 47-50,53,84,96-99,104-106
+3 -11
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2021 Regents of the University of California.
* Copyright (c) 2013-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -33,12 +33,6 @@ namespace examples {
class ConsumerWithTimer
{
public:
ConsumerWithTimer()
: m_face(m_ioService) // Create face with io_service object
, m_scheduler(m_ioService)
{
}
void
run()
{
@@ -46,7 +40,6 @@ public:
interestName.appendVersion();
Interest interest(interestName);
interest.setCanBePrefix(false);
interest.setMustBeFresh(true);
interest.setInterestLifetime(2_s);
@@ -96,7 +89,6 @@ private:
interestName.appendVersion();
Interest interest(interestName);
interest.setCanBePrefix(false);
interest.setMustBeFresh(true);
interest.setInterestLifetime(2_s);
@@ -110,8 +102,8 @@ private:
private:
// Explicitly create io_service object, which will be shared between Face and Scheduler
boost::asio::io_service m_ioService;
Face m_face;
Scheduler m_scheduler;
Face m_face{m_ioService};
Scheduler m_scheduler{m_ioService};
};
} // namespace examples
+1 -2
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2021 Regents of the University of California.
* Copyright (c) 2013-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -44,7 +44,6 @@ public:
interestName.appendVersion();
Interest interest(interestName);
interest.setCanBePrefix(false);
interest.setMustBeFresh(true);
interest.setInterestLifetime(6_s); // The default is 4 seconds
-5
View File
@@ -40,17 +40,12 @@ BOOST_CONCEPT_ASSERT((WireDecodable<Interest>));
static_assert(std::is_base_of<tlv::Error, Interest::Error>::value,
"Interest::Error must inherit from tlv::Error");
boost::logic::tribool Interest::s_defaultCanBePrefix = boost::logic::indeterminate;
bool Interest::s_autoCheckParametersDigest = true;
Interest::Interest(const Name& name, time::milliseconds lifetime)
{
setName(name);
setInterestLifetime(lifetime);
if (!boost::logic::indeterminate(s_defaultCanBePrefix)) {
setCanBePrefix(bool(s_defaultCanBePrefix));
}
}
Interest::Interest(const Block& wire)
-22
View File
@@ -32,7 +32,6 @@
#include <array>
#include <boost/endian/conversion.hpp>
#include <boost/logic/tribool.hpp>
namespace ndn {
@@ -181,26 +180,6 @@ public: // element access
Interest&
setName(const Name& name);
/** @brief Declare the default CanBePrefix setting of the application.
*
* As part of transitioning to NDN Packet Format v0.3, the default setting for CanBePrefix
* has been changed from "true" to "false". Application developers are advised to review all
* Interests expressed by their applications and decide what CanBePrefix setting is appropriate
* for each Interest. Applications must set CanBePrefix on a per-Interest basis, if different
* from the default value. Changing the application-wide default CanBePrefix setting via this
* function is deprecated.
*
* @deprecated
* @note This function should not be used in libraries or in ndn-cxx unit tests.
* @sa https://redmine.named-data.net/projects/nfd/wiki/Packet03Transition
*/
[[deprecated]]
static void
setDefaultCanBePrefix(bool canBePrefix)
{
s_defaultCanBePrefix = canBePrefix;
}
/** @brief Check whether the CanBePrefix element is present.
*/
bool
@@ -489,7 +468,6 @@ private:
findFirstParameter(uint32_t type) const;
private:
static boost::logic::tribool s_defaultCanBePrefix;
static bool s_autoCheckParametersDigest;
Name m_name;
+1 -2
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2021 Regents of the University of California.
* Copyright (c) 2013-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -69,7 +69,6 @@ InterestSigner::makeCommandInterest(Name name, const SigningInfo& params)
.append(name::Component::fromNumber(random::generateWord64())) // nonce
;
interest.setName(name);
interest.setCanBePrefix(false);
m_keyChain.sign(interest, params);
return interest;
}
+1 -2
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2019 Regents of the University of California,
* Copyright (c) 2014-2022 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -91,7 +91,6 @@ NotificationSubscriberBase::sendNextInterest()
nextName.appendSequenceNumber(m_lastSequenceNum + 1);
auto interest = make_shared<Interest>(nextName);
interest->setCanBePrefix(false);
interest->setInterestLifetime(m_interestLifetime);
sendInterest(*interest);
}
@@ -1,39 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2020 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.
*/
#define BOOST_TEST_MODULE ndn-cxx Integration (DefaultCanBePrefix)
#include "tests/boost-test.hpp"
#include "ndn-cxx/interest.hpp"
namespace ndn {
namespace tests {
BOOST_AUTO_TEST_CASE(DefaultCanBePrefix0)
{
Interest::setDefaultCanBePrefix(false);
Interest interest1("/I");
Interest interest2(interest1.wireEncode());
BOOST_CHECK_EQUAL(interest2.getCanBePrefix(), false);
}
} // namespace tests
} // namespace ndn
@@ -1,39 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2020 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.
*/
#define BOOST_TEST_MODULE ndn-cxx Integration (DefaultCanBePrefix)
#include "tests/boost-test.hpp"
#include "ndn-cxx/interest.hpp"
namespace ndn {
namespace tests {
BOOST_AUTO_TEST_CASE(DefaultCanBePrefix1)
{
Interest::setDefaultCanBePrefix(true);
Interest interest1("/I");
Interest interest2(interest1.wireEncode());
BOOST_CHECK_EQUAL(interest2.getCanBePrefix(), true);
}
} // namespace tests
} // namespace ndn
@@ -1,10 +0,0 @@
# DefaultCanBePrefix test
`default-can-be-prefix-*.cpp` verifies the effect of `Interest::setDefaultCanBePrefix`.
They are written as integration tests because ndn-cxx unit tests are prohibited from calling `Interest::setDefaultCanBePrefix`.
Manual verification steps:
1. `default-can-be-prefix-unset` program should print a "CanBePrefix unset" warning to stderr.
2. `default-can-be-prefix-0` and `default-can-be-prefix-1` test cases should not print that warning.
-10
View File
@@ -82,7 +82,6 @@ BOOST_AUTO_TEST_CASE(Basic)
Interest i1;
i1.setName("/local/ndn/prefix");
i1.setCanBePrefix(false);
i1.setNonce(0x01020304);
BOOST_CHECK_EQUAL(i1.isParametersDigestValid(), true);
@@ -125,7 +124,6 @@ BOOST_AUTO_TEST_CASE(WithParameters)
Interest i1;
i1.setName("/local/ndn/prefix");
i1.setCanBePrefix(false);
i1.setNonce(0x1);
i1.setApplicationParameters("2404C0C1C2C3"_block);
BOOST_CHECK_EQUAL(i1.isParametersDigestValid(), true);
@@ -265,7 +263,6 @@ BOOST_AUTO_TEST_CASE(Signed)
BOOST_CHECK_EQUAL_COLLECTIONS(wire1.begin(), wire1.end(), WIRE, WIRE + sizeof(WIRE));
Interest i2("/local/ndn/prefix");
i2.setCanBePrefix(false);
i2.setMustBeFresh(true);
i2.setNonce(0x4c1ecb4a);
i2.setApplicationParameters("2404C0C1C2C3"_block);
@@ -347,7 +344,6 @@ BOOST_AUTO_TEST_CASE(MissingApplicationParameters)
{
Interest i;
i.setName(Name("/A").appendParametersSha256DigestPlaceholder());
i.setCanBePrefix(false);
BOOST_CHECK_EQUAL(i.isParametersDigestValid(), false);
BOOST_CHECK_EXCEPTION(i.wireEncode(), tlv::Error, [] (const auto& e) {
return e.what() == "Interest without parameters must not have a ParametersSha256DigestComponent"s;
@@ -783,7 +779,6 @@ BOOST_AUTO_TEST_CASE(GetNonce)
BOOST_AUTO_TEST_CASE(SetNonce)
{
Interest i1("/A");
i1.setCanBePrefix(false);
BOOST_CHECK(!i1.hasNonce());
i1.setNonce(1);
@@ -820,7 +815,6 @@ BOOST_AUTO_TEST_CASE(RefreshNonce)
BOOST_AUTO_TEST_CASE(NonceConversions)
{
Interest i;
i.setCanBePrefix(false);
// 4-arg constructor
Interest::Nonce n1(1, 2, 3, 4);
@@ -908,7 +902,6 @@ BOOST_AUTO_TEST_CASE(SetApplicationParameters)
BOOST_AUTO_TEST_CASE(SetSignature)
{
Interest i;
i.setCanBePrefix(false);
BOOST_CHECK(i.getSignatureInfo() == nullopt);
BOOST_CHECK_EQUAL(i.isSigned(), false);
@@ -1055,7 +1048,6 @@ BOOST_AUTO_TEST_CASE(ParametersSha256DigestComponent)
BOOST_AUTO_TEST_CASE(ExtractSignedRanges)
{
Interest i1;
i1.setCanBePrefix(false);
BOOST_CHECK_EXCEPTION(i1.extractSignedRanges(), tlv::Error, [] (const auto& e) {
return e.what() == "Name has zero name components"s;
});
@@ -1136,7 +1128,6 @@ BOOST_AUTO_TEST_CASE(ExtractSignedRanges)
// Test failure with missing ParametersSha256DigestComponent
Interest i3("/a");
i3.setCanBePrefix(false);
BOOST_CHECK_EXCEPTION(i3.extractSignedRanges(), tlv::Error, [] (const auto& e) {
return e.what() == "Interest Name must end with a ParametersSha256DigestComponent"s;
});
@@ -1151,7 +1142,6 @@ BOOST_AUTO_TEST_CASE(ExtractSignedRanges)
BOOST_AUTO_TEST_CASE(ToUri)
{
Interest i;
i.setCanBePrefix(false);
BOOST_CHECK_EQUAL(i.toUri(), "/");
i.setName("/foo");
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2020 Regents of the University of California.
* Copyright (c) 2013-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -74,9 +74,7 @@ public:
cache.insert(subSubIdentity.getDefaultKey().getDefaultCertificate());
m_keyChain.sign(data, signingByIdentity(subSubIdentity));
interest.setCanBePrefix(false);
m_keyChain.sign(interest, signingByIdentity(subSubIdentity));
interestNoTag.setCanBePrefix(false);
m_keyChain.sign(interestNoTag, signingByIdentity(subSubIdentity));
data.setTag(make_shared<lp::IncomingFaceIdTag>(123));
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2021 Regents of the University of California.
* Copyright (c) 2013-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -62,7 +62,6 @@ public:
cache.insert(subSubIdentity.getDefaultKey().getDefaultCertificate());
m_keyChain.sign(data, signingByIdentity(subSubIdentity));
interest.setCanBePrefix(false);
m_keyChain.sign(interest, signingByIdentity(subSubIdentity));
processInterest = [this] (const Interest& i) { makeResponse(i); };
+4 -7
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2020 Regents of the University of California.
* Copyright (c) 2013-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -75,10 +75,9 @@ BOOST_AUTO_TEST_CASE(V03)
InterestSigner signer(m_keyChain);
Interest i1("/hello/world");
i1.setCanBePrefix(false);
signer.makeSignedInterest(i1, SigningInfo(),
InterestSigner::SigningFlags::WantNonce |
InterestSigner::SigningFlags::WantTime);
InterestSigner::SigningFlags::WantTime);
BOOST_TEST(i1.isSigned() == true);
BOOST_TEST_REQUIRE(i1.getName().size() == 3);
BOOST_TEST_REQUIRE(i1.getSignatureInfo().has_value());
@@ -88,11 +87,10 @@ BOOST_AUTO_TEST_CASE(V03)
BOOST_TEST(i1.getSignatureInfo()->getSeqNum().has_value() == false);
Interest i2("/hello/world/!");
i2.setCanBePrefix(false);
signer.makeSignedInterest(i2, signingByIdentity("/test"),
InterestSigner::SigningFlags::WantNonce |
InterestSigner::SigningFlags::WantTime |
InterestSigner::SigningFlags::WantSeqNum);
InterestSigner::SigningFlags::WantTime |
InterestSigner::SigningFlags::WantSeqNum);
BOOST_TEST(i2.isSigned() == true);
BOOST_REQUIRE_EQUAL(i2.getName().size(), 4);
BOOST_REQUIRE(i2.getSignatureInfo());
@@ -104,7 +102,6 @@ BOOST_AUTO_TEST_CASE(V03)
advanceClocks(100_s);
Interest i3("/hello/world/2");
i3.setCanBePrefix(false);
signer.makeSignedInterest(i3, SigningInfo(), InterestSigner::SigningFlags::WantSeqNum);
BOOST_TEST(i3.isSigned() == true);
BOOST_REQUIRE_EQUAL(i3.getName().size(), 4);
+3 -3
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2021 Regents of the University of California.
* Copyright (c) 2013-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -341,7 +341,7 @@ struct DataPkt
struct InterestV02Pkt
{
Interest packet = Interest{"/interest02"}.setCanBePrefix(false);
Interest packet{"/interest02"};
SignedInterestFormat sigFormat = SignedInterestFormat::V02;
SignatureInfo
@@ -353,7 +353,7 @@ struct InterestV02Pkt
struct InterestV03Pkt
{
Interest packet = Interest{"/interest03"}.setCanBePrefix(false);
Interest packet{"/interest03"};
SignedInterestFormat sigFormat = SignedInterestFormat::V03;
SignatureInfo
@@ -69,7 +69,6 @@ public:
{
if (wantV3) {
Interest i(Name(identity.getName()).append("CMD"));
i.setCanBePrefix(false);
m_signer.makeSignedInterest(i, signingByIdentity(identity));
return i;
}
@@ -113,7 +112,6 @@ BOOST_AUTO_TEST_CASE(BasicV3)
VALIDATE_SUCCESS(i2, "Should succeed (timestamp larger than previous)");
Interest i3(Name(identity.getName()).append("CMD"));
i3.setCanBePrefix(false);
m_signer.makeSignedInterest(i3, signingWithSha256());
VALIDATE_FAILURE(i3, "Should fail (Sha256 signature violates policy)");
}
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2021 Regents of the University of California.
* Copyright (c) 2013-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -56,7 +56,6 @@ BOOST_FIXTURE_TEST_CASE(EmptyConfig, HierarchicalValidatorFixture<ValidationPoli
VALIDATE_FAILURE(d, "Empty policy should reject everything");
Interest i("/Security/ValidationPolicyConfig/I");
i.setCanBePrefix(false);
this->m_keyChain.sign(i, signingByIdentity(this->identity));
VALIDATE_FAILURE(i, "Empty policy should reject everything");
}
@@ -412,9 +411,6 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(ValidateInterest, Policy, InterestPolicies, Pol
using Packet = typename Policy::Packet;
Packet unsignedPacket("/Security/ValidatorFixture/Sub1/Sub2/Packet");
// All of the packet types inputed to this test case template are Interests, so we can call
// setCanBePrefix
unsignedPacket.setCanBePrefix(false);
Packet packet = unsignedPacket;
VALIDATE_FAILURE(packet, "Unsigned");
@@ -484,7 +480,6 @@ BOOST_FIXTURE_TEST_CASE(DigestSha256, HierarchicalValidatorFixture<ValidationPol
Interest interest("/Security/ValidatorFixture/Sub1/Sub2/Packet");
interest.setCanBePrefix(false);
this->m_keyChain.sign(interest, signingWithSha256());
VALIDATE_SUCCESS(interest, "Should be accepted");
@@ -557,7 +552,6 @@ BOOST_FIXTURE_TEST_CASE(DigestSha256WithKeyLocator, HierarchicalValidatorFixture
Interest interest("/localhost/identity/digest-sha256/foobar");
interest.setCanBePrefix(false);
this->m_keyChain.sign(interest, signingWithSha256());
VALIDATE_SUCCESS(interest, "Should be accepted");
@@ -630,7 +624,6 @@ BOOST_FIXTURE_TEST_CASE(SigTypeCheck, HierarchicalValidatorFixture<ValidationPol
Interest interest("/localhost/identity/digest-sha256/foobar");
interest.setCanBePrefix(false);
this->m_keyChain.sign(interest, signingWithSha256());
VALIDATE_FAILURE(interest, "Signature type check should fail");
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2020 Regents of the University of California.
* Copyright (c) 2013-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -75,7 +75,6 @@ public:
uint32_t signingFlags = InterestSigner::WantNonce | InterestSigner::WantTime)
{
Interest i(Name(identity.getName()).append("CMD"));
i.setCanBePrefix(false);
m_signer.makeSignedInterest(i, signingByIdentity(identity), signingFlags);
return i;
}
@@ -102,7 +101,6 @@ BOOST_AUTO_TEST_CASE(BasicV3)
VALIDATE_SUCCESS(i2, "Should succeed (timestamp and sequence number larger than previous)");
Interest i3(Name(identity.getName()).append("CMD"));
i3.setCanBePrefix(false);
m_signer.makeSignedInterest(i3, signingWithSha256());
VALIDATE_FAILURE(i3, "Should fail (Sha256 signature violates policy)");
}
+1 -3
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2021 Regents of the University of California.
* Copyright (c) 2013-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -157,7 +157,6 @@ BOOST_FIXTURE_TEST_CASE(ValidateSignedInterest, ValidatorConfigFixture)
InterestSigner signer(m_keyChain);
Interest i1("/hello/world");
i1.setCanBePrefix(false);
signer.makeSignedInterest(i1);
size_t nValidated = 0, nFailed = 0;
@@ -170,7 +169,6 @@ BOOST_FIXTURE_TEST_CASE(ValidateSignedInterest, ValidatorConfigFixture)
BOOST_CHECK_EQUAL(nFailed, 1);
Interest i2("/hello/world");
i2.setCanBePrefix(false);
signer.makeSignedInterest(i2, signingWithSha256());
validator.validate(i2, [&] (auto&&...) { ++nValidated; }, [&] (auto&&...) { ++nFailed; });
BOOST_CHECK_EQUAL(nValidated, 2);
+1 -3
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2021 Regents of the University of California.
* Copyright (c) 2013-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -79,7 +79,6 @@ Name
InterestV02Pkt::makeName(Name name, KeyChain& keyChain)
{
Interest interest(name);
interest.setCanBePrefix(false);
SigningInfo params;
params.setSignedInterestFormat(SignedInterestFormat::V02);
keyChain.sign(interest, params);
@@ -90,7 +89,6 @@ Name
InterestV03Pkt::makeName(Name name, KeyChain& keyChain)
{
Interest interest(name);
interest.setCanBePrefix(false);
SigningInfo params;
params.setSignedInterestFormat(SignedInterestFormat::V03);
keyChain.sign(interest, params);
+3 -3
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2021 Regents of the University of California.
* Copyright (c) 2013-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -212,7 +212,7 @@ struct InterestV02Pkt
static Interest
makePacket(const Name& name)
{
return Interest(name).setCanBePrefix(false);
return Interest(name);
}
static shared_ptr<ValidationState>
@@ -238,7 +238,7 @@ struct InterestV03Pkt
static Interest
makePacket(const Name& name)
{
return Interest(name).setCanBePrefix(false);
return Interest(name);
}
static shared_ptr<ValidationState>
+1 -3
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2020 Regents of the University of California.
* Copyright (c) 2013-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -209,7 +209,6 @@ BOOST_FIXTURE_TEST_CASE(ValidateInterestsButBypassForData,
HierarchicalValidatorFixture<ValidationPolicySimpleHierarchyForInterestOnly>)
{
Interest interest("/Security/ValidatorFixture/Sub1/Sub2/Interest");
interest.setCanBePrefix(false);
Data data("/Security/ValidatorFixture/Sub1/Sub2/Interest");
VALIDATE_FAILURE(interest, "Unsigned");
@@ -218,7 +217,6 @@ BOOST_FIXTURE_TEST_CASE(ValidateInterestsButBypassForData,
face.sentInterests.clear();
interest = Interest("/Security/ValidatorFixture/Sub1/Sub2/Interest");
interest.setCanBePrefix(false);
m_keyChain.sign(interest, signingWithSha256());
m_keyChain.sign(data, signingWithSha256());
VALIDATE_FAILURE(interest, "Required KeyLocator/Name missing (not passed to policy)");
@@ -97,7 +97,6 @@ BOOST_AUTO_TEST_SUITE(TestVerificationHelpers)
// Interest interest1(Name("/test/interest").append(type));
// SigningInfo signingInfoV03(signingInfo);
// signingInfoV03.setSignedInterestFormat(SignedInterestFormat::V03);
// interest1.setCanBePrefix(false);
// interest1.setNonce(0xF72C8A4B);
// m_keyChain.sign(interest1, signingInfoV03);
// print("goodInterest", interest1.wireEncode().wire(), interest1.wireEncode().size());
@@ -113,7 +112,6 @@ BOOST_AUTO_TEST_SUITE(TestVerificationHelpers)
// Interest interest2(Name("/test/interest").append(type));
// SigningInfo signingInfoV02(signingInfo);
// signingInfoV02.setSignedInterestFormat(SignedInterestFormat::V03);
// interest2.setCanBePrefix(false);
// interest2.setNonce(0xF72C8A4B);
// m_keyChain.sign(interest2, signingInfoV02);
// print("goodInterestOldFormat", interest2.wireEncode().wire(), interest2.wireEncode().size());
@@ -580,9 +578,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(VerifySignature, Dataset, SignatureDatasets)
Data unsignedData("/some/data");
Interest unsignedInterest1("/some/interest/with/several/name/components");
unsignedInterest1.setCanBePrefix(false);
Interest unsignedInterest2("/interest-with-one-name-component");
unsignedInterest2.setCanBePrefix(false);
BOOST_CHECK(!verifySignature(unsignedData, cert));
BOOST_CHECK(!verifySignature(unsignedData, key));
@@ -605,9 +601,7 @@ BOOST_FIXTURE_TEST_CASE(VerifyHmac, KeyChainFixture)
const Tpm& tpm = m_keyChain.getTpm();
Data data("/data");
Interest interest("/interest");
interest.setCanBePrefix(false);
Interest interestOldFormat("/interest");
interestOldFormat.setCanBePrefix(false);
SigningInfo signingInfo;
signingInfo.setSigningHmacKey("QjM3NEEyNkE3MTQ5MDQzN0FBMDI0RTRGQURENUI0OTdGREZGMUE4RUE2RkYxMkY2"
"RkI2NUFGMjcyMEI1OUNDRg==");
@@ -649,9 +643,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(VerifyDigest, Dataset, DigestDatasets)
Data unsignedData("/some/data");
Interest unsignedInterest1("/some/interest/with/several/name/components");
unsignedInterest1.setCanBePrefix(false);
Interest unsignedInterest2("/interest-with-one-name-component");
unsignedInterest2.setCanBePrefix(false);
BOOST_CHECK(!verifySignature(unsignedData, nullopt));
BOOST_CHECK(!verifySignature(unsignedInterest1, nullopt));