pub struct MessageVerifier { /* private fields */ }Expand description
Stateful verification context using EVP_PKEY_verify_message_* (OpenSSL 3.2+).
Mirror of MessageSigner for the verification side.
For streaming mode: call set_signature, then
update zero or more times, then finish.
For one-shot: call verify_oneshot.
Implementations§
Source§impl MessageVerifier
impl MessageVerifier
Sourcepub fn new<T: HasPublic>(
key: &Pkey<T>,
alg: &mut SigAlg,
params: Option<&Params<'_>>,
) -> Result<Self, ErrorStack>
pub fn new<T: HasPublic>( key: &Pkey<T>, alg: &mut SigAlg, params: Option<&Params<'_>>, ) -> Result<Self, ErrorStack>
Create and initialise a message-verify context.
§Errors
Sourcepub fn set_params(&mut self, params: &Params<'_>) -> Result<(), ErrorStack>
pub fn set_params(&mut self, params: &Params<'_>) -> Result<(), ErrorStack>
Apply parameters after init.
§Errors
Sourcepub fn set_signature(&mut self, sig: &[u8]) -> Result<(), ErrorStack>
pub fn set_signature(&mut self, sig: &[u8]) -> Result<(), ErrorStack>
Supply the signature to verify against (required before streaming finish).
Calls EVP_PKEY_CTX_set_signature. Not needed for
verify_oneshot which sets it internally.
§Errors
Sourcepub fn supports_streaming(&mut self) -> bool
pub fn supports_streaming(&mut self) -> bool
Probe whether this algorithm supports incremental update calls.
Uses the same ERR_set_mark / ERR_pop_to_mark probe as
MessageSigner::supports_streaming.
Sourcepub fn update(&mut self, data: &[u8]) -> Result<(), ErrorStack>
pub fn update(&mut self, data: &[u8]) -> Result<(), ErrorStack>
Feed data into the verification operation.
§Errors
Sourcepub fn finish(self) -> Result<(), ErrorStack>
pub fn finish(self) -> Result<(), ErrorStack>
Finalise and verify.
The signature must have been set via set_signature.
Consumes self. Returns Ok(()) if the signature is valid.
§Errors
Sourcepub fn verify_oneshot(self, data: &[u8], sig: &[u8]) -> Result<(), ErrorStack>
pub fn verify_oneshot(self, data: &[u8], sig: &[u8]) -> Result<(), ErrorStack>
One-shot verify sig over data.
Sets the signature, feeds all data, and finalises. Consumes self.
§Errors
Sourcepub fn verify(&mut self, data: &[u8], sig: &[u8]) -> Result<bool, ErrorStack>
pub fn verify(&mut self, data: &[u8], sig: &[u8]) -> Result<bool, ErrorStack>
One-shot verify sig over data using EVP_PKEY_verify.
The context must have been initialised with EVP_PKEY_verify_message_init
(this type’s constructor); EVP_PKEY_verify accepts both
EVP_PKEY_OP_VERIFY and EVP_PKEY_OP_VERIFYMSG operation modes.
Returns Ok(true) if the signature verifies, Ok(false) if it does
not. Fatal protocol or library errors are returned as Err.
The context is not consumed and may be reused for further verifications.
Contrast with verify_oneshot: verify_oneshot
consumes self; verify borrows self and may be called repeatedly
without re-creating the context.
§Errors
Trait Implementations§
Source§impl Drop for MessageVerifier
Available on ossl320 only.
impl Drop for MessageVerifier
ossl320 only.impl Send for MessageVerifier
ossl320 only.