Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

der: Encoding higher tag number #1381

Open
xaqq opened this issue Apr 11, 2024 · 6 comments · May be fixed by #1416
Open

der: Encoding higher tag number #1381

xaqq opened this issue Apr 11, 2024 · 6 comments · May be fixed by #1416

Comments

@xaqq
Copy link

xaqq commented Apr 11, 2024

Hello,

I have an use case where I need to DER-encode ASN.1 message using greater than 30 for tag number.
I noticed in some comments that "This library deliberately does not support this: tag numbers greater than 30 are disallowed.".

I realize that TagNumber are an enumeration in this library, which makes arbitrarily high tag number problematic.
I am curious if you would consider lifting this limitation and willing to accept patches.

I can imagine 2 approaches:
+ Increase max tag number to 127, and support 2-bytes encoding of tags. Since 127 is still reasonable number it sounds like it would acceptable to have tag number up to TagNumber::N127.
+ Accept large number by using u64 or u128. This might be a too big impact the library API.

Thank you,

@tarcieri
Copy link
Member

I have an use case where I need to DER-encode ASN.1 message using greater than 30 for tag number.

Can you provide more information on what you're implementing which uses a combination of DER and the high tag number form?

I am curious if you would consider lifting this limitation and willing to accept patches.

We're making breaking changes right now, so it's something that can be considered. As it's something that's not needed for @RustCrypto-related use cases, it's not something I'd personally be interested in implementing, but a PR for it could be considered.

It would be helpful if it were motivated by a published specification that uses the combination of DER and high tag number form.

@xaqq
Copy link
Author

xaqq commented Apr 16, 2024

Hello,
I can't provide much information, but this is basically to support (proprietary) existing protocols.
I can't link to a public spec using that.

As it's something that's not needed for @RustCrypto-related use cases, it's not something I'd personally be interested in implementing, but a PR for it could be considered.

Yeah that sounds fair enough.

@kamulos
Copy link

kamulos commented Apr 30, 2024

I also stumbled on this issue. For my company I am working on der encoded files in a proprietary format. The der crate is perfect for us except for the fact, that we have PRIVATE declared members, that go up to 255.

This project is time-critical and in general critical for us. So I would try to put this in a PR as fast as possible. If I manage to get to a working solution I would love to get feedback. Especially concerning the fact if this approach has the chance to be merged at some point.

@xaqq did you work on this in the meantime?

I think I will try to accomplish two things:

  • allow the long form of tag numbers (>30). I think it makes sense to have high numbers represented by a normal number. Having 255 constants is quite strange.
  • allowing PRIVATE tags be annotated like context specific ones in der_derive

@tarcieri
Copy link
Member

tarcieri commented May 4, 2024

I should note that while PRs are welcome, there are various places in the codebase that assume a tag is always equivalent to u8, so this change might be a little bit tricky. If anyone attempts it, let me know if you run into problems.

@kamulos
Copy link

kamulos commented May 4, 2024

Last week I hacked together a proof-of-concept, which seems to be already working 👍 So currently I do not expect run into any problems. I also think the crate's code is really nice to work with.

I think pretty soon I will find the time to clean it up and post an initial draft for some early feedback.

@kamulos
Copy link

kamulos commented May 23, 2024

I opened #1416 to get some initial feedback on my approach

@tarcieri tarcieri changed the title DER: Encoding higher tag number der: Encoding higher tag number Aug 18, 2024
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 a pull request may close this issue.

3 participants