Skip to content

Commit 9739b9e

Browse files
committed
fixup pss
Signed-off-by: Arthur Gautier <[email protected]>
1 parent dc2672d commit 9739b9e

File tree

3 files changed

+5
-22
lines changed

3 files changed

+5
-22
lines changed

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cryptoki-rustcrypto/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ p224 = { version = "0.13.2", features = ["pkcs8"] }
1818
p256 = { version = "0.13.2", features = ["pkcs8"] }
1919
p384 = { version = "0.13.0", features = ["pkcs8"] }
2020
k256 = { version = "0.13.2", features = ["pkcs8"] }
21-
rsa = "0.9"
21+
rsa = "0.9.6"
2222
signature = { version = "2.2.0", features = ["digest"] }
2323
sha1 = { version = "0.10", features = ["oid"] }
2424
sha2 = { version = "0.10", features = ["oid"] }

cryptoki-rustcrypto/src/rsa/pss.rs

+2-19
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use der::{asn1::ObjectIdentifier, oid::AssociatedOid, Any, AnyRef};
66
use rsa::{
77
pkcs1::{self, RsaPssParams},
88
pkcs8::{self},
9-
pss::{Signature, VerifyingKey},
9+
pss::{get_default_pss_signature_algo_id, Signature, VerifyingKey},
1010
};
1111
use signature::digest::Digest;
1212
use spki::{
@@ -22,7 +22,6 @@ pub struct Signer<D: DigestSigning, S: SessionLike> {
2222
session: S,
2323
private_key: ObjectHandle,
2424
verifying_key: VerifyingKey<D>,
25-
salt_len: usize,
2625
}
2726

2827
impl<D: DigestSigning, S: SessionLike> Signer<D, S> {
@@ -64,13 +63,11 @@ impl<D: DigestSigning, S: SessionLike> Signer<D, S> {
6463
let public_key = read_key(&session, template)?;
6564

6665
let verifying_key = VerifyingKey::new(public_key);
67-
let salt_len = <D as Digest>::output_size();
6866

6967
Ok(Self {
7068
session,
7169
private_key,
7270
verifying_key,
73-
salt_len,
7471
})
7572
}
7673

@@ -109,20 +106,6 @@ impl<D: DigestSigning, S: SessionLike> signature::Signer<Signature> for Signer<D
109106

110107
impl<D: DigestSigning, S: SessionLike> DynSignatureAlgorithmIdentifier for Signer<D, S> {
111108
fn signature_algorithm_identifier(&self) -> pkcs8::spki::Result<AlgorithmIdentifierOwned> {
112-
get_pss_signature_algo_id::<D>(self.salt_len as u8)
109+
get_default_pss_signature_algo_id::<D>()
113110
}
114111
}
115-
116-
fn get_pss_signature_algo_id<D>(salt_len: u8) -> pkcs8::spki::Result<AlgorithmIdentifierOwned>
117-
where
118-
D: Digest + AssociatedOid,
119-
{
120-
const ID_RSASSA_PSS: ObjectIdentifier = ObjectIdentifier::new_unwrap("1.2.840.113549.1.1.10");
121-
122-
let pss_params = RsaPssParams::new::<D>(salt_len);
123-
124-
Ok(AlgorithmIdentifierOwned {
125-
oid: ID_RSASSA_PSS,
126-
parameters: Some(Any::encode_from(&pss_params)?),
127-
})
128-
}

0 commit comments

Comments
 (0)