-
Notifications
You must be signed in to change notification settings - Fork 136
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
pkcs8: provide PrivateKeyInfoRef/PrivateKeyInfoOwned #1483
pkcs8: provide PrivateKeyInfoRef/PrivateKeyInfoOwned #1483
Conversation
Signed-off-by: Arthur Gautier <[email protected]>
Signed-off-by: Arthur Gautier <[email protected]>
Signed-off-by: Arthur Gautier <[email protected]>
Signed-off-by: Arthur Gautier <[email protected]>
Signed-off-by: Arthur Gautier <[email protected]>
pkcs8/src/private_key_info.rs
Outdated
reader.read_nested(header.length, |reader| { | ||
// Parse and validate `version` INTEGER. | ||
let version = Version::decode(reader)?; | ||
let algorithm = reader.decode()?; | ||
let private_key = OctetStringRef::decode(reader)?.into(); | ||
let private_key: &[u8] = OctetStringRef::decode(reader)?.into(); | ||
let private_key = Key::try_from(private_key)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, this could be an OctetString or OctetStringRef instead. I don't know what I was thinking last year.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clippy
seems to suggest From
over TryFrom
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, clippy lead me to rethink my position on OctetString actually.
I rewrote the backing storage in the follow up commit.
71c9927
to
8191fb6
Compare
and that is now causing problems all over the place, sweet. |
5e9b14d
to
bcf2035
Compare
pub trait BitStringLike { | ||
fn as_bit_string(&self) -> BitStringRef<'_>; | ||
} | ||
|
||
impl<'a> BitStringLike for BitStringRef<'a> { | ||
fn as_bit_string(&self) -> BitStringRef<'_> { | ||
BitStringRef::from(self) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could not figure out a way to express this with the traits implemented by both BitStringRef
and BitString
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the interest of getting this PR across the finish line I'll go ahead and merge this, but I think we should definitely find a better solution, and it should go in the der
crate.
Something like OwnedToRef
but impl'd for both the owned and reference types so it can be used interchangeably, and for any of the *Ref
types and not just specialized to BitString*
.
Signed-off-by: Arthur Gautier <[email protected]>
Signed-off-by: Arthur Gautier <[email protected]>
Signed-off-by: Arthur Gautier <[email protected]>
Signed-off-by: Arthur Gautier <[email protected]>
Signed-off-by: Arthur Gautier <[email protected]>
Signed-off-by: Arthur Gautier <[email protected]>
Signed-off-by: Arthur Gautier <[email protected]>
fb4becf
to
3400a03
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved with mild dissatisfaction in BitStringLike
. Hopefully we can find a better, more general solution.
- pkcs1 `0.8.0-rc.1` - pkcs8 `0.11.0-rc.1` - sec1 `0.8.0-rc.1` This comes after the merge of API breaks on pkcs8 ([RustCrypto#1483]) [RustCrypto#1483]: RustCrypto#1483
This bump the following dependencies: - pkcs8 0.11.0-rc.0 -> 0.11.0-rc.1 - elliptic-curve 0.14.0-pre.6 -> 0.14.0-rc.0 This is a followup on breaking changes made on pkcs8 (RustCrypto/formats#1483).
This bump the following dependencies: - pkcs8 0.11.0-rc.0 -> 0.11.0-rc.1 - elliptic-curve 0.14.0-pre.6 -> 0.14.0-rc.0 This is a followup on breaking changes made on pkcs8 (RustCrypto/formats#1483).
#1183 mark 2
This makes the
PrivateKeyInfo
generic over its backing storage, and this provides two version of it, namelyPrivateKeyInfoRef
andPrivateKeyInfoOwned
respectively borrowing the value and owning the storage of the value.followup PRs: