pyasn1-modules

A collection of pre-built ASN.1 data structures for X.509, CMS, PKCS, and other IETF protocols in Python

Library
PyPI
v0.4.2
10stars
BSD-2-Clause

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
28/100Needs Attention
Development Activity0
Maintenance20
Community24
Maturity56
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
51/100Fair
Architecture55
Code Quality62
Innovation40
Learning Curve45

pyasn1-modules is a companion package to pyasn1 that ships ready-made ASN.1 schema definitions for dozens of widely used IETF and cryptographic protocols, including X.509 certificates, PKCS formats, CMS, SNMP, and OCSP. Instead of hand-writing ASN.1 modules from RFC specifications, developers can import a module like rfc2459 (X.509) or rfc5280 and immediately decode or encode conformant structures using pyasn1’s codec machinery.

The library is maintained by the same community responsible for pyasn1 itself and is widely depended on by cryptography and security tooling in the Python ecosystem, including python-ldap, scapy, and various certificate-handling utilities. It focuses purely on data modeling and does not implement cryptographic operations directly.

What You Get

  • Pre-built ASN.1 module definitions for 60+ RFCs covering X.509, PKCS, CMS, SNMP, OCSP, and timestamping protocols
  • Ready-to-use pyasn1 univ/char/useful type compositions matching each RFC’s formal ASN.1 grammar
  • A pem.py helper for reading PEM-encoded structures before DER/BER decoding
  • Test suite validating decode/re-encode round trips against real-world certificate and protocol samples
  • A stable dependency boundary pinned to a compatible pyasn1 core version range

Common Use Cases

  • Parsing and inspecting X.509 certificate fields (subject, issuer, extensions) without a full crypto library
  • Decoding CMS/PKCS#7 signed or enveloped data structures for signature or certificate-chain tooling
  • Implementing or debugging SNMP agents/managers that need SNMPv1/v2/v3 PDU structures
  • Building certificate-request (PKCS#10/CMP) tooling that needs to construct or parse ASN.1 requests
  • Academic or protocol-compliance work that needs a faithful ASN.1 model of an IETF specification

Under The Hood

Architecture The package is organized as a flat collection of per-RFC modules (e.g. rfc2459.py, rfc5280.py) under pyasn1_modules/, each independently translating one IETF specification’s ASN.1 grammar into pyasn1 univ/char/useful type compositions; a small pem.py utility handles PEM-to-DER conversion ahead of decoding, and there is no shared runtime engine beyond what pyasn1 itself provides.

Tech Stack Pure Python (100%), packaged with setuptools/pyproject.toml, with a single runtime dependency on a version-pinned pyasn1 (>=0.6.1,<0.7.0); no build step beyond standard packaging, and tox.ini drives the test matrix across supported Python versions.

Code Quality The tests/ directory contains per-RFC test modules (test_rfc2459.py, test_rfc2315.py, etc.) totaling significant coverage, exercising decode/re-encode round trips against real sample data; module code favors direct declarative ASN.1 type definitions over abstraction, keeping each file readable against its source RFC, though documentation is minimal beyond RFC references.

API Design The developer experience mirrors pyasn1’s own API: import the RFC module you need and use pyasn1’s decoder/encoder against its exported type classes, which is efficient for users already familiar with pyasn1 and ASN.1 but presents a learning curve for newcomers since the primary documentation is the RFC text itself rather than prose guides.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search