Skip to content

Conversation

@tarcieri
Copy link
Member

@tarcieri tarcieri commented Jul 2, 2025

One of the blockers for addressing indefinite length handling (#779) has been where to consume the EOC tag.

This commit (re)introduces Reader::read_value (added in #1877, removed in #1887) and handles decoding the EOC there. This gives us a single place where EOC can be handled for all constructed messages.

With these changes, the decoder is able to parse cms_ber.bin from cms/tests, from which the cms_der.bin file has been translated. This file provides a real-world example of nested indefinite lengths from CMS.

Note, however, that the example contains a constructed Any which isn't yet being correctly handled. A TODO for ensuring the BER and DER decode identically has been added.

cc @dishmaker

@tarcieri tarcieri force-pushed the der/restore-read-value branch 2 times, most recently from 759d6f1 to f2f6da0 Compare July 2, 2025 21:42
One of the blockers for addressing indefinite length handling (#779) has
been where to consume the EOC tag.

This commit (re)introduces `Reader::read_value` (added in #1877, removed
in #1887) and handles decoding the EOC there. This gives us a single
place where EOC can be handled for all constructed messages.

With these changes, the decoder is able to parse `cms_ber.bin` from
`cms/tests`, from which the `cms_der.bin` file has been translated. This
file provides a real-world example of nested indefinite lengths from
CMS.

Note, however, that the example contains a constructed `Any` which isn't
yet being correctly handled. A `TODO` for ensuring the BER and DER
decode identically has been added.
@tarcieri tarcieri force-pushed the der/restore-read-value branch from f2f6da0 to 586e4c4 Compare July 2, 2025 21:44
@dishmaker
Copy link
Contributor

dishmaker commented Jul 2, 2025

Note: because read_nested is not needed for primitive types, I suggest to introduce decode_value_nested.

As stated in comment #1877

Therefore call chain would be:
decode -> read_value -> decode_value_nested -> read_nested -> decode_value

@tarcieri tarcieri merged commit ae36061 into master Jul 2, 2025
107 checks passed
@tarcieri tarcieri deleted the der/restore-read-value branch July 2, 2025 22:07
@tarcieri
Copy link
Member Author

tarcieri commented Jul 2, 2025

@dishmaker I would love to find somewhere better to put this logic, but it ends up being quite difficult given the current usage

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.

3 participants