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());
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;
SignatureInfo & setSeqNum(optional< uint64_t > seqNum)
Append or replace SignatureSeqNum.
Sign Interest using Packet Specification v0.3 semantics.
Represents a SignatureInfo or InterestSignatureInfo TLV element.
The interface of signing key management.
const SignatureInfo & getSignatureInfo() const
Interest makeCommandInterest(Name name, const SigningInfo ¶ms=SigningInfo())
Creates and signs a command Interest.
InterestSigner(KeyChain &keyChain)
void sign(Data &data, const SigningInfo ¶ms=SigningInfo())
Sign a Data packet according to the supplied signing information.
Represents an Interest packet.
static time_point now() noexcept
Name & append(const Component &component)
Append a component.
Signing parameters passed to KeyChain.
SignatureInfo & setTime(optional< time::system_clock::time_point > time=time::system_clock::now())
Append or replace SignatureTime.
Represents an absolute name.
SigningInfo & setSignatureInfo(const SignatureInfo &signatureInfo)
Set a semi-prepared SignatureInfo.
uint64_t generateWord64()
Generate a non-cryptographically-secure random integer in the range [0, 2^64)
milliseconds toUnixTimestamp(const system_clock::TimePoint &point)
Convert system_clock::TimePoint to UNIX timestamp.
static Component fromNumber(uint64_t number, uint32_t type=tlv::GenericNameComponent)
Create a component encoded as nonNegativeInteger.
void generateSecureBytes(uint8_t *bytes, size_t size)
Fill bytes of size with cryptographically secure random bytes.
void makeSignedInterest(Interest &interest, SigningInfo params=SigningInfo(), uint32_t signingFlags=WantNonce|WantTime)
Signs an Interest (following Packet Specification v0.3 or newer)
SigningInfo & setSignedInterestFormat(SignedInterestFormat signedInterestFormat)
Set signed Interest format.
SignatureInfo & setNonce(optional< std::vector< uint8_t >> nonce)
Append or replace SignatureNonce.
Interest & setCanBePrefix(bool canBePrefix)
Add or remove CanBePrefix element.
Interest & setName(const Name &name)
Set the Interest's name.