Skip to content

Instantly share code, notes, and snippets.

@StarrFox
Last active January 24, 2023 03:32
Show Gist options
  • Save StarrFox/c5f989517c026016e7dd768ab77a0993 to your computer and use it in GitHub Desktop.
Save StarrFox/c5f989517c026016e7dd768ab77a0993 to your computer and use it in GitHub Desktop.
[dependencies]
aes = "0.8"
ghash = "0.5"
vale didnt give entire cargo.toml bc trolling
attempted vale untrolling:
[package]
name = "aes_test"
version = "0.1.0"
edition = "2021"
use aes::cipher::{
generic_array::GenericArray, typenum::U16, BlockCipher, BlockDecrypt, BlockEncrypt, KeyInit,
Unsigned,
};
use aes::Aes128;
use ghash::{universal_hash::UniversalHash, GHash};
fn initial_ctr(key: GenericArray<u8, U16>, nonce: &[u8]) {
let j0 = {
let mut ghash = GHash::new(&ghash_key);
ghash.update_padded(nonce);
let mut block = ghash::Block::default();
let nonce_bits = (U16::to_usize() as u64) << 3;
block[8..].copy_from_slice(&nonce_bits.to_be_bytes());
ghash.update(&[block]);
ghash.finalize()
};
println!("{j0:x?}");
}
fn main() {
initial_ctr(
[0x1E, 0x62, 0x8F, 0xC0, 0xD6, 0x08, 0x4D, 0x3B, 0x3E, 0x8C, 0x5B, 0x4F, 0xE4, 0x9F, 0xD3, 0x56].into(),
&[0x86, 0xC1, 0x1E, 0xE1, 0xBC, 0xFA, 0x8B, 0x77, 0x98, 0x28, 0xC1, 0x41, 0xA7, 0x66, 0xA5, 0x2A],
);
}
@StarrFox
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment