29 : m_keyChain(keyChain)
30 , m_lastUsedSeqNum(-1)
40 NDN_THROW(std::invalid_argument(
"No signature elements specified"));
44 std::vector<uint8_t> nonce(8);
50 info.setTime(getFreshTimestamp());
54 info.setSeqNum(++m_lastUsedSeqNum);
59 m_keyChain.
sign(interest, params);
73 m_keyChain.
sign(interest, params);
78 InterestSigner::getFreshTimestamp()
81 if (time::duration_cast<time::milliseconds>(timestamp - m_lastUsedTimestamp) > 0_ms) {
82 m_lastUsedTimestamp = timestamp;
85 m_lastUsedTimestamp = m_lastUsedTimestamp + 1_ms;
86 timestamp = m_lastUsedTimestamp;
Represents an Interest packet.
Interest & setCanBePrefix(bool canBePrefix)
Add or remove CanBePrefix element.
Interest & setName(const Name &name)
Set the Interest's name.
Represents an absolute name.
Name & append(const Component &component)
Append a component.
Represents a SignatureInfo or InterestSignatureInfo TLV element.
static Component fromNumber(uint64_t number, uint32_t type=tlv::GenericNameComponent)
Create a component encoded as NonNegativeInteger.
InterestSigner(KeyChain &keyChain)
Interest makeCommandInterest(Name name, const SigningInfo ¶ms=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.
SigningInfo & setSignedInterestFormat(SignedInterestFormat signedInterestFormat)
Set signed Interest format.
SigningInfo & setSignatureInfo(const SignatureInfo &signatureInfo)
Set a semi-prepared SignatureInfo.
const SignatureInfo & getSignatureInfo() const
The interface of signing key management.
void sign(Data &data, const SigningInfo ¶ms=SigningInfo())
Sign a Data packet according to the supplied signing information.
static time_point now() noexcept
void generateSecureBytes(span< uint8_t > buf)
Fill buffer with cryptographically secure random bytes.
uint64_t generateWord64()
Generate a non-cryptographically-secure random integer in the range [0, 2^64)
@ V03
Sign Interest using Packet Specification v0.3 semantics.
milliseconds toUnixTimestamp(const system_clock::time_point &point)
Convert system_clock::time_point to UNIX timestamp.
boost::chrono::milliseconds milliseconds