blob: f1e7185fcebd47aae97d72104db721eaf620d498 [file] [log] [blame]
Alexander Afanasyev574aa862017-01-10 19:53:28 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Junxiao Shi2bea5c42017-08-14 20:10:32 +00002/*
Alexander Afanasyev09236c22020-06-03 13:42:38 -04003 * Copyright (c) 2013-2020 Regents of the University of California.
Alexander Afanasyev574aa862017-01-10 19:53:28 -08004 *
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 Pesavento7e780642018-11-24 15:51:34 -050022#include "ndn-cxx/security/verification-helpers.hpp"
23#include "ndn-cxx/security/transform/public-key.hpp"
24// #include "ndn-cxx/util/string-helper.hpp"
Alexander Afanasyev574aa862017-01-10 19:53:28 -080025
Davide Pesavento7e780642018-11-24 15:51:34 -050026#include "tests/boost-test.hpp"
27#include "tests/identity-management-fixture.hpp"
28#include "tests/make-interest-data.hpp"
Alexander Afanasyev574aa862017-01-10 19:53:28 -080029
Davide Pesavento77d9e812019-06-03 22:05:54 -040030#include <boost/mpl/vector.hpp>
Alexander Afanasyev574aa862017-01-10 19:53:28 -080031
32namespace ndn {
33namespace security {
34namespace tests {
35
36using namespace ndn::tests;
37
38BOOST_AUTO_TEST_SUITE(Security)
39BOOST_AUTO_TEST_SUITE(TestVerificationHelpers)
40
Eric Newberryb74bbda2020-06-18 19:33:58 -070041// // Use this test case to regenerate the dataset if the signature format changes
42// BOOST_FIXTURE_TEST_CASE(Generator, IdentityManagementFixture)
Alexander Afanasyev574aa862017-01-10 19:53:28 -080043// {
44// Identity wrongIdentity = addIdentity("/Security/TestVerificationHelpers/Wrong");
45// std::map<std::string, SigningInfo> identities = {
46// {"Ecdsa", signingByIdentity(addIdentity("/Security/TestVerificationHelpers/EC", EcKeyParams()))},
47// {"Rsa", signingByIdentity(addIdentity("/Security/TestVerificationHelpers/RSA", RsaKeyParams()))},
48// {"Sha256", signingWithSha256()}
49// };
50
51// auto print = [] (const std::string& name, const uint8_t* buf, size_t size) {
52// std::cout << " std::vector<uint8_t> " + name + " = {\n ";
53
54// std::string hex = toHex(buf, size);
55
56// for (size_t i = 0; i < hex.size(); i++) {
57// if (i > 0 && i % 32 == 0)
58// std::cout << "\n ";
59
60// std::cout << "0x" << hex[i];
61// std::cout << hex[++i];
62
63// if ((i + 1) != hex.size())
64// std::cout << ", ";
65// }
66// std::cout << "\n };";
67// };
68
69// for (const auto& i : identities) {
70// const std::string& type = i.first;
71// const SigningInfo& signingInfo = i.second;
72
73// std::cout << "struct " + type + "Dataset\n{\n";
74// std::cout << " const std::string name = \"" << type << "\";\n";
75
Junxiao Shife1239a2017-01-27 20:36:12 +000076// if (signingInfo.getSignerType() == SigningInfo::SIGNER_TYPE_ID) {
Alexander Afanasyev574aa862017-01-10 19:53:28 -080077// print("cert", signingInfo.getPibIdentity().getDefaultKey().getDefaultCertificate().wireEncode().wire(),
78// signingInfo.getPibIdentity().getDefaultKey().getDefaultCertificate().wireEncode().size());
79// }
80// else {
81// print("cert", nullptr, 0);
82// }
83// std::cout << "\n";
84
85// // Create data that can be verified by cert
86// Data data(Name("/test/data").append(type));
87// m_keyChain.sign(data, signingInfo);
88// print("goodData", data.wireEncode().wire(), data.wireEncode().size());
89// std::cout << "\n";
90
91// // Create data that cannot be verified by cert
92// m_keyChain.sign(data, signingByIdentity(wrongIdentity));
93// print("badSigData", data.wireEncode().wire(), data.wireEncode().size());
94// std::cout << "\n";
95
96// // Create interest that can be verified by cert
Eric Newberryb74bbda2020-06-18 19:33:58 -070097// Interest interest1(Name("/test/interest").append(type));
98// SigningInfo signingInfoV03(signingInfo);
99// signingInfoV03.setSignedInterestFormat(SignedInterestFormat::V03);
100// interest1.setCanBePrefix(false);
101// interest1.setNonce(0xF72C8A4B);
102// m_keyChain.sign(interest1, signingInfoV03);
103// print("goodInterest", interest1.wireEncode().wire(), interest1.wireEncode().size());
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800104// std::cout << "\n";
105
106// // Create interest that cannot be verified by cert
Eric Newberryb74bbda2020-06-18 19:33:58 -0700107// m_keyChain.sign(interest1, signingByIdentity(wrongIdentity)
108// .setSignedInterestFormat(SignedInterestFormat::V03));
109// print("badSigInterest", interest1.wireEncode().wire(), interest1.wireEncode().size());
110// std::cout << "\n";
111
112// // Create interest that can be verified by cert (old signed Interest format)
113// Interest interest2(Name("/test/interest").append(type));
114// SigningInfo signingInfoV02(signingInfo);
115// signingInfoV02.setSignedInterestFormat(SignedInterestFormat::V03);
116// interest2.setCanBePrefix(false);
117// interest2.setNonce(0xF72C8A4B);
118// m_keyChain.sign(interest2, signingInfoV02);
119// print("goodInterestOldFormat", interest2.wireEncode().wire(), interest2.wireEncode().size());
120// std::cout << "\n";
121
122// // Create interest that cannot be verified by cert (old signed Interest format)
123// m_keyChain.sign(interest2, signingByIdentity(wrongIdentity)
124// .setSignedInterestFormat(SignedInterestFormat::V02));
125// print("badSigInterestOldFormat", interest2.wireEncode().wire(), interest2.wireEncode().size());
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800126// std::cout << "\n};\n\n";
127// }
128// }
129
130struct EcdsaDataset
131{
132 const std::string name = "Ecdsa";
133 std::vector<uint8_t> cert = {
Eric Newberryb74bbda2020-06-18 19:33:58 -0700134 0x06, 0xFD, 0x01, 0x62, 0x07, 0x47, 0x08, 0x08, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79,
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800135 0x08, 0x17, 0x54, 0x65, 0x73, 0x74, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69,
136 0x6F, 0x6E, 0x48, 0x65, 0x6C, 0x70, 0x65, 0x72, 0x73, 0x08, 0x02, 0x45, 0x43, 0x08, 0x03, 0x4B,
Eric Newberryb74bbda2020-06-18 19:33:58 -0700137 0x45, 0x59, 0x08, 0x08, 0xA5, 0x8F, 0x5F, 0x7F, 0x18, 0x1A, 0x98, 0x14, 0x08, 0x04, 0x73, 0x65,
138 0x6C, 0x66, 0x08, 0x09, 0xFD, 0x00, 0x00, 0x01, 0x72, 0xCE, 0xA8, 0xE7, 0x53, 0x14, 0x09, 0x18,
139 0x01, 0x02, 0x19, 0x04, 0x00, 0x36, 0xEE, 0x80, 0x15, 0x5B, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07,
140 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, 0x01, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01,
141 0x07, 0x03, 0x42, 0x00, 0x04, 0x15, 0x94, 0xDF, 0xBF, 0x2D, 0x83, 0x2C, 0x1F, 0xB7, 0x9D, 0x55,
142 0x9A, 0x6A, 0xC2, 0xDB, 0x03, 0xE9, 0xB2, 0x6B, 0x77, 0x6D, 0xF6, 0x42, 0x81, 0x2F, 0xC8, 0xDE,
143 0x3F, 0x8B, 0xF4, 0x27, 0x1C, 0x4F, 0xE9, 0x47, 0x0C, 0x44, 0x83, 0x52, 0xA0, 0xA2, 0x4E, 0x52,
144 0x49, 0xC5, 0xAD, 0x2D, 0x9B, 0x9C, 0xAE, 0xF5, 0x4C, 0x2A, 0xB5, 0xC4, 0xF5, 0xFB, 0xF3, 0x93,
145 0xD4, 0x86, 0x61, 0xE6, 0x70, 0x16, 0x67, 0x1B, 0x01, 0x03, 0x1C, 0x38, 0x07, 0x36, 0x08, 0x08,
146 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x08, 0x17, 0x54, 0x65, 0x73, 0x74, 0x56, 0x65,
147 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x48, 0x65, 0x6C, 0x70, 0x65, 0x72,
148 0x73, 0x08, 0x02, 0x45, 0x43, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x08, 0xA5, 0x8F, 0x5F, 0x7F,
149 0x18, 0x1A, 0x98, 0x14, 0xFD, 0x00, 0xFD, 0x26, 0xFD, 0x00, 0xFE, 0x0F, 0x31, 0x39, 0x37, 0x30,
150 0x30, 0x31, 0x30, 0x31, 0x54, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0xFD, 0x00, 0xFF, 0x0F, 0x32,
151 0x30, 0x34, 0x30, 0x30, 0x36, 0x31, 0x34, 0x54, 0x32, 0x32, 0x31, 0x37, 0x35, 0x35, 0x17, 0x46,
152 0x30, 0x44, 0x02, 0x20, 0x4B, 0xF7, 0x85, 0xB8, 0x01, 0x7D, 0x65, 0x02, 0x6C, 0xFB, 0x69, 0x00,
153 0x8B, 0x4D, 0xCC, 0x0F, 0xB5, 0x87, 0xF8, 0x4C, 0x69, 0xE0, 0x7C, 0x16, 0xCC, 0x52, 0xB2, 0x29,
154 0x6B, 0x24, 0xF5, 0x7F, 0x02, 0x20, 0x1C, 0x88, 0xDE, 0x32, 0x3F, 0x1A, 0xE6, 0x60, 0xA2, 0x29,
155 0x94, 0xD9, 0x05, 0x8F, 0x57, 0x14, 0xD6, 0x17, 0x3C, 0x78, 0xBF, 0x85, 0xF5, 0x1D, 0xCC, 0x03,
156 0x35, 0x9E, 0xC9, 0xA9, 0x6B, 0x09
157 };
158 std::vector<uint8_t> goodData = {
159 0x06, 0xA2, 0x07, 0x13, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x04, 0x64, 0x61, 0x74, 0x61,
160 0x08, 0x05, 0x45, 0x63, 0x64, 0x73, 0x61, 0x14, 0x00, 0x15, 0x00, 0x16, 0x3D, 0x1B, 0x01, 0x03,
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800161 0x1C, 0x38, 0x07, 0x36, 0x08, 0x08, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x08, 0x17,
162 0x54, 0x65, 0x73, 0x74, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E,
163 0x48, 0x65, 0x6C, 0x70, 0x65, 0x72, 0x73, 0x08, 0x02, 0x45, 0x43, 0x08, 0x03, 0x4B, 0x45, 0x59,
Eric Newberryb74bbda2020-06-18 19:33:58 -0700164 0x08, 0x08, 0xA5, 0x8F, 0x5F, 0x7F, 0x18, 0x1A, 0x98, 0x14, 0x17, 0x48, 0x30, 0x46, 0x02, 0x21,
165 0x00, 0xD2, 0x35, 0xAD, 0xA9, 0xE6, 0x1E, 0x0F, 0xF3, 0xDE, 0x1D, 0xEA, 0x18, 0xCA, 0xEE, 0x5D,
166 0x05, 0xD1, 0xE0, 0x6A, 0x1E, 0xA5, 0x1A, 0xD6, 0xE6, 0x88, 0xB3, 0x24, 0xA9, 0xD5, 0x97, 0x4D,
167 0xC3, 0x02, 0x21, 0x00, 0xB5, 0xA3, 0x87, 0xD8, 0x9B, 0xB6, 0x92, 0xAD, 0x19, 0x84, 0xAE, 0x4D,
168 0xF5, 0x64, 0xEC, 0x1C, 0xF2, 0xA0, 0xB7, 0x4D, 0x6B, 0x74, 0xFF, 0x39, 0x38, 0xFD, 0x5D, 0x9D,
169 0x46, 0xE0, 0xD2, 0xB4
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800170 };
171 std::vector<uint8_t> badSigData = {
Eric Newberryb74bbda2020-06-18 19:33:58 -0700172 0x06, 0xA5, 0x07, 0x13, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x04, 0x64, 0x61, 0x74, 0x61,
173 0x08, 0x05, 0x45, 0x63, 0x64, 0x73, 0x61, 0x14, 0x00, 0x15, 0x00, 0x16, 0x40, 0x1B, 0x01, 0x03,
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800174 0x1C, 0x3B, 0x07, 0x39, 0x08, 0x08, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x08, 0x17,
175 0x54, 0x65, 0x73, 0x74, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E,
176 0x48, 0x65, 0x6C, 0x70, 0x65, 0x72, 0x73, 0x08, 0x05, 0x57, 0x72, 0x6F, 0x6E, 0x67, 0x08, 0x03,
Eric Newberryb74bbda2020-06-18 19:33:58 -0700177 0x4B, 0x45, 0x59, 0x08, 0x08, 0xF3, 0xD0, 0x1A, 0x45, 0x87, 0x5D, 0x6E, 0x43, 0x17, 0x48, 0x30,
178 0x46, 0x02, 0x21, 0x00, 0xBB, 0x15, 0xAC, 0x92, 0xFB, 0x7D, 0x6F, 0x6C, 0x90, 0xC9, 0x45, 0x71,
179 0x97, 0x39, 0xCD, 0x8C, 0x30, 0xA0, 0x8C, 0x69, 0xCA, 0x39, 0xDB, 0xE5, 0xC2, 0x95, 0x55, 0xB4,
180 0x13, 0xB4, 0xB8, 0x95, 0x02, 0x21, 0x00, 0xDA, 0x54, 0x99, 0xF8, 0xE5, 0xC1, 0x74, 0xAC, 0xE0,
181 0xF2, 0xDF, 0x0D, 0xC5, 0xE1, 0xCF, 0x99, 0x28, 0x6C, 0xB0, 0x2D, 0x55, 0xC8, 0x74, 0x63, 0x56,
182 0x2A, 0x1A, 0xB0, 0x00, 0xBD, 0xFF, 0xC5
183 };
184 std::vector<uint8_t> goodInterest = {
185 0x05, 0xCA, 0x07, 0x39, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x08, 0x69, 0x6E, 0x74, 0x65,
186 0x72, 0x65, 0x73, 0x74, 0x08, 0x05, 0x45, 0x63, 0x64, 0x73, 0x61, 0x02, 0x20, 0x8F, 0x41, 0x49,
187 0x40, 0xDA, 0x38, 0xC1, 0x0E, 0x75, 0x5A, 0x6D, 0x4A, 0xD4, 0xFC, 0xE2, 0xDF, 0xBA, 0x52, 0xAF,
188 0x0C, 0x9E, 0xEB, 0xD6, 0xC5, 0xD1, 0x1B, 0x51, 0x43, 0xBD, 0x19, 0xA7, 0x62, 0x0A, 0x04, 0xF7,
189 0x2C, 0x8A, 0x4B, 0x24, 0x00, 0x2C, 0x3D, 0x1B, 0x01, 0x03, 0x1C, 0x38, 0x07, 0x36, 0x08, 0x08,
190 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x08, 0x17, 0x54, 0x65, 0x73, 0x74, 0x56, 0x65,
191 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x48, 0x65, 0x6C, 0x70, 0x65, 0x72,
192 0x73, 0x08, 0x02, 0x45, 0x43, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x08, 0xA5, 0x8F, 0x5F, 0x7F,
193 0x18, 0x1A, 0x98, 0x14, 0x2E, 0x46, 0x30, 0x44, 0x02, 0x20, 0x14, 0x1A, 0xF5, 0x9C, 0xD2, 0x3F,
194 0xA9, 0x71, 0x3B, 0x37, 0xD7, 0x97, 0xE6, 0x29, 0x12, 0x40, 0x44, 0x7B, 0xF1, 0x98, 0x03, 0xC1,
195 0xDB, 0xEA, 0x3A, 0x71, 0x83, 0x0D, 0xC4, 0x26, 0xB7, 0x24, 0x02, 0x20, 0x0F, 0x14, 0x10, 0xDB,
196 0xDB, 0x24, 0xCB, 0xB3, 0xD2, 0x4B, 0x45, 0x6D, 0xA0, 0xBB, 0x4B, 0x87, 0xC1, 0x59, 0x9F, 0xC8,
197 0xBE, 0x75, 0xF5, 0xCC, 0xCB, 0xD2, 0x4F, 0xD8, 0x87, 0x26, 0x51, 0xBF
198 };
199 std::vector<uint8_t> badSigInterest = {
200 0x05, 0xCF, 0x07, 0x39, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x08, 0x69, 0x6E, 0x74, 0x65,
201 0x72, 0x65, 0x73, 0x74, 0x08, 0x05, 0x45, 0x63, 0x64, 0x73, 0x61, 0x02, 0x20, 0x53, 0x14, 0x5E,
202 0xA3, 0x31, 0x41, 0xD8, 0xA1, 0x10, 0x06, 0x3C, 0x8E, 0xF3, 0x51, 0xA0, 0xC2, 0x8A, 0xBC, 0xFC,
203 0x01, 0x5F, 0x12, 0x12, 0x11, 0x27, 0xD2, 0x18, 0xE5, 0xE7, 0xE4, 0xBD, 0x57, 0x0A, 0x04, 0xF7,
204 0x2C, 0x8A, 0x4B, 0x24, 0x00, 0x2C, 0x40, 0x1B, 0x01, 0x03, 0x1C, 0x3B, 0x07, 0x39, 0x08, 0x08,
205 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x08, 0x17, 0x54, 0x65, 0x73, 0x74, 0x56, 0x65,
206 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x48, 0x65, 0x6C, 0x70, 0x65, 0x72,
207 0x73, 0x08, 0x05, 0x57, 0x72, 0x6F, 0x6E, 0x67, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x08, 0xF3,
208 0xD0, 0x1A, 0x45, 0x87, 0x5D, 0x6E, 0x43, 0x2E, 0x48, 0x30, 0x46, 0x02, 0x21, 0x00, 0xC9, 0x69,
209 0xD8, 0xB8, 0x59, 0x38, 0x31, 0x0B, 0x44, 0x66, 0xAE, 0x1C, 0x1C, 0x88, 0x2A, 0x95, 0xD0, 0xE5,
210 0x31, 0x61, 0xA6, 0x94, 0x1F, 0x9B, 0xAD, 0x47, 0x1C, 0x9D, 0x56, 0x37, 0x50, 0xBE, 0x02, 0x21,
211 0x00, 0xC7, 0x23, 0x25, 0xF7, 0xFA, 0x6A, 0x2D, 0x3D, 0xF4, 0xD8, 0xDB, 0xE9, 0x76, 0x6A, 0x63,
212 0xD4, 0x11, 0x17, 0x4A, 0xDB, 0x7F, 0x85, 0x52, 0x97, 0xFC, 0x5B, 0x0B, 0x1B, 0xBA, 0xE5, 0xED,
213 0x9A
214 };
215 std::vector<uint8_t> goodInterestOldFormat = {
216 0x05, 0xCB, 0x07, 0x39, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x08, 0x69, 0x6E, 0x74, 0x65,
217 0x72, 0x65, 0x73, 0x74, 0x08, 0x05, 0x45, 0x63, 0x64, 0x73, 0x61, 0x02, 0x20, 0xDB, 0x6D, 0x5E,
218 0xA7, 0xBF, 0xAF, 0xEC, 0xA0, 0xC6, 0x20, 0x4E, 0xF2, 0x04, 0xF8, 0xFF, 0x39, 0x2A, 0x5F, 0xE6,
219 0x5F, 0x5B, 0xCE, 0x02, 0xA6, 0xBE, 0x82, 0x3F, 0xD2, 0x26, 0x47, 0x92, 0x62, 0x0A, 0x04, 0xF7,
220 0x2C, 0x8A, 0x4B, 0x24, 0x00, 0x2C, 0x3D, 0x1B, 0x01, 0x03, 0x1C, 0x38, 0x07, 0x36, 0x08, 0x08,
221 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x08, 0x17, 0x54, 0x65, 0x73, 0x74, 0x56, 0x65,
222 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x48, 0x65, 0x6C, 0x70, 0x65, 0x72,
223 0x73, 0x08, 0x02, 0x45, 0x43, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x08, 0xA5, 0x8F, 0x5F, 0x7F,
224 0x18, 0x1A, 0x98, 0x14, 0x2E, 0x47, 0x30, 0x45, 0x02, 0x21, 0x00, 0xCA, 0xFD, 0x19, 0x4C, 0x6C,
225 0x1B, 0x95, 0xD4, 0x2B, 0x15, 0x01, 0xE3, 0x87, 0x1F, 0xD7, 0xF2, 0x3D, 0x3E, 0x2E, 0x64, 0xAA,
226 0x60, 0x63, 0x51, 0xB3, 0x52, 0xBC, 0x6D, 0x24, 0x0C, 0x6D, 0x38, 0x02, 0x20, 0x0E, 0x21, 0xF1,
227 0x51, 0x39, 0x2D, 0x4A, 0x45, 0x05, 0x45, 0xFA, 0x85, 0xA7, 0xCC, 0x00, 0xFE, 0x89, 0x8A, 0xD6,
228 0xD7, 0x34, 0x0D, 0x31, 0x6A, 0x94, 0xAE, 0x1F, 0xD8, 0x07, 0xF1, 0xDF, 0x80
229 };
230 std::vector<uint8_t> badSigInterestOldFormat = {
231 0x05, 0xFD, 0x01, 0x5B, 0x07, 0xC9, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x08, 0x69, 0x6E,
232 0x74, 0x65, 0x72, 0x65, 0x73, 0x74, 0x08, 0x05, 0x45, 0x63, 0x64, 0x73, 0x61, 0x02, 0x20, 0xDB,
233 0x6D, 0x5E, 0xA7, 0xBF, 0xAF, 0xEC, 0xA0, 0xC6, 0x20, 0x4E, 0xF2, 0x04, 0xF8, 0xFF, 0x39, 0x2A,
234 0x5F, 0xE6, 0x5F, 0x5B, 0xCE, 0x02, 0xA6, 0xBE, 0x82, 0x3F, 0xD2, 0x26, 0x47, 0x92, 0x62, 0x08,
235 0x42, 0x16, 0x40, 0x1B, 0x01, 0x03, 0x1C, 0x3B, 0x07, 0x39, 0x08, 0x08, 0x53, 0x65, 0x63, 0x75,
236 0x72, 0x69, 0x74, 0x79, 0x08, 0x17, 0x54, 0x65, 0x73, 0x74, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69,
237 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x48, 0x65, 0x6C, 0x70, 0x65, 0x72, 0x73, 0x08, 0x05, 0x57,
238 0x72, 0x6F, 0x6E, 0x67, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x08, 0xF3, 0xD0, 0x1A, 0x45, 0x87,
239 0x5D, 0x6E, 0x43, 0x08, 0x4A, 0x17, 0x48, 0x30, 0x46, 0x02, 0x21, 0x00, 0xD0, 0x33, 0x6A, 0x5D,
240 0x8A, 0x1B, 0x04, 0xF9, 0xE5, 0xEE, 0x3A, 0x5A, 0x73, 0x63, 0xBF, 0xD4, 0x39, 0x07, 0x53, 0xA9,
241 0xF5, 0xBB, 0xB3, 0xD4, 0x7E, 0x65, 0x7B, 0xCB, 0x5A, 0xB1, 0x4B, 0xCE, 0x02, 0x21, 0x00, 0xD4,
242 0xA0, 0x7F, 0x40, 0x7A, 0xCF, 0xA5, 0xAD, 0x11, 0x44, 0x2F, 0xB1, 0xE0, 0x48, 0x25, 0x0B, 0x1C,
243 0x84, 0x76, 0x1F, 0x1B, 0x28, 0x4B, 0x36, 0x5F, 0x23, 0x3F, 0x91, 0xB3, 0xEF, 0x38, 0x2F, 0x0A,
244 0x04, 0xF7, 0x2C, 0x8A, 0x4B, 0x24, 0x00, 0x2C, 0x3D, 0x1B, 0x01, 0x03, 0x1C, 0x38, 0x07, 0x36,
245 0x08, 0x08, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x08, 0x17, 0x54, 0x65, 0x73, 0x74,
246 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x48, 0x65, 0x6C, 0x70,
247 0x65, 0x72, 0x73, 0x08, 0x02, 0x45, 0x43, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x08, 0xA5, 0x8F,
248 0x5F, 0x7F, 0x18, 0x1A, 0x98, 0x14, 0x2E, 0x47, 0x30, 0x45, 0x02, 0x21, 0x00, 0xCA, 0xFD, 0x19,
249 0x4C, 0x6C, 0x1B, 0x95, 0xD4, 0x2B, 0x15, 0x01, 0xE3, 0x87, 0x1F, 0xD7, 0xF2, 0x3D, 0x3E, 0x2E,
250 0x64, 0xAA, 0x60, 0x63, 0x51, 0xB3, 0x52, 0xBC, 0x6D, 0x24, 0x0C, 0x6D, 0x38, 0x02, 0x20, 0x0E,
251 0x21, 0xF1, 0x51, 0x39, 0x2D, 0x4A, 0x45, 0x05, 0x45, 0xFA, 0x85, 0xA7, 0xCC, 0x00, 0xFE, 0x89,
252 0x8A, 0xD6, 0xD7, 0x34, 0x0D, 0x31, 0x6A, 0x94, 0xAE, 0x1F, 0xD8, 0x07, 0xF1, 0xDF, 0x80
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800253 };
254};
255
256struct RsaDataset
257{
258 const std::string name = "Rsa";
259 std::vector<uint8_t> cert = {
260 0x06, 0xFD, 0x02, 0xED, 0x07, 0x48, 0x08, 0x08, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79,
261 0x08, 0x17, 0x54, 0x65, 0x73, 0x74, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69,
262 0x6F, 0x6E, 0x48, 0x65, 0x6C, 0x70, 0x65, 0x72, 0x73, 0x08, 0x03, 0x52, 0x53, 0x41, 0x08, 0x03,
Eric Newberryb74bbda2020-06-18 19:33:58 -0700263 0x4B, 0x45, 0x59, 0x08, 0x08, 0x0C, 0x1E, 0xDE, 0xDB, 0xE7, 0x2E, 0xC6, 0xC7, 0x08, 0x04, 0x73,
264 0x65, 0x6C, 0x66, 0x08, 0x09, 0xFD, 0x00, 0x00, 0x01, 0x72, 0xCE, 0xA8, 0xE7, 0xA4, 0x14, 0x09,
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800265 0x18, 0x01, 0x02, 0x19, 0x04, 0x00, 0x36, 0xEE, 0x80, 0x15, 0xFD, 0x01, 0x26, 0x30, 0x82, 0x01,
266 0x22, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00,
Eric Newberryb74bbda2020-06-18 19:33:58 -0700267 0x03, 0x82, 0x01, 0x0F, 0x00, 0x30, 0x82, 0x01, 0x0A, 0x02, 0x82, 0x01, 0x01, 0x00, 0xED, 0x32,
268 0x03, 0x4A, 0xC1, 0xC4, 0x73, 0xA7, 0xC3, 0x3C, 0xB3, 0x09, 0x62, 0xF7, 0xA7, 0x5F, 0x83, 0x98,
269 0xBD, 0x8A, 0x9F, 0xB3, 0x02, 0x02, 0x53, 0xF1, 0x62, 0x78, 0xE0, 0x08, 0x42, 0x48, 0xC7, 0x81,
270 0x2E, 0xA5, 0xD4, 0x9E, 0x7D, 0xD1, 0x38, 0x51, 0x8C, 0xAB, 0x18, 0x87, 0xC5, 0x0B, 0x57, 0x1C,
271 0x01, 0xD7, 0xA9, 0x4B, 0xA8, 0xD8, 0xEB, 0x96, 0x95, 0xAC, 0x09, 0xBC, 0xCE, 0xF4, 0x3E, 0xE5,
272 0x8D, 0x72, 0x81, 0x30, 0x30, 0xBA, 0xB7, 0xA2, 0x0D, 0xFE, 0x21, 0x2F, 0x97, 0x76, 0x59, 0x80,
273 0xC2, 0x92, 0x1B, 0x16, 0xF9, 0x15, 0xE3, 0xF5, 0xA0, 0x2C, 0x87, 0xAB, 0x88, 0x5B, 0x6E, 0x73,
274 0x36, 0xDB, 0xE4, 0xF0, 0x19, 0x78, 0x93, 0x26, 0xC3, 0x39, 0x33, 0x27, 0xBE, 0x06, 0x33, 0x84,
275 0x9C, 0xA8, 0x8A, 0xF7, 0x41, 0x82, 0xAD, 0xE4, 0x25, 0x86, 0xCC, 0x32, 0x1D, 0x5A, 0x8C, 0x52,
276 0x2F, 0x91, 0xD9, 0xD1, 0x31, 0x3F, 0x07, 0xF9, 0x43, 0xF9, 0xA8, 0xE7, 0x92, 0x70, 0xF4, 0xB0,
277 0x2F, 0xE1, 0x76, 0x91, 0x42, 0x9C, 0xB9, 0xF3, 0x69, 0x88, 0xD3, 0x36, 0x75, 0x5C, 0x13, 0x18,
278 0x85, 0xAA, 0x17, 0xCE, 0x5F, 0x0D, 0x49, 0xED, 0x79, 0xB2, 0x7F, 0x00, 0xF4, 0x5F, 0xD7, 0x29,
279 0xD2, 0xB3, 0x1E, 0xA6, 0xFC, 0x7E, 0x0C, 0xCD, 0x6A, 0x5F, 0xC6, 0x68, 0x46, 0x4C, 0x8A, 0x71,
280 0x57, 0x08, 0x86, 0xCD, 0xD4, 0xD2, 0x89, 0x37, 0x46, 0xAA, 0x79, 0xA9, 0x3A, 0x13, 0xB0, 0xA0,
281 0x63, 0x86, 0xA2, 0x18, 0xC6, 0xB3, 0x8C, 0x59, 0x5D, 0xF7, 0x6F, 0x77, 0xC3, 0x16, 0x42, 0xA7,
282 0x9A, 0x3F, 0xF9, 0x07, 0xB4, 0x5A, 0x7B, 0xE3, 0xA6, 0xF1, 0x76, 0xC5, 0x58, 0xB2, 0xC2, 0xAC,
283 0x7C, 0x02, 0x9A, 0xB2, 0xD1, 0x2B, 0xBC, 0x23, 0x11, 0x9F, 0xEB, 0x6F, 0xB4, 0x73, 0x02, 0x03,
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800284 0x01, 0x00, 0x01, 0x16, 0x68, 0x1B, 0x01, 0x01, 0x1C, 0x39, 0x07, 0x37, 0x08, 0x08, 0x53, 0x65,
285 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x08, 0x17, 0x54, 0x65, 0x73, 0x74, 0x56, 0x65, 0x72, 0x69,
286 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x48, 0x65, 0x6C, 0x70, 0x65, 0x72, 0x73, 0x08,
Eric Newberryb74bbda2020-06-18 19:33:58 -0700287 0x03, 0x52, 0x53, 0x41, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x08, 0x0C, 0x1E, 0xDE, 0xDB, 0xE7,
288 0x2E, 0xC6, 0xC7, 0xFD, 0x00, 0xFD, 0x26, 0xFD, 0x00, 0xFE, 0x0F, 0x31, 0x39, 0x37, 0x30, 0x30,
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800289 0x31, 0x30, 0x31, 0x54, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0xFD, 0x00, 0xFF, 0x0F, 0x32, 0x30,
Eric Newberryb74bbda2020-06-18 19:33:58 -0700290 0x34, 0x30, 0x30, 0x36, 0x31, 0x34, 0x54, 0x32, 0x32, 0x31, 0x37, 0x35, 0x35, 0x17, 0xFD, 0x01,
291 0x00, 0x0F, 0x4D, 0x43, 0x2F, 0x6E, 0xCC, 0xB3, 0xAA, 0x8A, 0x50, 0xBB, 0x3D, 0x92, 0xE6, 0xB7,
292 0xFB, 0xD4, 0xEA, 0x20, 0xB4, 0xF8, 0xF0, 0xD8, 0x03, 0x45, 0xB3, 0xFB, 0x82, 0xCE, 0xDB, 0xCE,
293 0x1F, 0xC7, 0x61, 0x58, 0x9D, 0x33, 0xAD, 0xA8, 0xFC, 0xB9, 0x31, 0x7F, 0xCF, 0x8D, 0x9C, 0xDF,
294 0x4C, 0x29, 0x25, 0xD6, 0x78, 0x8F, 0xCC, 0xC4, 0xF9, 0xF8, 0x88, 0xA9, 0x66, 0x7E, 0xD9, 0x4A,
295 0xB2, 0x6F, 0x2A, 0x60, 0xB8, 0x43, 0xCC, 0x46, 0xC3, 0x88, 0x93, 0xC8, 0x0C, 0xD3, 0x87, 0x70,
296 0xDA, 0x59, 0x16, 0xF1, 0x37, 0xD0, 0xB5, 0xF0, 0x92, 0x9E, 0xBC, 0xAE, 0xA2, 0x3A, 0x96, 0xB1,
297 0x36, 0x26, 0x8E, 0x43, 0xA7, 0x33, 0xEB, 0x13, 0x8C, 0x57, 0x02, 0x20, 0xCB, 0x97, 0xB7, 0x78,
298 0x08, 0x58, 0x07, 0x77, 0x66, 0xE9, 0x5D, 0xCB, 0xCD, 0x1E, 0x0D, 0x36, 0x43, 0x23, 0x64, 0x8E,
299 0x48, 0x66, 0x60, 0xF6, 0xF4, 0x4C, 0xD6, 0x9E, 0xAF, 0x3C, 0xC6, 0x23, 0x03, 0x09, 0x8A, 0xB1,
300 0x26, 0xDA, 0x82, 0x6D, 0xA2, 0x3D, 0x0C, 0x36, 0x56, 0x76, 0x9A, 0x62, 0xBB, 0xDD, 0x0C, 0x91,
301 0xB3, 0x8D, 0x0D, 0x9B, 0x55, 0x17, 0xC3, 0xFA, 0x26, 0xC3, 0xE5, 0x77, 0xB3, 0x55, 0x5C, 0xB7,
302 0xC9, 0x74, 0x86, 0xD1, 0xEE, 0xDF, 0xEB, 0xAF, 0xC6, 0x4D, 0x42, 0x3F, 0x09, 0x6A, 0x44, 0x7F,
303 0xB9, 0xC1, 0xE9, 0xAB, 0xBF, 0xBA, 0xED, 0xDD, 0xE9, 0x09, 0x11, 0x8C, 0x03, 0x1E, 0x5A, 0xA6,
304 0x74, 0xF1, 0x39, 0x71, 0xF3, 0x71, 0x26, 0xD5, 0xF2, 0x87, 0xBC, 0x1A, 0x6D, 0xD2, 0x37, 0xC6,
305 0x3E, 0xFA, 0xE6, 0xB9, 0x8E, 0x08, 0x82, 0x50, 0xCA, 0xEE, 0x7F, 0x5D, 0x80, 0x65, 0xBA, 0x10,
306 0x1F, 0x24, 0xC1, 0x15, 0x78, 0xB7, 0x90, 0xE5, 0x3D, 0xDA, 0x0F, 0x0E, 0x03, 0x20, 0xC1, 0xEA,
307 0x85
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800308 };
309 std::vector<uint8_t> goodData = {
310 0x06, 0xFD, 0x01, 0x5B, 0x07, 0x11, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x04, 0x64, 0x61,
311 0x74, 0x61, 0x08, 0x03, 0x52, 0x73, 0x61, 0x14, 0x00, 0x15, 0x00, 0x16, 0x3E, 0x1B, 0x01, 0x01,
312 0x1C, 0x39, 0x07, 0x37, 0x08, 0x08, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x08, 0x17,
313 0x54, 0x65, 0x73, 0x74, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E,
314 0x48, 0x65, 0x6C, 0x70, 0x65, 0x72, 0x73, 0x08, 0x03, 0x52, 0x53, 0x41, 0x08, 0x03, 0x4B, 0x45,
Eric Newberryb74bbda2020-06-18 19:33:58 -0700315 0x59, 0x08, 0x08, 0x0C, 0x1E, 0xDE, 0xDB, 0xE7, 0x2E, 0xC6, 0xC7, 0x17, 0xFD, 0x01, 0x00, 0x15,
316 0x5E, 0x36, 0xEB, 0x43, 0x60, 0x9E, 0x06, 0xC1, 0x2A, 0xC8, 0x92, 0xAC, 0x0B, 0xC9, 0x8D, 0xEB,
317 0x54, 0x4A, 0x3A, 0xC4, 0x88, 0x3C, 0x51, 0x67, 0x19, 0x93, 0x68, 0xC7, 0xD5, 0x70, 0xE7, 0x2C,
318 0xB1, 0x78, 0xEA, 0x6A, 0x84, 0x5A, 0x7A, 0x5E, 0xAA, 0x43, 0xE7, 0x09, 0x3E, 0xF8, 0xF1, 0x7C,
319 0x9C, 0xE7, 0x72, 0x2D, 0x7B, 0x77, 0xD0, 0xD9, 0x86, 0x6B, 0x05, 0xE9, 0xA7, 0x83, 0x7C, 0xAB,
320 0x16, 0xDF, 0x0D, 0x36, 0x37, 0x74, 0x6E, 0xBC, 0x42, 0x2F, 0xFE, 0xDE, 0x40, 0x03, 0x2B, 0xC0,
321 0x7E, 0xF8, 0x67, 0xD7, 0x38, 0xD7, 0xE8, 0x7C, 0xCF, 0xCE, 0x9D, 0x14, 0x39, 0xDE, 0xF1, 0x02,
322 0x9E, 0xC4, 0x9B, 0xD6, 0x46, 0xBA, 0x57, 0xF9, 0x76, 0xB2, 0x25, 0xD4, 0x0A, 0xB5, 0x31, 0x09,
323 0x36, 0x77, 0xF4, 0xDB, 0xC7, 0xD2, 0xD9, 0x14, 0xB0, 0x98, 0xAC, 0x48, 0x7C, 0x30, 0x90, 0xE2,
324 0x1E, 0xF1, 0xF5, 0xC5, 0x69, 0xE4, 0xA5, 0xBE, 0xF7, 0x9C, 0x74, 0x97, 0x97, 0xE6, 0xA4, 0x41,
325 0x75, 0xDF, 0x8D, 0xFB, 0x2E, 0x9E, 0xA0, 0x57, 0xBB, 0x96, 0xE5, 0x81, 0x9F, 0xF7, 0x95, 0x7B,
326 0x6A, 0x2C, 0xE3, 0xF8, 0x48, 0x0C, 0xB2, 0x3F, 0xB6, 0xCF, 0xB8, 0x7F, 0x08, 0x24, 0x77, 0x44,
327 0x9A, 0x7F, 0x34, 0x35, 0xFF, 0x68, 0x7E, 0x61, 0x2C, 0x09, 0xF9, 0x0A, 0xAD, 0xBE, 0x57, 0xD3,
328 0x2A, 0x2A, 0x9E, 0xE0, 0x8E, 0x5B, 0x79, 0x1C, 0x4C, 0x32, 0x8D, 0xFA, 0xBF, 0xEE, 0xBB, 0xA0,
329 0x4F, 0xD9, 0xEB, 0xC1, 0x5D, 0x53, 0x15, 0xBF, 0x8C, 0x7C, 0x6B, 0x22, 0xB9, 0x24, 0x70, 0xAE,
330 0x63, 0x13, 0x96, 0x3B, 0x2A, 0xDA, 0x7F, 0x64, 0x0D, 0x9E, 0xA7, 0x90, 0x20, 0x2A, 0x2A, 0xAB,
331 0xA9, 0xA6, 0xC9, 0xB2, 0x37, 0x8E, 0xE3, 0x09, 0xFD, 0xA3, 0x68, 0x06, 0xCB, 0x96, 0x80
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800332 };
333 std::vector<uint8_t> badSigData = {
Eric Newberryb74bbda2020-06-18 19:33:58 -0700334 0x06, 0xA2, 0x07, 0x11, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x04, 0x64, 0x61, 0x74, 0x61,
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800335 0x08, 0x03, 0x52, 0x73, 0x61, 0x14, 0x00, 0x15, 0x00, 0x16, 0x40, 0x1B, 0x01, 0x03, 0x1C, 0x3B,
336 0x07, 0x39, 0x08, 0x08, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x08, 0x17, 0x54, 0x65,
337 0x73, 0x74, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x48, 0x65,
338 0x6C, 0x70, 0x65, 0x72, 0x73, 0x08, 0x05, 0x57, 0x72, 0x6F, 0x6E, 0x67, 0x08, 0x03, 0x4B, 0x45,
Eric Newberryb74bbda2020-06-18 19:33:58 -0700339 0x59, 0x08, 0x08, 0xF3, 0xD0, 0x1A, 0x45, 0x87, 0x5D, 0x6E, 0x43, 0x17, 0x47, 0x30, 0x45, 0x02,
340 0x20, 0x15, 0xFC, 0x4C, 0xA4, 0xBA, 0x18, 0xF9, 0x6A, 0x92, 0xC8, 0xA9, 0x62, 0x96, 0x60, 0x39,
341 0x6B, 0x74, 0x4A, 0x7C, 0x38, 0x1A, 0x83, 0x33, 0xB2, 0x40, 0x03, 0x59, 0x2C, 0xA4, 0x1A, 0xD1,
342 0x1E, 0x02, 0x21, 0x00, 0xA5, 0x62, 0xA5, 0x04, 0x60, 0xBC, 0x96, 0x54, 0x2C, 0x9E, 0x6F, 0xA8,
343 0x1B, 0xDB, 0xF9, 0xF0, 0x7E, 0xFF, 0xED, 0x92, 0x3A, 0x4B, 0xDE, 0x3D, 0x20, 0x02, 0x7B, 0xD7,
344 0x1C, 0xD0, 0xAA, 0xAB
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800345 };
346 std::vector<uint8_t> goodInterest = {
Eric Newberryb74bbda2020-06-18 19:33:58 -0700347 0x05, 0xFD, 0x01, 0x85, 0x07, 0x37, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x08, 0x69, 0x6E,
348 0x74, 0x65, 0x72, 0x65, 0x73, 0x74, 0x08, 0x03, 0x52, 0x73, 0x61, 0x02, 0x20, 0x08, 0x39, 0xEE,
349 0x12, 0xF1, 0x10, 0xB7, 0x8B, 0x49, 0xF2, 0xE2, 0x54, 0x23, 0xFF, 0x66, 0xB3, 0x0F, 0xC6, 0x91,
350 0x89, 0x59, 0x99, 0x20, 0xAA, 0x06, 0xEA, 0x8F, 0xB3, 0x3A, 0x8F, 0xB3, 0xB1, 0x0A, 0x04, 0xF7,
351 0x2C, 0x8A, 0x4B, 0x24, 0x00, 0x2C, 0x3E, 0x1B, 0x01, 0x01, 0x1C, 0x39, 0x07, 0x37, 0x08, 0x08,
352 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x08, 0x17, 0x54, 0x65, 0x73, 0x74, 0x56, 0x65,
353 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x48, 0x65, 0x6C, 0x70, 0x65, 0x72,
354 0x73, 0x08, 0x03, 0x52, 0x53, 0x41, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x08, 0x0C, 0x1E, 0xDE,
355 0xDB, 0xE7, 0x2E, 0xC6, 0xC7, 0x2E, 0xFD, 0x01, 0x00, 0x54, 0xD8, 0xED, 0xAB, 0x63, 0xE0, 0x89,
356 0x9D, 0x31, 0x0B, 0xD7, 0x2F, 0xF6, 0x4C, 0x4B, 0xCE, 0x2A, 0xB9, 0x65, 0x55, 0x65, 0x15, 0x4F,
357 0x1B, 0x59, 0xFF, 0xF7, 0x10, 0xB8, 0xA6, 0x33, 0x88, 0xA6, 0xCF, 0x9B, 0x23, 0x7E, 0x48, 0x83,
358 0x60, 0x59, 0xF9, 0xB5, 0x7F, 0x68, 0x2B, 0x1E, 0x2F, 0x35, 0x3B, 0x48, 0x64, 0x15, 0xD8, 0xE1,
359 0x27, 0x1F, 0xDE, 0x0A, 0x27, 0xBE, 0x7A, 0xA6, 0xFE, 0x8B, 0x01, 0x7C, 0x94, 0xDC, 0x2D, 0x4B,
360 0x2E, 0x78, 0xA0, 0xF4, 0xA2, 0x9B, 0x63, 0x47, 0x5B, 0x8C, 0x57, 0x04, 0xF3, 0x92, 0x3F, 0x4C,
361 0x84, 0x70, 0x06, 0x16, 0xD2, 0xF0, 0x49, 0x9E, 0x4E, 0x2E, 0x9A, 0xC5, 0xB0, 0xC8, 0x0F, 0x4C,
362 0xB9, 0xD0, 0x37, 0x9F, 0xEB, 0x53, 0x68, 0x1B, 0xC9, 0xBF, 0x77, 0x12, 0xBD, 0x25, 0x23, 0x38,
363 0x56, 0x63, 0x22, 0xA4, 0x52, 0xA1, 0x00, 0x47, 0x08, 0xEB, 0xC7, 0x36, 0x33, 0x46, 0xC1, 0x92,
364 0x89, 0xE4, 0xC8, 0x52, 0x05, 0xB7, 0x01, 0x2B, 0x24, 0x04, 0x56, 0xC3, 0x8C, 0x1F, 0x18, 0x78,
365 0x73, 0x99, 0xFF, 0x7B, 0x0E, 0x92, 0x3D, 0x92, 0x61, 0xF1, 0xDC, 0x55, 0xDB, 0x55, 0x8B, 0xBA,
366 0xDB, 0xD9, 0x14, 0x7C, 0x7B, 0x9B, 0xDC, 0x90, 0x15, 0xC6, 0x59, 0x80, 0xE7, 0xFC, 0x03, 0x71,
367 0x7E, 0x35, 0x05, 0x30, 0xBE, 0xED, 0xC4, 0xB2, 0x2E, 0x39, 0xDB, 0xAA, 0x2A, 0x7E, 0x50, 0x37,
368 0x4D, 0xC8, 0x3F, 0x00, 0xD8, 0xE9, 0xF1, 0x9D, 0x57, 0x43, 0x2B, 0x1C, 0x5F, 0x09, 0x18, 0xA3,
369 0xE3, 0x11, 0x85, 0xCC, 0x0E, 0xAF, 0x56, 0x6B, 0xE1, 0xAC, 0xB3, 0x20, 0xF2, 0x47, 0xFE, 0x95,
370 0xC8, 0x71, 0x99, 0xCC, 0x52, 0x8A, 0x6F, 0xF1, 0x01, 0xD6, 0xE9, 0x2E, 0x6C, 0x27, 0xC3, 0xED,
371 0xE3, 0xF2, 0xDD, 0x78, 0xB4, 0x7F, 0xFA, 0xD0, 0xC2
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800372 };
373 std::vector<uint8_t> badSigInterest = {
Eric Newberryb74bbda2020-06-18 19:33:58 -0700374 0x05, 0xCC, 0x07, 0x37, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x08, 0x69, 0x6E, 0x74, 0x65,
375 0x72, 0x65, 0x73, 0x74, 0x08, 0x03, 0x52, 0x73, 0x61, 0x02, 0x20, 0x64, 0xE3, 0x6F, 0xD5, 0x73,
376 0x21, 0xBC, 0xAB, 0xDE, 0xDE, 0x0F, 0x99, 0xCB, 0x49, 0x7F, 0x46, 0xE7, 0xF0, 0x7A, 0xF1, 0x2C,
377 0xF9, 0x36, 0xE0, 0xBD, 0x3A, 0x8A, 0x1C, 0x08, 0x6A, 0xD1, 0x21, 0x0A, 0x04, 0xF7, 0x2C, 0x8A,
378 0x4B, 0x24, 0x00, 0x2C, 0x40, 0x1B, 0x01, 0x03, 0x1C, 0x3B, 0x07, 0x39, 0x08, 0x08, 0x53, 0x65,
379 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x08, 0x17, 0x54, 0x65, 0x73, 0x74, 0x56, 0x65, 0x72, 0x69,
380 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x48, 0x65, 0x6C, 0x70, 0x65, 0x72, 0x73, 0x08,
381 0x05, 0x57, 0x72, 0x6F, 0x6E, 0x67, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x08, 0xF3, 0xD0, 0x1A,
382 0x45, 0x87, 0x5D, 0x6E, 0x43, 0x2E, 0x47, 0x30, 0x45, 0x02, 0x21, 0x00, 0xC3, 0x9A, 0xDC, 0x5A,
383 0x59, 0x10, 0x4D, 0x29, 0x9A, 0x64, 0x8D, 0x18, 0xBD, 0x27, 0x73, 0xBB, 0x98, 0xAB, 0xE9, 0xF2,
384 0x4A, 0xBF, 0xC0, 0x5B, 0xA8, 0x05, 0xA2, 0xC8, 0x61, 0xC4, 0x2E, 0x64, 0x02, 0x20, 0x1F, 0x5E,
385 0xF5, 0x8E, 0xC9, 0xDC, 0x9E, 0x15, 0x1C, 0xFA, 0x58, 0x5F, 0xDF, 0xAE, 0xA0, 0xFD, 0xDA, 0x34,
386 0x21, 0xE0, 0xA8, 0x2D, 0x32, 0x47, 0x9E, 0x44, 0x83, 0x79, 0x23, 0x5F, 0xBE, 0x16
387 };
388 std::vector<uint8_t> goodInterestOldFormat = {
389 0x05, 0xFD, 0x01, 0x85, 0x07, 0x37, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x08, 0x69, 0x6E,
390 0x74, 0x65, 0x72, 0x65, 0x73, 0x74, 0x08, 0x03, 0x52, 0x73, 0x61, 0x02, 0x20, 0x08, 0x39, 0xEE,
391 0x12, 0xF1, 0x10, 0xB7, 0x8B, 0x49, 0xF2, 0xE2, 0x54, 0x23, 0xFF, 0x66, 0xB3, 0x0F, 0xC6, 0x91,
392 0x89, 0x59, 0x99, 0x20, 0xAA, 0x06, 0xEA, 0x8F, 0xB3, 0x3A, 0x8F, 0xB3, 0xB1, 0x0A, 0x04, 0xF7,
393 0x2C, 0x8A, 0x4B, 0x24, 0x00, 0x2C, 0x3E, 0x1B, 0x01, 0x01, 0x1C, 0x39, 0x07, 0x37, 0x08, 0x08,
394 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x08, 0x17, 0x54, 0x65, 0x73, 0x74, 0x56, 0x65,
395 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x48, 0x65, 0x6C, 0x70, 0x65, 0x72,
396 0x73, 0x08, 0x03, 0x52, 0x53, 0x41, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x08, 0x0C, 0x1E, 0xDE,
397 0xDB, 0xE7, 0x2E, 0xC6, 0xC7, 0x2E, 0xFD, 0x01, 0x00, 0x54, 0xD8, 0xED, 0xAB, 0x63, 0xE0, 0x89,
398 0x9D, 0x31, 0x0B, 0xD7, 0x2F, 0xF6, 0x4C, 0x4B, 0xCE, 0x2A, 0xB9, 0x65, 0x55, 0x65, 0x15, 0x4F,
399 0x1B, 0x59, 0xFF, 0xF7, 0x10, 0xB8, 0xA6, 0x33, 0x88, 0xA6, 0xCF, 0x9B, 0x23, 0x7E, 0x48, 0x83,
400 0x60, 0x59, 0xF9, 0xB5, 0x7F, 0x68, 0x2B, 0x1E, 0x2F, 0x35, 0x3B, 0x48, 0x64, 0x15, 0xD8, 0xE1,
401 0x27, 0x1F, 0xDE, 0x0A, 0x27, 0xBE, 0x7A, 0xA6, 0xFE, 0x8B, 0x01, 0x7C, 0x94, 0xDC, 0x2D, 0x4B,
402 0x2E, 0x78, 0xA0, 0xF4, 0xA2, 0x9B, 0x63, 0x47, 0x5B, 0x8C, 0x57, 0x04, 0xF3, 0x92, 0x3F, 0x4C,
403 0x84, 0x70, 0x06, 0x16, 0xD2, 0xF0, 0x49, 0x9E, 0x4E, 0x2E, 0x9A, 0xC5, 0xB0, 0xC8, 0x0F, 0x4C,
404 0xB9, 0xD0, 0x37, 0x9F, 0xEB, 0x53, 0x68, 0x1B, 0xC9, 0xBF, 0x77, 0x12, 0xBD, 0x25, 0x23, 0x38,
405 0x56, 0x63, 0x22, 0xA4, 0x52, 0xA1, 0x00, 0x47, 0x08, 0xEB, 0xC7, 0x36, 0x33, 0x46, 0xC1, 0x92,
406 0x89, 0xE4, 0xC8, 0x52, 0x05, 0xB7, 0x01, 0x2B, 0x24, 0x04, 0x56, 0xC3, 0x8C, 0x1F, 0x18, 0x78,
407 0x73, 0x99, 0xFF, 0x7B, 0x0E, 0x92, 0x3D, 0x92, 0x61, 0xF1, 0xDC, 0x55, 0xDB, 0x55, 0x8B, 0xBA,
408 0xDB, 0xD9, 0x14, 0x7C, 0x7B, 0x9B, 0xDC, 0x90, 0x15, 0xC6, 0x59, 0x80, 0xE7, 0xFC, 0x03, 0x71,
409 0x7E, 0x35, 0x05, 0x30, 0xBE, 0xED, 0xC4, 0xB2, 0x2E, 0x39, 0xDB, 0xAA, 0x2A, 0x7E, 0x50, 0x37,
410 0x4D, 0xC8, 0x3F, 0x00, 0xD8, 0xE9, 0xF1, 0x9D, 0x57, 0x43, 0x2B, 0x1C, 0x5F, 0x09, 0x18, 0xA3,
411 0xE3, 0x11, 0x85, 0xCC, 0x0E, 0xAF, 0x56, 0x6B, 0xE1, 0xAC, 0xB3, 0x20, 0xF2, 0x47, 0xFE, 0x95,
412 0xC8, 0x71, 0x99, 0xCC, 0x52, 0x8A, 0x6F, 0xF1, 0x01, 0xD6, 0xE9, 0x2E, 0x6C, 0x27, 0xC3, 0xED,
413 0xE3, 0xF2, 0xDD, 0x78, 0xB4, 0x7F, 0xFA, 0xD0, 0xC2
414 };
415 std::vector<uint8_t> badSigInterestOldFormat = {
416 0x05, 0xFD, 0x02, 0x15, 0x07, 0xC7, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x08, 0x69, 0x6E,
417 0x74, 0x65, 0x72, 0x65, 0x73, 0x74, 0x08, 0x03, 0x52, 0x73, 0x61, 0x02, 0x20, 0x08, 0x39, 0xEE,
418 0x12, 0xF1, 0x10, 0xB7, 0x8B, 0x49, 0xF2, 0xE2, 0x54, 0x23, 0xFF, 0x66, 0xB3, 0x0F, 0xC6, 0x91,
419 0x89, 0x59, 0x99, 0x20, 0xAA, 0x06, 0xEA, 0x8F, 0xB3, 0x3A, 0x8F, 0xB3, 0xB1, 0x08, 0x42, 0x16,
420 0x40, 0x1B, 0x01, 0x03, 0x1C, 0x3B, 0x07, 0x39, 0x08, 0x08, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69,
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800421 0x74, 0x79, 0x08, 0x17, 0x54, 0x65, 0x73, 0x74, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61,
Eric Newberryb74bbda2020-06-18 19:33:58 -0700422 0x74, 0x69, 0x6F, 0x6E, 0x48, 0x65, 0x6C, 0x70, 0x65, 0x72, 0x73, 0x08, 0x05, 0x57, 0x72, 0x6F,
423 0x6E, 0x67, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x08, 0xF3, 0xD0, 0x1A, 0x45, 0x87, 0x5D, 0x6E,
424 0x43, 0x08, 0x4A, 0x17, 0x48, 0x30, 0x46, 0x02, 0x21, 0x00, 0x9D, 0x24, 0x46, 0x3D, 0x37, 0xAE,
425 0x81, 0xB7, 0x7C, 0x2C, 0x86, 0x8A, 0x34, 0xEF, 0xC8, 0xC8, 0xB0, 0x18, 0x78, 0x3E, 0xA3, 0xE5,
426 0xED, 0x31, 0x93, 0x26, 0x73, 0x0E, 0x58, 0xE8, 0xF8, 0x47, 0x02, 0x21, 0x00, 0xFD, 0x82, 0xD2,
427 0x69, 0xEF, 0xB0, 0x72, 0xE8, 0xCA, 0x33, 0x43, 0xEB, 0x27, 0xB1, 0xDD, 0xB6, 0xD1, 0x97, 0x14,
428 0x43, 0xC5, 0xA9, 0xFC, 0x87, 0x59, 0xAF, 0x87, 0xF3, 0x02, 0x2C, 0x59, 0x2E, 0x0A, 0x04, 0xF7,
429 0x2C, 0x8A, 0x4B, 0x24, 0x00, 0x2C, 0x3E, 0x1B, 0x01, 0x01, 0x1C, 0x39, 0x07, 0x37, 0x08, 0x08,
430 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x08, 0x17, 0x54, 0x65, 0x73, 0x74, 0x56, 0x65,
431 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x48, 0x65, 0x6C, 0x70, 0x65, 0x72,
432 0x73, 0x08, 0x03, 0x52, 0x53, 0x41, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x08, 0x0C, 0x1E, 0xDE,
433 0xDB, 0xE7, 0x2E, 0xC6, 0xC7, 0x2E, 0xFD, 0x01, 0x00, 0x54, 0xD8, 0xED, 0xAB, 0x63, 0xE0, 0x89,
434 0x9D, 0x31, 0x0B, 0xD7, 0x2F, 0xF6, 0x4C, 0x4B, 0xCE, 0x2A, 0xB9, 0x65, 0x55, 0x65, 0x15, 0x4F,
435 0x1B, 0x59, 0xFF, 0xF7, 0x10, 0xB8, 0xA6, 0x33, 0x88, 0xA6, 0xCF, 0x9B, 0x23, 0x7E, 0x48, 0x83,
436 0x60, 0x59, 0xF9, 0xB5, 0x7F, 0x68, 0x2B, 0x1E, 0x2F, 0x35, 0x3B, 0x48, 0x64, 0x15, 0xD8, 0xE1,
437 0x27, 0x1F, 0xDE, 0x0A, 0x27, 0xBE, 0x7A, 0xA6, 0xFE, 0x8B, 0x01, 0x7C, 0x94, 0xDC, 0x2D, 0x4B,
438 0x2E, 0x78, 0xA0, 0xF4, 0xA2, 0x9B, 0x63, 0x47, 0x5B, 0x8C, 0x57, 0x04, 0xF3, 0x92, 0x3F, 0x4C,
439 0x84, 0x70, 0x06, 0x16, 0xD2, 0xF0, 0x49, 0x9E, 0x4E, 0x2E, 0x9A, 0xC5, 0xB0, 0xC8, 0x0F, 0x4C,
440 0xB9, 0xD0, 0x37, 0x9F, 0xEB, 0x53, 0x68, 0x1B, 0xC9, 0xBF, 0x77, 0x12, 0xBD, 0x25, 0x23, 0x38,
441 0x56, 0x63, 0x22, 0xA4, 0x52, 0xA1, 0x00, 0x47, 0x08, 0xEB, 0xC7, 0x36, 0x33, 0x46, 0xC1, 0x92,
442 0x89, 0xE4, 0xC8, 0x52, 0x05, 0xB7, 0x01, 0x2B, 0x24, 0x04, 0x56, 0xC3, 0x8C, 0x1F, 0x18, 0x78,
443 0x73, 0x99, 0xFF, 0x7B, 0x0E, 0x92, 0x3D, 0x92, 0x61, 0xF1, 0xDC, 0x55, 0xDB, 0x55, 0x8B, 0xBA,
444 0xDB, 0xD9, 0x14, 0x7C, 0x7B, 0x9B, 0xDC, 0x90, 0x15, 0xC6, 0x59, 0x80, 0xE7, 0xFC, 0x03, 0x71,
445 0x7E, 0x35, 0x05, 0x30, 0xBE, 0xED, 0xC4, 0xB2, 0x2E, 0x39, 0xDB, 0xAA, 0x2A, 0x7E, 0x50, 0x37,
446 0x4D, 0xC8, 0x3F, 0x00, 0xD8, 0xE9, 0xF1, 0x9D, 0x57, 0x43, 0x2B, 0x1C, 0x5F, 0x09, 0x18, 0xA3,
447 0xE3, 0x11, 0x85, 0xCC, 0x0E, 0xAF, 0x56, 0x6B, 0xE1, 0xAC, 0xB3, 0x20, 0xF2, 0x47, 0xFE, 0x95,
448 0xC8, 0x71, 0x99, 0xCC, 0x52, 0x8A, 0x6F, 0xF1, 0x01, 0xD6, 0xE9, 0x2E, 0x6C, 0x27, 0xC3, 0xED,
449 0xE3, 0xF2, 0xDD, 0x78, 0xB4, 0x7F, 0xFA, 0xD0, 0xC2
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800450 };
451};
452
453struct Sha256Dataset
454{
455 const std::string name = "Sha256";
456 std::vector<uint8_t> cert = {
457
458 };
459 std::vector<uint8_t> goodData = {
460 0x06, 0x41, 0x07, 0x14, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x04, 0x64, 0x61, 0x74, 0x61,
461 0x08, 0x06, 0x53, 0x68, 0x61, 0x32, 0x35, 0x36, 0x14, 0x00, 0x15, 0x00, 0x16, 0x03, 0x1B, 0x01,
462 0x00, 0x17, 0x20, 0xE2, 0xE2, 0x2F, 0x02, 0x70, 0xA7, 0xF7, 0x48, 0x70, 0x45, 0x29, 0x46, 0xBD,
463 0xD2, 0x62, 0x24, 0xA6, 0x1E, 0x1D, 0x75, 0x2A, 0x26, 0x98, 0x04, 0xAD, 0x9C, 0x47, 0x63, 0xF8,
464 0x98, 0x5A, 0x49
465 };
466 std::vector<uint8_t> badSigData = {
Eric Newberryb74bbda2020-06-18 19:33:58 -0700467 0x06, 0xA6, 0x07, 0x14, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x04, 0x64, 0x61, 0x74, 0x61,
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800468 0x08, 0x06, 0x53, 0x68, 0x61, 0x32, 0x35, 0x36, 0x14, 0x00, 0x15, 0x00, 0x16, 0x40, 0x1B, 0x01,
469 0x03, 0x1C, 0x3B, 0x07, 0x39, 0x08, 0x08, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x08,
470 0x17, 0x54, 0x65, 0x73, 0x74, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F,
471 0x6E, 0x48, 0x65, 0x6C, 0x70, 0x65, 0x72, 0x73, 0x08, 0x05, 0x57, 0x72, 0x6F, 0x6E, 0x67, 0x08,
Eric Newberryb74bbda2020-06-18 19:33:58 -0700472 0x03, 0x4B, 0x45, 0x59, 0x08, 0x08, 0xF3, 0xD0, 0x1A, 0x45, 0x87, 0x5D, 0x6E, 0x43, 0x17, 0x48,
473 0x30, 0x46, 0x02, 0x21, 0x00, 0xF0, 0x72, 0x9A, 0x68, 0x36, 0xC5, 0xAA, 0x9D, 0x75, 0x03, 0x36,
474 0xDA, 0xAA, 0x80, 0x0C, 0x29, 0xEE, 0xC9, 0x48, 0x95, 0xA2, 0xEC, 0xAB, 0x78, 0x28, 0x3B, 0x9D,
475 0x28, 0x19, 0x6C, 0x5C, 0xD6, 0x02, 0x21, 0x00, 0xF0, 0xD2, 0x23, 0xEA, 0xD9, 0x43, 0x6D, 0x8A,
476 0xD2, 0x02, 0x3F, 0xF1, 0x41, 0x12, 0xA6, 0xED, 0x87, 0xB3, 0xD5, 0x5A, 0x27, 0x5D, 0x4E, 0xEB,
477 0x13, 0x29, 0x01, 0xBC, 0x3C, 0xCC, 0x50, 0x61
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800478 };
479 std::vector<uint8_t> goodInterest = {
Eric Newberryb74bbda2020-06-18 19:33:58 -0700480 0x05, 0x6B, 0x07, 0x3A, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x08, 0x69, 0x6E, 0x74, 0x65,
481 0x72, 0x65, 0x73, 0x74, 0x08, 0x06, 0x53, 0x68, 0x61, 0x32, 0x35, 0x36, 0x02, 0x20, 0x8F, 0x03,
482 0x0B, 0x85, 0xA7, 0x05, 0xD8, 0x05, 0x31, 0x8E, 0x80, 0x81, 0xD3, 0xE2, 0xA8, 0x5E, 0x74, 0xD7,
483 0x4F, 0x3A, 0xDC, 0xFF, 0x9C, 0x44, 0xF6, 0xA1, 0xC6, 0x6B, 0x97, 0x99, 0x8E, 0xDA, 0x0A, 0x04,
484 0xF7, 0x2C, 0x8A, 0x4B, 0x24, 0x00, 0x2C, 0x03, 0x1B, 0x01, 0x00, 0x2E, 0x20, 0xEF, 0x45, 0x55,
485 0x75, 0xC8, 0x18, 0x5E, 0xE9, 0x2A, 0xAE, 0x52, 0x61, 0x0A, 0x94, 0x41, 0x03, 0x36, 0x4C, 0x13,
486 0x59, 0xD4, 0xC7, 0xA4, 0x3A, 0xA0, 0x40, 0x61, 0x44, 0x33, 0x93, 0x5E, 0x99
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800487 };
488 std::vector<uint8_t> badSigInterest = {
Eric Newberryb74bbda2020-06-18 19:33:58 -0700489 0x05, 0xCE, 0x07, 0x3A, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x08, 0x69, 0x6E, 0x74, 0x65,
490 0x72, 0x65, 0x73, 0x74, 0x08, 0x06, 0x53, 0x68, 0x61, 0x32, 0x35, 0x36, 0x02, 0x20, 0x32, 0x3F,
491 0x2F, 0xA3, 0xDC, 0x15, 0x7E, 0x8C, 0xA9, 0x75, 0xF7, 0x66, 0xFF, 0xFD, 0x13, 0x42, 0x1B, 0xE1,
492 0x3A, 0x27, 0xDD, 0xE4, 0x98, 0x42, 0x77, 0xFA, 0xAD, 0x8F, 0x3E, 0x91, 0x75, 0xF9, 0x0A, 0x04,
493 0xF7, 0x2C, 0x8A, 0x4B, 0x24, 0x00, 0x2C, 0x40, 0x1B, 0x01, 0x03, 0x1C, 0x3B, 0x07, 0x39, 0x08,
494 0x08, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x08, 0x17, 0x54, 0x65, 0x73, 0x74, 0x56,
495 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x48, 0x65, 0x6C, 0x70, 0x65,
496 0x72, 0x73, 0x08, 0x05, 0x57, 0x72, 0x6F, 0x6E, 0x67, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x08,
497 0xF3, 0xD0, 0x1A, 0x45, 0x87, 0x5D, 0x6E, 0x43, 0x2E, 0x46, 0x30, 0x44, 0x02, 0x20, 0x0C, 0xA0,
498 0x6F, 0x90, 0xEF, 0x5E, 0x04, 0x15, 0xAF, 0x94, 0x8E, 0x33, 0x12, 0x1F, 0xF9, 0x50, 0xDD, 0x49,
499 0x73, 0xB3, 0xA6, 0xD2, 0x99, 0x32, 0x26, 0xE2, 0x46, 0x3A, 0xE0, 0x69, 0xDF, 0xB2, 0x02, 0x20,
500 0x6A, 0x03, 0xCE, 0xB6, 0x85, 0x1E, 0x01, 0x5E, 0xF8, 0x48, 0xDE, 0x65, 0xB9, 0xE1, 0xEB, 0x9A,
501 0xF8, 0x47, 0x43, 0x5B, 0xBA, 0x63, 0xCB, 0xBA, 0xFB, 0x62, 0x1C, 0x38, 0xE8, 0x53, 0xF7, 0x29
502 };
503 std::vector<uint8_t> goodInterestOldFormat = {
504 0x05, 0x6B, 0x07, 0x3A, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x08, 0x69, 0x6E, 0x74, 0x65,
505 0x72, 0x65, 0x73, 0x74, 0x08, 0x06, 0x53, 0x68, 0x61, 0x32, 0x35, 0x36, 0x02, 0x20, 0x8F, 0x03,
506 0x0B, 0x85, 0xA7, 0x05, 0xD8, 0x05, 0x31, 0x8E, 0x80, 0x81, 0xD3, 0xE2, 0xA8, 0x5E, 0x74, 0xD7,
507 0x4F, 0x3A, 0xDC, 0xFF, 0x9C, 0x44, 0xF6, 0xA1, 0xC6, 0x6B, 0x97, 0x99, 0x8E, 0xDA, 0x0A, 0x04,
508 0xF7, 0x2C, 0x8A, 0x4B, 0x24, 0x00, 0x2C, 0x03, 0x1B, 0x01, 0x00, 0x2E, 0x20, 0xEF, 0x45, 0x55,
509 0x75, 0xC8, 0x18, 0x5E, 0xE9, 0x2A, 0xAE, 0x52, 0x61, 0x0A, 0x94, 0x41, 0x03, 0x36, 0x4C, 0x13,
510 0x59, 0xD4, 0xC7, 0xA4, 0x3A, 0xA0, 0x40, 0x61, 0x44, 0x33, 0x93, 0x5E, 0x99
511 };
512 std::vector<uint8_t> badSigInterestOldFormat = {
513 0x05, 0xFA, 0x07, 0xC9, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x08, 0x69, 0x6E, 0x74, 0x65,
514 0x72, 0x65, 0x73, 0x74, 0x08, 0x06, 0x53, 0x68, 0x61, 0x32, 0x35, 0x36, 0x02, 0x20, 0x8F, 0x03,
515 0x0B, 0x85, 0xA7, 0x05, 0xD8, 0x05, 0x31, 0x8E, 0x80, 0x81, 0xD3, 0xE2, 0xA8, 0x5E, 0x74, 0xD7,
516 0x4F, 0x3A, 0xDC, 0xFF, 0x9C, 0x44, 0xF6, 0xA1, 0xC6, 0x6B, 0x97, 0x99, 0x8E, 0xDA, 0x08, 0x42,
517 0x16, 0x40, 0x1B, 0x01, 0x03, 0x1C, 0x3B, 0x07, 0x39, 0x08, 0x08, 0x53, 0x65, 0x63, 0x75, 0x72,
518 0x69, 0x74, 0x79, 0x08, 0x17, 0x54, 0x65, 0x73, 0x74, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63,
519 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x48, 0x65, 0x6C, 0x70, 0x65, 0x72, 0x73, 0x08, 0x05, 0x57, 0x72,
520 0x6F, 0x6E, 0x67, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x08, 0xF3, 0xD0, 0x1A, 0x45, 0x87, 0x5D,
521 0x6E, 0x43, 0x08, 0x49, 0x17, 0x47, 0x30, 0x45, 0x02, 0x21, 0x00, 0xB3, 0x30, 0x0A, 0x93, 0x16,
522 0x16, 0xBB, 0xD0, 0x3C, 0x73, 0x01, 0xED, 0x0D, 0x40, 0xEE, 0x28, 0x69, 0xA6, 0xAA, 0xF0, 0x34,
523 0x44, 0xBD, 0x7E, 0x1F, 0xBF, 0x6D, 0x7C, 0x52, 0xA1, 0x85, 0x1D, 0x02, 0x20, 0x3F, 0x18, 0x66,
524 0x48, 0xC9, 0x0F, 0x5B, 0x18, 0xB0, 0xD0, 0x45, 0xDE, 0x93, 0xA6, 0x21, 0xA0, 0xDC, 0x7E, 0x47,
525 0x3A, 0x61, 0x56, 0xD2, 0xAE, 0x70, 0x8D, 0xE8, 0xD5, 0xB7, 0xD0, 0x12, 0x35, 0x0A, 0x04, 0xF7,
526 0x2C, 0x8A, 0x4B, 0x24, 0x00, 0x2C, 0x03, 0x1B, 0x01, 0x00, 0x2E, 0x20, 0xEF, 0x45, 0x55, 0x75,
527 0xC8, 0x18, 0x5E, 0xE9, 0x2A, 0xAE, 0x52, 0x61, 0x0A, 0x94, 0x41, 0x03, 0x36, 0x4C, 0x13, 0x59,
528 0xD4, 0xC7, 0xA4, 0x3A, 0xA0, 0x40, 0x61, 0x44, 0x33, 0x93, 0x5E, 0x99
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800529 };
530};
531
532// Note about the datasets:
533// - .cert a valid certificate
Eric Newberryb74bbda2020-06-18 19:33:58 -0700534// - .goodData is a Data packet that can be verified against .cert
535// - .badSigData a valid and signed Data packet that cannot be verified against cert (signed using
536// a different private key)
537// - .goodInterest is an Interest packet that can be verified against .cert
538// - .badSigInterest is a valid and signed Interest packet that cannot be verified against .cert
539// (signed using a different private key)
540// - .goodInterestOldFormat is an Interest packet that can be verified against .cert (in the old
541// signed Interest format)
542// - .badSigInterestOldFormat is a valid and signed Interest packet that cannot be verified against
543// .cert (signed using a different private key and in the old signed Interest format)
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800544
Davide Pesavento77d9e812019-06-03 22:05:54 -0400545using SignatureDatasets = boost::mpl::vector<EcdsaDataset, RsaDataset>;
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800546
547BOOST_AUTO_TEST_CASE_TEMPLATE(VerifySignature, Dataset, SignatureDatasets)
548{
549 Dataset dataset;
550 v2::Certificate cert(Block(dataset.cert.data(), dataset.cert.size()));
551 Buffer keyRaw = cert.getPublicKey();
Davide Pesavento77d9e812019-06-03 22:05:54 -0400552 transform::PublicKey key;
Davide Pesavento5d0b0102017-10-07 13:43:16 -0400553 key.loadPkcs8(keyRaw.data(), keyRaw.size());
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800554 Data data(Block(dataset.goodData.data(), dataset.goodData.size()));
555 Data badSigData(Block(dataset.badSigData.data(), dataset.badSigData.size()));
556 Interest interest(Block(dataset.goodInterest.data(), dataset.goodInterest.size()));
557 Interest badSigInterest(Block(dataset.badSigInterest.data(), dataset.badSigInterest.size()));
Eric Newberryb74bbda2020-06-18 19:33:58 -0700558 Interest interestOldFormat(Block(dataset.goodInterestOldFormat.data(),
559 dataset.goodInterestOldFormat.size()));
560 Interest badSigInterestOldFormat(Block(dataset.badSigInterestOldFormat.data(),
561 dataset.badSigInterestOldFormat.size()));
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800562
563 BOOST_CHECK(verifySignature(data, key));
Davide Pesavento5d0b0102017-10-07 13:43:16 -0400564 BOOST_CHECK(verifySignature(data, keyRaw.data(), keyRaw.size()));
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800565 BOOST_CHECK(verifySignature(data, cert));
566 BOOST_CHECK(verifySignature(interest, key));
Davide Pesavento5d0b0102017-10-07 13:43:16 -0400567 BOOST_CHECK(verifySignature(interest, keyRaw.data(), keyRaw.size()));
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800568 BOOST_CHECK(verifySignature(interest, cert));
Eric Newberryb74bbda2020-06-18 19:33:58 -0700569 BOOST_CHECK(verifySignature(interestOldFormat, key));
570 BOOST_CHECK(verifySignature(interestOldFormat, keyRaw.data(), keyRaw.size()));
571 BOOST_CHECK(verifySignature(interestOldFormat, cert));
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800572
573 BOOST_CHECK(!verifySignature(badSigData, key));
Davide Pesavento5d0b0102017-10-07 13:43:16 -0400574 BOOST_CHECK(!verifySignature(badSigData, keyRaw.data(), keyRaw.size()));
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800575 BOOST_CHECK(!verifySignature(badSigData, cert));
576 BOOST_CHECK(!verifySignature(badSigInterest, key));
Davide Pesavento5d0b0102017-10-07 13:43:16 -0400577 BOOST_CHECK(!verifySignature(badSigInterest, keyRaw.data(), keyRaw.size()));
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800578 BOOST_CHECK(!verifySignature(badSigInterest, cert));
Eric Newberryb74bbda2020-06-18 19:33:58 -0700579 BOOST_CHECK(!verifySignature(badSigInterestOldFormat, key));
580 BOOST_CHECK(!verifySignature(badSigInterestOldFormat, keyRaw.data(), keyRaw.size()));
581 BOOST_CHECK(!verifySignature(badSigInterestOldFormat, cert));
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800582
583 Data unsignedData("/some/data");
584 Interest unsignedInterest1("/some/interest/with/several/name/components");
Eric Newberryb74bbda2020-06-18 19:33:58 -0700585 unsignedInterest1.setCanBePrefix(false);
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800586 Interest unsignedInterest2("/interest-with-one-name-component");
Eric Newberryb74bbda2020-06-18 19:33:58 -0700587 unsignedInterest2.setCanBePrefix(false);
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800588
589 BOOST_CHECK(!verifySignature(unsignedData, cert));
590 BOOST_CHECK(!verifySignature(unsignedData, key));
591 BOOST_CHECK(!verifySignature(unsignedInterest1, cert));
592 BOOST_CHECK(!verifySignature(unsignedInterest1, key));
593 BOOST_CHECK(!verifySignature(unsignedInterest2, cert));
594 BOOST_CHECK(!verifySignature(unsignedInterest2, key));
595
596 uint8_t invalidKey[] = {0x00, 0x00};
597 BOOST_CHECK(!verifySignature(unsignedData, invalidKey, sizeof(invalidKey)));
598 BOOST_CHECK(!verifySignature(unsignedInterest1, invalidKey, sizeof(invalidKey)));
599
600 // - base version of verifySignature is tested transitively
Alexander Afanasyev09236c22020-06-03 13:42:38 -0400601 // - pib::Key version is tested as part of key-chain.t.cpp (Security/TestKeyChain)
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800602}
603
laqinfanbc997e52019-06-25 22:11:09 -0500604BOOST_FIXTURE_TEST_CASE(VerifyHmac, IdentityManagementFixture)
605{
606 const Tpm& tpm = m_keyChain.getTpm();
607 Data data("/data");
608 Interest interest("/interest");
Eric Newberryb74bbda2020-06-18 19:33:58 -0700609 interest.setCanBePrefix(false);
610 Interest interestOldFormat("/interest");
611 interestOldFormat.setCanBePrefix(false);
laqinfanbc997e52019-06-25 22:11:09 -0500612 SigningInfo signingInfo;
613 signingInfo.setSigningHmacKey("QjM3NEEyNkE3MTQ5MDQzN0FBMDI0RTRGQURENUI0OTdGREZGMUE4RUE2RkYxMkY2"
614 "RkI2NUFGMjcyMEI1OUNDRg==");
615 signingInfo.setDigestAlgorithm(DigestAlgorithm::SHA256);
616
617 BOOST_CHECK(!verifySignature(data, tpm, signingInfo.getSignerName(), DigestAlgorithm::SHA256));
618 BOOST_CHECK(!verifySignature(interest, tpm, signingInfo.getSignerName(), DigestAlgorithm::SHA256));
619
620 m_keyChain.sign(data, signingInfo);
Eric Newberryb74bbda2020-06-18 19:33:58 -0700621 signingInfo.setSignedInterestFormat(SignedInterestFormat::V03);
laqinfanbc997e52019-06-25 22:11:09 -0500622 m_keyChain.sign(interest, signingInfo);
Eric Newberryb74bbda2020-06-18 19:33:58 -0700623 signingInfo.setSignedInterestFormat(SignedInterestFormat::V02);
624 m_keyChain.sign(interestOldFormat, signingInfo);
laqinfanbc997e52019-06-25 22:11:09 -0500625 BOOST_CHECK(verifySignature(data, tpm, signingInfo.getSignerName(), DigestAlgorithm::SHA256));
626 BOOST_CHECK(verifySignature(interest, tpm, signingInfo.getSignerName(), DigestAlgorithm::SHA256));
Eric Newberryb74bbda2020-06-18 19:33:58 -0700627 BOOST_CHECK(verifySignature(interestOldFormat, tpm, signingInfo.getSignerName(), DigestAlgorithm::SHA256));
laqinfanbc997e52019-06-25 22:11:09 -0500628}
629
Davide Pesavento77d9e812019-06-03 22:05:54 -0400630using DigestDatasets = boost::mpl::vector<Sha256Dataset>;
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800631
632BOOST_AUTO_TEST_CASE_TEMPLATE(VerifyDigest, Dataset, DigestDatasets)
633{
634 Dataset dataset;
635 Data data(Block(dataset.goodData.data(), dataset.goodData.size()));
636 Data badSigData(Block(dataset.badSigData.data(), dataset.badSigData.size()));
637 Interest interest(Block(dataset.goodInterest.data(), dataset.goodInterest.size()));
638 Interest badSigInterest(Block(dataset.badSigInterest.data(), dataset.badSigInterest.size()));
Eric Newberryb74bbda2020-06-18 19:33:58 -0700639 Interest interestOldFormat(Block(dataset.goodInterestOldFormat.data(),
640 dataset.goodInterestOldFormat.size()));
641 Interest badSigInterestOldFormat(Block(dataset.badSigInterestOldFormat.data(),
642 dataset.badSigInterestOldFormat.size()));
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800643
644 BOOST_CHECK(verifyDigest(data, DigestAlgorithm::SHA256));
645 BOOST_CHECK(verifyDigest(interest, DigestAlgorithm::SHA256));
Eric Newberryb74bbda2020-06-18 19:33:58 -0700646 BOOST_CHECK(verifyDigest(interestOldFormat, DigestAlgorithm::SHA256));
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800647
648 BOOST_CHECK(!verifyDigest(badSigData, DigestAlgorithm::SHA256));
649 BOOST_CHECK(!verifyDigest(badSigInterest, DigestAlgorithm::SHA256));
Eric Newberryb74bbda2020-06-18 19:33:58 -0700650 BOOST_CHECK(!verifyDigest(badSigInterestOldFormat, DigestAlgorithm::SHA256));
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800651
652 Data unsignedData("/some/data");
653 Interest unsignedInterest1("/some/interest/with/several/name/components");
Eric Newberryb74bbda2020-06-18 19:33:58 -0700654 unsignedInterest1.setCanBePrefix(false);
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800655 Interest unsignedInterest2("/interest-with-one-name-component");
Eric Newberryb74bbda2020-06-18 19:33:58 -0700656 unsignedInterest2.setCanBePrefix(false);
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800657
658 BOOST_CHECK(!verifyDigest(unsignedData, DigestAlgorithm::SHA256));
659 BOOST_CHECK(!verifyDigest(unsignedInterest1, DigestAlgorithm::SHA256));
660 BOOST_CHECK(!verifyDigest(unsignedInterest2, DigestAlgorithm::SHA256));
661
662 // - base version of verifyDigest is tested transitively
663}
664
Eric Newberrye36aae12020-08-31 22:23:13 -0700665const uint8_t sha256DataUnrecognizedElements[] = {
666 0x06, 0x47, 0x07, 0x14, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x04, 0x64, 0x61, 0x74, 0x61,
667 0x08, 0x06, 0x53, 0x68, 0x61, 0x32, 0x35, 0x36, 0x14, 0x00, 0x15, 0x00, 0x16, 0x03, 0x1B, 0x01,
668 0x00, 0x17, 0x20, 0xE2, 0xE2, 0x2F, 0x02, 0x70, 0xA7, 0xF7, 0x48, 0x70, 0x45, 0x29, 0x46, 0xBD,
669 0xD2, 0x62, 0x24, 0xA6, 0x1E, 0x1D, 0x75, 0x2A, 0x26, 0x98, 0x04, 0xAD, 0x9C, 0x47, 0x63, 0xF8,
670 0x98, 0x5A, 0x49, 0xAA, 0x04, 0x01, 0x02, 0x03, 0x04
671};
672
673const uint8_t sha256InterestUnrecognizedElements[] = {
674 0x05, 0x71, 0x07, 0x3A, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x08, 0x69, 0x6E, 0x74, 0x65,
675 0x72, 0x65, 0x73, 0x74, 0x08, 0x06, 0x53, 0x68, 0x61, 0x32, 0x35, 0x36, 0x02, 0x20, 0x9A, 0x55,
676 0xC0, 0xB5, 0x36, 0xC6, 0x6C, 0x0E, 0x11, 0x41, 0xAF, 0xA5, 0x7F, 0x0B, 0x45, 0x53, 0x3D, 0xEE,
677 0x40, 0x1B, 0x9B, 0xAF, 0xEA, 0xBF, 0x3D, 0x56, 0x89, 0x12, 0xE0, 0x18, 0x98, 0x26, 0x0A, 0x04,
678 0xF7, 0x2C, 0x8A, 0x4B, 0x24, 0x00, 0x2C, 0x03, 0x1B, 0x01, 0x00, 0x2E, 0x20, 0xEF, 0x45, 0x55,
679 0x75, 0xC8, 0x18, 0x5E, 0xE9, 0x2A, 0xAE, 0x52, 0x61, 0x0A, 0x94, 0x41, 0x03, 0x36, 0x4C, 0x13,
680 0x59, 0xD4, 0xC7, 0xA4, 0x3A, 0xA0, 0x40, 0x61, 0x44, 0x33, 0x93, 0x5E, 0x99, 0xAA, 0x04, 0x01,
681 0x02, 0x03, 0x04
682};
683
684BOOST_AUTO_TEST_CASE(VerifyWithUnrecognizedElements) // Bug #4583
685{
686 Data data(Block(sha256DataUnrecognizedElements, sizeof(sha256DataUnrecognizedElements)));
687 Interest interest(Block(sha256InterestUnrecognizedElements, sizeof(sha256InterestUnrecognizedElements)));
688
689 BOOST_CHECK(verifyDigest(data, DigestAlgorithm::SHA256));
690 BOOST_CHECK(verifyDigest(interest, DigestAlgorithm::SHA256));
691}
692
Alexander Afanasyev574aa862017-01-10 19:53:28 -0800693BOOST_AUTO_TEST_SUITE_END() // TestVerificationHelpers
694BOOST_AUTO_TEST_SUITE_END() // Security
695
696} // namespace tests
697} // namespace security
698} // namespace ndn