Alexander Afanasyev | fde570c | 2016-12-19 16:02:55 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Yumin Xia | 2c509c2 | 2017-02-09 14:37:36 -0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2014-2017, Regents of the University of California. |
Alexander Afanasyev | fde570c | 2016-12-19 16:02:55 -0800 | [diff] [blame] | 4 | * |
Yumin Xia | 2c509c2 | 2017-02-09 14:37:36 -0800 | [diff] [blame] | 5 | * This file is part of NDNS (Named Data Networking Domain Name Service). |
Alexander Afanasyev | fde570c | 2016-12-19 16:02:55 -0800 | [diff] [blame] | 6 | * 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 | |
| 24 | namespace ndn { |
| 25 | namespace ndns { |
| 26 | namespace tests { |
| 27 | |
| 28 | shared_ptr<Interest> |
| 29 | makeInterest(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 | |
| 38 | shared_ptr<Data> |
| 39 | makeData(const Name& name) |
| 40 | { |
| 41 | auto data = make_shared<Data>(name); |
| 42 | return signData(data); |
| 43 | } |
| 44 | |
| 45 | Data& |
| 46 | signData(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 Afanasyev | fde570c | 2016-12-19 16:02:55 -0800 | [diff] [blame] | 56 | lp::Nack |
| 57 | makeNack(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 |