93 Error encode(uint8_t* buf,
size_t bufSize,
size_t& encodedLen)
const;
135 const uint8_t*
content()
const {
return content_.data(); }
190 bool isLink()
const {
return contentType_ == ContentType::Link; }
277 const Name*
keyLocator()
const {
return hasKeyLocator_ ? &keyLocator_ :
nullptr; }
352 bool verifyHmac(
const uint8_t* key,
size_t keyLen)
const;
386 Error encodeSignedPortion(uint8_t* buf,
size_t bufSize,
size_t& encodedLen)
const;
389 std::array<uint8_t, DATA_MAX_CONTENT_SIZE> content_{};
390 size_t contentSize_ = 0;
391 ContentType contentType_ = ContentType::Blob;
392 std::optional<uint32_t> freshnessPeriod_;
393 std::optional<uint64_t> finalBlockId_;
394 SignatureType signatureType_ = SignatureType::DigestSha256;
396 bool hasKeyLocator_ =
false;
397 std::array<uint8_t, SIGNATURE_MAX_SIZE> signatureValue_{};
398 size_t signatureSize_ = 0;
Data & setFreshnessPeriod(uint32_t periodMs)
Set the FreshnessPeriod.
Data & setKeyLocator(const Name &name)
Set the KeyLocator.
Data & clearKeyLocator()
Clear the KeyLocator.
Error signWithEcdsa(const uint8_t *privKey)
Sign with ECDSA P-256.
bool isLink() const
Check if this is a Link Object.
const Name & name() const
Get the Name (const reference)
bool hasContent() const
Check if content is set.
Error signWithDigestSha256()
Sign with DigestSha256.
size_t contentSize() const
Get the content size.
bool hasFinalBlockId() const
Check if FinalBlockId is set.
Data & setContentType(ContentType type)
Set the content type.
Data & setFinalBlockId(uint64_t segmentNum)
Set the FinalBlockId.
bool verifyHmac(const uint8_t *key, size_t keyLen) const
Verify an HMAC-SHA256 signature.
const uint8_t * content() const
Get a pointer to the content data.
const uint8_t * signatureValue() const
Get a pointer to the signature value.
bool hasKeyLocator() const
Check if KeyLocator is set.
Name & name()
Get the Name (reference)
Error setContent(const uint8_t *data, size_t size)
Set binary data as content.
std::optional< uint64_t > finalBlockId() const
Get the FinalBlockId.
const Name * keyLocator() const
Get the KeyLocator.
bool verifyDigestSha256() const
Verify a DigestSha256 signature.
std::optional< uint32_t > freshnessPeriod() const
Get the FreshnessPeriod.
Error encode(uint8_t *buf, size_t bufSize, size_t &encodedLen) const
Encode the Data packet to TLV wire format.
Data & clearFinalBlockId()
Clear the FinalBlockId.
Data & setSignatureType(SignatureType type)
Set the signature type.
size_t signatureValueSize() const
Get the size of the signature value.
SignatureType signatureType() const
Get the signature type.
bool verifyEcdsa(const uint8_t *pubKey) const
Verify an ECDSA P-256 signature.
ContentType contentType() const
Get the content type.
bool hasSignature() const
Check if a signature is set.
static Result< Data > fromWire(const uint8_t *buf, size_t len)
Decode a Data packet from TLV wire format.
Data()=default
Default constructor.
Data & setName(const Name &name)
Set the Name (supports method chaining)
Error signWithHmac(const uint8_t *key, size_t keyLen)
Sign with HMAC-SHA256.
Common definitions for the NDN protocol stack.
NDN signature types and constants.
SignatureType
Signature type.