🐛 implement ordered components of ASN.1 sets #1025
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1013
This implements sorting of ASN.1 types.
According to the X.690 specification (ISO/IEC 8825-1:2021 (E)) the ASN.1 standard for
Set Of
components must be encoded in order when using DER:This checks if the current ASN.1 object is a SET - if so it will order the encoded values. It also allows the
option
ofsort
to be set to force sorting, this is required when items need to be encoded as SET but have context specific tag class.The ordering is done by comparing each byte in turn until we find either a difference or can determine they are the same.
Because of the change in how internals are now constructing the ASN.1 values, the PKCS#7 test output has had to change.
For completeness I have tested openssl is still able to validate the produced PKCS#7 signatures: