blob: 13c05d32eac4398062c7cd686221c8b9bdd3d030 [file] [log] [blame]
Alexander Afanasyev49e2e4c2017-05-06 13:42:57 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014-2017, Regents of the University of California
4 *
5 * This file is part of NDN DeLorean, An Authentication System for Data Archives in
6 * Named Data Networking. See AUTHORS.md for complete list of NDN DeLorean authors
7 * and contributors.
8 *
9 * NDN DeLorean is free software: you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option) any later
12 * version.
13 *
14 * NDN DeLorean is distributed in the hope that it will be useful, but WITHOUT ANY
15 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
16 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along with NDN
19 * DeLorean, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#include "test-common.hpp"
23
24#include <ndn-cxx/security/signature-sha256-with-rsa.hpp>
25
26namespace ndn {
27namespace delorean {
28namespace tests {
29
30shared_ptr<Interest>
31makeInterest(const Name& name, uint32_t nonce)
32{
33 auto interest = make_shared<Interest>(name);
34 if (nonce != 0) {
35 interest->setNonce(nonce);
36 }
37 return interest;
38}
39
40shared_ptr<Data>
41makeData(const Name& name)
42{
43 auto data = make_shared<Data>(name);
44 return signData(data);
45}
46
47Data&
48signData(Data& data)
49{
50 ndn::SignatureSha256WithRsa fakeSignature;
51 fakeSignature.setValue(ndn::encoding::makeEmptyBlock(tlv::SignatureValue));
52 data.setSignature(fakeSignature);
53 data.wireEncode();
54
55 return data;
56}
57
58shared_ptr<Link>
59makeLink(const Name& name, std::initializer_list<std::pair<uint32_t, Name>> delegations)
60{
61 auto link = make_shared<Link>(name, delegations);
62 signData(link);
63 return link;
64}
65
66lp::Nack
67makeNack(const Name& name, uint32_t nonce, lp::NackReason reason)
68{
69 Interest interest(name);
70 interest.setNonce(nonce);
71 lp::Nack nack(std::move(interest));
72 nack.setReason(reason);
73 return nack;
74}
75
76} // namespace tests
77} // namespace delorean
78} // namespace ndn