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