Skip to content

spki: make SubjectPublicKeyInfo own the public key #778

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

Conversation

baloo
Copy link
Member

@baloo baloo commented Nov 29, 2022

This is based on #769

tarcieri and others added 3 commits November 25, 2022 15:52
NOTE: breaking change.

Previously `AlgorithmIdentifier::parameters` were always `AnyRef`.
This commit changes them to a generic parameter `Params`.

An alias `AlgorithmIdentifierRef` provides a type identical to the
original with `AnyRef` as its `parameters`, which is used in all of the
other crates in this repo.
@baloo baloo force-pushed the baloo/owned-api/spki-publickey branch from 6adaae7 to 1efe27a Compare November 29, 2022 19:42
spki/src/spki.rs Outdated
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct SubjectPublicKeyInfo<'a, Params> {
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct SubjectPublicKeyInfo<Params> {
Copy link
Member Author

@baloo baloo Nov 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This obviously doesn't work as this, the intention was to remove the lifetime from here, maybe I should add a parameter like

Suggested change
pub struct SubjectPublicKeyInfo<Params> {
pub struct SubjectPublicKeyInfo<Params,Pkey> {

And consume that as a

SubjectPublicKeyInfo<Any,BitString>  // Owned version
pub type SubjectPublicKeyInfoRef<'a> = SubjectPublicKeyInfo<AnyRef<'a>,BitStringRef<'a>>  // zero copy version

Copy link
Member

@tarcieri tarcieri Nov 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It definitely needs a generic parameter so as to continue supporting a heapless profile.

I was thinking of using a generic Bits parameter with &[u8] and Box<[u8]> type aliased as you propose. The former could be aliased as something like type SubjectPublicKeyInfoOwned.

There's a potential argument to be made that using a BitString* type is semantically more correct, although I'm not aware of any public key formats which aren't octet-aligned.

Copy link
Member Author

@baloo baloo Nov 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went with BitString/BitStringRef to stick as close as possible to the RFC definition.
I can reuse the Bytes type I introduced in #771

@tarcieri
Copy link
Member

This was definitely my next planned followup to #769, but if you want to work on it in parallel that's cool.

@baloo
Copy link
Member Author

baloo commented Nov 29, 2022

haha :) I missed that! sorry.

@baloo baloo force-pushed the baloo/owned-api/spki-publickey branch 3 times, most recently from 763cc8f to b259658 Compare November 30, 2022 06:45
@baloo baloo force-pushed the baloo/owned-api/spki-publickey branch from b259658 to 25b9e19 Compare November 30, 2022 06:57
@tarcieri tarcieri force-pushed the spki/generic-algorithm-identifier branch from b09ff11 to d6741cb Compare December 11, 2022 15:03
@tarcieri tarcieri deleted the branch RustCrypto:spki/generic-algorithm-identifier December 11, 2022 16:09
@tarcieri tarcieri closed this Dec 11, 2022
@tarcieri
Copy link
Member

@baloo this was closed by way of me deleting the RustCrypto:spki/generic-algorithm-identifier branch but please rebase on master and resubmit as this is mergable now

@baloo
Copy link
Member Author

baloo commented Dec 12, 2022

yup, that took me some time to clean my changes.

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 this pull request may close these issues.

2 participants