pub trait SignatureVerificationAlgorithm: Send + Sync {
// Required methods
fn public_key_alg_id(&self) -> AlgorithmIdentifier;
fn signature_alg_id(&self) -> AlgorithmIdentifier;
fn verify_signature(
&self,
public_key: &[u8],
message: &[u8],
signature: &[u8]
) -> Result<(), InvalidSignature>;
}Expand description
An abstract signature verification algorithm.
One of these is needed per supported pair of public key type (identified
with public_key_alg_id()) and signatureAlgorithm (identified with
signature_alg_id()). Note that both of these AlgorithmIdentifiers include
the parameters encoding, so separate SignatureVerificationAlgorithms are needed
for each possible public key or signature parameters.
Required Methods§
sourcefn public_key_alg_id(&self) -> AlgorithmIdentifier
fn public_key_alg_id(&self) -> AlgorithmIdentifier
Return the AlgorithmIdentifier that must be present on a subjectPublicKeyInfo
for this SignatureVerificationAlgorithm to be considered for verification.
sourcefn signature_alg_id(&self) -> AlgorithmIdentifier
fn signature_alg_id(&self) -> AlgorithmIdentifier
Return the AlgorithmIdentifier that must be present as the signatureAlgorithm
on the data to be verified for this SignatureVerificationAlgorithm to be considered
for this SignatureVerificationAlgorithm to be considered.
sourcefn verify_signature(
&self,
public_key: &[u8],
message: &[u8],
signature: &[u8]
) -> Result<(), InvalidSignature>
fn verify_signature( &self, public_key: &[u8], message: &[u8], signature: &[u8] ) -> Result<(), InvalidSignature>
Verify a signature.
public_key is the subjectPublicKey value from a SubjectPublicKeyInfo encoding
and is untrusted.
message is the data over which the signature was allegedly computed.
It is not hashed; implementations of this trait function must do hashing
if that is required by the algorithm they implement.
signature is the signature allegedly over message.
Return Ok(()) only if signature is a valid signature on message.
Return Err(InvalidSignature) if the signature is invalid, including if the public_key
encoding is invalid. There is no need or opportunity to produce errors
that are more specific than this.