Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DerObject.__repr__() #735

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

JamesTheAwesomeDude
Copy link
Contributor

@JamesTheAwesomeDude JamesTheAwesomeDude commented May 6, 2023

The base case handles sequences and most primitives.

Special handling was given to DerOctetString and DerBitString by way of inspiration from this site — the false-positives still yield technically valid representations, and the true-positives provide tremendous utility when playing around with many real-world ASN.1 formats that nest values within octet- and bit-strings.

Special handling was required for DerNull since it takes no value, not even None, and doesn't currently accept explicit or implicit tag overrides.

This should make "playpenning" around with ASN.1-based formats a lot more convenient.

Is this something you'd be interested in merging? Do you have any feedback on it?

@JamesTheAwesomeDude
Copy link
Contributor Author

To be clear, the entire _try_decode function could be discarded if dropping the nested-objects amenity. It's only used there.

The base case handles sequences and most primitives.

Special handling was required for `DerOctetString` and `DerBitString`
since they store their value at `.payload` rather than `.value`.

Special handling was required for `DerNull` since its current
constructor takes no argument at all, not even `None`.

This should make "playpenning" around with ASN.1-based formats a lot
more convenient.
James Edington added 2 commits May 8, 2023 13:07
Considering that the 'else' codepath in the `DerSequence` constructor
will encode these objects automatically, this will create valid
representations.
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.

None yet

1 participant