Struct openssl::md_ctx::MdCtx

source ·
pub struct MdCtx(_);

Implementations§

source§

impl MdCtx

source

pub fn new() -> Result<Self, ErrorStack>

Creates a new context.

This corresponds to EVP_MD_CTX_new.

Methods from Deref<Target = 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 Deref for MdCtx

§

type Target = MdCtxRef

The resulting type after dereferencing.
source§

fn deref(&self) -> &MdCtxRef

Dereferences the value.
source§

impl DerefMut for MdCtx

source§

fn deref_mut(&mut self) -> &mut MdCtxRef

Mutably dereferences the value.
source§

impl Drop for MdCtx

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl ForeignType for MdCtx

§

type CType = EVP_MD_CTX

The raw C type.
§

type Ref = MdCtxRef

The type representing a reference to this type.
source§

unsafe fn from_ptr(ptr: *mut EVP_MD_CTX) -> MdCtx

Constructs an instance of this type from its raw type.
source§

fn as_ptr(&self) -> *mut EVP_MD_CTX

Returns a raw pointer to the wrapped value.
source§

impl Send for MdCtx

source§

impl Sync for MdCtx

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.