Skip to main content

rpki-ccr

PyPI Python

Python bindings for rpki-ccr, a parser and encoder for RPKI Canonical Cache Representation (CCR) files (draft-ietf-sidrops-rpki-ccr).

A CCR is a DER-encoded, byte-for-byte reproducible snapshot of a validated RPKI cache: the current manifests, validated ROA payloads (VRPs), ASPA payloads, trust anchors and BGPsec router keys. Every state aspect carries a SHA-256 digest so that corruption is detectable without a signature.

pip install rpki-ccr

Reading

from rpki_ccr import Ccr

ccr = Ccr.from_file("rpki.ccr")          # plain DER or gzip (.ccr.gz)
print(ccr)                               # Ccr(produced_at=..., manifests=55587, roa_payloads=1026530, ...)

for vrp in ccr.roa_payloads:             # flattened: Vrp(asn, prefix, max_length)
    print(vrp)                           # 198.51.100.0/24-28 AS 65536

for mi in ccr.manifests:                 # ManifestInstance
    print(mi.aki.hex(), mi.manifest_number, mi.this_update, mi.locations[0].uri)

Ccr.decode(data) enforces every requirement of the specification and raises a typed rpki_ccr.Error subclass on failure (DerError, HashMismatchError with aspect, declared and computed, NotSortedError, DuplicateError, ConsistencyError, InvalidValueError). File problems raise OSError. Non-conforming files can be inspected with the checks switched off:

ccr = Ccr.decode(data, verify_hashes=False)

The five state views (ccr.manifests, ccr.roa_payloads, ccr.aspa_payloads, ccr.trust_anchors, ccr.router_keys) are read-only sequences backed by the Rust data: indexing, slicing, iteration, in, index and count work without copying the whole file. Key identifiers and digests are bytes, OIDs are dotted strings, AS numbers and manifest numbers are int, and times are timezone-aware UTC datetime objects. Everything is immutable, hashable and picklable.

Writing

from datetime import datetime, timezone
from rpki_ccr import AspaPayloadSet, Ccr, ManifestInstance, Vrp

ccr = Ccr(
    datetime(2026, 5, 15, 0, 0, 10, tzinfo=timezone.utc),
    manifests=[ManifestInstance(hash=..., size=1729, aki=..., manifest_number=257,
                                this_update=..., locations=["rsync://example.net/ca1/x.mft"])],
    roa_payloads=[Vrp(65536, "198.51.100.0/24", 28), Vrp(65536, "2001:db8::/48")],
    aspa_payloads=[AspaPayloadSet(65536, [65540, 65544])],
    trust_anchors=[bytes.fromhex("25f8ccfcefc046d8dcd00fc0e444e0aa7b790f96")],
)
der = ccr.to_der()                       # canonical: sorted, deduplicated, digests computed

to_der() validates first, so an object decoded with checks switched off is refused unless the same checks are switched off again (to_der(verify_hashes=False)). ccr.validate() runs the checks without encoding. Decoded objects re-encode byte for byte.

Comparing files

diff = Ccr.from_file("old.ccr").diff(Ccr.from_file("new.ccr"))
if diff:                                     # anything changed?
    for vrp in diff.roa_payloads.added:      # RoaPayloadDiff: added, removed, unchanged
        print("+", vrp)
    for change in diff.manifests.issuers:    # by issuer: kind is "added", "removed" or "updated"
        print(change.kind, change.aki.hex(), [mi.manifest_number for mi in change.after])
    for update in diff.aspa_payloads.updated:
        print(update.customer_asn, update.providers_added, update.providers_removed)

Operators cover the common cases. new - old is old.diff(new), and unary minus reverses a diff. The views support set algebra returning lists in canonical order:

added = new.roa_payloads - old.roa_payloads      # VRPs only the newer file has
removed = old.roa_payloads - new.roa_payloads
common = new.roa_payloads & old.roa_payloads     # also | (union) and ^ (symmetric difference)
report = new - old
assert report.roa_payloads.added == added and (-report).roa_payloads.added == removed

Manifest instances are identified by hash, trust anchors by key identifier, router keys by AS and key identifier, ASPA sets by customer and providers.

The diff is a linear merge in Rust over the canonical sequences (aspects with equal digests are skipped), so comparing two full-RPKI files costs milliseconds. Manifests are reported both by hash (added/removed) and grouped by issuer (issuers); aspects absent on one side are compared as empty, aspects absent on both are None.

Examples

examples/ccr_diff.py OLD NEW prints the changes between two files in the same layout as the Rust ccr-diff example.

Development

cd crates/rpki-ccr-py
uv sync                                  # builds the extension into .venv
uv run maturin develop --uv              # after Rust changes
uv run pytest
uv run python -m mypy.stubtest rpki_ccr --allowlist stubtest-allowlist.txt  # keeps rpki_ccr.pyi honest

Wheels are built for the stable ABI (abi3, Python 3.9+).

License

BSD 3-Clause, see LICENSE.

Metadata

Release files for rpki-ccr 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rpki-ccr 0.2.0
File Size Uploaded Provenance Actions
rpki_ccr-0.2.0.tar.gz 136.2 kB With provenance Details for rpki_ccr-0.2.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for rpki-ccr 0.2.0
File Interpreter ABI Platform Actions
rpki_ccr-0.2.0-cp39-abi3-manylinux_2_28_x86_64.whl CPython 3.9 abi3 Linux glibc 2.28+ x86-64 Details for rpki_ccr-0.2.0-cp39-abi3-manylinux_2_28_x86_64.whl
rpki_ccr-0.2.0-cp39-abi3-manylinux_2_28_aarch64.whl CPython 3.9 abi3 Linux glibc 2.28+ ARM64 Details for rpki_ccr-0.2.0-cp39-abi3-manylinux_2_28_aarch64.whl
rpki_ccr-0.2.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for rpki_ccr-0.2.0-cp39-abi3-macosx_11_0_arm64.whl

Total release size: 2.7 MB

Release files / rpki_ccr-0.2.0.tar.gz

Download URL rpki_ccr-0.2.0.tar.gz
Size 136.2 kB
Tags Source
SHA-256 checksum
How to use checksums
f12d2f3da7da492a431d333a9086faa199ad0c578679431b6040ff71ef14b622
BLAKE2b-256 checksum
How to use checksums
1e5d460df892eeedb46ded2b8e20d366c568b9be4b9d812c5ceb4201ea043e24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

Release files / rpki_ccr-0.2.0-cp39-abi3-manylinux_2_28_x86_64.whl

Download URL rpki_ccr-0.2.0-cp39-abi3-manylinux_2_28_x86_64.whl
Size 860.9 kB
Tags CPython 3.9 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
359e86c770358a7ce8381afa5d354fdccd0255fb18a2850efe63b7f81ab67d12
BLAKE2b-256 checksum
How to use checksums
d90e965f91c3b83468cdf9101f73009afbdf9be1910009154909c1cbf048164e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

Release files / rpki_ccr-0.2.0-cp39-abi3-manylinux_2_28_aarch64.whl

Download URL rpki_ccr-0.2.0-cp39-abi3-manylinux_2_28_aarch64.whl
Size 871.8 kB
Tags CPython 3.9 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
5f528c5aee85b01f32cf3588c097abaed0d842b272a0cc40009b8c9a9affc7a7
BLAKE2b-256 checksum
How to use checksums
eafaedf5bbcf5e3b57015c79023bc11ba3840d74e5d466ac8152343b631cd96a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

Release files / rpki_ccr-0.2.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL rpki_ccr-0.2.0-cp39-abi3-macosx_11_0_arm64.whl
Size 795.9 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2cd9bdda5057e2be5a77fcec9bcf0a20e53a664bfd847491229591320974f053
BLAKE2b-256 checksum
How to use checksums
8aa2d280ea1b014163284a0294ca5eec682472ced6e8643c4faedab3123ca3a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

Security for rpki-ccr 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 4 files in this release have been uploaded with provenance metadata.

Select from 4 files

Attestation for rpki_ccr-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

4 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page