Skip to content

Commit 4f10de3

Browse files
committed
x509-cert: consume the SignatureBitStringEncoding trait
1 parent ade4dc3 commit 4f10de3

4 files changed

Lines changed: 19 additions & 16 deletions

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,6 @@ tls_codec = { path = "./tls_codec" }
5757
tls_codec_derive = { path = "./tls_codec/derive" }
5858
x509-cert = { path = "./x509-cert" }
5959
x509-ocsp = { path = "./x509-ocsp" }
60+
61+
rsa = { git = "https://github.com/baloo/RSA.git", branch = "baloo/bitstring-signature" }
62+
ecdsa = { git = "https://github.com/baloo/signatures.git", branch = "baloo/ecdsa/bitstring-encoding" }

x509-cert/Cargo.toml

Lines changed: 1 addition & 1 deletion
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 }

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)