Module key_wrap

Source
Expand description

Key Wrap Algorithms.

§Examples

use aws_lc_rs::key_wrap::{AesKek, KeyWrapPadded, AES_128};

const KEY: &[u8] = &[
    0xa8, 0xe0, 0x6d, 0xa6, 0x25, 0xa6, 0x5b, 0x25, 0xcf, 0x50, 0x30, 0x82, 0x68, 0x30, 0xb6,
    0x61,
];
const PLAINTEXT: &[u8] = &[0x43, 0xac, 0xff, 0x29, 0x31, 0x20, 0xdd, 0x5d];

let kek = AesKek::new(&AES_128, KEY)?;

let mut output = vec![0u8; PLAINTEXT.len() + 15];

let ciphertext = kek.wrap_with_padding(PLAINTEXT, &mut output)?;

let kek = AesKek::new(&AES_128, KEY)?;

let mut output = vec![0u8; ciphertext.len()];

let plaintext = kek.unwrap_with_padding(&*ciphertext, &mut output)?;

assert_eq!(PLAINTEXT, plaintext);

Structs§

AesBlockCipher
An AES Block Cipher
KeyEncryptionKey
The key-encryption key used with the selected cipher algorithn to wrap or unwrap a key.

Enums§

BlockCipherId
The Key Wrapping Algorithm Identifier

Constants§

AES_128
AES Block Cipher with 128-bit key.
AES_256
AES Block Cipher with 256-bit key.

Traits§

BlockCipher
A key wrap block cipher.
KeyWrap
A Key Wrap (KW) algorithm implementation.
KeyWrapPadded
A Key Wrap with Padding (KWP) algorithm implementation.

Type Aliases§

AesKek
AES Key Encryption Key.