ndn-protocol
Implements the core Named Data Networking (NDN) packet types -- names, Interests, Data, and signatures -- on top of ndn-tlv.
It gives you typed, spec-compliant packet construction, signing, and verification.
Installation
cargo add ndn-protocol
Example
use Bytes;
use ;
How it works
- Names (
Name) are hierarchical and built from typedNameComponents -- a plain segment, a version number, an embedded digest, and so on -- so components can't be constructed from the wrong kind of data. Parse one from a URI withName::from_str, or build one component by component. - Interests and Data (
Interest,Data) are the two packet types NDN's request/response exchange is built from. Both are generic over their payload type, so application data is encoded and decoded through the sameTlvEncode/TlvDecodetraits used everywhere else in the stack, instead of forcing callers to work with raw bytes. - Signing and verification go through the
SignMethodandSignatureVerifiertraits, implemented byDigestSha256(a plain digest, proving only that a packet wasn't corrupted in transit) andSignatureSha256WithRsa(RSA over SHA-256, for real authentication). The same traits are used on the consuming side, so verifying an incoming Data or Interest looks the same regardless of which scheme signed it. - Certificates (
Certificate,RsaCertificate) are signed Data packets carrying a public key. Load one together with its private key from a.safebagfile exported byndnsecwithRsaCertificate::from_safebag. - Errors are reported through
NdnErrorfor parsing and I/O, and the narrowerSignError/VerifyErrorfor the signing and verification paths specifically.
This crate implements the packet types themselves; it doesn't talk to a forwarder. See ndn-app for that.
Related crates
ndn-appis an application framework for building NDN producers and consumers, built on top of this crate plusndn-ndnlpandndn-nfd-mgmt.ndn-tlvprovides the TLV encoding/decoding traits this crate's packet types are built on.ndn-ndnlpimplements NDNLPv2, the link-layer protocol used to send these packets over a transport.ndn-nfd-mgmtimplements the NFD management protocol, used e.g. to register routes with a local forwarder.
License
MIT
Produced as part of a Master's thesis in Computer Science.