Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aes-gcm: support instantiation from an existing cipher instance #101

Merged
merged 1 commit into from
Mar 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions aes-gcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,16 @@ where
fn new(mut key: GenericArray<u8, B::KeySize>) -> Self {
let cipher = B::new(&key);
key.as_mut_slice().zeroize();
cipher.into()
}
}

impl<B> From<B> for AesGcm<B>
where
B: BlockCipher<BlockSize = U16>,
B::ParBlocks: ArrayLength<GenericArray<u8, B::BlockSize>>,
{
fn from(cipher: B) -> Self {
let mut ghash_key = GenericArray::default();
cipher.encrypt_block(&mut ghash_key);

Expand Down
2 changes: 1 addition & 1 deletion chacha20poly1305/src/cipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

use aead::generic_array::GenericArray;
use aead::Error;
use stream_cipher::{SyncStreamCipher, SyncStreamCipherSeek};
use core::convert::TryInto;
use poly1305::{universal_hash::UniversalHash, Poly1305};
use stream_cipher::{SyncStreamCipher, SyncStreamCipherSeek};
use zeroize::Zeroizing;

use super::Tag;
Expand Down