Struct openssl::md_ctx::MdCtxRef

source ·
pub struct MdCtxRef(/* private fields */);
Expand description

A reference to an MdCtx.

Implementations§

source§

impl MdCtxRef

source

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.

source

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.

source

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.

source

pub fn digest_update(&mut self, data: &[u8]) -> Result<(), ErrorStack>

Updates the context with more data.

This corresponds to EVP_DigestUpdate.

source

pub fn digest_sign_update(&mut self, data: &[u8]) -> Result<(), ErrorStack>

Updates the context with more data.

This corresponds to EVP_DigestSignUpdate.

source

pub fn digest_verify_update(&mut self, data: &[u8]) -> Result<(), ErrorStack>

Updates the context with more data.

This corresponds to EVP_DigestVerifyUpdate.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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 AsRef<MdCtxRef> for MdCtx

source§

fn as_ref(&self) -> &MdCtxRef

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Borrow<MdCtxRef> for MdCtx

source§

fn borrow(&self) -> &MdCtxRef

Immutably borrows from an owned value. Read more
source§

impl ForeignTypeRef for MdCtxRef

§

type CType = EVP_MD_CTX

The raw C type.
source§

unsafe fn from_ptr<'a>(ptr: *mut Self::CType) -> &'a Self

Constructs a shared instance of this type from its raw type.
source§

unsafe fn from_ptr_mut<'a>(ptr: *mut Self::CType) -> &'a mut Self

Constructs a mutable reference of this type from its raw type.
source§

fn as_ptr(&self) -> *mut Self::CType

Returns a raw pointer to the wrapped value.
source§

impl Send for MdCtxRef

source§

impl Sync for MdCtxRef

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.