Choose what this site may use

This site uses strictly necessary cookies to work and to remember your privacy choices. With your permission it would also load content hosted by other services, such as videos, maps and fonts, which then receive your network address and device data. We do not sell or share your personal information and we run no advertising. Choose Accept all, Reject all or Customise. You can change your mind at any time through Privacy choices at the foot of every page.

  • Always on

    Needed for the site to work and to remember your privacy choices. Always on.

  • Remembers settings you choose, such as the light or dark display, in your browser.

  • Loads videos, maps and other content hosted by other services. Those services receive your address and device data.

Menu Close
In this section: Build
Start
Reference code
Tools
API reference
Public services
Agents
Bindings and crosswalks

obsp-node-embedded

REFERENCE Source reference/rust/obsp-node-embedded/README.md

On this page
  1. Covers
  2. Does not cover
  3. Tests
  4. Embedded build and size
  5. Layout
FieldValue
StatusReference code written against draft proposals (DRAFT); accepts no proposal; no conformance claim
Version0.0.1
SourceRust reference workspace

A #![no_std] reference of the device and gateway-edge side of the NODE-CONSTRAINED profile (draft proposal OIP-0027, status DRAFT). It makes no conformance claim: the profile, the compact form and the batch rules are drafts, this code has no declared level, and no implementation is listed on the strength of it.

Covers

Module What it does
message Encodes one measurement as a compact device message: deterministic CBOR (RFC 8949 section 4.2.1), keys 1 ctx, 2 property index, 3 value, 4 unit, 5 phenomenon time, 6 result time, 8 uncertainty; integers as integers, floats in preferred form (section 4.2.2); a clockless device leaves the time out. The 40-byte budget (NC-5) is a constant and a unit of more than 8 characters is refused.
outbox A fixed-size ring buffer (SLOTS messages of up to MSG bytes, const generics, no heap) with a wrapping u32 sequence counter and a full-buffer policy: refuse the new message, or drop the oldest and count it.
frame Packs the oldest queued messages into a frame of at most 51, 115 or 222 bytes (the LoRaWAN payload classes named for this slice) and parses a frame on the gateway side. The frame layout (version, count, low 16 bits of the first sequence number, length-prefixed messages) is this crate’s own; OIP-0027 does not define one.
batch Builds an evidence batch: SHA-256 of each message’s exact bytes, the batch digest over the deterministic CBOR array of those digests, the signed payload (the batch map without entries and signature), the COSE_Sign1 (RFC 9052 section 4.2, detached payload, Ed25519 with COSE code point -19, protected header {1: -19, 4: kid}) over Sig_structure (section 4.4), and the compact batch map (CDDL evidence-batch). Gateway-declared times for clockless devices are carried in key 12. The signing key is a caller-supplied 32-byte seed; the crate stores no key.

| orchestrate (feature orchestrate) | Verification only, for a device that receives signed plans: the node decision of the draft OIP-0003 (each of the four TUF roles meets its threshold of distinct root-listed Ed25519 keys over its RFC 8785 payload, root chaining at version + 1 signed by the trusted root’s threshold, plan, root and snapshot expiry, timestamp freeze, snapshot and timestamp consistency, version monotonicity, tasking reserved; codes OBS-PLAN-0001 to -0007 as bits) and the install decision of the OIP-0028 SUIT binding (INSTALL, SKIP or the BND-SUIT ids broken). The caller hands decoded members and the payload bytes as received; Sig_structure is built in a caller buffer. See ../obsp-node/ORCHESTRATE.md. |

Dependencies: ed25519-dalek and sha2, both with default features off. The alloc feature only adds a convenience Measurement::encode_vec; the core never allocates and contains no unsafe.

Does not cover

  • Expansion of a message into an ObservationRecord (NC-3), SenML (NC-6), the CompactContext and join (NC-4). The test harness holds a small expansion to prove the round trip; obsp-core has none, and its CBOR decoder refuses floats, so the harness decodes messages with its own decoder and uses obsp-core only for digests and for the float-free batch.
  • OSCORE and EDHOC (NC-10): no vector exists, and no link security is implemented. Frames here are plain bytes.
  • Verification of a batch signature, key storage, key rotation, a hardware random source, a clock. The device never signs (NC-7); the signing code is for the node that plays gateway.
  • Timestamps other than whole seconds since the epoch, tags and text timestamps, every record field outside the measured-quantity message (quality, geometry, interval times, other result forms).
  • Constant-time or side-channel properties beyond what ed25519-dalek provides, stack depth (not measured), and the LoRaWAN payload limits per region and data rate (checked: not checked against the regional parameters).

Tests

cargo test -p obsp-node-embedded (from reference/rust, or make embedded):

  • tests/vectors.rs reproduces every message in the OIP-0027 messages.json byte for byte (hex, length, digest), the 36-byte worst case, the evidence batch of batch.json (batch digest, signature, tagged COSE_Sign1 and the whole 498-byte compact batch), checks that the signature verifies over the vector’s Sig_structure, expands each message and compares the record with the vector’s expanded, checks the preferred float form for all 65536 half-precision values and 20000 pseudo-random doubles, 2000 random messages against the 40-byte budget, and batches of 1 to 300 entries with worst-case identifiers against 46 N + 480.
  • tests/orchestrate.rs (feature orchestrate) gives the hosted decision’s codes on the 12 OIP-0003 plan vectors copied in ../obsp-node/tests/vectors/oip-0003/, refuses without trusted time or root, counts a repeated signature once, and reproduces the decisions of the SUIT binding’s golden examples (../obsp-node/tests/vectors/oip-0028/).
  • tests/outbox_frame.rs covers ring wrap, both full policies, sequence numbers, frame packing in each class, frame parse faults.
  • tests/vectors/ holds copies of the draft vectors (messages, batch, two contexts), because the live tree does not contain conformance/vectors/compact/ until OIP-0027 is accepted. A test compares each copy with the published file once it exists.

Embedded build and size

make embedded runs the tests and, if the thumbv7em-none-eabihf target is installed (rustup target add thumbv7em-none-eabihf), builds the crate for it (with and without alloc) and links size-probe/, an image holding an outbox of 16 x 40 bytes, a batch of 16 entries, a 512-byte signing scratch and a 222-byte frame buffer, with opt-level = "s" and LTO.

Measured with the Rust 1.97 toolchain, llvm-size, on the probe:

text (flash) data bss flash total (text + data) static RAM (data + bss)
54318 788 2600 55106 bytes 3388 bytes

About 28 KB of the text is the SHA-512 compression function that Ed25519 needs, and about 5 KB the SHA-256 one. Static RAM is the outbox (788), batch (840), scratch (512), output (1024) and frame buffers; stack use during signing is not measured. The figures describe this probe on this toolchain, not a target part.

Layout

src/        cbor, message, outbox, frame, batch
tests/      vectors.rs, outbox_frame.rs, common/ (test decoder and expansion), vectors/ (draft vector copies)
size-probe/ firmware-shaped binary and linker script for the size report (not a workspace member)