1
$\begingroup$

For my hobby cryptography project, I'm planning to implement some helper functions that parses a subset of ASN.1 BER encoding without using a ASN.1 compiler. For this purpose, I'd like to use 32-bit integer for the internal representation of tags' and lengths' values.

If I were to extend my library to other application domains such as CMS (cryptographic message syntax), should I prepare to extend my type to 64-bit?

$\endgroup$
2
  • $\begingroup$ I'm beginning to regret asking it, as my parser functions are multi-pass and couldn't confidently handle streaming encoding/decoding. But anyway, an answer might be helpful for others concerned with CMS. $\endgroup$ – DannyNiu Feb 11 at 9:55
  • $\begingroup$ If it cannot handle streaming then the question becomes a bit meaningless for the length encoding; you don't want to store more than 4GiB of data, even if you could (array / indexing restrictions). I have never seen a 4 byte tag, so that's OK. Beware that BER may store a small length into multiple bytes including zero padding at the left... $\endgroup$ – Maarten Bodewes Feb 11 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.