Skip to content

spki: make SubjectPublicKeyInfo own the public key - #778

Closed
baloo wants to merge 5 commits into
RustCrypto:spki/generic-algorithm-identifierfrom
baloo:baloo/owned-api/spki-publickey
Closed

spki: make SubjectPublicKeyInfo own the public key#778
baloo wants to merge 5 commits into
RustCrypto:spki/generic-algorithm-identifierfrom
baloo:baloo/owned-api/spki-publickey

Conversation

@baloo

@baloobaloo commented Nov 29, 2022

Copy link
Copy Markdown
Member

This is based on #769

tarcieriand 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
balooforce-pushed the baloo/owned-api/spki-publickey branch from 6adaae7 to 1efe27aCompareNovember 29, 2022 19:42
Comment threadspki/src/spki.rs Outdated
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct SubjectPublicKeyInfo<'a, Params> {
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct SubjectPublicKeyInfo<Params> {

@baloobalooNov 29, 2022

Copy link
Copy Markdown
MemberAuthor

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
pubstructSubjectPublicKeyInfo<Params>{
pubstructSubjectPublicKeyInfo<Params,Pkey>{

And consume that as a

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

@tarcieritarcieriNov 29, 2022

Copy link
Copy Markdown
Member

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.

@baloobalooNov 30, 2022

Copy link
Copy Markdown
MemberAuthor

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
Copy Markdown
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
Copy Markdown
MemberAuthor

haha :) I missed that! sorry.

@baloo
balooforce-pushed the baloo/owned-api/spki-publickey branch 3 times, most recently from 763cc8f to b259658CompareNovember 30, 2022 06:45
@baloo
balooforce-pushed the baloo/owned-api/spki-publickey branch from b259658 to 25b9e19CompareNovember 30, 2022 06:57
@tarcieri
tarcieriforce-pushed the spki/generic-algorithm-identifier branch from b09ff11 to d6741cbCompareDecember 11, 2022 15:03
@tarcieri
tarcieri deleted the branch RustCrypto:spki/generic-algorithm-identifierDecember 11, 2022 16:09
@tarcieri

Copy link
Copy Markdown
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
Copy Markdown
MemberAuthor

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

Sign up for freeto 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

@baloo@tarcieri