Skip to content

Commit 1be36d2

Browse files
committed
signature: Deprecate VerificationAlgorithm::verify.
1 parent 4171fc2 commit 1be36d2

File tree

4 files changed

+27
-9
lines changed

4 files changed

+27
-9
lines changed

src/ec/curve25519/ed25519/verification.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ impl core::fmt::Debug for EdDSAParameters {
3333
/// [Ed25519]: https://ed25519.cr.yp.to/
3434
pub static ED25519: EdDSAParameters = EdDSAParameters {};
3535

36-
impl signature::VerificationAlgorithm for EdDSAParameters {
37-
fn verify(
36+
impl signature::VerificationAlgorithm for EdDSAParameters {}
37+
impl signature::VerificationAlgorithm_ for EdDSAParameters {
38+
fn verify_(
3839
&self,
3940
public_key: untrusted::Input,
4041
msg: untrusted::Input,

src/ec/suite_b/ecdsa/verification.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ enum AlgorithmID {
4949

5050
derive_debug_via_id!(EcdsaVerificationAlgorithm);
5151

52-
impl signature::VerificationAlgorithm for EcdsaVerificationAlgorithm {
53-
fn verify(
52+
impl signature::VerificationAlgorithm for EcdsaVerificationAlgorithm {}
53+
impl signature::VerificationAlgorithm_ for EcdsaVerificationAlgorithm {
54+
fn verify_(
5455
&self,
5556
public_key: untrusted::Input,
5657
msg: untrusted::Input,

src/rsa/verification.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ use crate::{
2424
sealed, signature,
2525
};
2626

27-
impl signature::VerificationAlgorithm for RsaParameters {
28-
fn verify(
27+
impl signature::VerificationAlgorithm for RsaParameters {}
28+
impl signature::VerificationAlgorithm_ for RsaParameters {
29+
fn verify_(
2930
&self,
3031
public_key: untrusted::Input,
3132
msg: untrusted::Input,

src/signature.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,16 +342,31 @@ pub trait KeyPair: core::fmt::Debug + Send + Sized + Sync {
342342
pub(crate) const MAX_LEN: usize = 1/*tag:SEQUENCE*/ + 2/*len*/ +
343343
(2 * (1/*tag:INTEGER*/ + 1/*len*/ + 1/*zero*/ + ec::SCALAR_MAX_BYTES));
344344

345+
pub(super) trait VerificationAlgorithm_: core::fmt::Debug + Sync + sealed::Sealed {
346+
fn verify_(
347+
&self,
348+
public_key: untrusted::Input,
349+
msg: untrusted::Input,
350+
signature: untrusted::Input,
351+
) -> Result<(), error::Unspecified>;
352+
}
353+
345354
/// A signature verification algorithm.
346-
pub trait VerificationAlgorithm: core::fmt::Debug + Sync + sealed::Sealed {
355+
#[allow(private_bounds)]
356+
pub trait VerificationAlgorithm:
357+
VerificationAlgorithm_ + core::fmt::Debug + Sync + sealed::Sealed
358+
{
347359
/// Verify the signature `signature` of message `msg` with the public key
348360
/// `public_key`.
361+
#[deprecated(note = "Internal API not intended for external use.")]
349362
fn verify(
350363
&self,
351364
public_key: untrusted::Input,
352365
msg: untrusted::Input,
353366
signature: untrusted::Input,
354-
) -> Result<(), error::Unspecified>;
367+
) -> Result<(), error::Unspecified> {
368+
self.verify_(public_key, msg, signature)
369+
}
355370
}
356371

357372
/// An unparsed, possibly malformed, public key for signature verification.
@@ -400,7 +415,7 @@ impl<B> UnparsedPublicKey<B> {
400415
B: AsRef<[u8]>,
401416
{
402417
let _ = cpu::features();
403-
self.algorithm.verify(
418+
self.algorithm.verify_(
404419
untrusted::Input::from(self.bytes.as_ref()),
405420
untrusted::Input::from(message),
406421
untrusted::Input::from(signature),

0 commit comments

Comments
 (0)