Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions 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.2", features = ["db"] } # TODO: path = "../const-oid"
der = { version = "0.7.5", features = ["alloc", "derive", "flagset", "oid"] }
spki = { version = "0.7.1", features = ["alloc"] }
spki = { version = "0.7.2", features = ["alloc"] }

# optional dependencies
arbitrary = { version = "1.3", features = ["derive"], optional = true }
Expand All @@ -28,7 +28,7 @@ signature = { version = "2.1.0", features = ["rand_core"], optional = true }
hex-literal = "0.4"
rand = "0.8.5"
rsa = { version = "0.9.2", features = ["sha2"] }
ecdsa = { version = "0.16.4", features = ["digest", "pem"] }
ecdsa = { version = "0.16.7", features = ["digest", "pem"] }
p256 = "0.13.0"
rstest = "0.17"
sha2 = { version = "0.10", features = ["oid"] }
Expand Down
19 changes: 10 additions & 9 deletions x509-cert/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
use alloc::vec;
use core::fmt;
use der::{asn1::BitString, referenced::OwnedToRef, Encode};
use signature::{rand_core::CryptoRngCore, Keypair, RandomizedSigner, SignatureEncoding, Signer};
use signature::{rand_core::CryptoRngCore, Keypair, RandomizedSigner, Signer};
use spki::{
DynSignatureAlgorithmIdentifier, EncodePublicKey, SubjectPublicKeyInfoOwned,
SubjectPublicKeyInfoRef,
DynSignatureAlgorithmIdentifier, EncodePublicKey, SignatureBitStringEncoding,
SubjectPublicKeyInfoOwned, SubjectPublicKeyInfoRef,
};

use crate::{
Expand Down Expand Up @@ -421,12 +421,11 @@ pub trait Builder: Sized {
fn build<Signature>(mut self) -> Result<Self::Output>
where
Self::Signer: Signer<Signature>,
Signature: SignatureEncoding,
Signature: SignatureBitStringEncoding,
{
let blob = self.finalize()?;

let signature = self.signer().try_sign(&blob)?;
let signature = BitString::from_bytes(signature.to_bytes().as_ref())?;
let signature = self.signer().try_sign(&blob)?.to_bitstring()?;

self.assemble(signature)
}
Expand All @@ -435,12 +434,14 @@ pub trait Builder: Sized {
fn build_with_rng<Signature>(mut self, rng: &mut impl CryptoRngCore) -> Result<Self::Output>
where
Self::Signer: RandomizedSigner<Signature>,
Signature: SignatureEncoding,
Signature: SignatureBitStringEncoding,
{
let blob = self.finalize()?;

let signature = self.signer().try_sign_with_rng(rng, &blob)?;
let signature = BitString::from_bytes(signature.to_bytes().as_ref())?;
let signature = self
.signer()
.try_sign_with_rng(rng, &blob)?
.to_bitstring()?;

self.assemble(signature)
}
Expand Down