Skip to main content

pqblocks-policy

PyPI version License Python Versions

Policy-as-code engine for evaluating cryptographic posture, post-quantum compliance, and cryptographic bill of materials (CBOM) conformance.

pqblocks-policy allows organizations to define, enforce, and audit cryptographic governance rules across systems, APIs, TLS endpoints, and software dependencies against modern post-quantum standards including NIST FIPS 203/204/205 and NSA CNSA 2.0.


Key Features

  • Policy-as-Code Engine: Evaluate individual cryptographic assets or entire CBOM collections against declarative YAML/JSON profiles.
  • Built-in CNSA 2.0 Profile: Pre-configured cnsa20_default() profile implementing US National Security Agency (NSA) Commercial National Security Algorithm Suite 2.0 timeline rules.
  • CBOM & CycloneDX Ingestion: Direct loading and canonical evaluation of CycloneDX 1.6 Cryptographic Bill of Materials (CBOM) documents.
  • Sub-Millisecond Evaluation: Evaluates 100 cryptographic assets in ~0.5 ms and 1,000 assets in under 5 ms.
  • Audit-Ready Reports: Generates structured ComplianceReport objects containing verdicts (pass, violation, warning), finding lists, severity scores, and violation reasons.

Installation

pip install pqblocks-policy

Dependencies

pqblocks-policy requires cryptography and PyYAML.


Quickstart

from pqblocks_policy import PolicyEngine, cnsa20_default, Asset, UsageClass

# 1. Load the default CNSA 2.0 profile
profile = cnsa20_default()
engine = PolicyEngine(profile)

# 2. Define a cryptographic asset to evaluate
asset = Asset(ref="tls-session-1", alg="ML-KEM-768+X25519", use=UsageClass.KEY_EXCHANGE)

# 3. Evaluate compliance
report = engine.evaluate([asset])
print(f"Verdict: {report.verdict.value} | Assets: {report.asset_count} | Violations: {report.violation_count}")

Execution Output:

Verdict: pass | Assets: 1 | Violations: 0

Usage Example: Auditing Heterogeneous Assets

from pqblocks_policy import PolicyEngine, cnsa20_default, Asset, UsageClass, Verdict

engine = PolicyEngine(cnsa20_default())

assets = [
    Asset(ref="edge-gateway", alg="ML-KEM-768+X25519", use=UsageClass.KEY_EXCHANGE),
    Asset(ref="identity-signing", alg="ML-DSA-87", use=UsageClass.SIGNATURE),
    Asset(ref="legacy-db", alg="RSA-2048", use=UsageClass.KEY_EXCHANGE),
]

report = engine.evaluate(assets)
print(f"Overall status: {report.verdict.value}")

for finding in report.findings:
    if finding.verdict == Verdict.VIOLATION:
        print(f"Violation in {finding.asset_ref} ({finding.algorithm}): {finding.detail}")

Architecture & Supported Usage Classes

pqblocks-policy classifies cryptographic assets by their operational role:

  • UsageClass.KEY_EXCHANGE: Key encapsulation mechanisms (KEM) and Diffie-Hellman protocols.
  • UsageClass.SIGNATURE: Digital signature algorithms for authentication and integrity.
  • UsageClass.KEY_GENERATION: Asymmetric and symmetric key derivation operations.
  • UsageClass.TLS: Transport layer security cipher suites and protocol configurations.
  • UsageClass.HASH: Cryptographic hash functions.

Non-Claims & Compliance Notice


License

This project is licensed under the Apache 2.0 License. See LICENSE and NOTICE for details.

Metadata

Release files for pqblocks-policy 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 pqblocks-policy 0.1.0
File Size Uploaded Provenance Actions
pqblocks_policy-0.1.0.tar.gz 45.9 kB Without provenance Details for pqblocks_policy-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pqblocks-policy 0.1.0
File Interpreter ABI Platform Actions
pqblocks_policy-0.1.0-py3-none-any.whl Python 3 none any Details for pqblocks_policy-0.1.0-py3-none-any.whl

Total release size: 65.4 kB

Release files / pqblocks_policy-0.1.0.tar.gz

Download URL pqblocks_policy-0.1.0.tar.gz
Size 45.9 kB
Tags Source
SHA-256 checksum
How to use checksums
da234d872826a961bf1e265ccf9892b95b2e4c1c610b4abd49f2363537e500b6
BLAKE2b-256 checksum
How to use checksums
b64c0215073f99c895ac77666cb00ca8bea2d726a3c2d7c68bdf3fe5ae921f00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pqblocks_policy-0.1.0-py3-none-any.whl

Download URL pqblocks_policy-0.1.0-py3-none-any.whl
Size 19.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46d1dc528ff4d6a2c904b1b53d4c745260ad310683807d02e1317effc66ab339
BLAKE2b-256 checksum
How to use checksums
ae43370066302b4215cf5509dc766a08df2b96f93d3d8348c5da8934f1c85f3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for pqblocks-policy 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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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

2 release files No 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