Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/RustCrypto/formats into c…
Browse files Browse the repository at this point in the history
…ms/pwri-builder
  • Loading branch information
bkstein committed Dec 5, 2023
2 parents d0a4f8e + 5eb52b0 commit b505f04
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 9 deletions.
1 change: 1 addition & 0 deletions .cargo/audit.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[advisories]
ignore = [
"RUSTSEC-2021-0127", # serde_cbor is unmaintained
"RUSTSEC-2023-0071", # rsa: Marvin Attack: potential key recovery
]
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions spki/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.7.3 (2023-11-28)
### Added
- public key to `SubjectPublicKeyInfoOwned` helper ([#1269])

[#1269]: https://github.com/RustCrypto/formats/pull/1269

## 0.7.2 (2023-05-04)

### Added
Expand Down
2 changes: 1 addition & 1 deletion spki/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "spki"
version = "0.7.2"
version = "0.7.3"
description = """
X.509 Subject Public Key Info (RFC5280) describing public keys as well as their
associated AlgorithmIdentifiers (i.e. OIDs)
Expand Down
12 changes: 12 additions & 0 deletions spki/src/spki.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ impl<Params, Key> PemLabel for SubjectPublicKeyInfo<Params, Key> {
#[cfg(feature = "alloc")]
mod allocating {
use super::*;
use crate::EncodePublicKey;
use der::referenced::*;

impl<'a> RefToOwned<'a> for SubjectPublicKeyInfoRef<'a> {
Expand All @@ -202,4 +203,15 @@ mod allocating {
}
}
}

impl SubjectPublicKeyInfoOwned {
/// Create a [`SubjectPublicKeyInfoOwned`] from any object that implements
/// [`EncodePublicKey`].
pub fn from_key<T>(source: T) -> Result<Self>
where
T: EncodePublicKey,
{
Ok(source.to_public_key_der()?.decode_msg::<Self>()?)
}
}
}
2 changes: 1 addition & 1 deletion x509-cert/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ rust-version = "1.65"
[dependencies]
const-oid = { version = "0.9.3", features = ["db"] }
der = { version = "0.7.6", features = ["alloc", "derive", "flagset", "oid"] }
spki = { version = "0.7.2", features = ["alloc"] }
spki = { version = "0.7.3", features = ["alloc"] }

# optional dependencies
arbitrary = { version = "1.3", features = ["derive"], optional = true }
Expand Down
8 changes: 2 additions & 6 deletions x509-cert/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,7 @@ where
cert_signer: &'s S,
) -> Result<Self> {
let verifying_key = cert_signer.verifying_key();
let signer_pub = verifying_key
.to_public_key_der()?
.decode_msg::<SubjectPublicKeyInfoOwned>()?;
let signer_pub = SubjectPublicKeyInfoOwned::from_key(verifying_key)?;

let signature_alg = cert_signer.signature_algorithm_identifier()?;
let issuer = profile.get_issuer(&subject);
Expand Down Expand Up @@ -370,9 +368,7 @@ where
pub fn new(subject: Name, req_signer: &'s S) -> Result<Self> {
let version = Default::default();
let verifying_key = req_signer.verifying_key();
let public_key = verifying_key
.to_public_key_der()?
.decode_msg::<SubjectPublicKeyInfoOwned>()?;
let public_key = SubjectPublicKeyInfoOwned::from_key(verifying_key)?;
let attributes = Default::default();
let extension_req = Default::default();

Expand Down

0 comments on commit b505f04

Please sign in to comment.