Skip to content

Conversation

@Nicceboy
Copy link
Contributor

  • When decoding optional values in BER, does not hide errors anymore and presence status is based on peeking the next tag
  • When Any type field is in Sequence, the outermost TLV defined by explicit tag is extracted away
  • When decoding Any outside of Sequence/Set context, TLV pattern is verified but data is just copied as it is. It is up to caller to decode it further with correct type/tag.

@Nicceboy Nicceboy mentioned this pull request Oct 17, 2025
@Nicceboy
Copy link
Contributor Author

I think there is "a bug" that was hidden by the .ok() mapping.

In

let encoded = rasn::cer::encode(&value).unwrap();
assert_eq!(value, rasn::cer::decode(&encoded).unwrap());
CER attempts to decode following bytes

30 80 06 01 00 00 00

as

pub struct AlgorithmIdentifier {
/// The identifier for the algorithm.
pub algorithm: ObjectIdentifier,
/// Parameters for the algorithm, if any.
pub parameters: Option<Any>,
}

It does not correctly detect the ending EOC, rather it tried to parse it as tag but failed. It was mapped to None previously.

@Nicceboy Nicceboy marked this pull request as draft October 18, 2025 09:17
@Nicceboy Nicceboy force-pushed the fix-ber-optional-any branch from 4d2ba57 to fc05ac9 Compare October 19, 2025 16:27
@Nicceboy Nicceboy force-pushed the fix-ber-optional-any branch from fc05ac9 to f74e05d Compare October 19, 2025 16:29
@Nicceboy
Copy link
Contributor Author

Can be reviewed and fixes #488.

@Nicceboy Nicceboy marked this pull request as ready for review October 19, 2025 16:36
@XAMPPRocky XAMPPRocky merged commit 710cfd9 into librasn:main Oct 20, 2025
44 checks passed
@github-actions github-actions bot mentioned this pull request Oct 20, 2025
@Nicceboy Nicceboy deleted the fix-ber-optional-any branch October 20, 2025 18:35
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