pub struct MdCtxRef(/* private fields */);
Expand description
A reference to an MdCtx
.
Implementations§
Source§impl MdCtxRef
impl MdCtxRef
Sourcepub fn digest_init(&mut self, digest: &MdRef) -> Result<(), ErrorStack>
pub fn digest_init(&mut self, digest: &MdRef) -> Result<(), ErrorStack>
Initializes the context to compute the digest of data.
This corresponds to EVP_DigestInit_ex
.
Sourcepub fn digest_sign_init<'a, T>(
&'a mut self,
digest: Option<&MdRef>,
pkey: &PKeyRef<T>,
) -> Result<&'a mut PkeyCtxRef<T>, ErrorStack>where
T: HasPrivate,
pub fn digest_sign_init<'a, T>(
&'a mut self,
digest: Option<&MdRef>,
pkey: &PKeyRef<T>,
) -> Result<&'a mut PkeyCtxRef<T>, ErrorStack>where
T: HasPrivate,
Initializes the context to compute the signature of data.
A reference to the context’s inner PkeyCtx
is returned, allowing signature settings to be configured.
This corresponds to EVP_DigestSignInit
.
Sourcepub fn digest_verify_init<'a, T>(
&'a mut self,
digest: Option<&MdRef>,
pkey: &PKeyRef<T>,
) -> Result<&'a mut PkeyCtxRef<T>, ErrorStack>where
T: HasPublic,
pub fn digest_verify_init<'a, T>(
&'a mut self,
digest: Option<&MdRef>,
pkey: &PKeyRef<T>,
) -> Result<&'a mut PkeyCtxRef<T>, ErrorStack>where
T: HasPublic,
Initializes the context to verify the signature of data.
A reference to the context’s inner PkeyCtx
is returned, allowing signature settings to be configured.
This corresponds to EVP_DigestVerifyInit
.
Sourcepub fn digest_update(&mut self, data: &[u8]) -> Result<(), ErrorStack>
pub fn digest_update(&mut self, data: &[u8]) -> Result<(), ErrorStack>
Updates the context with more data.
This corresponds to EVP_DigestUpdate
.
Sourcepub fn digest_sign_update(&mut self, data: &[u8]) -> Result<(), ErrorStack>
pub fn digest_sign_update(&mut self, data: &[u8]) -> Result<(), ErrorStack>
Updates the context with more data.
This corresponds to EVP_DigestSignUpdate
.
Sourcepub fn digest_verify_update(&mut self, data: &[u8]) -> Result<(), ErrorStack>
pub fn digest_verify_update(&mut self, data: &[u8]) -> Result<(), ErrorStack>
Updates the context with more data.
This corresponds to EVP_DigestVerifyUpdate
.
Sourcepub fn digest_final(&mut self, out: &mut [u8]) -> Result<usize, ErrorStack>
pub fn digest_final(&mut self, out: &mut [u8]) -> Result<usize, ErrorStack>
Copies the computed digest into the buffer, returning the number of bytes written.
This corresponds to EVP_DigestFinal
.
Sourcepub fn digest_final_xof(&mut self, out: &mut [u8]) -> Result<(), ErrorStack>
pub fn digest_final_xof(&mut self, out: &mut [u8]) -> Result<(), ErrorStack>
Copies the computed digest into the buffer.
Requires OpenSSL 1.1.1 or newer.
This corresponds to EVP_DigestFinalXOF
.
Sourcepub fn digest_sign_final(
&mut self,
out: Option<&mut [u8]>,
) -> Result<usize, ErrorStack>
pub fn digest_sign_final( &mut self, out: Option<&mut [u8]>, ) -> Result<usize, ErrorStack>
Signs the computed digest.
If out
is set to None
, an upper bound on the number of bytes required for the output buffer will be
returned.
This corresponds to EVP_DigestSignFinal
.
Sourcepub fn digest_sign_final_to_vec(
&mut self,
out: &mut Vec<u8>,
) -> Result<usize, ErrorStack>
pub fn digest_sign_final_to_vec( &mut self, out: &mut Vec<u8>, ) -> Result<usize, ErrorStack>
Like Self::digest_sign_final
but appends the signature to a Vec
.
Sourcepub fn digest_verify_final(
&mut self,
signature: &[u8],
) -> Result<bool, ErrorStack>
pub fn digest_verify_final( &mut self, signature: &[u8], ) -> Result<bool, ErrorStack>
Verifies the provided signature.
Returns Ok(true)
if the signature is valid, Ok(false)
if the signature is invalid, and Err
if an error
occurred.
This corresponds to EVP_DigestVerifyFinal
.
Sourcepub fn digest_sign(
&mut self,
from: &[u8],
to: Option<&mut [u8]>,
) -> Result<usize, ErrorStack>
pub fn digest_sign( &mut self, from: &[u8], to: Option<&mut [u8]>, ) -> Result<usize, ErrorStack>
Computes the signature of the data in from
.
If to
is set to None
, an upper bound on the number of bytes required for the output buffer will be
returned.
Requires OpenSSL 1.1.1 or newer.
This corresponds to EVP_DigestSign
.
Sourcepub fn digest_sign_to_vec(
&mut self,
from: &[u8],
to: &mut Vec<u8>,
) -> Result<usize, ErrorStack>
pub fn digest_sign_to_vec( &mut self, from: &[u8], to: &mut Vec<u8>, ) -> Result<usize, ErrorStack>
Like Self::digest_sign
but appends the signature to a Vec
.
Sourcepub fn digest_verify(
&mut self,
data: &[u8],
signature: &[u8],
) -> Result<bool, ErrorStack>
pub fn digest_verify( &mut self, data: &[u8], signature: &[u8], ) -> Result<bool, ErrorStack>
Verifies the signature of the data in data
.
Returns Ok(true)
if the signature is valid, Ok(false)
if the signature is invalid, and Err
if an error
occurred.
Requires OpenSSL 1.1.1 or newer.
This corresponds to EVP_DigestVerify
.
Sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
Returns the size of the message digest, i.e. the size of the hash
This corresponds to EVP_MD_CTX_size
.
Sourcepub fn reset(&mut self) -> Result<(), ErrorStack>
pub fn reset(&mut self) -> Result<(), ErrorStack>
Resets the underlying EVP_MD_CTX instance
This corresponds to EVP_MD_CTX_reset
.
Trait Implementations§
Source§impl ForeignTypeRef for MdCtxRef
impl ForeignTypeRef for MdCtxRef
Source§type CType = EVP_MD_CTX
type CType = EVP_MD_CTX
Source§unsafe fn from_ptr<'a>(ptr: *mut Self::CType) -> &'a Self
unsafe fn from_ptr<'a>(ptr: *mut Self::CType) -> &'a Self
Source§unsafe fn from_ptr_mut<'a>(ptr: *mut Self::CType) -> &'a mut Self
unsafe fn from_ptr_mut<'a>(ptr: *mut Self::CType) -> &'a mut Self
impl Send for MdCtxRef
impl Sync for MdCtxRef
Auto Trait Implementations§
impl !Freeze for MdCtxRef
impl !RefUnwindSafe for MdCtxRef
impl Unpin for MdCtxRef
impl UnwindSafe for MdCtxRef
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 0 bytes