pub struct Deriver<'a>(/* private fields */);
Expand description
A type used to derive a shared secret between two keys.
Implementations§
source§impl<'a> Deriver<'a>
impl<'a> Deriver<'a>
sourcepub fn new<T>(key: &'a PKeyRef<T>) -> Result<Deriver<'a>, ErrorStack>where
T: HasPrivate,
pub fn new<T>(key: &'a PKeyRef<T>) -> Result<Deriver<'a>, ErrorStack>where
T: HasPrivate,
Creates a new Deriver
using the provided private key.
This corresponds to EVP_PKEY_derive_init
.
sourcepub fn set_peer<T>(&mut self, key: &'a PKeyRef<T>) -> Result<(), ErrorStack>where
T: HasPublic,
pub fn set_peer<T>(&mut self, key: &'a PKeyRef<T>) -> Result<(), ErrorStack>where
T: HasPublic,
Sets the peer key used for secret derivation.
This corresponds to EVP_PKEY_derive_set_peer
.
sourcepub fn len(&mut self) -> Result<usize, ErrorStack>
pub fn len(&mut self) -> Result<usize, ErrorStack>
Returns the size of the shared secret.
It can be used to size the buffer passed to Deriver::derive
.
This corresponds to EVP_PKEY_derive
.
sourcepub fn derive(&mut self, buf: &mut [u8]) -> Result<usize, ErrorStack>
pub fn derive(&mut self, buf: &mut [u8]) -> Result<usize, ErrorStack>
Derives a shared secret between the two keys, writing it into the buffer.
Returns the number of bytes written.
This corresponds to EVP_PKEY_derive
.
sourcepub fn derive_to_vec(&mut self) -> Result<Vec<u8>, ErrorStack>
pub fn derive_to_vec(&mut self) -> Result<Vec<u8>, ErrorStack>
A convenience function which derives a shared secret and returns it in a new buffer.
This simply wraps Deriver::len
and Deriver::derive
.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Deriver<'a>
impl<'a> RefUnwindSafe for Deriver<'a>
impl<'a> Unpin for Deriver<'a>
impl<'a> UnwindSafe for Deriver<'a>
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