formats
formats copied to clipboard
oiddbgen: parse types aliased to OBJECT IDENTIFIER
As part of RFC 5280, there are a few types that are essentially aliases for OBJECT IDENTIFIER.
One example is the AttributeType used in the x509 subject name:
AttributeType ::= OBJECT IDENTIFIER
-- Arc for standard naming attributes
id-at OBJECT IDENTIFIER ::= { joint-iso-ccitt(2) ds(5) 4 }
-- Naming attributes of type X520name
id-at-name AttributeType ::= { id-at 41 }
id-at-surname AttributeType ::= { id-at 4 }
id-at-givenName AttributeType ::= { id-at 42 }
id-at-initials AttributeType ::= { id-at 43 }
id-at-generationQualifier AttributeType ::= { id-at 44 }
[...]
-- Naming attributes of type X520SerialNumber
id-at-serialNumber AttributeType ::= { id-at 5 }
Since items like the id-at-name are not directly of type OBJECT IDENTIFIER, the oiddbgen does not pick them up.
I'm not sure about the best way to handle this, but I gave it a proof-of-concept at https://github.com/simpsoneric/formats/tree/object-id-aliases
The resulting src/db/gen.rs picks up the OIDs I was interested in.
On a related note, I was attempting to test this local crate version with my code but I am having conflicts for the ObjectIdentifier type. I'm not sure how to handle the workspace dependencies and could use a pointer.
In my project's Cargo.toml I have:
[dependencies]
x509-cert = { path = "../formats/x509-cert", features = ["builder"] }
const-oid = { path = "../formats/const-oid", features = ["db", "std"] }
But when I compile, I get errors like the following:
Compiling foo-bar v0.1.0
error[E0308]: mismatched types
--> src/foo.rs:97:36
|
97 | let r = a.find(|&av| av.oid == attr);
| ------ ^^^^ expected `ObjectIdentifier`, found `ObjectIdentifier<39>`
| |
| expected because this is `x509_cert::spki::ObjectIdentifier`
|
= note: `ObjectIdentifier<39>` and `ObjectIdentifier` have similar names, but are actually distinct types
note: `ObjectIdentifier<39>` is defined in crate `const_oid`
--> /home/foo/formats/const-oid/src/lib.rs:69:1
|
69 | pub struct ObjectIdentifier<const MAX_SIZE: usize = DEFAULT_MAX_SIZE> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: `ObjectIdentifier` is defined in crate `const_oid`
--> /home/foo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/const-oid-0.9.6/src/lib.rs:81:1
|
81 | pub struct ObjectIdentifier {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: perhaps two different versions of crate `const_oid` are being used?
How do you handle local development for the crate? I'm not that familiar with rust workspace projects.
We're in the middle of transitioning over to a new release cycle, and x509-cert has not yet been upgraded to use the new prerelease version of const-oid