Skip to content

Commit f09fd72

Browse files
committed
x509-cert: consume the SignatureBitStringEncoding trait
1 parent 93f87c4 commit f09fd72

3 files changed

Lines changed: 15 additions & 13 deletions

File tree

Cargo.lock

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x509-cert/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ rust-version = "1.65"
1717
[dependencies]
1818
const-oid = { version = "0.9.2", features = ["db"] } # TODO: path = "../const-oid"
1919
der = { version = "0.7.5", features = ["alloc", "derive", "flagset", "oid"] }
20-
spki = { version = "0.7.1", features = ["alloc"] }
20+
spki = { version = "0.7.2", features = ["alloc"] }
2121

2222
# optional dependencies
2323
arbitrary = { version = "1.3", features = ["derive"], optional = true }
@@ -28,7 +28,7 @@ signature = { version = "2.1.0", features = ["rand_core"], optional = true }
2828
hex-literal = "0.4"
2929
rand = "0.8.5"
3030
rsa = { version = "0.9.2", features = ["sha2"] }
31-
ecdsa = { version = "0.16.4", features = ["digest", "pem"] }
31+
ecdsa = { version = "0.16.7", features = ["digest", "pem"] }
3232
p256 = "0.13.0"
3333
rstest = "0.17"
3434
sha2 = { version = "0.10", features = ["oid"] }

x509-cert/src/builder.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
use alloc::vec;
44
use core::fmt;
55
use der::{asn1::BitString, referenced::OwnedToRef, Encode};
6-
use signature::{rand_core::CryptoRngCore, Keypair, RandomizedSigner, SignatureEncoding, Signer};
6+
use signature::{rand_core::CryptoRngCore, Keypair, RandomizedSigner, Signer};
77
use spki::{
8-
DynSignatureAlgorithmIdentifier, EncodePublicKey, SubjectPublicKeyInfoOwned,
9-
SubjectPublicKeyInfoRef,
8+
DynSignatureAlgorithmIdentifier, EncodePublicKey, SignatureBitStringEncoding,
9+
SubjectPublicKeyInfoOwned, SubjectPublicKeyInfoRef,
1010
};
1111

1212
use crate::{
@@ -421,12 +421,11 @@ pub trait Builder: Sized {
421421
fn build<Signature>(mut self) -> Result<Self::Output>
422422
where
423423
Self::Signer: Signer<Signature>,
424-
Signature: SignatureEncoding,
424+
Signature: SignatureBitStringEncoding,
425425
{
426426
let blob = self.finalize()?;
427427

428-
let signature = self.signer().try_sign(&blob)?;
429-
let signature = BitString::from_bytes(signature.to_bytes().as_ref())?;
428+
let signature = self.signer().try_sign(&blob)?.to_bitstring()?;
430429

431430
self.assemble(signature)
432431
}
@@ -435,12 +434,14 @@ pub trait Builder: Sized {
435434
fn build_with_rng<Signature>(mut self, rng: &mut impl CryptoRngCore) -> Result<Self::Output>
436435
where
437436
Self::Signer: RandomizedSigner<Signature>,
438-
Signature: SignatureEncoding,
437+
Signature: SignatureBitStringEncoding,
439438
{
440439
let blob = self.finalize()?;
441440

442-
let signature = self.signer().try_sign_with_rng(rng, &blob)?;
443-
let signature = BitString::from_bytes(signature.to_bytes().as_ref())?;
441+
let signature = self
442+
.signer()
443+
.try_sign_with_rng(rng, &blob)?
444+
.to_bitstring()?;
444445

445446
self.assemble(signature)
446447
}

0 commit comments

Comments
 (0)