KDuma.Pcf 0.0.9

dotnet add package KDuma.Pcf --version 0.0.9
                    
NuGet\Install-Package KDuma.Pcf -Version 0.0.9
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="KDuma.Pcf" Version="0.0.9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="KDuma.Pcf" Version="0.0.9" />
                    
Directory.Packages.props
<PackageReference Include="KDuma.Pcf" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add KDuma.Pcf --version 0.0.9
                    
#r "nuget: KDuma.Pcf, 0.0.9"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package KDuma.Pcf@0.0.9
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=KDuma.Pcf&version=0.0.9
                    
Install as a Cake Addin
#tool nuget:?package=KDuma.Pcf&version=0.0.9
                    
Install as a Cake Tool

Pcf — Partitioned Container Format (C# / .NET implementation)

A C# reader/writer for PCF v1.0, a language-agnostic binary container that stores multiple independent byte regions ("partitions") in one file.

This is the first port of the Rust reference implementation and tracks the written specification (PCF-spec-v1.0.txt) field-for-field. It is verified byte-for-byte against the spec's canonical 395-byte test vector (section 15) and, like the reference, favours auditability over performance.

Layout

[ 20-byte header ] [ table block(s) ] [ partition data regions ]
  • Header (20 B): magic 0x89 K P R T 0x0D 0x0A 0x1A, major/minor version, absolute offset of the first table block.
  • Table block: 74-byte header (partition_count, next_table_offset, hash algo + 64-byte block hash) followed by partition_count entries. Blocks form a singly linked chain to hold more than 255 partitions.
  • Entry (141 B): type, 16-byte UID, 32-byte ASCII label, start_offset, max_length, used_bytes, 1-byte data-hash algorithm, 64-byte data hash.

All integers are little-endian. Free space is max_length - used_bytes.

Hash registry

id algorithm id algorithm
0 none 5 SHA-1
1 CRC-32/ISO-HDLC 16 SHA-256 (default)
2 CRC-32C 17 SHA-512
3 CRC-64/XZ 18 BLAKE3
4 MD5

SHA-1/2 and MD5 use System.Security.Cryptography; the three CRCs are self-contained reflected-CRC routines (Crc.cs); BLAKE3 uses the Blake3 NuGet package.

Usage

using System.IO;
using System.Text;
using Pcf;

var c = Container.Create(new MemoryStream());
c.AddPartition(
    partitionType: 0x10,
    uid: new byte[16] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
    label: "notes",
    data: Encoding.ASCII.GetBytes("hello"),
    extraReserve: 64,
    dataHashAlgo: HashAlgo.Sha256);

c.Verify();

foreach (PartitionEntry e in c.Entries())
{
    byte[] data = c.ReadPartitionData(e);
    // ...
}

// Reclaim unused reservations and produce the canonical, tightly packed form:
byte[] image = c.CompactedImage();

Container is backed by any readable/writable/seekable System.IO.Stream (both MemoryStream and FileStream work) — the C# analogue of the reference's Read + Write + Seek store. Operations raise PcfException, whose Kind (PcfError) identifies the exact failure.

Project structure

implementations/dotnet/pcf/
├── Pcf.sln
├── src/Pcf/                 # the library (targets netstandard2.0)
│   ├── Constants.cs         # on-disk constants (spec Appendix A)
│   ├── PcfError.cs          # PcfError + PcfException
│   ├── LittleEndian.cs      # explicit little-endian helpers
│   ├── Crc.cs               # CRC-32 / CRC-32C / CRC-64
│   ├── HashAlgo.cs          # hash-algorithm registry (spec 8)
│   ├── FileHeader.cs        # 20-byte header (spec 4)
│   ├── PartitionEntry.cs    # 141-byte entry + labels (spec 5.2, 10)
│   ├── TableBlockHeader.cs  # 74-byte block header + table hash (spec 5.1, 8.4)
│   └── Container.cs         # high-level reader/writer
└── tests/Pcf.Tests/         # xUnit suite (targets net8.0)
    ├── SpecComplianceTests.cs  # one assertion per normative MUST/SHALL
    ├── RoundtripTests.cs       # end-to-end create/read/verify/update/remove/compact
    └── CoverageTests.cs        # error paths, every hash algo, label edge cases

The library targets netstandard2.0 for broad reach; the test project targets net8.0. BLAKE3 is provided by Blake3 0.6.1 — the last release that ships a netstandard2.0 assembly together with native runtimes for linux/macOS/windows (x64 + arm64).

Building and testing

cd implementations/dotnet/pcf
dotnet build -c Release
dotnet test  -c Release

The section-15 test (S15_canonical_vector_is_byte_exact) proves this implementation emits the spec's exact 395-byte file.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

NuGet packages (1)

Showing the top 1 NuGet packages that depend on KDuma.Pcf:

Package Downloads
KDuma.Pcf.Sig

Reader/writer for PCF-SIG v1.0, the PCF Cryptographic Signatures profile.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.9 153 6/8/2026
0.0.8 144 6/7/2026
0.0.7 152 6/7/2026
0.0.6 108 6/6/2026
0.0.5 108 6/6/2026
0.0.4 112 6/6/2026
0.0.3 118 6/6/2026