KeyRef

Struct KeyRef 

Source
pub struct KeyRef<'r> { /* private fields */ }
Available on crate feature allow-non-fips only.
Expand description

A reference to a Key, allowing for efficient key handling without ownership.

Implementations§

Source§

impl<'r> KeyRef<'r>

Source

pub const fn new(inner: &'r [u8; 32]) -> Self

Creates a new KeyRef from a reference to a 32-byte array.

§Arguments
  • inner - A reference to a 32-byte array containing the key material.
§Example
use wolf_crypto::mac::poly1305::{Key, KeyRef};

let key_bytes = [2u8; 32];
let key = Key::new(key_bytes,);
let key_ref: KeyRef = key.as_ref();
Source

pub const fn copy(&self) -> Key

Creates a copy of the key as a Key.

§Returns

A new Key instance containing the same key material.

§Example
use wolf_crypto::mac::poly1305::{Key, KeyRef};

let key_ref: KeyRef = (&[7u8; 32]).into();
let owned_key = key_ref.copy();

Trait Implementations§

Source§

impl<'r> Debug for KeyRef<'r>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'r> From<&'r [u8; 32]> for KeyRef<'r>

Source§

fn from(value: &'r [u8; 32]) -> Self

Converts a reference to a 32-byte array into a KeyRef.

§Arguments
  • value - A reference to a 32-byte array containing the key material.
§Example
use wolf_crypto::mac::poly1305::{Key, KeyRef};

let key_ref = KeyRef::from(&[2u8; 32]);
Source§

impl<'r> TryFrom<&'r [u8]> for KeyRef<'r>

Source§

fn try_from(value: &'r [u8]) -> Result<Self, Self::Error>

Attempts to convert a slice of bytes into a KeyRef.

§Arguments
  • value - A slice of bytes to convert.
§Errors

Returns TryFromSliceError if the slice length is not exactly 32 bytes.

§Example
use wolf_crypto::mac::poly1305::KeyRef;

let key_slice = &[5u8; 32];
let key_ref = KeyRef::try_from(key_slice).unwrap();
Source§

type Error = TryFromSliceError

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

impl<'r> GenericKey for KeyRef<'r>

Auto Trait Implementations§

§

impl<'r> Freeze for KeyRef<'r>

§

impl<'r> RefUnwindSafe for KeyRef<'r>

§

impl<'r> Send for KeyRef<'r>

§

impl<'r> Sync for KeyRef<'r>

§

impl<'r> Unpin for KeyRef<'r>

§

impl<'r> UnwindSafe for KeyRef<'r>

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>,

Source§

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>,

Source§

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.