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-2024 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::security {
28 
35 {
36 public:
37  explicit
38  InterestSigner(KeyChain& keyChain) noexcept
39  : m_keyChain(keyChain)
40  {
41  }
42 
48  enum SigningFlags : uint32_t {
49  WantNonce = 1 << 0,
50  WantTime = 1 << 1,
51  WantSeqNum = 1 << 2,
52  };
53 
63  void
64  makeSignedInterest(Interest& interest,
65  SigningInfo params = SigningInfo(),
66  uint32_t signingFlags = WantNonce | WantTime);
67 
75  Interest
76  makeCommandInterest(Name name, const SigningInfo& params = SigningInfo());
77 
78 private:
83  getFreshTimestamp();
84 
85 private:
86  KeyChain& m_keyChain;
87  time::system_clock::time_point m_lastUsedTimestamp;
88  uint64_t m_lastUsedSeqNum = static_cast<uint64_t>(-1); // will wrap around to 0 on next Interest
89 };
90 
91 } // namespace ndn::security
92 
93 #endif // NDN_CXX_SECURITY_INTEREST_SIGNER_HPP
Represents an Interest packet.
Definition: interest.hpp:50
Represents an absolute name.
Definition: name.hpp:45
Helper class to create signed Interests.
SigningFlags
Flags to indicate which elements to include in Interest signatures created with makeSignedInterest.
Interest makeCommandInterest(Name name, const SigningInfo &params=SigningInfo())
Creates and signs a command Interest.
InterestSigner(KeyChain &keyChain) noexcept
void makeSignedInterest(Interest &interest, SigningInfo params=SigningInfo(), uint32_t signingFlags=WantNonce|WantTime)
Signs an Interest (following Packet Specification v0.3 or newer)
The main interface for signing key management.
Definition: key-chain.hpp:87
Signing parameters passed to KeyChain.
::boost::chrono::time_point< system_clock > time_point
Definition: time.hpp:205
Contains the ndn-cxx security framework.