Skip to content

asn1c: fix _to_asn1() for various types - #70

Merged
mitshell merged 2 commits into
pycrate-org:masterfrom
lukem:to_asn1-fixes
Oct 10, 2026
Merged

mitshell merged 2 commits into
pycrate-org:masterfrom
lukem:to_asn1-fixes

Conversation

@lukem

@lukem lukem commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Fix _to_asn1() for various types:

  • REAL: sequential (b'S') had format() error
  • BIT_STR: hstring (b'H') should be upper.
  • OCT_STR: bstring (b'B') had wrong length calculation.
  • OCT_STR: hstring (b'H') should be upper, without excess quotes.
  • TIME_UTC: val is a tuple[str|None], not tuple[int|None]
  • TIME_GEN: val is a tuple[str|None], not tuple[int|None]

Note: _String._to_asn1() still doubles all " and wraps in "; unsure if this is a sensible behaviour.

Now seems to match the equivalent classes in python_asn1rt.

Fix _to_asn1() for various types:
- REAL: sequential (b'S') had format() error
- BIT_STR: hstring (b'H') should be upper.
- OCT_STR: bstring (b'B') had wrong length calculation.
- OCT_STR: hstring (b'H') should be upper, without excess quotes.
- TIME_UTC: val is a tuple[str|None], not tuple[int|None]
- TIME_GEN: val is a tuple[str|None], not tuple[int|None]

Note: _String._to_asn1() still doubles all " and wraps in "; unsure
if this is a sensible behaviour.

Now seems to match the equivalent classes in python_asn1rt.
@mitshell
mitshell merged commit 0165acc into pycrate-org:master Oct 10, 2026
13 checks passed
@mitshell

Copy link
Copy Markdown
Member

Thanks for the PR and the fixes

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