RustCrypto / formats

Cryptography-related format encoders/decoders: DER, PEM, PKCS, PKIX
250 stars 133 forks source link

Support parsing X509 certificates with no allocations #1603

Open DemiMarie opened 1 week ago

DemiMarie commented 1 week ago

WebPKI supports this, as does my own barebones-x509 crate.

tarcieri commented 1 week ago

See ample related discussion in #689 for the encoding side of things.

We pretty much went in the opposite direction in #765 and leaned further into the existing hard dependency on alloc.

tarcieri commented 1 week ago

In some other crates, notably spki and the latest prereleases of pkcs8, we do abstract over the owned and borrowed forms using generics:

https://docs.rs/pkcs8/0.11.0-rc.1/pkcs8/struct.PrivateKeyInfo.html

This has the following forms, one of which has a lifetime and the other does not:

We could potentially do something like that with x509-cert as well, though we already use generics to carry a profile ZST, so it might become a lot of generic parameters, which makes the API more cumbersome.