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 set_peer_ex<T>(
&mut self,
key: &'a PKeyRef<T>,
validate_peer: bool,
) -> Result<(), ErrorStack>where
T: HasPublic,
pub fn set_peer_ex<T>(
&mut self,
key: &'a PKeyRef<T>,
validate_peer: bool,
) -> Result<(), ErrorStack>where
T: HasPublic,
Sets the peer key used for secret derivation along with optionally validating the peer public key.
Requires OpenSSL 3.0.0 or newer.
This corresponds to EVP_PKEY_derive_set_peer_ex
.
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
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 8 bytes