Module sqlite_pib

Module sqlite_pib 

Source
Expand description

SQLite-backed Public Info Base (PIB), wire-compatible with ndn-cxx’s pib-sqlite3 backend.

§Compatibility

An ndn-rs binary using SqlitePib should be able to open a pib.db created by ndnsec (the ndn-cxx CLI) and operate on it without corruption, and vice versa. To make that work, this module replicates the ndn-cxx schema bit-for-bit — same tables, same indexes, same triggers, same column types, same wireEncode()-based name storage. Diverging from the schema in any way (adding PRAGMA user_version, storing names as URI strings, omitting a trigger, …) would silently make the resulting database incompatible.

Pinned to ndn-cxx tag ndn-cxx-0.9.0, commit 0751bba88021b745c1a0ab7198efd279756c9a3c, file ndn-cxx/security/pib/impl/pib-sqlite3.cpp lines 33–186 (DB_INIT).

§Storage conventions (MUST match ndn-cxx)

  • Default DB path: $HOME/.ndn/pib.db (with TEST_HOME and CWD fallbacks; see SqlitePib::open_default).
  • All Name columns hold the TLV wire encoding of the Name (outer type 0x07 + length + components), not URI strings.
  • The key_bits column holds raw public-key bytes — for ndn-cxx-issued keys, this is a DER-encoded SubjectPublicKeyInfo.
  • The certificate_data column holds the full Data-packet wire encoding of the certificate.
  • tpm_locator is stored as a UTF-8 string in a BLOB column.
  • PRAGMA foreign_keys=ON is set at every connection open. Without it the ON DELETE CASCADE rules become no-ops, leaking orphan rows that ndnsec will then trip over.
  • Default-row invariants are maintained by triggers, not by Rust code. add_* calls just INSERT and let the triggers do the rest. Mutating a row’s is_default is also delegated.

Structs§

SqlitePib
SQLite-backed PIB, wire-compatible with ndn-cxx pib-sqlite3.