NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
command-interest-signer.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
23 #include "../util/random.hpp"
24 
25 namespace ndn {
26 namespace security {
27 
29  : m_lastUsedTimestamp(0)
30 {
31 }
32 
33 Name
35 {
37  if (timestamp <= m_lastUsedTimestamp) {
38  timestamp = m_lastUsedTimestamp + time::milliseconds(1);
39  }
40  m_lastUsedTimestamp = timestamp;
41 
42  name
43  .append(name::Component::fromNumber(timestamp.count()))
45  ;
46 
47  return name;
48 }
49 
51  : m_keyChain(keyChain)
52 {
53 }
54 
57 {
58  Interest commandInterest(prepareCommandInterestName(name));
59  m_keyChain.sign(commandInterest, params);
60  return commandInterest;
61 }
62 
63 } // namespace security
64 } // namespace ndn
static Component fromNumber(uint64_t number)
Create a component encoded as nonNegativeInteger.
Copyright (c) 2011-2015 Regents of the University of California.
boost::posix_time::time_duration milliseconds(long duration)
Definition: asio.hpp:117
represents an Interest packet
Definition: interest.hpp:42
Name prepareCommandInterestName(Name name)
Prepare name of the CommandInterest.
static time_point now() noexcept
Definition: time.cpp:46
Name & append(const Component &component)
Append a component.
Definition: name.hpp:256
Signing parameters passed to KeyChain.
Catch-all error for security policy errors that don&#39;t fit in other categories.
Definition: base.hpp:79
Interest makeCommandInterest(const Name &name, const SigningInfo &params=KeyChain::getDefaultSigningInfo())
Create CommandInterest.
Represents an absolute name.
Definition: name.hpp:42
uint64_t generateWord64()
Generate a non-cryptographically-secure random integer in the range [0, 2^64)
Definition: random.cpp:70
milliseconds toUnixTimestamp(const system_clock::TimePoint &point)
Convert system_clock::TimePoint to UNIX timestamp.
Definition: time.cpp:119
ndn security v2 KeyChain
Definition: key-chain.cpp:76