aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/aes/src/c/aes256.c
diff options
context:
space:
mode:
authorEgor Tensin <egor@tensin.name>2026-06-13 19:06:16 +0200
committerEgor Tensin <egor@tensin.name>2026-06-13 19:06:16 +0200
commit1b2505ac21ce8dd09a34aff86455a8a3677094a0 (patch)
tree61124c0c28bb884842ac931f11a6c203a034fe7e /aes/src/c/aes256.c
parentworkflows/ci: add linting for Python test scripts (diff)
downloadaes-tools-1b2505ac21ce8dd09a34aff86455a8a3677094a0.tar.gz
aes-tools-1b2505ac21ce8dd09a34aff86455a8a3677094a0.zip
finally, perfect .clang-format settings?
Diffstat (limited to 'aes/src/c/aes256.c')
-rw-r--r--aes/src/c/aes256.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/aes/src/c/aes256.c b/aes/src/c/aes256.c
index ea64f0f..5bce5b5 100644
--- a/aes/src/c/aes256.c
+++ b/aes/src/c/aes256.c
@@ -10,8 +10,10 @@
#include <emmintrin.h>
#include <wmmintrin.h>
-AES_AES_Block __fastcall aes_AES256_encrypt_block_(AES_AES_Block plaintext,
- const AES_AES256_RoundKeys* encryption_keys) {
+AES_AES_Block __fastcall aes_AES256_encrypt_block_(
+ AES_AES_Block plaintext,
+ const AES_AES256_RoundKeys* encryption_keys
+) {
plaintext = _mm_xor_si128(plaintext, encryption_keys->keys[0]);
plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[1]);
plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[2]);
@@ -29,8 +31,10 @@ AES_AES_Block __fastcall aes_AES256_encrypt_block_(AES_AES_Block plaintext,
return _mm_aesenclast_si128(plaintext, encryption_keys->keys[14]);
}
-AES_AES_Block __fastcall aes_AES256_decrypt_block_(AES_AES_Block ciphertext,
- const AES_AES256_RoundKeys* decryption_keys) {
+AES_AES_Block __fastcall aes_AES256_decrypt_block_(
+ AES_AES_Block ciphertext,
+ const AES_AES256_RoundKeys* decryption_keys
+) {
ciphertext = _mm_xor_si128(ciphertext, decryption_keys->keys[0]);
ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[1]);
ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[2]);
@@ -48,9 +52,11 @@ AES_AES_Block __fastcall aes_AES256_decrypt_block_(AES_AES_Block ciphertext,
return _mm_aesdeclast_si128(ciphertext, decryption_keys->keys[14]);
}
-static AES_AES_Block __fastcall aes_aes256_expand_key_assist(AES_AES_Block* prev_lo,
- AES_AES_Block* prev_hi,
- AES_AES_Block hwgen) {
+static AES_AES_Block __fastcall aes_aes256_expand_key_assist(
+ AES_AES_Block* prev_lo,
+ AES_AES_Block* prev_hi,
+ AES_AES_Block hwgen
+) {
AES_AES_Block tmp = *prev_lo;
tmp = _mm_slli_si128(tmp, 4);
@@ -69,9 +75,11 @@ static AES_AES_Block __fastcall aes_aes256_expand_key_assist(AES_AES_Block* prev
return *prev_hi;
}
-void __fastcall aes_AES256_expand_key_(AES_AES_Block key_lo,
- AES_AES_Block key_hi,
- AES_AES256_RoundKeys* encryption_keys) {
+void __fastcall aes_AES256_expand_key_(
+ AES_AES_Block key_lo,
+ AES_AES_Block key_hi,
+ AES_AES256_RoundKeys* encryption_keys
+) {
AES_AES_Block prev_lo, prev_hi;
AES_AES_Block hwgen;
@@ -131,8 +139,10 @@ void __fastcall aes_AES256_expand_key_(AES_AES_Block key_lo,
encryption_keys->keys[14] = aes_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
}
-void __fastcall aes_AES256_derive_decryption_keys_(const AES_AES256_RoundKeys* encryption_keys,
- AES_AES256_RoundKeys* decryption_keys) {
+void __fastcall aes_AES256_derive_decryption_keys_(
+ const AES_AES256_RoundKeys* encryption_keys,
+ AES_AES256_RoundKeys* decryption_keys
+) {
decryption_keys->keys[0] = encryption_keys->keys[14];
decryption_keys->keys[1] = _mm_aesimc_si128(encryption_keys->keys[13]);
decryption_keys->keys[2] = _mm_aesimc_si128(encryption_keys->keys[12]);