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

const-oid: add borrowed form of OID (e.g. ObjectIdentifierRef) #266

Closed
tarcieri opened this issue Feb 17, 2021 · 2 comments
Closed

const-oid: add borrowed form of OID (e.g. ObjectIdentifierRef) #266

tarcieri opened this issue Feb 17, 2021 · 2 comments

Comments

@tarcieri
Copy link
Member

tarcieri commented Feb 17, 2021

In certain cases it would be nice to be able to have a "borrowed" type which is backed by a byte slice containing the BER/DER encoding of an OID. This would be particularly nice in conjunction with the der::Any type, allowing conversions backed by references.

With a sufficiently powerful const fn we could even accept the OID as an array of integer arcs (or ideally, even a string!) and handle encoding the DER serialization at compile time. This is also possible with proc macros but ideally we could avoid those.

tarcieri added a commit that referenced this issue Feb 17, 2021
Adds an enum representing `ANY`, `NULL`, and `Objectidentifier` cases
for the `parameters` field of `AlgorithmIdentifier`.

Ideally this enum would be unnecessary and we could just use the
`der::Any` type for this field, however to make that possible in all
relevant use cases we'd need a reference-based type for
`ObjectIdentifier` backed by a byte slice containing the DER
serialization of the OID. See:

#266

Until we have such a type, this enum suffices to make it possible to
decode and encode an owned OID value which stores the decoded arcs that
comprise it, rather than the DER serialization.
tarcieri added a commit that referenced this issue Feb 17, 2021
Adds an enum representing `ANY`, `NULL`, and `Objectidentifier` cases
for the `parameters` field of `AlgorithmIdentifier`.

Ideally this enum would be unnecessary and we could just use the
`der::Any` type for this field, however to make that possible in all
relevant use cases we'd need a reference-based type for
`ObjectIdentifier` backed by a byte slice containing the DER
serialization of the OID. See:

#266

Until we have such a type, this enum suffices to make it possible to
decode and encode an owned OID value which stores the decoded arcs that
comprise it, rather than the DER serialization.
@tarcieri
Copy link
Member Author

tarcieri commented Mar 18, 2021

This might still be useful, but for what it's worth there is now a conversion available from &'a ObjectIdentifier to Any<'a> which largely solves the original problem:

https://docs.rs/der/0.2.10/der/struct.Any.html#impl-From%3C%26%27a%20ObjectIdentifier%3E

@tarcieri
Copy link
Member Author

tarcieri commented May 6, 2021

Closing this out as the conversion from &'a ObjectIdentifier to der::Any<'a> largely addresses the original concerns.

Please leave a comment if you'd like this reopened.

@tarcieri tarcieri closed this as completed May 6, 2021
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

No branches or pull requests

1 participant