Skip to content

wip(py): initial python bindings#435

Draft
XAMPPRocky wants to merge 1 commit intomainfrom
ep/py
Draft

wip(py): initial python bindings#435
XAMPPRocky wants to merge 1 commit intomainfrom
ep/py

Conversation

@XAMPPRocky
Copy link
Collaborator

@XAMPPRocky XAMPPRocky commented Mar 28, 2025

The goal of this PR is provide a package and Pythonic API to rasn for working with ASN.1 in Python. The goal for the initial bindings is get to following example to fully compile and work, alongside all of the infrastructure needed to release and ship python packages.

@rasn.sequence
class UserRecord:
    id: rasn.types.Integer
    oid: rasn.types.ObjectIdentifier
    age: rasn.types.Integer
    department: Department

@rasn.sequence(tag=(Tag.EXPLICIT, 1))
class Department:
  name: rasn.types.OctetString
  code: rasn.types.Integer

user = UserRecord(id=123, data=b"test", age=30)
encoded = user.encode(rasn.Codec.DER)

print(base64.b64encode(encoded))
print(UserRecord.decode(encoded))

@Nicceboy
Copy link
Contributor

Some "competition" coming up, Trail of Bits trying to bring DER Python bindings for Rust-based projects: https://blog.trailofbits.com/2025/04/18/sneak-peek-a-new-asn.1-api-for-python/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants