pub struct DigestAlg { /* private fields */ }Expand description
An OpenSSL digest algorithm descriptor (EVP_MD*).
Fetched once and reused. Implements Clone via EVP_MD_up_ref.
Implementations§
Source§impl DigestAlg
impl DigestAlg
Sourcepub fn fetch(name: &CStr, props: Option<&CStr>) -> Result<Self, ErrorStack>
pub fn fetch(name: &CStr, props: Option<&CStr>) -> Result<Self, ErrorStack>
Fetch a digest algorithm from the global default library context.
§Errors
Returns Err if the algorithm is not available.
Sourcepub fn fetch_in(
ctx: &Arc<LibCtx>,
name: &CStr,
props: Option<&CStr>,
) -> Result<Self, ErrorStack>
pub fn fetch_in( ctx: &Arc<LibCtx>, name: &CStr, props: Option<&CStr>, ) -> Result<Self, ErrorStack>
Fetch a digest algorithm from an explicit library context.
The Arc is cloned and held so the context outlives this descriptor.
§Errors
Sourcepub fn output_len(&self) -> usize
pub fn output_len(&self) -> usize
Digest output size in bytes (e.g. 32 for SHA-256).
Sourcepub fn block_size(&self) -> usize
pub fn block_size(&self) -> usize
Block size in bytes (e.g. 64 for SHA-256).
Source§impl DigestAlg
impl DigestAlg
Sourcepub fn new_context(&self) -> Result<DigestCtx, ErrorStack>
pub fn new_context(&self) -> Result<DigestCtx, ErrorStack>
Create a new digest context initialised with this algorithm.
§Errors
Returns Err if context allocation or init fails.
Sourcepub fn digest(&self, data: &[u8], out: &mut [u8]) -> Result<usize, ErrorStack>
pub fn digest(&self, data: &[u8], out: &mut [u8]) -> Result<usize, ErrorStack>
Compute a digest in a single call (one-shot path).
Zero-copy: reads from data, writes into out.
out must be at least self.output_len() bytes.
§Errors
Sourcepub fn digest_to_vec(&self, data: &[u8]) -> Result<Vec<u8>, ErrorStack>
pub fn digest_to_vec(&self, data: &[u8]) -> Result<Vec<u8>, ErrorStack>
Compute a digest and return it in a freshly allocated Vec<u8>.
§Errors
Trait Implementations§
impl Send for DigestAlg
impl Sync for DigestAlg
Auto Trait Implementations§
impl Freeze for DigestAlg
impl RefUnwindSafe for DigestAlg
impl Unpin for DigestAlg
impl UnsafeUnpin for DigestAlg
impl UnwindSafe for DigestAlg
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
Mutably borrows from an owned value. Read more