Yingdi Yu | 4a55705 | 2014-07-09 16:40:37 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Junxiao Shi | 605671d | 2017-08-26 13:41:06 +0000 | [diff] [blame] | 2 | /* |
Davide Pesavento | f6b4589 | 2023-03-13 15:00:51 -0400 | [diff] [blame] | 3 | * Copyright (c) 2013-2023 Regents of the University of California. |
Yingdi Yu | 4a55705 | 2014-07-09 16:40:37 -0700 | [diff] [blame] | 4 | * |
| 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
| 6 | * |
| 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the |
| 8 | * terms of the GNU Lesser General Public License as published by the Free Software |
| 9 | * Foundation, either version 3 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY |
| 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received copies of the GNU General Public License and GNU Lesser |
| 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see |
| 17 | * <http://www.gnu.org/licenses/>. |
| 18 | * |
| 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. |
| 20 | */ |
| 21 | |
Davide Pesavento | 7e78064 | 2018-11-24 15:51:34 -0500 | [diff] [blame] | 22 | #include "ndn-cxx/signature-info.hpp" |
Yingdi Yu | 4a55705 | 2014-07-09 16:40:37 -0700 | [diff] [blame] | 23 | |
Davide Pesavento | 7e78064 | 2018-11-24 15:51:34 -0500 | [diff] [blame] | 24 | #include "tests/boost-test.hpp" |
Davide Pesavento | 14c56cd | 2020-05-21 01:44:03 -0400 | [diff] [blame] | 25 | |
Alexander Afanasyev | 4146975 | 2017-01-10 21:51:55 -0800 | [diff] [blame] | 26 | #include <boost/lexical_cast.hpp> |
Yingdi Yu | 4a55705 | 2014-07-09 16:40:37 -0700 | [diff] [blame] | 27 | |
| 28 | namespace ndn { |
Spyridon Mastorakis | 429634f | 2015-02-19 17:35:33 -0800 | [diff] [blame] | 29 | namespace tests { |
Yingdi Yu | 4a55705 | 2014-07-09 16:40:37 -0700 | [diff] [blame] | 30 | |
Davide Pesavento | 152ef44 | 2023-04-22 02:02:29 -0400 | [diff] [blame] | 31 | BOOST_CONCEPT_ASSERT((boost::EqualityComparable<SignatureInfo>)); |
| 32 | BOOST_CONCEPT_ASSERT((WireEncodable<SignatureInfo>)); |
| 33 | BOOST_CONCEPT_ASSERT((WireEncodableWithEncodingBuffer<SignatureInfo>)); |
| 34 | BOOST_CONCEPT_ASSERT((WireDecodable<SignatureInfo>)); |
| 35 | static_assert(std::is_convertible_v<SignatureInfo::Error*, tlv::Error*>, |
| 36 | "SignatureInfo::Error must inherit from tlv::Error"); |
| 37 | |
Yingdi Yu | 4a55705 | 2014-07-09 16:40:37 -0700 | [diff] [blame] | 38 | BOOST_AUTO_TEST_SUITE(TestSignatureInfo) |
| 39 | |
Yingdi Yu | 4a55705 | 2014-07-09 16:40:37 -0700 | [diff] [blame] | 40 | BOOST_AUTO_TEST_CASE(Constructor) |
| 41 | { |
| 42 | SignatureInfo info; |
| 43 | BOOST_CHECK_EQUAL(info.getSignatureType(), -1); |
| 44 | BOOST_CHECK_EQUAL(info.hasKeyLocator(), false); |
| 45 | BOOST_CHECK_THROW(info.getKeyLocator(), SignatureInfo::Error); |
Davide Pesavento | 14c56cd | 2020-05-21 01:44:03 -0400 | [diff] [blame] | 46 | BOOST_CHECK_THROW(info.getValidityPeriod(), SignatureInfo::Error); |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 47 | BOOST_CHECK(!info.getNonce()); |
| 48 | BOOST_CHECK(!info.getTime()); |
| 49 | BOOST_CHECK(!info.getSeqNum()); |
Davide Pesavento | 7e6f6f8 | 2017-10-31 18:05:28 -0400 | [diff] [blame] | 50 | |
Steve DiBenedetto | 54ce668 | 2014-07-22 13:22:57 -0600 | [diff] [blame] | 51 | SignatureInfo sha256Info(tlv::DigestSha256); |
| 52 | BOOST_CHECK_EQUAL(sha256Info.getSignatureType(), tlv::DigestSha256); |
Yingdi Yu | 4a55705 | 2014-07-09 16:40:37 -0700 | [diff] [blame] | 53 | BOOST_CHECK_THROW(sha256Info.getKeyLocator(), SignatureInfo::Error); |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 54 | BOOST_CHECK(!info.getNonce()); |
| 55 | BOOST_CHECK(!info.getTime()); |
| 56 | BOOST_CHECK(!info.getSeqNum()); |
Alexander Afanasyev | 4146975 | 2017-01-10 21:51:55 -0800 | [diff] [blame] | 57 | |
Yingdi Yu | 4a55705 | 2014-07-09 16:40:37 -0700 | [diff] [blame] | 58 | KeyLocator keyLocator("/test/key/locator"); |
Steve DiBenedetto | 54ce668 | 2014-07-22 13:22:57 -0600 | [diff] [blame] | 59 | SignatureInfo sha256RsaInfo(tlv::SignatureSha256WithRsa, keyLocator); |
| 60 | BOOST_CHECK_EQUAL(sha256RsaInfo.getSignatureType(), tlv::SignatureSha256WithRsa); |
Yingdi Yu | 4a55705 | 2014-07-09 16:40:37 -0700 | [diff] [blame] | 61 | BOOST_CHECK_EQUAL(sha256RsaInfo.hasKeyLocator(), true); |
Yingdi Yu | 4a55705 | 2014-07-09 16:40:37 -0700 | [diff] [blame] | 62 | BOOST_CHECK_EQUAL(sha256RsaInfo.getKeyLocator().getName(), Name("/test/key/locator")); |
Davide Pesavento | 14c56cd | 2020-05-21 01:44:03 -0400 | [diff] [blame] | 63 | BOOST_CHECK_THROW(sha256RsaInfo.getValidityPeriod(), SignatureInfo::Error); |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 64 | BOOST_CHECK(!info.getNonce()); |
| 65 | BOOST_CHECK(!info.getTime()); |
| 66 | BOOST_CHECK(!info.getSeqNum()); |
Yingdi Yu | 4a55705 | 2014-07-09 16:40:37 -0700 | [diff] [blame] | 67 | } |
| 68 | |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 69 | BOOST_AUTO_TEST_CASE(SignatureType) |
Yingdi Yu | 4a55705 | 2014-07-09 16:40:37 -0700 | [diff] [blame] | 70 | { |
| 71 | SignatureInfo info; |
| 72 | BOOST_CHECK_EQUAL(info.getSignatureType(), -1); |
Davide Pesavento | 14c56cd | 2020-05-21 01:44:03 -0400 | [diff] [blame] | 73 | BOOST_CHECK_THROW(info.wireEncode(), SignatureInfo::Error); |
Yingdi Yu | 4a55705 | 2014-07-09 16:40:37 -0700 | [diff] [blame] | 74 | |
Davide Pesavento | 14c56cd | 2020-05-21 01:44:03 -0400 | [diff] [blame] | 75 | info.setSignatureType(tlv::SignatureSha256WithEcdsa); |
| 76 | BOOST_CHECK_EQUAL(info.getSignatureType(), tlv::SignatureSha256WithEcdsa); |
| 77 | BOOST_CHECK_EQUAL(info.hasWire(), false); |
Yingdi Yu | 4a55705 | 2014-07-09 16:40:37 -0700 | [diff] [blame] | 78 | |
Davide Pesavento | 14c56cd | 2020-05-21 01:44:03 -0400 | [diff] [blame] | 79 | info.wireEncode(); |
| 80 | BOOST_CHECK_EQUAL(info.hasWire(), true); |
| 81 | info.setSignatureType(tlv::SignatureSha256WithEcdsa); |
| 82 | BOOST_CHECK_EQUAL(info.hasWire(), true); |
Yingdi Yu | 4a55705 | 2014-07-09 16:40:37 -0700 | [diff] [blame] | 83 | |
Davide Pesavento | 14c56cd | 2020-05-21 01:44:03 -0400 | [diff] [blame] | 84 | info.setSignatureType(static_cast<tlv::SignatureTypeValue>(1234)); |
| 85 | BOOST_CHECK_EQUAL(info.getSignatureType(), 1234); |
| 86 | BOOST_CHECK_EQUAL(info.hasWire(), false); |
Yingdi Yu | 4a55705 | 2014-07-09 16:40:37 -0700 | [diff] [blame] | 87 | } |
| 88 | |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 89 | // We must name this test case differently to avoid naming conflicts |
| 90 | BOOST_AUTO_TEST_CASE(KeyLocatorField) |
Davide Pesavento | 14c56cd | 2020-05-21 01:44:03 -0400 | [diff] [blame] | 91 | { |
| 92 | SignatureInfo info(tlv::SignatureSha256WithEcdsa); |
| 93 | BOOST_CHECK_EQUAL(info.hasKeyLocator(), false); |
| 94 | BOOST_CHECK_THROW(info.getKeyLocator(), SignatureInfo::Error); |
| 95 | |
| 96 | info.setKeyLocator(Name("/test/key/locator")); |
| 97 | BOOST_CHECK_EQUAL(info.hasKeyLocator(), true); |
| 98 | BOOST_CHECK_EQUAL(info.getKeyLocator().getName(), "/test/key/locator"); |
| 99 | BOOST_CHECK_EQUAL(info.hasWire(), false); |
| 100 | |
| 101 | info.wireEncode(); |
| 102 | BOOST_CHECK_EQUAL(info.hasWire(), true); |
| 103 | info.setKeyLocator(Name("/test/key/locator")); |
| 104 | BOOST_CHECK_EQUAL(info.hasWire(), true); |
| 105 | info.setKeyLocator(Name("/another/key/locator")); |
| 106 | BOOST_CHECK_EQUAL(info.hasWire(), false); |
| 107 | |
| 108 | info.wireEncode(); |
| 109 | BOOST_CHECK_EQUAL(info.hasWire(), true); |
Davide Pesavento | f6b4589 | 2023-03-13 15:00:51 -0400 | [diff] [blame] | 110 | info.setKeyLocator(std::nullopt); |
Davide Pesavento | 14c56cd | 2020-05-21 01:44:03 -0400 | [diff] [blame] | 111 | BOOST_CHECK_EQUAL(info.hasKeyLocator(), false); |
| 112 | BOOST_CHECK_THROW(info.getKeyLocator(), SignatureInfo::Error); |
| 113 | BOOST_CHECK_EQUAL(info.hasWire(), false); |
| 114 | } |
| 115 | |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 116 | BOOST_AUTO_TEST_CASE(SignatureNonce) |
| 117 | { |
| 118 | SignatureInfo info(tlv::SignatureSha256WithEcdsa); |
| 119 | BOOST_CHECK(!info.getNonce()); |
| 120 | info.wireEncode(); |
| 121 | BOOST_CHECK_EQUAL(info.hasWire(), true); |
| 122 | std::vector<uint8_t> nonce{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}; |
| 123 | info.setNonce(nonce); |
| 124 | BOOST_CHECK_EQUAL(info.hasWire(), false); |
| 125 | BOOST_CHECK(info.getNonce() == nonce); |
| 126 | |
| 127 | info.wireEncode(); |
| 128 | info.setNonce(nonce); |
| 129 | BOOST_CHECK_EQUAL(info.hasWire(), true); |
| 130 | nonce[2] = 0xFF; |
| 131 | info.setNonce(nonce); |
| 132 | BOOST_CHECK_EQUAL(info.hasWire(), false); |
| 133 | BOOST_CHECK(info.getNonce() == nonce); |
| 134 | |
| 135 | info.wireEncode(); |
| 136 | BOOST_CHECK_EQUAL(info.hasWire(), true); |
Davide Pesavento | f6b4589 | 2023-03-13 15:00:51 -0400 | [diff] [blame] | 137 | info.setNonce(std::nullopt); |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 138 | BOOST_CHECK_EQUAL(info.hasWire(), false); |
| 139 | BOOST_CHECK(!info.getNonce()); |
| 140 | } |
| 141 | |
| 142 | BOOST_AUTO_TEST_CASE(SignatureTime) |
| 143 | { |
| 144 | SignatureInfo info(tlv::SignatureSha256WithEcdsa); |
| 145 | BOOST_CHECK(!info.getTime()); |
| 146 | info.wireEncode(); |
| 147 | BOOST_CHECK_EQUAL(info.hasWire(), true); |
| 148 | time::system_clock::time_point timePoint(1590169108480_ms); |
| 149 | info.setTime(timePoint); |
| 150 | BOOST_CHECK_EQUAL(info.hasWire(), false); |
| 151 | BOOST_CHECK(info.getTime() == timePoint); |
| 152 | |
| 153 | info.wireEncode(); |
| 154 | info.setTime(timePoint); |
| 155 | BOOST_CHECK_EQUAL(info.hasWire(), true); |
| 156 | info.setTime(timePoint + 2_s); |
| 157 | BOOST_CHECK_EQUAL(info.hasWire(), false); |
| 158 | BOOST_CHECK(info.getTime() == timePoint + 2_s); |
| 159 | |
| 160 | info.wireEncode(); |
| 161 | BOOST_CHECK_EQUAL(info.hasWire(), true); |
Davide Pesavento | f6b4589 | 2023-03-13 15:00:51 -0400 | [diff] [blame] | 162 | info.setTime(std::nullopt); |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 163 | BOOST_CHECK_EQUAL(info.hasWire(), false); |
| 164 | BOOST_CHECK(!info.getTime()); |
| 165 | } |
| 166 | |
| 167 | BOOST_AUTO_TEST_CASE(SignatureSeqNum) |
| 168 | { |
| 169 | SignatureInfo info(tlv::SignatureSha256WithEcdsa); |
| 170 | BOOST_CHECK(!info.getSeqNum()); |
| 171 | info.wireEncode(); |
| 172 | BOOST_CHECK_EQUAL(info.hasWire(), true); |
| 173 | info.setSeqNum(256); |
| 174 | BOOST_CHECK_EQUAL(info.hasWire(), false); |
| 175 | BOOST_CHECK(info.getSeqNum() == 256UL); |
| 176 | |
| 177 | info.wireEncode(); |
| 178 | info.setSeqNum(256); |
| 179 | BOOST_CHECK_EQUAL(info.hasWire(), true); |
| 180 | info.setSeqNum(512); |
| 181 | BOOST_CHECK_EQUAL(info.hasWire(), false); |
| 182 | BOOST_CHECK(info.getSeqNum() == 512UL); |
| 183 | |
| 184 | info.wireEncode(); |
| 185 | BOOST_CHECK_EQUAL(info.hasWire(), true); |
Davide Pesavento | f6b4589 | 2023-03-13 15:00:51 -0400 | [diff] [blame] | 186 | info.setSeqNum(std::nullopt); |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 187 | BOOST_CHECK_EQUAL(info.hasWire(), false); |
| 188 | BOOST_CHECK(!info.getSeqNum()); |
| 189 | } |
| 190 | |
Davide Pesavento | a86300a | 2020-12-05 14:55:45 -0500 | [diff] [blame] | 191 | const uint8_t sigInfoDataRsa[] = { |
| 192 | 0x16, 0x1b, // SignatureInfo |
| 193 | 0x1b, 0x01, // SignatureType |
| 194 | 0x01, // Sha256WithRsa |
| 195 | 0x1c, 0x16, // KeyLocator |
| 196 | 0x07, 0x14, // Name |
| 197 | 0x08, 0x04, |
| 198 | 0x74, 0x65, 0x73, 0x74, |
| 199 | 0x08, 0x03, |
| 200 | 0x6b, 0x65, 0x79, |
| 201 | 0x08, 0x07, |
| 202 | 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, |
| 203 | }; |
| 204 | |
| 205 | const uint8_t sigInfoInterestRsa[] = { |
| 206 | 0x2c, 0x33, // InterestSignatureInfo |
| 207 | 0x1b, 0x01, // SignatureType |
| 208 | 0x01, // Sha256WithRsa |
| 209 | 0x1c, 0x16, // KeyLocator |
| 210 | 0x07, 0x14, // Name |
| 211 | 0x08, 0x04, |
| 212 | 0x74, 0x65, 0x73, 0x74, |
| 213 | 0x08, 0x03, |
| 214 | 0x6b, 0x65, 0x79, |
| 215 | 0x08, 0x07, |
| 216 | 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, |
| 217 | 0x26, 0x08, // SignatureNonce |
| 218 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, |
| 219 | 0x28, 0x08, // SignatureTime |
| 220 | 0x00, 0x00, 0x01, 0x72, 0x3d, 0x77, 0x00, 0x00, |
| 221 | 0x2a, 0x02, // SignatureSeqNum |
| 222 | 0x10, 0x20, |
| 223 | }; |
| 224 | |
| 225 | const uint8_t sigInfoDataEcdsa[] = { |
| 226 | 0x16, 0x1b, // SignatureInfo |
| 227 | 0x1b, 0x01, // SignatureType |
| 228 | 0x03, // Sha256WithEcdsa |
| 229 | 0x1c, 0x16, // KeyLocator |
| 230 | 0x07, 0x14, // Name |
| 231 | 0x08, 0x04, |
| 232 | 0x74, 0x65, 0x73, 0x74, |
| 233 | 0x08, 0x03, |
| 234 | 0x6b, 0x65, 0x79, |
| 235 | 0x08, 0x07, |
| 236 | 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, |
| 237 | }; |
| 238 | |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 239 | BOOST_AUTO_TEST_CASE(EncodeDecode) |
| 240 | { |
Davide Pesavento | a86300a | 2020-12-05 14:55:45 -0500 | [diff] [blame] | 241 | const KeyLocator keyLocator("/test/key/locator"); |
| 242 | |
| 243 | // RSA |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 244 | SignatureInfo info(tlv::SignatureSha256WithRsa, keyLocator); |
| 245 | |
Davide Pesavento | a86300a | 2020-12-05 14:55:45 -0500 | [diff] [blame] | 246 | // Encode as (Data)SignatureInfo |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 247 | auto encodedData = info.wireEncode(SignatureInfo::Type::Data); |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 248 | |
Davide Pesavento | a86300a | 2020-12-05 14:55:45 -0500 | [diff] [blame] | 249 | BOOST_CHECK_EQUAL_COLLECTIONS(sigInfoDataRsa, sigInfoDataRsa + sizeof(sigInfoDataRsa), |
| 250 | encodedData.begin(), encodedData.end()); |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 251 | |
Davide Pesavento | a86300a | 2020-12-05 14:55:45 -0500 | [diff] [blame] | 252 | // Decode as (Data)SignatureInfo |
Davide Pesavento | fbea4fc | 2022-02-08 07:26:04 -0500 | [diff] [blame] | 253 | info = SignatureInfo(Block(sigInfoDataRsa), SignatureInfo::Type::Data); |
Davide Pesavento | a86300a | 2020-12-05 14:55:45 -0500 | [diff] [blame] | 254 | |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 255 | BOOST_CHECK_EQUAL(info.getSignatureType(), tlv::SignatureSha256WithRsa); |
| 256 | BOOST_CHECK_EQUAL(info.hasKeyLocator(), true); |
| 257 | BOOST_CHECK_EQUAL(info.getKeyLocator().getName(), Name("/test/key/locator")); |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 258 | BOOST_CHECK(!info.getNonce()); |
| 259 | BOOST_CHECK(!info.getTime()); |
| 260 | BOOST_CHECK(!info.getSeqNum()); |
| 261 | |
| 262 | // Encode as InterestSignatureInfo |
Davide Pesavento | a86300a | 2020-12-05 14:55:45 -0500 | [diff] [blame] | 263 | const std::vector<uint8_t> nonce{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}; |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 264 | info.setNonce(nonce); |
Davide Pesavento | a86300a | 2020-12-05 14:55:45 -0500 | [diff] [blame] | 265 | const time::system_clock::time_point timePoint(1590169108480_ms); |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 266 | info.setTime(timePoint); |
| 267 | info.setSeqNum(0x1020); |
| 268 | auto encodedInterest = info.wireEncode(SignatureInfo::Type::Interest); |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 269 | |
Davide Pesavento | a86300a | 2020-12-05 14:55:45 -0500 | [diff] [blame] | 270 | BOOST_CHECK_EQUAL_COLLECTIONS(sigInfoInterestRsa, sigInfoInterestRsa + sizeof(sigInfoInterestRsa), |
| 271 | encodedInterest.begin(), encodedInterest.end()); |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 272 | |
| 273 | // Decode as InterestSignatureInfo |
Davide Pesavento | fbea4fc | 2022-02-08 07:26:04 -0500 | [diff] [blame] | 274 | info = SignatureInfo(Block(sigInfoInterestRsa), SignatureInfo::Type::Interest); |
Davide Pesavento | a86300a | 2020-12-05 14:55:45 -0500 | [diff] [blame] | 275 | |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 276 | BOOST_CHECK_EQUAL(info.getSignatureType(), tlv::SignatureSha256WithRsa); |
| 277 | BOOST_CHECK_EQUAL(info.hasKeyLocator(), true); |
| 278 | BOOST_CHECK_EQUAL(info.getKeyLocator().getName(), Name("/test/key/locator")); |
| 279 | BOOST_CHECK(info.getNonce() == nonce); |
| 280 | BOOST_CHECK(info.getTime() == timePoint); |
| 281 | BOOST_CHECK(info.getSeqNum() == 0x1020UL); |
Davide Pesavento | a86300a | 2020-12-05 14:55:45 -0500 | [diff] [blame] | 282 | |
| 283 | // ECDSA |
| 284 | info = SignatureInfo(tlv::SignatureSha256WithEcdsa, keyLocator); |
| 285 | |
| 286 | // Encode as (Data)SignatureInfo |
| 287 | auto encodedDataEcdsa = info.wireEncode(SignatureInfo::Type::Data); |
| 288 | |
| 289 | BOOST_CHECK_EQUAL_COLLECTIONS(sigInfoDataEcdsa, sigInfoDataEcdsa + sizeof(sigInfoDataEcdsa), |
| 290 | encodedDataEcdsa.begin(), encodedDataEcdsa.end()); |
| 291 | |
| 292 | // Decode as (Data)SignatureInfo |
Davide Pesavento | fbea4fc | 2022-02-08 07:26:04 -0500 | [diff] [blame] | 293 | info = SignatureInfo(Block(sigInfoDataEcdsa), SignatureInfo::Type::Data); |
Davide Pesavento | a86300a | 2020-12-05 14:55:45 -0500 | [diff] [blame] | 294 | |
| 295 | BOOST_CHECK_EQUAL(info.getSignatureType(), tlv::SignatureSha256WithEcdsa); |
| 296 | BOOST_CHECK_EQUAL(info.hasKeyLocator(), true); |
| 297 | BOOST_CHECK_EQUAL(info.getKeyLocator().getName(), Name("/test/key/locator")); |
| 298 | BOOST_CHECK(!info.getNonce()); |
| 299 | BOOST_CHECK(!info.getTime()); |
| 300 | BOOST_CHECK(!info.getSeqNum()); |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | BOOST_AUTO_TEST_CASE(DecodeError) |
| 304 | { |
| 305 | const uint8_t error1[] = { |
| 306 | 0x15, 0x1b, // Wrong SignatureInfo (0x16, 0x1b) |
| 307 | 0x1b, 0x01, // SignatureType |
| 308 | 0x01, // Sha256WithRsa |
| 309 | 0x1c, 0x16, // KeyLocator |
| 310 | 0x07, 0x14, // Name |
| 311 | 0x08, 0x04, |
| 312 | 0x74, 0x65, 0x73, 0x74, |
| 313 | 0x08, 0x03, |
| 314 | 0x6b, 0x65, 0x79, |
| 315 | 0x08, 0x07, |
| 316 | 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72 |
| 317 | }; |
Davide Pesavento | fbea4fc | 2022-02-08 07:26:04 -0500 | [diff] [blame] | 318 | Block errorBlock1(error1); |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 319 | BOOST_CHECK_THROW(SignatureInfo(errorBlock1, SignatureInfo::Type::Data), tlv::Error); |
| 320 | |
| 321 | const uint8_t error2[] = { |
| 322 | 0x16, 0x05, // SignatureInfo |
| 323 | 0x1b, 0x01, // SignatureType |
| 324 | 0x01, // Sha256WithRsa |
| 325 | 0x83, 0x00, // Unrecognized critical TLV |
| 326 | }; |
Davide Pesavento | fbea4fc | 2022-02-08 07:26:04 -0500 | [diff] [blame] | 327 | Block errorBlock2(error2); |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 328 | BOOST_CHECK_THROW(SignatureInfo(errorBlock2, SignatureInfo::Type::Data), tlv::Error); |
| 329 | |
| 330 | const uint8_t error3[] = { |
| 331 | 0x16, 0x00 // Empty SignatureInfo |
| 332 | }; |
Davide Pesavento | fbea4fc | 2022-02-08 07:26:04 -0500 | [diff] [blame] | 333 | Block errorBlock3(error3); |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 334 | BOOST_CHECK_THROW(SignatureInfo(errorBlock3, SignatureInfo::Type::Data), tlv::Error); |
| 335 | |
| 336 | // Encoding is correct for SignatureInfo, but decoder is expecting InterestSignatureInfo |
| 337 | const uint8_t error4[] = { |
| 338 | 0x16, 0x1b, // SignatureInfo |
| 339 | 0x1b, 0x01, // SignatureType |
| 340 | 0x01, // Sha256WithRsa |
| 341 | 0x1c, 0x16, // KeyLocator |
| 342 | 0x07, 0x14, // Name |
| 343 | 0x08, 0x04, |
| 344 | 0x74, 0x65, 0x73, 0x74, |
| 345 | 0x08, 0x03, |
| 346 | 0x6b, 0x65, 0x79, |
| 347 | 0x08, 0x07, |
| 348 | 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72 |
| 349 | }; |
Davide Pesavento | fbea4fc | 2022-02-08 07:26:04 -0500 | [diff] [blame] | 350 | Block errorBlock4(error4); |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 351 | BOOST_CHECK_THROW(SignatureInfo(errorBlock4, SignatureInfo::Type::Interest), tlv::Error); |
| 352 | |
| 353 | // SignatureType and KeyLocator out-of-order |
| 354 | const uint8_t error5[] = { |
| 355 | 0x2c, 0x1b, // SignatureInfo |
| 356 | 0x1c, 0x16, // KeyLocator |
| 357 | 0x07, 0x14, // Name |
| 358 | 0x08, 0x04, |
| 359 | 0x74, 0x65, 0x73, 0x74, |
| 360 | 0x08, 0x03, |
| 361 | 0x6b, 0x65, 0x79, |
| 362 | 0x08, 0x07, |
| 363 | 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, |
| 364 | 0x1b, 0x01, // SignatureType |
| 365 | 0x01, // Sha256WithRsa |
| 366 | }; |
Davide Pesavento | fbea4fc | 2022-02-08 07:26:04 -0500 | [diff] [blame] | 367 | Block errorBlock5(error5); |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 368 | BOOST_CHECK_THROW(SignatureInfo(errorBlock5, SignatureInfo::Type::Interest), tlv::Error); |
| 369 | |
| 370 | // Repeated KeyLocator |
| 371 | const uint8_t error6[] = { |
| 372 | 0x2c, 0x33, // SignatureInfo |
| 373 | 0x1b, 0x01, // SignatureType |
| 374 | 0x01, // Sha256WithRsa |
| 375 | 0x1c, 0x16, // KeyLocator |
| 376 | 0x07, 0x14, // Name |
| 377 | 0x08, 0x04, |
| 378 | 0x74, 0x65, 0x73, 0x74, |
| 379 | 0x08, 0x03, |
| 380 | 0x6b, 0x65, 0x79, |
| 381 | 0x08, 0x07, |
| 382 | 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, |
| 383 | 0x1c, 0x16, // KeyLocator |
| 384 | 0x07, 0x14, // Name |
| 385 | 0x08, 0x04, |
| 386 | 0x74, 0x65, 0x73, 0x74, |
| 387 | 0x08, 0x03, |
| 388 | 0x6b, 0x65, 0x79, |
| 389 | 0x08, 0x07, |
| 390 | 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72 |
| 391 | }; |
Davide Pesavento | fbea4fc | 2022-02-08 07:26:04 -0500 | [diff] [blame] | 392 | Block errorBlock6(error6); |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 393 | BOOST_CHECK_THROW(SignatureInfo(errorBlock6, SignatureInfo::Type::Interest), tlv::Error); |
| 394 | |
| 395 | // Zero-length SignatureNonce |
| 396 | const uint8_t error7[] = { |
| 397 | 0x2c, 0x05, // SignatureInfo |
| 398 | 0x1b, 0x01, // SignatureType |
| 399 | 0x01, // Sha256WithRsa |
| 400 | 0x26, 0x00 // SignatureNonce |
| 401 | }; |
Davide Pesavento | fbea4fc | 2022-02-08 07:26:04 -0500 | [diff] [blame] | 402 | Block errorBlock7(error7); |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 403 | BOOST_CHECK_THROW(SignatureInfo(errorBlock7, SignatureInfo::Type::Interest), tlv::Error); |
| 404 | } |
| 405 | |
Davide Pesavento | 14c56cd | 2020-05-21 01:44:03 -0400 | [diff] [blame] | 406 | BOOST_AUTO_TEST_CASE(ValidityPeriod) |
Yingdi Yu | 6be43f3 | 2015-06-09 14:19:54 -0700 | [diff] [blame] | 407 | { |
| 408 | const uint8_t sigInfo[] = { |
| 409 | 0x16, 0x45, // SignatureInfo |
| 410 | 0x1b, 0x01, // SignatureType |
| 411 | 0x01, // Sha256WithRsa |
| 412 | 0x1c, 0x16, // KeyLocator |
| 413 | 0x07, 0x14, // Name |
| 414 | 0x08, 0x04, |
| 415 | 0x74, 0x65, 0x73, 0x74, |
| 416 | 0x08, 0x03, |
| 417 | 0x6b, 0x65, 0x79, |
| 418 | 0x08, 0x07, |
| 419 | 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, |
| 420 | 0xfd, 0x00, 0xfd, 0x26, // ValidityPeriod |
| 421 | 0xfd, 0x00, 0xfe, 0x0f, // NotBefore |
| 422 | 0x31, 0x39, 0x37, 0x30, 0x30, 0x31, 0x30, 0x31, // 19700101T000000 |
| 423 | 0x54, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, |
| 424 | 0xfd, 0x00, 0xff, 0x0f, // NotAfter |
| 425 | 0x31, 0x39, 0x37, 0x30, 0x30, 0x31, 0x30, 0x32, // 19700102T000000 |
| 426 | 0x54, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30 |
| 427 | }; |
| 428 | |
Davide Pesavento | 14c56cd | 2020-05-21 01:44:03 -0400 | [diff] [blame] | 429 | const auto notBefore = time::getUnixEpoch(); |
| 430 | const auto notAfter = notBefore + 1_day; |
Yingdi Yu | 6be43f3 | 2015-06-09 14:19:54 -0700 | [diff] [blame] | 431 | security::ValidityPeriod vp1(notBefore, notAfter); |
| 432 | |
Davide Pesavento | 14c56cd | 2020-05-21 01:44:03 -0400 | [diff] [blame] | 433 | SignatureInfo info(tlv::SignatureSha256WithRsa, KeyLocator("/test/key/locator")); |
Davide Pesavento | 14c56cd | 2020-05-21 01:44:03 -0400 | [diff] [blame] | 434 | BOOST_CHECK_THROW(info.getValidityPeriod(), SignatureInfo::Error); |
| 435 | |
| 436 | info.wireEncode(); |
Yingdi Yu | 6be43f3 | 2015-06-09 14:19:54 -0700 | [diff] [blame] | 437 | info.setValidityPeriod(vp1); |
Junxiao Shi | 72c0c64 | 2018-04-20 15:41:09 +0000 | [diff] [blame] | 438 | BOOST_CHECK_EQUAL(info.getValidityPeriod(), vp1); |
Davide Pesavento | 14c56cd | 2020-05-21 01:44:03 -0400 | [diff] [blame] | 439 | BOOST_CHECK_EQUAL(info.hasWire(), false); |
Yingdi Yu | 6be43f3 | 2015-06-09 14:19:54 -0700 | [diff] [blame] | 440 | |
Davide Pesavento | 14c56cd | 2020-05-21 01:44:03 -0400 | [diff] [blame] | 441 | // encode |
| 442 | auto encoded = info.wireEncode(); |
| 443 | BOOST_CHECK_EQUAL(info.hasWire(), true); |
Davide Pesavento | 258d51a | 2022-02-27 21:26:28 -0500 | [diff] [blame] | 444 | BOOST_TEST(encoded == sigInfo, boost::test_tools::per_element()); |
Yingdi Yu | 6be43f3 | 2015-06-09 14:19:54 -0700 | [diff] [blame] | 445 | |
Davide Pesavento | 14c56cd | 2020-05-21 01:44:03 -0400 | [diff] [blame] | 446 | info.setValidityPeriod(vp1); |
| 447 | BOOST_CHECK_EQUAL(info.hasWire(), true); |
| 448 | |
Yingdi Yu | 6be43f3 | 2015-06-09 14:19:54 -0700 | [diff] [blame] | 449 | // decode |
Davide Pesavento | fbea4fc | 2022-02-08 07:26:04 -0500 | [diff] [blame] | 450 | Block block(sigInfo); |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 451 | SignatureInfo info2(block, SignatureInfo::Type::Data); |
Junxiao Shi | 72c0c64 | 2018-04-20 15:41:09 +0000 | [diff] [blame] | 452 | BOOST_CHECK_EQUAL(info2.getValidityPeriod(), vp1); |
Davide Pesavento | 14c56cd | 2020-05-21 01:44:03 -0400 | [diff] [blame] | 453 | BOOST_CHECK_EQUAL(info2.hasWire(), true); |
Yingdi Yu | 6be43f3 | 2015-06-09 14:19:54 -0700 | [diff] [blame] | 454 | |
Davide Pesavento | 14c56cd | 2020-05-21 01:44:03 -0400 | [diff] [blame] | 455 | info2.setValidityPeriod(security::ValidityPeriod(notBefore, notBefore + 42_days)); |
Davide Pesavento | 14c56cd | 2020-05-21 01:44:03 -0400 | [diff] [blame] | 456 | BOOST_CHECK_NE(info2.getValidityPeriod(), vp1); |
Davide Pesavento | 187e9f9 | 2023-03-20 22:46:22 -0400 | [diff] [blame] | 457 | BOOST_CHECK(info2.getValidityPeriod().getPeriod() == std::pair(notBefore, notBefore + 42_days)); |
Davide Pesavento | 14c56cd | 2020-05-21 01:44:03 -0400 | [diff] [blame] | 458 | BOOST_CHECK_EQUAL(info2.hasWire(), false); |
| 459 | |
| 460 | info2.wireEncode(); |
| 461 | BOOST_CHECK_EQUAL(info2.hasWire(), true); |
Davide Pesavento | f6b4589 | 2023-03-13 15:00:51 -0400 | [diff] [blame] | 462 | info2.setValidityPeriod(std::nullopt); |
Davide Pesavento | 14c56cd | 2020-05-21 01:44:03 -0400 | [diff] [blame] | 463 | BOOST_CHECK_THROW(info2.getValidityPeriod(), SignatureInfo::Error); |
| 464 | BOOST_CHECK_EQUAL(info2.hasWire(), false); |
Yingdi Yu | 6be43f3 | 2015-06-09 14:19:54 -0700 | [diff] [blame] | 465 | } |
| 466 | |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 467 | BOOST_AUTO_TEST_CASE(CustomTlvs) |
Yingdi Yu | 4a55705 | 2014-07-09 16:40:37 -0700 | [diff] [blame] | 468 | { |
Davide Pesavento | 14c56cd | 2020-05-21 01:44:03 -0400 | [diff] [blame] | 469 | SignatureInfo info(tlv::SignatureSha256WithEcdsa); |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 470 | info.addCustomTlv("810101"_block); |
| 471 | BOOST_CHECK(!info.getCustomTlv(0x82)); |
| 472 | BOOST_REQUIRE(info.getCustomTlv(0x81)); |
| 473 | BOOST_CHECK_EQUAL(info.getCustomTlv(0x81)->type(), 0x81); |
Davide Pesavento | 14c56cd | 2020-05-21 01:44:03 -0400 | [diff] [blame] | 474 | |
| 475 | info.wireEncode(); |
| 476 | BOOST_CHECK_EQUAL(info.hasWire(), true); |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 477 | info.addCustomTlv("82020202"_block); |
Davide Pesavento | 14c56cd | 2020-05-21 01:44:03 -0400 | [diff] [blame] | 478 | BOOST_CHECK_EQUAL(info.hasWire(), false); |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 479 | |
| 480 | info.wireEncode(); |
| 481 | BOOST_CHECK_EQUAL(info.hasWire(), true); |
| 482 | info.removeCustomTlv(0x81); |
| 483 | BOOST_CHECK_EQUAL(info.hasWire(), false); |
| 484 | BOOST_CHECK(!info.getCustomTlv(0x81)); |
Yingdi Yu | 4a55705 | 2014-07-09 16:40:37 -0700 | [diff] [blame] | 485 | } |
| 486 | |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 487 | BOOST_AUTO_TEST_CASE(CustomTlvsEncoding) // Bug #3914 |
Alexander Afanasyev | 4146975 | 2017-01-10 21:51:55 -0800 | [diff] [blame] | 488 | { |
Junxiao Shi | 605671d | 2017-08-26 13:41:06 +0000 | [diff] [blame] | 489 | SignatureInfo info1(tlv::SignatureSha256WithRsa); |
Davide Pesavento | a86300a | 2020-12-05 14:55:45 -0500 | [diff] [blame] | 490 | info1.addCustomTlv(makeStringBlock(102, "First")); |
| 491 | info1.addCustomTlv(makeStringBlock(104, "Second")); |
| 492 | info1.addCustomTlv(makeStringBlock(106, "Third")); |
Alexander Afanasyev | 4146975 | 2017-01-10 21:51:55 -0800 | [diff] [blame] | 493 | |
Davide Pesavento | a86300a | 2020-12-05 14:55:45 -0500 | [diff] [blame] | 494 | BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(info1), |
| 495 | "SignatureSha256WithRsa { 102 104 106 }"); |
Alexander Afanasyev | 4146975 | 2017-01-10 21:51:55 -0800 | [diff] [blame] | 496 | |
| 497 | SignatureInfo info2; |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 498 | info2.wireDecode(info1.wireEncode(), SignatureInfo::Type::Data); |
Alexander Afanasyev | 4146975 | 2017-01-10 21:51:55 -0800 | [diff] [blame] | 499 | BOOST_CHECK_EQUAL(info1, info2); |
| 500 | |
Alexander Afanasyev | 4146975 | 2017-01-10 21:51:55 -0800 | [diff] [blame] | 501 | const uint8_t infoBytes[] = { |
Junxiao Shi | 605671d | 2017-08-26 13:41:06 +0000 | [diff] [blame] | 502 | 0x16, 0x19, // SignatureInfo |
| 503 | 0x1b, 0x01, 0x01, // SignatureType=1 |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 504 | 0x66, 0x05, 0x46, 0x69, 0x72, 0x73, 0x74, // 102 "First" |
| 505 | 0x68, 0x06, 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, // 104 "Second" |
| 506 | 0x6a, 0x05, 0x54, 0x68, 0x69, 0x72, 0x64 // 106 "Third" |
Alexander Afanasyev | 4146975 | 2017-01-10 21:51:55 -0800 | [diff] [blame] | 507 | }; |
| 508 | |
Davide Pesavento | fbea4fc | 2022-02-08 07:26:04 -0500 | [diff] [blame] | 509 | SignatureInfo info3(Block(infoBytes), SignatureInfo::Type::Data); |
Alexander Afanasyev | 4146975 | 2017-01-10 21:51:55 -0800 | [diff] [blame] | 510 | BOOST_CHECK_EQUAL(info3, info1); |
| 511 | BOOST_CHECK_EQUAL_COLLECTIONS(infoBytes, infoBytes + sizeof(infoBytes), |
| 512 | info1.wireEncode().begin(), info1.wireEncode().end()); |
| 513 | } |
| 514 | |
Eric Newberry | f165bb4 | 2020-05-22 11:28:45 -0700 | [diff] [blame] | 515 | BOOST_AUTO_TEST_CASE(OutputStream) |
| 516 | { |
| 517 | SignatureInfo info; |
| 518 | BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(info), "Invalid SignatureInfo"); |
| 519 | |
| 520 | info.setSignatureType(tlv::DigestSha256); |
| 521 | BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(info), "DigestSha256"); |
| 522 | |
| 523 | info.setSignatureType(tlv::SignatureSha256WithRsa); |
| 524 | info.setKeyLocator(KeyLocator("/test/key/locator")); |
| 525 | BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(info), |
| 526 | "SignatureSha256WithRsa Name=/test/key/locator"); |
| 527 | |
| 528 | info.setNonce(std::vector<uint8_t>{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}); |
| 529 | info.setTime(time::system_clock::time_point(1590169108480_ms)); |
| 530 | info.setSeqNum(0x1020); |
| 531 | |
| 532 | BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(info), |
| 533 | "SignatureSha256WithRsa Name=/test/key/locator " |
| 534 | "{ Nonce=0102030405060708 Time=1590169108480 SeqNum=4128 }"); |
| 535 | |
| 536 | info.setValidityPeriod(security::ValidityPeriod(time::getUnixEpoch(), time::getUnixEpoch() + 31_days)); |
| 537 | |
| 538 | info.addCustomTlv("82020102"_block); |
| 539 | BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(info), |
| 540 | "SignatureSha256WithRsa Name=/test/key/locator " |
| 541 | "{ Nonce=0102030405060708 Time=1590169108480 SeqNum=4128 " |
| 542 | "ValidityPeriod=(19700101T000000, 19700201T000000) 130 }"); |
| 543 | |
| 544 | info.addCustomTlv("84020102"_block); |
| 545 | BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(info), |
| 546 | "SignatureSha256WithRsa Name=/test/key/locator " |
| 547 | "{ Nonce=0102030405060708 Time=1590169108480 SeqNum=4128 " |
| 548 | "ValidityPeriod=(19700101T000000, 19700201T000000) 130 132 }"); |
| 549 | } |
| 550 | |
Davide Pesavento | eee3e82 | 2016-11-26 19:19:34 +0100 | [diff] [blame] | 551 | BOOST_AUTO_TEST_SUITE_END() // TestSignatureInfo |
Yingdi Yu | 4a55705 | 2014-07-09 16:40:37 -0700 | [diff] [blame] | 552 | |
Spyridon Mastorakis | 429634f | 2015-02-19 17:35:33 -0800 | [diff] [blame] | 553 | } // namespace tests |
Yingdi Yu | 4a55705 | 2014-07-09 16:40:37 -0700 | [diff] [blame] | 554 | } // namespace ndn |