librasn / rasn

A Safe #[no_std] ASN.1 Codec Framework
Other
199 stars 50 forks source link

Split OID codec functionality in BER to be usable by other codecs #144

Closed Nicceboy closed 1 year ago

Nicceboy commented 1 year ago

Other codecs seems to re-use bytepresentation of BER encoding for ObjectIdentifier type.

This change would make it easier to access bytes without added length or tags.

XAMPPRocky commented 1 year ago

This change would make it easier to access bytes without added length or tags.

Thank you for your PR! Are you sure the length and tag should not be included other codecs? In the specs it's often cited as being a complete representation of the BER value, which would include tag and length.

Nicceboy commented 1 year ago

The existing functions are still there which can be used to get the tag and length as well, if required. I do not know all the codecs. I noticed that in UPER you used the tag and length at least.

I compared to other implementations of OER and at least in this case they seems to drop. OER adds its own length determinant.

In OER standard section 21, it says that "contents octets of BER encoding of the object identifier value" (object identifier value specified in 8.19 ,BER standard), so I would assume that it is without length and tags.

In 8.19.5 section there is an example, which distincts contents

OBJECT IDENTIFIER Length Contents
0616 0316 88370316
Nicceboy commented 1 year ago

Seems like that similar wording is also used in PER. Apparently the logic should be the same but which one it is 😄

Nicceboy commented 1 year ago

I think this also applies for types GeneralizedTime and UTCTime. Should we split these functions in BER as well, or do helper functions outside of BER? Parsing the time strings would be identical.

XAMPPRocky commented 1 year ago

Should we split these functions in BER as well, or do helper functions outside of BER? Parsing the time strings would be identical.

In BER so it's clear that it's the BER encoding being used.

XAMPPRocky commented 1 year ago

Thank you for your PR!