94 Error encode(uint8_t* buf,
size_t bufSize,
size_t& encodedLen)
const;
139 std::optional<uint32_t>
nonce()
const {
return nonce_; }
189 std::optional<uint8_t>
hopLimit()
const {
return hopLimit_; }
308 return appParamsLen_ > 0 ? appParams_ :
nullptr;
337 bool isSigned()
const {
return signatureSize_ > 0; }
352 const uint8_t*
signatureNonce()
const {
return hasSignatureNonce_ ? signatureNonce_ :
nullptr; }
385 const Name*
keyLocator()
const {
return hasKeyLocator_ ? &keyLocator_ :
nullptr; }
454 bool verifyHmac(
const uint8_t* key,
size_t keyLen)
const;
488 Error encodeSignedPortion(uint8_t* buf,
size_t bufSize,
size_t& encodedLen)
const;
493 void generateSignatureNonce();
512 static constexpr size_t APP_PARAMS_MAX_SIZE = 200;
515 static constexpr size_t SIGNATURE_NONCE_SIZE = 8;
521 std::optional<uint32_t> nonce_;
523 std::optional<uint8_t> hopLimit_;
524 bool canBePrefix_ =
false;
525 bool mustBeFresh_ =
false;
526 std::array<Name, FW_HINT_MAX_COUNT> fwHints_{};
527 size_t fwHintCount_ = 0;
528 uint8_t appParams_[APP_PARAMS_MAX_SIZE] = {};
529 size_t appParamsLen_ = 0;
533 uint8_t signatureNonce_[SIGNATURE_NONCE_SIZE] = {};
534 bool hasSignatureNonce_ =
false;
535 std::optional<uint64_t> signatureTime_;
536 std::optional<uint64_t> signatureSeqNum_;
538 bool hasKeyLocator_ =
false;
539 std::array<uint8_t, SIGNATURE_MAX_SIZE> signatureValue_{};
540 size_t signatureSize_ = 0;
Error signWithDigestSha256()
Sign with DigestSha256.
const uint8_t * signatureNonce() const
Get the signature nonce.
bool verifyHmac(const uint8_t *key, size_t keyLen) const
Verify an HMAC-SHA256 signature.
uint32_t lifetime() const
Get the InterestLifetime.
Interest & setLifetime(uint32_t lifetimeMs)
Set the InterestLifetime.
static Result< Interest > fromWire(const uint8_t *buf, size_t len)
Decode an Interest from TLV wire format.
Interest & setCanBePrefix(bool canBePrefix)
Set the CanBePrefix flag.
bool mustBeFresh() const
Get the MustBeFresh flag.
std::optional< uint8_t > hopLimit() const
Get the HopLimit.
const uint8_t * signatureValue() const
Get a pointer to the signature value.
Error signWithEcdsa(const uint8_t *privKey)
Sign with ECDSA P-256.
Interest & setApplicationParameters(const uint8_t *params, size_t len)
Set ApplicationParameters.
Error addForwardingHint(const Name &name)
Add a ForwardingHint.
Interest & setSignatureSeqNum(uint64_t seqNum)
Set the signature sequence number.
bool canBePrefix() const
Get the CanBePrefix flag.
bool isSigned() const
Check if the Interest is signed.
Interest()=default
Default constructor.
Interest & setMustBeFresh(bool mustBeFresh)
Set the MustBeFresh flag.
Error encode(uint8_t *buf, size_t bufSize, size_t &encodedLen) const
Encode the Interest to TLV wire format.
Name & name()
Get the Name (reference)
const Name * forwardingHint(size_t index) const
Get a ForwardingHint by index.
SignatureType signatureType() const
Get the signature type.
const Name * keyLocator() const
Get the KeyLocator.
size_t signatureValueSize() const
Get the size of the signature value.
size_t applicationParametersSize() const
Get the size of ApplicationParameters.
bool verifyEcdsa(const uint8_t *pubKey) const
Verify an ECDSA P-256 signature.
void clearForwardingHints()
Clear all ForwardingHints.
Interest & setKeyLocator(const Name &name)
Set the KeyLocator.
Interest & setNonce(uint32_t nonce)
Set the Nonce.
bool hasForwardingHint() const
Check if ForwardingHints are set.
Interest & generateNonce()
Generate and set a random Nonce.
const uint8_t * applicationParameters() const
Get the ApplicationParameters.
bool verifyDigestSha256() const
Verify a DigestSha256 signature.
bool hasKeyLocator() const
Check if KeyLocator is set.
Interest & clearKeyLocator()
Clear the KeyLocator.
Interest & setName(const Name &name)
Set the Name (supports method chaining)
std::optional< uint64_t > signatureTime() const
Get the signature time.
std::optional< uint32_t > nonce() const
Get the Nonce.
size_t forwardingHintCount() const
Get the number of ForwardingHints.
Interest & setHopLimit(uint8_t limit)
Set the HopLimit.
Error signWithHmac(const uint8_t *key, size_t keyLen)
Sign with HMAC-SHA256.
const Name & name() const
Get the Name (const reference)
std::optional< uint64_t > signatureSeqNum() const
Get the signature sequence number.
Interest & decrementHopLimit()
Decrement the HopLimit by 1.
Common definitions for the NDN protocol stack.
constexpr uint32_t INTEREST_DEFAULT_LIFETIME_MS
Default Interest lifetime (milliseconds)
constexpr size_t LINK_MAX_DELEGATIONS
Maximum number of Names in a Link.
constexpr uint32_t Name
Name.
NDN signature types and constants.
SignatureType
Signature type.