Struct bc_components::SymmetricKey
source · pub struct SymmetricKey(_);
Expand description
A symmetric encryption key.
Implementations§
source§impl SymmetricKey
impl SymmetricKey
pub const SYMMETRIC_KEY_SIZE: usize = 32usize
sourcepub fn new_using(rng: &mut impl RandomNumberGenerator) -> Self
pub fn new_using(rng: &mut impl RandomNumberGenerator) -> Self
Create a new random symmetric key using the given random number generator.
sourcepub fn from_data_ref<T>(data: &T) -> Option<Self>where
T: AsRef<[u8]>,
pub fn from_data_ref<T>(data: &T) -> Option<Self>where T: AsRef<[u8]>,
Create a new symmetric key from data.
sourcepub fn from_hex<T>(hex: T) -> Selfwhere
T: AsRef<str>,
pub fn from_hex<T>(hex: T) -> Selfwhere T: AsRef<str>,
Create a new symmetric key from the given hexadecimal string.
Panics
Panics if the string is not exactly 24 hexadecimal digits.
sourcepub fn encrypt<D, N>(
&self,
plaintext: D,
aad: Option<&[u8]>,
nonce: Option<N>
) -> EncryptedMessagewhere
D: AsRef<[u8]>,
N: AsRef<Nonce>,
pub fn encrypt<D, N>( &self, plaintext: D, aad: Option<&[u8]>, nonce: Option<N> ) -> EncryptedMessagewhere D: AsRef<[u8]>, N: AsRef<Nonce>,
Encrypt the given plaintext with this key, and the given additional authenticated data and nonce.
sourcepub fn encrypt_with_digest<D, N>(
&self,
plaintext: D,
digest: &Digest,
nonce: Option<N>
) -> EncryptedMessagewhere
D: AsRef<[u8]>,
N: AsRef<Nonce>,
pub fn encrypt_with_digest<D, N>( &self, plaintext: D, digest: &Digest, nonce: Option<N> ) -> EncryptedMessagewhere D: AsRef<[u8]>, N: AsRef<Nonce>,
Encrypt the given plaintext with this key, and the given digest of the plaintext, and nonce.
Trait Implementations§
source§impl CBORDecodable for SymmetricKey
impl CBORDecodable for SymmetricKey
source§impl CBOREncodable for SymmetricKey
impl CBOREncodable for SymmetricKey
source§impl CBORTagged for SymmetricKey
impl CBORTagged for SymmetricKey
source§impl CBORTaggedDecodable for SymmetricKey
impl CBORTaggedDecodable for SymmetricKey
source§fn from_untagged_cbor(cbor: &CBOR) -> Result<Self, Error>
fn from_untagged_cbor(cbor: &CBOR) -> Result<Self, Error>
Creates an instance of this type by decoding it from untagged CBOR.
source§fn from_tagged_cbor(cbor: &CBOR) -> Result<Self, Error>where
Self: Sized,
fn from_tagged_cbor(cbor: &CBOR) -> Result<Self, Error>where Self: Sized,
Creates an instance of this type by decoding it from tagged CBOR.
source§impl CBORTaggedEncodable for SymmetricKey
impl CBORTaggedEncodable for SymmetricKey
source§fn untagged_cbor(&self) -> CBOR
fn untagged_cbor(&self) -> CBOR
Returns the untagged CBOR encoding of this instance.
source§fn tagged_cbor(&self) -> CBOR
fn tagged_cbor(&self) -> CBOR
Returns the tagged CBOR encoding of this instance.
source§impl Clone for SymmetricKey
impl Clone for SymmetricKey
source§fn clone(&self) -> SymmetricKey
fn clone(&self) -> SymmetricKey
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for SymmetricKey
impl Debug for SymmetricKey
source§impl Default for SymmetricKey
impl Default for SymmetricKey
source§impl<'a> From<&'a SymmetricKey> for &'a [u8; 32]
impl<'a> From<&'a SymmetricKey> for &'a [u8; 32]
source§fn from(digest: &'a SymmetricKey) -> Self
fn from(digest: &'a SymmetricKey) -> Self
Converts to this type from the input type.
source§impl From<&SymmetricKey> for SymmetricKey
impl From<&SymmetricKey> for SymmetricKey
source§fn from(digest: &SymmetricKey) -> Self
fn from(digest: &SymmetricKey) -> Self
Converts to this type from the input type.
source§impl From<&SymmetricKey> for Vec<u8>
impl From<&SymmetricKey> for Vec<u8>
source§fn from(digest: &SymmetricKey) -> Self
fn from(digest: &SymmetricKey) -> Self
Converts to this type from the input type.
source§impl From<SymmetricKey> for Vec<u8>
impl From<SymmetricKey> for Vec<u8>
source§fn from(digest: SymmetricKey) -> Self
fn from(digest: SymmetricKey) -> Self
Converts to this type from the input type.
source§impl Hash for SymmetricKey
impl Hash for SymmetricKey
source§impl PartialEq<SymmetricKey> for SymmetricKey
impl PartialEq<SymmetricKey> for SymmetricKey
source§fn eq(&self, other: &SymmetricKey) -> bool
fn eq(&self, other: &SymmetricKey) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl URDecodable for SymmetricKey
impl URDecodable for SymmetricKey
source§impl UREncodable for SymmetricKey
impl UREncodable for SymmetricKey
impl Eq for SymmetricKey
impl StructuralEq for SymmetricKey
impl StructuralPartialEq for SymmetricKey
impl URCodable for SymmetricKey
Auto Trait Implementations§
impl RefUnwindSafe for SymmetricKey
impl Send for SymmetricKey
impl Sync for SymmetricKey
impl Unpin for SymmetricKey
impl UnwindSafe for SymmetricKey
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