Closed newpavlov closed 2 years ago
why didn't this include ecb
? It was deleted from block-ciphers
but not imported into this crate.
ECB is implemented by block cipher types themselves, i.e. instead of Ecb<Aes128>
you can use Aes128
directly.
Thanks, but I currently use block_modes::Ecb<aes::Aes128, block_modes::block_padding::NoPadding>
and I don't see any padding options in aes
0.8
With the new versions you now specify padding on encryption/decryption methods, not on a block mode type. For example, see cbc
docs. For ECB instead of cbc::Encryptor<aes::Aes128>
you would simply use aes::Aes128
.
where is Ecb<Aes128, Pkcs7>
ECB is "implemented" by block ciphers directly, i.e. you can use methods like encrypt_padded
on Aes128
.
aes = "0.7.0" block-modes = "0.8.1" AES/ECB/PKCS5Padding impl on old-version
use aes::Aes128;
use block_modes::block_padding::Pkcs7;
use block_modes::{BlockMode, Ecb};
type Aes128Ecb = Ecb<Aes128, Pkcs7>;
let cipher = Aes128Ecb::new_from_slices(&key, &key).unwrap();
let mut buffer = [0u8; 32];
let pos = plaintext.len();
buffer[..pos].copy_from_slice(plaintext);
let ciphertext = cipher.encrypt(&mut buffer, pos).unwrap();
Use the linked methods directly on Aes128
(ee docs for BlockEncrypt
and BlockDecrypt
). You do not need Ecb
with the new crate versions. Padding is passed as a type argument to the padding-based methods.
Depends on RustCrypto/utils#566, RustCrypto/traits#727, and RustCrypto/block-ciphers#284.
Closes #5 Closes #6
TODO:
IvState
for CFBDrop
for CTR