Expand description
Advanced Encryption Standard.
AES is a 128-bit block cipher that supports key sizes of 128, 192, or 256 bits. (Although 192 isn’t supported here.)
Each key defines a permutation of the set of 128-bit blocks and AES can perform the forward and reverse permutation. (These directions are arbitrarily labeled “encryption” and “decryption”.)
AES requires relatively expensive preprocessing of keys and thus the
processed form of the key is represented here using EncryptKey and
DecryptKey.
use bssl_crypto::aes;
let key_bytes = bssl_crypto::rand_array();
let enc_key = aes::EncryptKey::new_256(&key_bytes);
let block = [0u8; aes::BLOCK_SIZE];
let mut transformed_block = enc_key.encrypt(&block);
let dec_key = aes::DecryptKey::new_256(&key_bytes);
dec_key.decrypt_in_place(&mut transformed_block);
assert_eq!(block, transformed_block);AES is a low-level primitive and must be used in a more complex construction
in nearly every case. See the aead crate for usable encryption and
decryption primitives.
Structs§
- Decrypt
Key - An initialized key which can be used for decrypting
- Encrypt
Key - An initialized key which can be used for encrypting.
Constants§
- BLOCK_
SIZE - AES block size in bytes.
Type Aliases§
- Block
- A single AES block.