Skip to content

asn1: Add support for SET#14521

Open
facutuesca wants to merge 1 commit intopyca:mainfrom
trail-of-forks:ft/asn1-set
Open

asn1: Add support for SET#14521
facutuesca wants to merge 1 commit intopyca:mainfrom
trail-of-forks:ft/asn1-set

Conversation

@facutuesca
Copy link
Copy Markdown
Contributor

@facutuesca facutuesca commented Mar 21, 2026

This adds support for encoding/decoding SET.

here's an example of how it would be used:

@asn1.set
class MySet:
    foo: int
    bar: int

object = MySet(foo=6, bar=9)
encoded = encode_der(object)

decoded = decode_der(MySet, encoded)
assert decoded.foo == 6
assert decoded.bar == 9

The asn1.set decorator behaves similarly to asn1.sequence, except that the order of the fields is checked during encoding/decoding:

object = MySet(foo=9, bar=6)
encoded = encode_der(object)
# this raises due to the encoded value of `foo` being higher than `bar`

Part of #12283

Signed-off-by: Facundo Tuesca <facundo.tuesca@trailofbits.com>
@facutuesca facutuesca marked this pull request as ready for review March 21, 2026 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant