Last active
January 24, 2023 03:32
-
-
Save StarrFox/c5f989517c026016e7dd768ab77a0993 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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], | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
python version: https://gist.github.com/vbe0201/7e98986d8db0f52e8e55e6bbf91d48fe