Skip to content

Commit

Permalink
Rename Pkcs1v15Sign::new_raw to Pkcs1v15Sign::new_unprefixed
Browse files Browse the repository at this point in the history
Following #290, which amended `pkcs1v15::SigningKey`, this commit makes
a corresponding change to `Pkcs1v15Sign` so the method name is
consistent with `SigningKey::new_unprefixed`
  • Loading branch information
tarcieri committed Apr 15, 2023
1 parent bf1defd commit 6095f90
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/pkcs1v15.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,23 @@ impl Pkcs1v15Sign {
}
}

/// Create new PKCS#1 v1.5 padding for computing a raw signature.
/// Create new PKCS#1 v1.5 padding for computing an unprefixed signature.
///
/// This sets `hash_len` to `None` and uses an empty `prefix`.
pub fn new_raw() -> Self {
pub fn new_unprefixed() -> Self {
Self {
hash_len: None,
prefix: Box::new([]),
}
}

/// Create new PKCS#1 v1.5 padding for computing an unprefixed signature.
///
/// This sets `hash_len` to `None` and uses an empty `prefix`.
#[deprecated(since = "0.9.0", note = "use Pkcs1v15Sign::new_unprefixed instead")]
pub fn new_raw() -> Self {
Self::new_unprefixed()
}
}

impl SignatureScheme for Pkcs1v15Sign {
Expand Down Expand Up @@ -1300,12 +1308,12 @@ mod tests {
let expected_sig = Base64::decode_vec("pX4DR8azytjdQ1rtUiC040FjkepuQut5q2ZFX1pTjBrOVKNjgsCDyiJDGZTCNoh9qpXYbhl7iEym30BWWwuiZg==").unwrap();
let priv_key = get_private_key();

let sig = priv_key.sign(Pkcs1v15Sign::new_raw(), msg).unwrap();
let sig = priv_key.sign(Pkcs1v15Sign::new_unprefixed(), msg).unwrap();
assert_eq!(expected_sig, sig);

let pub_key: RsaPublicKey = priv_key.into();
pub_key
.verify(Pkcs1v15Sign::new_raw(), msg, &sig)
.verify(Pkcs1v15Sign::new_unprefixed(), msg, &sig)
.expect("failed to verify");
}

Expand Down

0 comments on commit 6095f90

Please sign in to comment.