interest-signer.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2021 Regents of the University of California.
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 
22 #ifndef NDN_CXX_SECURITY_INTEREST_SIGNER_HPP
23 #define NDN_CXX_SECURITY_INTEREST_SIGNER_HPP
24 
26 
27 namespace ndn {
28 namespace security {
29 
36 {
37 public:
43  enum SigningFlags : uint32_t {
44  WantNonce = 1 << 0,
45  WantTime = 1 << 1,
46  WantSeqNum = 1 << 2,
47  };
48 
49 public:
50  explicit
51  InterestSigner(KeyChain& keyChain);
52 
62  void
63  makeSignedInterest(Interest& interest,
64  SigningInfo params = SigningInfo(),
65  uint32_t signingFlags = WantNonce | WantTime);
66 
74  Interest
75  makeCommandInterest(Name name, const SigningInfo& params = SigningInfo());
76 
77 private:
82  getFreshTimestamp();
83 
84 private:
85  KeyChain& m_keyChain;
86  time::system_clock::TimePoint m_lastUsedTimestamp;
87  uint64_t m_lastUsedSeqNum;
88 };
89 
90 } // namespace security
91 } // namespace ndn
92 
93 #endif // NDN_CXX_SECURITY_INTEREST_SIGNER_HPP
Represents an Interest packet.
Definition: interest.hpp:50
Represents an absolute name.
Definition: name.hpp:44
Helper class to create signed Interests.
SigningFlags
Flags to indicate which elements to include in Interest signatures created with makeSignedInterest.
InterestSigner(KeyChain &keyChain)
Interest makeCommandInterest(Name name, const SigningInfo &params=SigningInfo())
Creates and signs a command Interest.
void makeSignedInterest(Interest &interest, SigningInfo params=SigningInfo(), uint32_t signingFlags=WantNonce|WantTime)
Signs an Interest (following Packet Specification v0.3 or newer)
Signing parameters passed to KeyChain.
The main interface for signing key management.
Definition: key-chain.hpp:87
time_point TimePoint
Definition: time.hpp:203
Definition: data.cpp:25