Skip to main content

rpki-ccr

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.1.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.1.0
File Size Uploaded Provenance Actions
rpki_ccr-0.1.0.tar.gz 135.1 kB With provenance Details for rpki_ccr-0.1.0.tar.gz

Built distributions (wheels)

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

Total release size: 2.7 MB

Release files / rpki_ccr-0.1.0.tar.gz

Download URL rpki_ccr-0.1.0.tar.gz
Size 135.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d1583061e666b91692503656eb0f413c4ffddad90b4654357ff493ed16a61c97
BLAKE2b-256 checksum
How to use checksums
ec9ea7a22b60105a7f3b75b564a68c26e5659a3f19858b71bd22a0d84023f439
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.1.0-cp39-abi3-manylinux_2_28_x86_64.whl

Download URL rpki_ccr-0.1.0-cp39-abi3-manylinux_2_28_x86_64.whl
Size 860.5 kB
Tags CPython 3.9 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
12721af10e323c3797ea801e5b6e9e23f3ba2279508965eb1cbeb6202a4d30f9
BLAKE2b-256 checksum
How to use checksums
7e6fbb27b7cc57281a669110d86a00c5b76bf7861c18348bd2350b46051c4c45
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.1.0-cp39-abi3-manylinux_2_28_aarch64.whl

Download URL rpki_ccr-0.1.0-cp39-abi3-manylinux_2_28_aarch64.whl
Size 871.7 kB
Tags CPython 3.9 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
3241cdc32bb3389301c7e2100e956722d3b4e5051f0ddcbd10bbf1b4cd802b52
BLAKE2b-256 checksum
How to use checksums
86a1c09c9b842dabb72a461fdc04213585830590085b6b9ed933d196542a6f78
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.1.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL rpki_ccr-0.1.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
c4527c1c670eed0934430b4d086bd7c3705298fc4aef31776e7ce101a45087eb
BLAKE2b-256 checksum
How to use checksums
4edfdd80d9581d452a3551ed7ffe16f6fd6fc2316c065eab492621bee32329f3
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.1.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.1.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.1.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