pub struct MdCtx(_);
Implementations
sourceimpl MdCtx
impl MdCtx
sourcepub fn new() -> Result<Self, ErrorStack>
pub fn new() -> Result<Self, ErrorStack>
Creates a new context.
This corresponds to EVP_MD_CTX_new
.
Methods from Deref<Target = 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: HasPrivate,
pub fn digest_verify_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 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
.
Trait Implementations
sourceimpl ForeignType for MdCtx
impl ForeignType for MdCtx
type CType = EVP_MD_CTX
type CType = EVP_MD_CTX
The raw C type.
sourceunsafe fn from_ptr(ptr: *mut EVP_MD_CTX) -> MdCtx
unsafe fn from_ptr(ptr: *mut EVP_MD_CTX) -> MdCtx
Constructs an instance of this type from its raw type.
sourcefn as_ptr(&self) -> *mut EVP_MD_CTX
fn as_ptr(&self) -> *mut EVP_MD_CTX
Returns a raw pointer to the wrapped value.
impl Send for MdCtx
impl Sync for MdCtx
Auto Trait Implementations
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more