pub struct Gcm<C: Cipher + BlockSizeIs16> { /* private fields */ }
Expand description
Galois/Counter mode (NIST SP800-38D).
Implementations§
source§impl<C: Cipher + BlockSizeIs16> Gcm<C>
impl<C: Cipher + BlockSizeIs16> Gcm<C>
sourcepub const DIGEST_SIZE: usize = 16usize
pub const DIGEST_SIZE: usize = 16usize
Size of a GCM digest in bytes.
sourcepub fn with_key_and_nonce(key: &[u8], nonce: &[u8]) -> Result<Self>
pub fn with_key_and_nonce(key: &[u8], nonce: &[u8]) -> Result<Self>
Creates a new GCM instance with secret key
and public nonce
.
Examples found in repository?
examples/polymorphic.rs (line 84)
81 82 83 84 85 86 87 88 89 90 91 92 93
fn init_aead(&self) -> Box<dyn Aead> {
if random_bool() {
Box::new(
Gcm::<Aes128>::with_key_and_nonce(&b"123"[..], &b"123"[..])
.unwrap(),
)
} else {
Box::new(
Eax::<Twofish>::with_key_and_nonce(&b"123"[..], &b"123"[..])
.unwrap(),
)
}
}
Trait Implementations§
source§impl<C: Cipher + BlockSizeIs16> Aead for Gcm<C>
impl<C: Cipher + BlockSizeIs16> Aead for Gcm<C>
source§fn digest_size(&self) -> usize
fn digest_size(&self) -> usize
Length of the digest in bytes.
Auto Trait Implementations§
impl<C> RefUnwindSafe for Gcm<C>where C: RefUnwindSafe,
impl<C> Send for Gcm<C>where C: Send,
impl<C> Sync for Gcm<C>where C: Sync,
impl<C> Unpin for Gcm<C>where C: Unpin,
impl<C> UnwindSafe for Gcm<C>where C: UnwindSafe,
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