AesKey

Struct AesKey 

Source
pub struct AesKey<T: AesType>(/* private fields */);
Available on crate feature aes only.
Expand description

An AES symmetric encryption key

Trait Implementations§

Source§

impl<T: AesType> Clone for AesKey<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: AesType> Debug for AesKey<T>

Source§

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

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

impl<'de, T: AesType> Deserialize<'de> for AesKey<T>
where ArrayKey<<T as AesType>::KeySize>: for<'a> Deserialize<'a>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T: AesType> FromJwk for AesKey<T>

Source§

fn from_jwk_parts(jwk: JwkParts<'_>) -> Result<Self, Error>

Import the key from a pre-parsed JWK
Source§

fn from_jwk(jwk: &str) -> Result<Self, Error>

Import the key from a JWK string reference
Source§

fn from_jwk_slice(jwk: &[u8]) -> Result<Self, Error>

Import the key from a JWK byte slice
Source§

impl<T: AesType> FromKeyDerivation for AesKey<T>

Source§

fn from_key_derivation<D: KeyDerivation>(derive: D) -> Result<Self, Error>
where Self: Sized,

Create a new instance of a key from a key derivation
Source§

impl<Lhs, Rhs, T> FromKeyExchange<Lhs, Rhs> for AesKey<T>
where Lhs: KeyExchange<Rhs> + ?Sized, Rhs: ?Sized, T: AesType,

Source§

fn from_key_exchange(lhs: &Lhs, rhs: &Rhs) -> Result<Self, Error>

Derive an instance of this key directly from a supported key exchange
Source§

impl<T: AesType> HasKeyAlg for AesKey<T>

Source§

fn algorithm(&self) -> KeyAlg

Get the corresponding key algorithm.
Source§

impl<T: AesType> HasKeyBackend for AesKey<T>

Source§

fn key_backend(&self) -> KeyBackend

Get the corresponding key backend.
Source§

impl<C, D> KeyAeadInPlace for AesKey<AesCbcHmac<C, D>>

Source§

fn encrypt_in_place( &self, buffer: &mut dyn ResizeBuffer, nonce: &[u8], aad: &[u8], ) -> Result<usize, Error>

Encrypt a secret value in place, appending the verification tag and returning the length of the ciphertext
Source§

fn decrypt_in_place( &self, buffer: &mut dyn ResizeBuffer, nonce: &[u8], aad: &[u8], ) -> Result<(), Error>

Decrypt an encrypted (verification tag appended) value in place
Source§

fn aead_params(&self) -> KeyAeadParams

Get the nonce and tag length for encryption
Source§

fn aead_padding(&self, msg_len: usize) -> usize

Get the ciphertext padding required
Source§

impl<C> KeyAeadInPlace for AesKey<AesKeyWrap<C>>
where AesKeyWrap<C>: AesType, C: KeyInit + KeySizeUser<KeySize = <AesKeyWrap<C> as AesType>::KeySize> + BlockCipher<BlockSize = U16> + BlockDecrypt + BlockEncrypt,

Source§

fn encrypt_in_place( &self, buffer: &mut dyn ResizeBuffer, nonce: &[u8], aad: &[u8], ) -> Result<usize, Error>

Encrypt a secret value in place, appending the verification tag and returning the length of the ciphertext
Source§

fn decrypt_in_place( &self, buffer: &mut dyn ResizeBuffer, nonce: &[u8], aad: &[u8], ) -> Result<(), Error>

Decrypt an encrypted (verification tag appended) value in place
Source§

fn aead_params(&self) -> KeyAeadParams

Get the nonce and tag length for encryption
Source§

fn aead_padding(&self, _msg_len: usize) -> usize

Get the ciphertext padding required
Source§

impl<T> KeyAeadInPlace for AesKey<T>
where T: KeyInit + AeadInPlace + AesType<KeySize = <T as KeySizeUser>::KeySize>,

Source§

fn encrypt_in_place( &self, buffer: &mut dyn ResizeBuffer, nonce: &[u8], aad: &[u8], ) -> Result<usize, Error>

Encrypt a secret value in place, appending the verification tag

Source§

fn decrypt_in_place( &self, buffer: &mut dyn ResizeBuffer, nonce: &[u8], aad: &[u8], ) -> Result<(), Error>

Decrypt an encrypted (verification tag appended) value in place

Source§

fn aead_params(&self) -> KeyAeadParams

Get the nonce and tag length for encryption
Source§

fn aead_padding(&self, _msg_len: usize) -> usize

Get the ciphertext padding required
Source§

impl<C, D> KeyAeadMeta for AesKey<AesCbcHmac<C, D>>
where AesCbcHmac<C, D>: AesType, C: BlockCipher + KeyInit,

Source§

type NonceSize = <C as BlockSizeUser>::BlockSize

The size of the AEAD nonce
Source§

type TagSize = <C as KeySizeUser>::KeySize

The size of the AEAD tag
Source§

fn random_nonce() -> GenericArray<u8, Self::NonceSize>

Available on crate feature getrandom only.
Generate a new random nonce
Source§

impl<C> KeyAeadMeta for AesKey<AesKeyWrap<C>>
where AesKeyWrap<C>: AesType,

Source§

type NonceSize = UTerm

The size of the AEAD nonce
Source§

type TagSize = UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>

The size of the AEAD tag
Source§

fn random_nonce() -> GenericArray<u8, Self::NonceSize>

Available on crate feature getrandom only.
Generate a new random nonce
Source§

impl<T: AeadCore + AesType> KeyAeadMeta for AesKey<T>

Source§

type NonceSize = <T as AeadCore>::NonceSize

The size of the AEAD nonce
Source§

type TagSize = <T as AeadCore>::TagSize

The size of the AEAD tag
Source§

fn random_nonce() -> GenericArray<u8, Self::NonceSize>

Available on crate feature getrandom only.
Generate a new random nonce
Source§

impl<T: AesType> KeyGen for AesKey<T>

Source§

fn generate(rng: impl KeyMaterial) -> Result<Self, Error>

Create a new key from a key material generator.
Source§

fn random() -> Result<Self, Error>

Available on crate feature getrandom only.
Generate a new random key.
Source§

impl<T: AesType> KeyMeta for AesKey<T>

Source§

type KeySize = <T as AesType>::KeySize

The size of the key secret bytes
Source§

impl<T: AesType> KeySecretBytes for AesKey<T>

Source§

fn from_secret_bytes(key: &[u8]) -> Result<Self, Error>

Create a new key instance from a slice of key secret bytes.
Source§

fn with_secret_bytes<O>(&self, f: impl FnOnce(Option<&[u8]>) -> O) -> O

Access a temporary slice of the key secret bytes, if any.
Source§

impl<T: AesType> PartialEq for AesKey<T>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: AesType> Serialize for AesKey<T>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T: AesType> ToJwk for AesKey<T>

Source§

fn encode_jwk(&self, enc: &mut dyn JwkEncoder) -> Result<(), Error>

Write the JWK representation to an encoder
Source§

fn to_jwk_thumbprint(&self, alg: Option<KeyAlg>) -> Result<String, Error>

Available on crate feature alloc only.
Create the JWK thumbprint of the key
Source§

fn to_jwk_public(&self, alg: Option<KeyAlg>) -> Result<String, Error>

Available on crate feature alloc only.
Create a JWK of the public key
Source§

fn to_jwk_secret(&self, alg: Option<KeyAlg>) -> Result<SecretBytes, Error>

Available on crate feature alloc only.
Create a JWK of the secret key
Source§

impl<T: AesType> Zeroize for AesKey<T>

Source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
Source§

impl<T: AesType> Eq for AesKey<T>

Auto Trait Implementations§

§

impl<T> Freeze for AesKey<T>
where <<T as AesType>::KeySize as ArrayLength<u8>>::ArrayType: Freeze,

§

impl<T> RefUnwindSafe for AesKey<T>

§

impl<T> Send for AesKey<T>

§

impl<T> Sync for AesKey<T>

§

impl<T> !Unpin for AesKey<T>

§

impl<T> UnwindSafe for AesKey<T>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<K> ToSecretBytes for K
where K: KeySecretBytes,

Source§

fn secret_bytes_length(&self) -> Result<usize, Error>

Get the length of a secret key
Source§

fn write_secret_bytes(&self, out: &mut dyn WriteBuffer) -> Result<(), Error>

Write the key secret bytes to a buffer.
Source§

fn to_secret_bytes(&self) -> Result<SecretBytes, Error>

Available on crate feature alloc only.
Write the key secret bytes to a new allocated buffer.
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,