Pamoja.Update
0.1.17
dotnet add package Pamoja.Update --version 0.1.17
NuGet\Install-Package Pamoja.Update -Version 0.1.17
<PackageReference Include="Pamoja.Update" Version="0.1.17" />
<PackageVersion Include="Pamoja.Update" Version="0.1.17" />
<PackageReference Include="Pamoja.Update" />
paket add Pamoja.Update --version 0.1.17
#r "nuget: Pamoja.Update, 0.1.17"
#:package Pamoja.Update@0.1.17
#addin nuget:?package=Pamoja.Update&version=0.1.17
#tool nuget:?package=Pamoja.Update&version=0.1.17
Pamoja.Update
Signed firmware manifests, streaming image verification, and A/B slots that fall back on their own. One capability of pamoja, one memory-safe Rust core with bindings for TypeScript, Python, and C#.
Install
dotnet add package Pamoja.Update
using Pamoja.Update;
This pulls in Pamoja.Native, the compiled engine, and Pamoja.Codec and Pamoja.Security. dotnet add package Pamoja is the whole framework in one package.
Example
The guide project's example, spliced here as it ran in CI.
From bindings/dotnet/samples/Pamoja.Guides/UpdateGuide.cs:
// The publisher's key signs releases; devices in the field are anchored to its
// public half and will take firmware from nobody else.
byte[] seed = new byte[32];
Array.Fill(seed, (byte)7);
using var publisher = new DeviceIdentity(seed);
byte[] vendor = Enumerable.Repeat((byte)0x0A, 16).ToArray();
byte[] deviceClass = Enumerable.Repeat((byte)0x0B, 16).ToArray();
// The release. A manifest says who the image is for, which slot it belongs in, how
// big it is and what it hashes to; nothing about the image is taken on trust.
byte[] image = Encoding.ASCII.GetBytes("firmware for a flow meter, version two");
var manifest = new Manifest(
Sequence: 2,
VendorId: vendor,
ClassId: deviceClass,
Storage: 1,
Digest: Update.ImageDigest(image),
Size: (uint)image.Length);
byte[] envelope = Update.SignManifest(manifest, publisher);
Console.WriteLine(
$"published sequence {manifest.Sequence} in a {envelope.Length}-byte envelope");
// On the device. It checks the envelope against the key it was anchored to before
// it accepts a single byte of the image.
Manifest opened = Update.VerifyEnvelope(envelope, publisher.PublicKey);
Console.WriteLine($"accepted a release for slot {opened.Storage}");
// It left the factory running sequence 1 from slot 0, so the release goes to the
// spare slot and the image it is running stays where it is.
using var fleet = new Updater(vendor, deviceClass, publisher.PublicKey, 2, 4096);
fleet.Provision(0, 1);
fleet.Begin(envelope);
for (int at = 0; at < image.Length; at += 16)
{
fleet.Write(image.AsSpan(at, Math.Min(16, image.Length - at)));
}
Console.WriteLine($"staged {fleet.CurrentProgress().Written} of {image.Length} bytes");
byte slot = fleet.Finish();
Console.WriteLine($"written to slot {slot}, leaving the running image alone");
// The first boot into a new image is a trial. It reverts on the next boot unless
// the device confirms it came up, which is what makes a bad release survivable.
Console.WriteLine($"booting {fleet.OnBoot().Action}");
fleet.Confirm();
Console.WriteLine($"confirmed slot {slot} is now {fleet.Record(slot).State}");
// The same release signed by a key this device is not anchored to gets nowhere.
byte[] impostorSeed = new byte[32];
Array.Fill(impostorSeed, (byte)90);
using var impostor = new DeviceIdentity(impostorSeed);
try
{
fleet.Stage(Update.SignManifest(manifest, impostor), image);
Console.WriteLine("a forged release was accepted, which should never happen");
}
catch (PamojaException error)
{
Console.WriteLine($"forged refused: {error.Message}");
}
The same capability in every language
| Language | Package | Reference |
|---|---|---|
| Rust | pamoja-update |
reference, docs.rs, install |
| TypeScript | @pamoja/update |
reference, install |
| Python | pamoja-update |
reference, install |
| C# | Pamoja.Update |
reference, install |
Documentation
Pamoja.Updatereference, every type in this namespace.- The Signed updates guide, with the same example in Rust, TypeScript, and Python.
- Every capability, and the install page.
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Pamoja.Codec (>= 0.1.17)
- Pamoja.Native (>= 0.1.17)
- Pamoja.Security (>= 0.1.17)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Pamoja.Update:
| Package | Downloads |
|---|---|
|
Pamoja
The whole pamoja framework in one package: every capability of one memory-safe Rust core, behind an idiomatic C# facade, for IoT, robotics, and drones. |
|
|
Pamoja.Trust
Trust and operation: Proving what a node did, saying it in confidence, fixing it in the field, and deciding how often it can afford to do any of that. |
GitHub repositories
This package is not used by any popular GitHub repositories.