aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2015-06-10 03:56:20 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2015-06-10 03:56:20 +0300
commit7468cbc7c4e69bbd2593c71c8a22953f41536963 (patch)
treebbc0b0ebb62ceb7385a418701897cb5577f035f9
parentutils: usage message update (diff)
downloadaes-tools-7468cbc7c4e69bbd2593c71c8a22953f41536963.tar.gz
aes-tools-7468cbc7c4e69bbd2593c71c8a22953f41536963.zip
refactoring
-rw-r--r--examples/aes128cbc.c4
-rw-r--r--examples/aes128cfb.c4
-rw-r--r--examples/aes128ctr.c4
-rw-r--r--examples/aes128ecb.c4
-rw-r--r--examples/aes128ofb.c4
-rw-r--r--examples/aes192cbc.c4
-rw-r--r--examples/aes192cfb.c4
-rw-r--r--examples/aes192ctr.c4
-rw-r--r--examples/aes192ecb.c4
-rw-r--r--examples/aes192ofb.c4
-rw-r--r--examples/aes256cbc.c4
-rw-r--r--examples/aes256cfb.c4
-rw-r--r--examples/aes256ctr.c4
-rw-r--r--examples/aes256ecb.c4
-rw-r--r--examples/aes256ofb.c4
-rw-r--r--include/aesni/api.h120
-rw-r--r--include/aesni/file.h4
-rw-r--r--include/aesni/raw.h12
-rw-r--r--src/aes128.asm8
-rw-r--r--src/aes128.c4
-rw-r--r--src/aes192.asm8
-rw-r--r--src/aes192.c4
-rw-r--r--src/aes256.asm8
-rw-r--r--src/aes256.c4
-rw-r--r--src/file.c26
-rw-r--r--test/aes128cbc_decrypt.c2
-rw-r--r--test/aes128cbc_encrypt.c2
-rw-r--r--test/aes128cfb_decrypt.c2
-rw-r--r--test/aes128cfb_encrypt.c2
-rw-r--r--test/aes128ctr_decrypt.c2
-rw-r--r--test/aes128ctr_encrypt.c2
-rw-r--r--test/aes128ecb_decrypt.c2
-rw-r--r--test/aes128ecb_encrypt.c2
-rw-r--r--test/aes128ofb_decrypt.c2
-rw-r--r--test/aes128ofb_encrypt.c2
-rw-r--r--test/aes192cbc_decrypt.c2
-rw-r--r--test/aes192cbc_encrypt.c2
-rw-r--r--test/aes192cfb_decrypt.c2
-rw-r--r--test/aes192cfb_encrypt.c2
-rw-r--r--test/aes192ctr_decrypt.c2
-rw-r--r--test/aes192ctr_encrypt.c2
-rw-r--r--test/aes192ecb_decrypt.c2
-rw-r--r--test/aes192ecb_encrypt.c2
-rw-r--r--test/aes192ofb_decrypt.c2
-rw-r--r--test/aes192ofb_encrypt.c2
-rw-r--r--test/aes256cbc_decrypt.c2
-rw-r--r--test/aes256cbc_encrypt.c2
-rw-r--r--test/aes256cfb_decrypt.c2
-rw-r--r--test/aes256cfb_encrypt.c2
-rw-r--r--test/aes256ctr_decrypt.c2
-rw-r--r--test/aes256ctr_encrypt.c2
-rw-r--r--test/aes256ecb_decrypt.c2
-rw-r--r--test/aes256ecb_encrypt.c2
-rw-r--r--test/aes256ofb_decrypt.c2
-rw-r--r--test/aes256ofb_encrypt.c2
-rw-r--r--utils/aes128ecb_decrypt_file.cpp4
-rw-r--r--utils/aes128ecb_encrypt_file.cpp16
57 files changed, 172 insertions, 166 deletions
diff --git a/examples/aes128cbc.c b/examples/aes128cbc.c
index 92c1f32..986be2e 100644
--- a/examples/aes128cbc.c
+++ b/examples/aes128cbc.c
@@ -37,7 +37,7 @@ int main()
for (int i = 0; i < 11; ++i)
printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
- cipher = aes128cbc_encrypt(plain, &key_schedule, iv, &next_iv);
+ cipher = aes128cbc_encrypt_block(plain, &key_schedule, iv, &next_iv);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
print_aes_block128_as_matrix(&cipher);
@@ -53,7 +53,7 @@ int main()
for (int i = 0; i < 11; ++i)
printf("\t[%d]: %s\n", i, format_aes_block128(&inverted_schedule.keys[i]).str);
- decrypted = aes128cbc_decrypt(cipher, &inverted_schedule, iv, &next_iv);
+ decrypted = aes128cbc_decrypt_block(cipher, &inverted_schedule, iv, &next_iv);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
print_aes_block128_as_matrix(&decrypted);
diff --git a/examples/aes128cfb.c b/examples/aes128cfb.c
index 91e1c73..2d209ca 100644
--- a/examples/aes128cfb.c
+++ b/examples/aes128cfb.c
@@ -37,7 +37,7 @@ int main()
for (int i = 0; i < 11; ++i)
printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
- cipher = aes128cfb_encrypt(plain, &key_schedule, iv, &next_iv);
+ cipher = aes128cfb_encrypt_block(plain, &key_schedule, iv, &next_iv);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
print_aes_block128_as_matrix(&cipher);
@@ -46,7 +46,7 @@ int main()
printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
print_aes_block128_as_matrix(&next_iv);
- decrypted = aes128cfb_decrypt(cipher, &key_schedule, iv, &next_iv);
+ decrypted = aes128cfb_decrypt_block(cipher, &key_schedule, iv, &next_iv);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
print_aes_block128_as_matrix(&decrypted);
diff --git a/examples/aes128ctr.c b/examples/aes128ctr.c
index 2cabdc1..c645da7 100644
--- a/examples/aes128ctr.c
+++ b/examples/aes128ctr.c
@@ -37,12 +37,12 @@ int main()
for (int i = 0; i < 11; ++i)
printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
- cipher = aes128ctr_encrypt(plain, &key_schedule, iv, 0);
+ cipher = aes128ctr_encrypt_block(plain, &key_schedule, iv, 0);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
print_aes_block128_as_matrix(&cipher);
- decrypted = aes128ctr_decrypt(cipher, &key_schedule, iv, 0);
+ decrypted = aes128ctr_decrypt_block(cipher, &key_schedule, iv, 0);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
print_aes_block128_as_matrix(&decrypted);
diff --git a/examples/aes128ecb.c b/examples/aes128ecb.c
index 5b2d2a0..e36cd66 100644
--- a/examples/aes128ecb.c
+++ b/examples/aes128ecb.c
@@ -32,7 +32,7 @@ int main()
for (int i = 0; i < 11; ++i)
printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
- cipher = aes128ecb_encrypt(plain, &key_schedule);
+ cipher = aes128ecb_encrypt_block(plain, &key_schedule);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
print_aes_block128_as_matrix(&cipher);
@@ -44,7 +44,7 @@ int main()
for (int i = 0; i < 11; ++i)
printf("\t[%d]: %s\n", i, format_aes_block128(&inverted_schedule.keys[i]).str);
- decrypted = aes128ecb_decrypt(cipher, &inverted_schedule);
+ decrypted = aes128ecb_decrypt_block(cipher, &inverted_schedule);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
print_aes_block128_as_matrix(&decrypted);
diff --git a/examples/aes128ofb.c b/examples/aes128ofb.c
index cef4df5..12ef468 100644
--- a/examples/aes128ofb.c
+++ b/examples/aes128ofb.c
@@ -37,7 +37,7 @@ int main()
for (int i = 0; i < 11; ++i)
printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
- cipher = aes128ofb_encrypt(plain, &key_schedule, iv, &next_iv);
+ cipher = aes128ofb_encrypt_block(plain, &key_schedule, iv, &next_iv);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
print_aes_block128_as_matrix(&cipher);
@@ -46,7 +46,7 @@ int main()
printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
print_aes_block128_as_matrix(&next_iv);
- decrypted = aes128ofb_decrypt(cipher, &key_schedule, iv, &next_iv);
+ decrypted = aes128ofb_decrypt_block(cipher, &key_schedule, iv, &next_iv);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
print_aes_block128_as_matrix(&decrypted);
diff --git a/examples/aes192cbc.c b/examples/aes192cbc.c
index fcd79c5..406575c 100644
--- a/examples/aes192cbc.c
+++ b/examples/aes192cbc.c
@@ -38,7 +38,7 @@ int main()
for (int i = 0; i < 13; ++i)
printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
- cipher = aes192cbc_encrypt(plain, &key_schedule, iv, &next_iv);
+ cipher = aes192cbc_encrypt_block(plain, &key_schedule, iv, &next_iv);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
print_aes_block128_as_matrix(&cipher);
@@ -54,7 +54,7 @@ int main()
for (int i = 0; i < 13; ++i)
printf("\t[%d]: %s\n", i, format_aes_block128(&inverted_schedule.keys[i]).str);
- decrypted = aes192cbc_decrypt(cipher, &inverted_schedule, iv, &next_iv);
+ decrypted = aes192cbc_decrypt_block(cipher, &inverted_schedule, iv, &next_iv);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
print_aes_block128_as_matrix(&decrypted);
diff --git a/examples/aes192cfb.c b/examples/aes192cfb.c
index 0ad8903..103ac12 100644
--- a/examples/aes192cfb.c
+++ b/examples/aes192cfb.c
@@ -38,7 +38,7 @@ int main()
for (int i = 0; i < 13; ++i)
printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
- cipher = aes192cfb_encrypt(plain, &key_schedule, iv, &next_iv);
+ cipher = aes192cfb_encrypt_block(plain, &key_schedule, iv, &next_iv);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
print_aes_block128_as_matrix(&cipher);
@@ -47,7 +47,7 @@ int main()
printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
print_aes_block128_as_matrix(&next_iv);
- decrypted = aes192cfb_decrypt(cipher, &key_schedule, iv, &next_iv);
+ decrypted = aes192cfb_decrypt_block(cipher, &key_schedule, iv, &next_iv);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
print_aes_block128_as_matrix(&decrypted);
diff --git a/examples/aes192ctr.c b/examples/aes192ctr.c
index eb5df43..48d4b14 100644
--- a/examples/aes192ctr.c
+++ b/examples/aes192ctr.c
@@ -38,12 +38,12 @@ int main()
for (int i = 0; i < 13; ++i)
printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
- cipher = aes192ctr_encrypt(plain, &key_schedule, iv, 0);
+ cipher = aes192ctr_encrypt_block(plain, &key_schedule, iv, 0);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
print_aes_block128_as_matrix(&cipher);
- decrypted = aes192ctr_decrypt(cipher, &key_schedule, iv, 0);
+ decrypted = aes192ctr_decrypt_block(cipher, &key_schedule, iv, 0);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
print_aes_block128_as_matrix(&decrypted);
diff --git a/examples/aes192ecb.c b/examples/aes192ecb.c
index 13311f7..f7a05af 100644
--- a/examples/aes192ecb.c
+++ b/examples/aes192ecb.c
@@ -33,7 +33,7 @@ int main()
for (int i = 0; i < 13; ++i)
printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
- cipher = aes192ecb_encrypt(plain, &key_schedule);
+ cipher = aes192ecb_encrypt_block(plain, &key_schedule);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
print_aes_block128_as_matrix(&cipher);
@@ -45,7 +45,7 @@ int main()
for (int i = 0; i < 13; ++i)
printf("\t[%d]: %s\n", i, format_aes_block128(&inverted_schedule.keys[i]).str);
- decrypted = aes192ecb_decrypt(cipher, &inverted_schedule);
+ decrypted = aes192ecb_decrypt_block(cipher, &inverted_schedule);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
print_aes_block128_as_matrix(&decrypted);
diff --git a/examples/aes192ofb.c b/examples/aes192ofb.c
index 3738820..3c4f025 100644
--- a/examples/aes192ofb.c
+++ b/examples/aes192ofb.c
@@ -38,7 +38,7 @@ int main()
for (int i = 0; i < 13; ++i)
printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
- cipher = aes192ofb_encrypt(plain, &key_schedule, iv, &next_iv);
+ cipher = aes192ofb_encrypt_block(plain, &key_schedule, iv, &next_iv);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
print_aes_block128_as_matrix(&cipher);
@@ -47,7 +47,7 @@ int main()
printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
print_aes_block128_as_matrix(&next_iv);
- decrypted = aes192ofb_decrypt(cipher, &key_schedule, iv, &next_iv);
+ decrypted = aes192ofb_decrypt_block(cipher, &key_schedule, iv, &next_iv);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
print_aes_block128_as_matrix(&decrypted);
diff --git a/examples/aes256cbc.c b/examples/aes256cbc.c
index 27e8458..0a148e1 100644
--- a/examples/aes256cbc.c
+++ b/examples/aes256cbc.c
@@ -38,7 +38,7 @@ int main()
for (int i = 0; i < 15; ++i)
printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
- cipher = aes256cbc_encrypt(plain, &key_schedule, iv, &next_iv);
+ cipher = aes256cbc_encrypt_block(plain, &key_schedule, iv, &next_iv);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
print_aes_block128_as_matrix(&cipher);
@@ -54,7 +54,7 @@ int main()
for (int i = 0; i < 15; ++i)
printf("\t[%d]: %s\n", i, format_aes_block128(&inverted_schedule.keys[i]).str);
- decrypted = aes256cbc_decrypt(cipher, &inverted_schedule, iv, &next_iv);
+ decrypted = aes256cbc_decrypt_block(cipher, &inverted_schedule, iv, &next_iv);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
print_aes_block128_as_matrix(&decrypted);
diff --git a/examples/aes256cfb.c b/examples/aes256cfb.c
index 21cd721..44d5f30 100644
--- a/examples/aes256cfb.c
+++ b/examples/aes256cfb.c
@@ -38,7 +38,7 @@ int main()
for (int i = 0; i < 15; ++i)
printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
- cipher = aes256cfb_encrypt(plain, &key_schedule, iv, &next_iv);
+ cipher = aes256cfb_encrypt_block(plain, &key_schedule, iv, &next_iv);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
print_aes_block128_as_matrix(&cipher);
@@ -47,7 +47,7 @@ int main()
printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
print_aes_block128_as_matrix(&next_iv);
- decrypted = aes256cfb_decrypt(cipher, &key_schedule, iv, &next_iv);
+ decrypted = aes256cfb_decrypt_block(cipher, &key_schedule, iv, &next_iv);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
print_aes_block128_as_matrix(&decrypted);
diff --git a/examples/aes256ctr.c b/examples/aes256ctr.c
index be19d11..0a47004 100644
--- a/examples/aes256ctr.c
+++ b/examples/aes256ctr.c
@@ -38,12 +38,12 @@ int main()
for (int i = 0; i < 15; ++i)
printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
- cipher = aes256ctr_encrypt(plain, &key_schedule, iv, 0);
+ cipher = aes256ctr_encrypt_block(plain, &key_schedule, iv, 0);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
print_aes_block128_as_matrix(&cipher);
- decrypted = aes256ctr_decrypt(cipher, &key_schedule, iv, 0);
+ decrypted = aes256ctr_decrypt_block(cipher, &key_schedule, iv, 0);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
print_aes_block128_as_matrix(&decrypted);
diff --git a/examples/aes256ecb.c b/examples/aes256ecb.c
index 1f265da..f96a368 100644
--- a/examples/aes256ecb.c
+++ b/examples/aes256ecb.c
@@ -33,7 +33,7 @@ int main()
for (int i = 0; i < 15; ++i)
printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
- cipher = aes256ecb_encrypt(plain, &key_schedule);
+ cipher = aes256ecb_encrypt_block(plain, &key_schedule);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
print_aes_block128_as_matrix(&cipher);
@@ -45,7 +45,7 @@ int main()
for (int i = 0; i < 15; ++i)
printf("\t[%d]: %s\n", i, format_aes_block128(&inverted_schedule.keys[i]).str);
- decrypted = aes256ecb_decrypt(cipher, &inverted_schedule);
+ decrypted = aes256ecb_decrypt_block(cipher, &inverted_schedule);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
print_aes_block128_as_matrix(&decrypted);
diff --git a/examples/aes256ofb.c b/examples/aes256ofb.c
index efb7eaa..1104438 100644
--- a/examples/aes256ofb.c
+++ b/examples/aes256ofb.c
@@ -38,7 +38,7 @@ int main()
for (int i = 0; i < 15; ++i)
printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
- cipher = aes256ofb_encrypt(plain, &key_schedule, iv, &next_iv);
+ cipher = aes256ofb_encrypt_block(plain, &key_schedule, iv, &next_iv);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
print_aes_block128_as_matrix(&cipher);
@@ -47,7 +47,7 @@ int main()
printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
print_aes_block128_as_matrix(&next_iv);
- decrypted = aes256ofb_decrypt(cipher, &key_schedule, iv, &next_iv);
+ decrypted = aes256ofb_decrypt_block(cipher, &key_schedule, iv, &next_iv);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
print_aes_block128_as_matrix(&decrypted);
diff --git a/include/aesni/api.h b/include/aesni/api.h
index e021fed..ea11817 100644
--- a/include/aesni/api.h
+++ b/include/aesni/api.h
@@ -25,87 +25,87 @@ static __inline void __fastcall aes128_invert_key_schedule(
raw_aes128_invert_key_schedule(key_schedule, inverted_schedule);
}
-static __inline AesBlock128 __fastcall aes128ecb_encrypt(
+static __inline AesBlock128 __fastcall aes128ecb_encrypt_block(
AesBlock128 plain,
Aes128KeySchedule* key_schedule)
{
- return raw_aes128_encrypt(plain, key_schedule);
+ return raw_aes128_encrypt_block(plain, key_schedule);
}
-static __inline AesBlock128 __fastcall aes128ecb_decrypt(
+static __inline AesBlock128 __fastcall aes128ecb_decrypt_block(
AesBlock128 cipher,
Aes128KeySchedule* inverted_schedule)
{
- return raw_aes128_decrypt(cipher, inverted_schedule);
+ return raw_aes128_decrypt_block(cipher, inverted_schedule);
}
-static __inline AesBlock128 __fastcall aes128cbc_encrypt(
+static __inline AesBlock128 __fastcall aes128cbc_encrypt_block(
AesBlock128 plain,
Aes128KeySchedule* key_schedule,
AesBlock128 init_vector,
AesBlock128* next_init_vector)
{
- AesBlock128 cipher = raw_aes128_encrypt(_mm_xor_si128(plain, init_vector), key_schedule);
+ AesBlock128 cipher = raw_aes128_encrypt_block(_mm_xor_si128(plain, init_vector), key_schedule);
*next_init_vector = cipher;
return cipher;
}
-static __inline AesBlock128 __fastcall aes128cbc_decrypt(
+static __inline AesBlock128 __fastcall aes128cbc_decrypt_block(
AesBlock128 cipher,
Aes128KeySchedule* inverted_schedule,
AesBlock128 init_vector,
AesBlock128* next_init_vector)
{
- AesBlock128 plain = _mm_xor_si128(raw_aes128_decrypt(cipher, inverted_schedule), init_vector);
+ AesBlock128 plain = _mm_xor_si128(raw_aes128_decrypt_block(cipher, inverted_schedule), init_vector);
*next_init_vector = cipher;
return plain;
}
-static __inline AesBlock128 __fastcall aes128cfb_encrypt(
+static __inline AesBlock128 __fastcall aes128cfb_encrypt_block(
AesBlock128 plain,
Aes128KeySchedule* key_schedule,
AesBlock128 init_vector,
AesBlock128* next_init_vector)
{
- AesBlock128 cipher = _mm_xor_si128(raw_aes128_encrypt(init_vector, key_schedule), plain);
+ AesBlock128 cipher = _mm_xor_si128(raw_aes128_encrypt_block(init_vector, key_schedule), plain);
*next_init_vector = cipher;
return cipher;
}
-static __inline AesBlock128 __fastcall aes128cfb_decrypt(
+static __inline AesBlock128 __fastcall aes128cfb_decrypt_block(
AesBlock128 cipher,
Aes128KeySchedule* key_schedule,
AesBlock128 init_vector,
AesBlock128* next_init_vector)
{
- AesBlock128 plain = _mm_xor_si128(raw_aes128_encrypt(init_vector, key_schedule), cipher);
+ AesBlock128 plain = _mm_xor_si128(raw_aes128_encrypt_block(init_vector, key_schedule), cipher);
*next_init_vector = cipher;
return plain;
}
-static __inline AesBlock128 __fastcall aes128ofb_encrypt(
+static __inline AesBlock128 __fastcall aes128ofb_encrypt_block(
AesBlock128 plain,
Aes128KeySchedule* key_schedule,
AesBlock128 init_vector,
AesBlock128* next_init_vector)
{
- AesBlock128 tmp = raw_aes128_encrypt(init_vector, key_schedule);
+ AesBlock128 tmp = raw_aes128_encrypt_block(init_vector, key_schedule);
*next_init_vector = tmp;
return _mm_xor_si128(tmp, plain);
}
-static __inline AesBlock128 __fastcall aes128ofb_decrypt(
+static __inline AesBlock128 __fastcall aes128ofb_decrypt_block(
AesBlock128 cipher,
Aes128KeySchedule* key_schedule,
AesBlock128 init_vector,
AesBlock128* next_init_vector)
{
- AesBlock128 tmp = raw_aes128_encrypt(init_vector, key_schedule);
+ AesBlock128 tmp = raw_aes128_encrypt_block(init_vector, key_schedule);
*next_init_vector = tmp;
return _mm_xor_si128(tmp, cipher);
}
-static __inline AesBlock128 __fastcall aes128ctr_encrypt(
+static __inline AesBlock128 __fastcall aes128ctr_encrypt_block(
AesBlock128 plain,
Aes128KeySchedule* key_schedule,
AesBlock128 init_vector,
@@ -114,10 +114,10 @@ static __inline AesBlock128 __fastcall aes128ctr_encrypt(
init_vector = aes128_le2be(init_vector);
init_vector = _mm_add_epi32(init_vector, make_aes_block128(0, 0, 0, counter));
init_vector = aes128_be2le(init_vector);
- return _mm_xor_si128(plain, raw_aes128_encrypt(init_vector, key_schedule));
+ return _mm_xor_si128(plain, raw_aes128_encrypt_block(init_vector, key_schedule));
}
-static __inline AesBlock128 __fastcall aes128ctr_decrypt(
+static __inline AesBlock128 __fastcall aes128ctr_decrypt_block(
AesBlock128 cipher,
Aes128KeySchedule* key_schedule,
AesBlock128 init_vector,
@@ -126,7 +126,7 @@ static __inline AesBlock128 __fastcall aes128ctr_decrypt(
init_vector = aes128_le2be(init_vector);
init_vector = _mm_add_epi32(init_vector, make_aes_block128(0, 0, 0, counter));
init_vector = aes128_be2le(init_vector);
- return _mm_xor_si128(cipher, raw_aes128_encrypt(init_vector, key_schedule));
+ return _mm_xor_si128(cipher, raw_aes128_encrypt_block(init_vector, key_schedule));
}
static __inline void __fastcall aes192_expand_key_schedule(
@@ -143,87 +143,87 @@ static __inline void __fastcall aes192_invert_key_schedule(
raw_aes192_invert_key_schedule(key_schedule, inverted_schedule);
}
-static __inline AesBlock128 __fastcall aes192ecb_encrypt(
+static __inline AesBlock128 __fastcall aes192ecb_encrypt_block(
AesBlock128 plain,
Aes192KeySchedule* key_schedule)
{
- return raw_aes192_encrypt(plain, key_schedule);
+ return raw_aes192_encrypt_block(plain, key_schedule);
}
-static __inline AesBlock128 __fastcall aes192ecb_decrypt(
+static __inline AesBlock128 __fastcall aes192ecb_decrypt_block(
AesBlock128 cipher,
Aes192KeySchedule* inverted_schedule)
{
- return raw_aes192_decrypt(cipher, inverted_schedule);
+ return raw_aes192_decrypt_block(cipher, inverted_schedule);
}
-static __inline AesBlock128 __fastcall aes192cbc_encrypt(
+static __inline AesBlock128 __fastcall aes192cbc_encrypt_block(
AesBlock128 plain,
Aes192KeySchedule* key_schedule,
AesBlock128 init_vector,
AesBlock128* next_init_vector)
{
- AesBlock128 cipher = raw_aes192_encrypt(_mm_xor_si128(plain, init_vector), key_schedule);
+ AesBlock128 cipher = raw_aes192_encrypt_block(_mm_xor_si128(plain, init_vector), key_schedule);
*next_init_vector = cipher;
return cipher;
}
-static __inline AesBlock128 __fastcall aes192cbc_decrypt(
+static __inline AesBlock128 __fastcall aes192cbc_decrypt_block(
AesBlock128 cipher,
Aes192KeySchedule* inverted_schedule,
AesBlock128 init_vector,
AesBlock128* next_init_vector)
{
- AesBlock128 plain = _mm_xor_si128(raw_aes192_decrypt(cipher, inverted_schedule), init_vector);
+ AesBlock128 plain = _mm_xor_si128(raw_aes192_decrypt_block(cipher, inverted_schedule), init_vector);
*next_init_vector = cipher;
return plain;
}
-static __inline AesBlock128 __fastcall aes192cfb_encrypt(
+static __inline AesBlock128 __fastcall aes192cfb_encrypt_block(
AesBlock128 plain,
Aes192KeySchedule* key_schedule,
AesBlock128 init_vector,
AesBlock128* next_init_vector)
{
- AesBlock128 cipher = _mm_xor_si128(raw_aes192_encrypt(init_vector, key_schedule), plain);
+ AesBlock128 cipher = _mm_xor_si128(raw_aes192_encrypt_block(init_vector, key_schedule), plain);
*next_init_vector = cipher;
return cipher;
}
-static __inline AesBlock128 __fastcall aes192cfb_decrypt(
+static __inline AesBlock128 __fastcall aes192cfb_decrypt_block(
AesBlock128 cipher,
Aes192KeySchedule* key_schedule,
AesBlock128 init_vector,
AesBlock128* next_init_vector)
{
- AesBlock128 plain = _mm_xor_si128(raw_aes192_encrypt(init_vector, key_schedule), cipher);
+ AesBlock128 plain = _mm_xor_si128(raw_aes192_encrypt_block(init_vector, key_schedule), cipher);
*next_init_vector = cipher;
return plain;
}
-static __inline AesBlock128 __fastcall aes192ofb_encrypt(
+static __inline AesBlock128 __fastcall aes192ofb_encrypt_block(
AesBlock128 plain,
Aes192KeySchedule* key_schedule,
AesBlock128 init_vector,
AesBlock128* next_init_vector)
{
- AesBlock128 tmp = raw_aes192_encrypt(init_vector, key_schedule);
+ AesBlock128 tmp = raw_aes192_encrypt_block(init_vector, key_schedule);
*next_init_vector = tmp;
return _mm_xor_si128(tmp, plain);
}
-static __inline AesBlock128 __fastcall aes192ofb_decrypt(
+static __inline AesBlock128 __fastcall aes192ofb_decrypt_block(
AesBlock128 cipher,
Aes192KeySchedule* key_schedule,
AesBlock128 init_vector,
AesBlock128* next_init_vector)
{
- AesBlock128 tmp = raw_aes192_encrypt(init_vector, key_schedule);
+ AesBlock128 tmp = raw_aes192_encrypt_block(init_vector, key_schedule);
*next_init_vector = tmp;
return _mm_xor_si128(tmp, cipher);
}
-static __inline AesBlock128 __fastcall aes192ctr_encrypt(
+static __inline AesBlock128 __fastcall aes192ctr_encrypt_block(
AesBlock128 plain,
Aes192KeySchedule* key_schedule,
AesBlock128 init_vector,
@@ -232,10 +232,10 @@ static __inline AesBlock128 __fastcall aes192ctr_encrypt(
init_vector = aes128_le2be(init_vector);
init_vector = _mm_add_epi32(init_vector, make_aes_block128(0, 0, 0, counter));
init_vector = aes128_be2le(init_vector);
- return _mm_xor_si128(plain, raw_aes192_encrypt(init_vector, key_schedule));
+ return _mm_xor_si128(plain, raw_aes192_encrypt_block(init_vector, key_schedule));
}
-static __inline AesBlock128 __fastcall aes192ctr_decrypt(
+static __inline AesBlock128 __fastcall aes192ctr_decrypt_block(
AesBlock128 cipher,
Aes192KeySchedule* key_schedule,
AesBlock128 init_vector,
@@ -244,7 +244,7 @@ static __inline AesBlock128 __fastcall aes192ctr_decrypt(
init_vector = aes128_le2be(init_vector);
init_vector = _mm_add_epi32(init_vector, make_aes_block128(0, 0, 0, counter));
init_vector = aes128_be2le(init_vector);
- return _mm_xor_si128(cipher, raw_aes192_encrypt(init_vector, key_schedule));
+ return _mm_xor_si128(cipher, raw_aes192_encrypt_block(init_vector, key_schedule));
}
static __inline void __fastcall aes256_expand_key_schedule(
@@ -261,87 +261,87 @@ static __inline void __fastcall aes256_invert_key_schedule(
raw_aes256_invert_key_schedule(key_schedule, inverted_schedule);
}
-static __inline AesBlock128 __fastcall aes256ecb_encrypt(
+static __inline AesBlock128 __fastcall aes256ecb_encrypt_block(
AesBlock128 plain,
Aes256KeySchedule* key_schedule)
{
- return raw_aes256_encrypt(plain, key_schedule);
+ return raw_aes256_encrypt_block(plain, key_schedule);
}
-static __inline AesBlock128 __fastcall aes256ecb_decrypt(
+static __inline AesBlock128 __fastcall aes256ecb_decrypt_block(
AesBlock128 cipher,
Aes256KeySchedule* inverted_schedule)
{
- return raw_aes256_decrypt(cipher, inverted_schedule);
+ return raw_aes256_decrypt_block(cipher, inverted_schedule);
}
-static __inline AesBlock128 __fastcall aes256cbc_encrypt(
+static __inline AesBlock128 __fastcall aes256cbc_encrypt_block(
AesBlock128 plain,
Aes256KeySchedule* key_schedule,
AesBlock128 init_vector,
AesBlock128* next_init_vector)
{
- AesBlock128 cipher = raw_aes256_encrypt(_mm_xor_si128(plain, init_vector), key_schedule);
+ AesBlock128 cipher = raw_aes256_encrypt_block(_mm_xor_si128(plain, init_vector), key_schedule);
*next_init_vector = cipher;
return cipher;
}
-static __inline AesBlock128 __fastcall aes256cbc_decrypt(
+static __inline AesBlock128 __fastcall aes256cbc_decrypt_block(
AesBlock128 cipher,
Aes256KeySchedule* inverted_schedule,
AesBlock128 init_vector,
AesBlock128* next_init_vector)
{
- AesBlock128 plain = _mm_xor_si128(raw_aes256_decrypt(cipher, inverted_schedule), init_vector);
+ AesBlock128 plain = _mm_xor_si128(raw_aes256_decrypt_block(cipher, inverted_schedule), init_vector);
*next_init_vector = cipher;
return plain;
}
-static __inline AesBlock128 __fastcall aes256cfb_encrypt(
+static __inline AesBlock128 __fastcall aes256cfb_encrypt_block(
AesBlock128 plain,
Aes256KeySchedule* key_schedule,
AesBlock128 init_vector,
AesBlock128* next_init_vector)
{
- AesBlock128 cipher = _mm_xor_si128(raw_aes256_encrypt(init_vector, key_schedule), plain);
+ AesBlock128 cipher = _mm_xor_si128(raw_aes256_encrypt_block(init_vector, key_schedule), plain);
*next_init_vector = cipher;
return cipher;
}
-static __inline AesBlock128 __fastcall aes256cfb_decrypt(
+static __inline AesBlock128 __fastcall aes256cfb_decrypt_block(
AesBlock128 cipher,
Aes256KeySchedule* key_schedule,
AesBlock128 init_vector,
AesBlock128* next_init_vector)
{
- AesBlock128 plain = _mm_xor_si128(raw_aes256_encrypt(init_vector, key_schedule), cipher);
+ AesBlock128 plain = _mm_xor_si128(raw_aes256_encrypt_block(init_vector, key_schedule), cipher);
*next_init_vector = cipher;
return plain;
}
-static __inline AesBlock128 __fastcall aes256ofb_encrypt(
+static __inline AesBlock128 __fastcall aes256ofb_encrypt_block(
AesBlock128 plain,
Aes256KeySchedule* key_schedule,
AesBlock128 init_vector,
AesBlock128* next_init_vector)
{
- AesBlock128 tmp = raw_aes256_encrypt(init_vector, key_schedule);
+ AesBlock128 tmp = raw_aes256_encrypt_block(init_vector, key_schedule);
*next_init_vector = tmp;
return _mm_xor_si128(tmp, plain);
}
-static __inline AesBlock128 __fastcall aes256ofb_decrypt(
+static __inline AesBlock128 __fastcall aes256ofb_decrypt_block(
AesBlock128 cipher,
Aes256KeySchedule* key_schedule,
AesBlock128 init_vector,
AesBlock128* next_init_vector)
{
- AesBlock128 tmp = raw_aes256_encrypt(init_vector, key_schedule);
+ AesBlock128 tmp = raw_aes256_encrypt_block(init_vector, key_schedule);
*next_init_vector = tmp;
return _mm_xor_si128(tmp, cipher);
}
-static __inline AesBlock128 __fastcall aes256ctr_encrypt(
+static __inline AesBlock128 __fastcall aes256ctr_encrypt_block(
AesBlock128 plain,
Aes256KeySchedule* key_schedule,
AesBlock128 init_vector,
@@ -350,10 +350,10 @@ static __inline AesBlock128 __fastcall aes256ctr_encrypt(
init_vector = aes128_le2be(init_vector);
init_vector = _mm_add_epi32(init_vector, make_aes_block128(0, 0, 0, counter));
init_vector = aes128_be2le(init_vector);
- return _mm_xor_si128(plain, raw_aes256_encrypt(init_vector, key_schedule));
+ return _mm_xor_si128(plain, raw_aes256_encrypt_block(init_vector, key_schedule));
}
-static __inline AesBlock128 __fastcall aes256ctr_decrypt(
+static __inline AesBlock128 __fastcall aes256ctr_decrypt_block(
AesBlock128 cipher,
Aes256KeySchedule* key_schedule,
AesBlock128 init_vector,
@@ -362,5 +362,5 @@ static __inline AesBlock128 __fastcall aes256ctr_decrypt(
init_vector = aes128_le2be(init_vector);
init_vector = _mm_add_epi32(init_vector, make_aes_block128(0, 0, 0, counter));
init_vector = aes128_be2le(init_vector);
- return _mm_xor_si128(cipher, raw_aes256_encrypt(init_vector, key_schedule));
+ return _mm_xor_si128(cipher, raw_aes256_encrypt_block(init_vector, key_schedule));
}
diff --git a/include/aesni/file.h b/include/aesni/file.h
index eb84d09..f3c845d 100644
--- a/include/aesni/file.h
+++ b/include/aesni/file.h
@@ -10,11 +10,11 @@
#include <stdio.h>
-size_t aes128ecb_encrypt_file(const unsigned char* src,
+size_t aes128ecb_encrypt_buffer(const unsigned char* src,
size_t src_size,
unsigned char* dest,
Aes128KeySchedule* key_schedule);
-size_t aes128ecb_decrypt_file(const unsigned char* src,
+size_t aes128ecb_decrypt_buffer(const unsigned char* src,
size_t src_size,
unsigned char* dest,
Aes128KeySchedule* inverted_schedule);
diff --git a/include/aesni/raw.h b/include/aesni/raw.h
index d570ecc..6ea0c8a 100644
--- a/include/aesni/raw.h
+++ b/include/aesni/raw.h
@@ -17,10 +17,10 @@ void __fastcall raw_aes128_invert_key_schedule(
Aes128KeySchedule* key_schedule,
Aes128KeySchedule* inverted_schedule);
-AesBlock128 __fastcall raw_aes128_encrypt(
+AesBlock128 __fastcall raw_aes128_encrypt_block(
AesBlock128 plain,
Aes128KeySchedule* key_schedule);
-AesBlock128 __fastcall raw_aes128_decrypt(
+AesBlock128 __fastcall raw_aes128_decrypt_block(
AesBlock128 cipher,
Aes128KeySchedule* inverted_schedule);
@@ -32,10 +32,10 @@ void __fastcall raw_aes192_invert_key_schedule(
Aes192KeySchedule* key_schedule,
Aes192KeySchedule* inverted_schedule);
-AesBlock128 __fastcall raw_aes192_encrypt(
+AesBlock128 __fastcall raw_aes192_encrypt_block(
AesBlock128 plain,
Aes192KeySchedule* key_schedule);
-AesBlock128 __fastcall raw_aes192_decrypt(
+AesBlock128 __fastcall raw_aes192_decrypt_block(
AesBlock128 cipher,
Aes192KeySchedule* inverted_schedule);
@@ -47,9 +47,9 @@ void __fastcall raw_aes256_invert_key_schedule(
Aes256KeySchedule* key_schedule,
Aes256KeySchedule* inverted_schedule);
-AesBlock128 __fastcall raw_aes256_encrypt(
+AesBlock128 __fastcall raw_aes256_encrypt_block(
AesBlock128 plain,
Aes256KeySchedule* key_schedule);
-AesBlock128 __fastcall raw_aes256_decrypt(
+AesBlock128 __fastcall raw_aes256_decrypt_block(
AesBlock128 cipher,
Aes256KeySchedule* inverted_schedule);
diff --git a/src/aes128.asm b/src/aes128.asm
index 081f25d..b49de0e 100644
--- a/src/aes128.asm
+++ b/src/aes128.asm
@@ -8,7 +8,7 @@
.code
-@raw_aes128_encrypt@20 proc
+@raw_aes128_encrypt_block@20 proc
pxor xmm0, [ecx]
aesenc xmm0, [ecx + 10h]
aesenc xmm0, [ecx + 20h]
@@ -21,9 +21,9 @@
aesenc xmm0, [ecx + 90h]
aesenclast xmm0, [ecx + 0A0h]
ret
-@raw_aes128_encrypt@20 endp
+@raw_aes128_encrypt_block@20 endp
-@raw_aes128_decrypt@20 proc
+@raw_aes128_decrypt_block@20 proc
pxor xmm0, [ecx]
aesdec xmm0, [ecx + 10h]
aesdec xmm0, [ecx + 20h]
@@ -36,7 +36,7 @@
aesdec xmm0, [ecx + 90h]
aesdeclast xmm0, [ecx + 0A0h]
ret
-@raw_aes128_decrypt@20 endp
+@raw_aes128_decrypt_block@20 endp
@raw_aes128_expand_key_schedule@20 proc
; A "word" (in terms of the FIPS 187 standard) is a 32-bit block.
diff --git a/src/aes128.c b/src/aes128.c
index c700e30..d4c609d 100644
--- a/src/aes128.c
+++ b/src/aes128.c
@@ -11,7 +11,7 @@
#include <emmintrin.h>
#include <wmmintrin.h>
-AesBlock128 __fastcall raw_aes128_encrypt(
+AesBlock128 __fastcall raw_aes128_encrypt_block(
AesBlock128 plain,
Aes128KeySchedule* key_schedule)
{
@@ -28,7 +28,7 @@ AesBlock128 __fastcall raw_aes128_encrypt(
return _mm_aesenclast_si128(plain, key_schedule->keys[10]);
}
-AesBlock128 __fastcall raw_aes128_decrypt(
+AesBlock128 __fastcall raw_aes128_decrypt_block(
AesBlock128 cipher,
Aes128KeySchedule* inverted_schedule)
{
diff --git a/src/aes192.asm b/src/aes192.asm
index a437801..5cc8ded 100644
--- a/src/aes192.asm
+++ b/src/aes192.asm
@@ -8,7 +8,7 @@
.code
-@raw_aes192_encrypt@20 proc
+@raw_aes192_encrypt_block@20 proc
pxor xmm0, [ecx]
aesenc xmm0, [ecx + 10h]
aesenc xmm0, [ecx + 20h]
@@ -23,9 +23,9 @@
aesenc xmm0, [ecx + 0B0h]
aesenclast xmm0, [ecx + 0C0h]
ret
-@raw_aes192_encrypt@20 endp
+@raw_aes192_encrypt_block@20 endp
-@raw_aes192_decrypt@20 proc
+@raw_aes192_decrypt_block@20 proc
pxor xmm0, [ecx]
aesdec xmm0, [ecx + 10h]
aesdec xmm0, [ecx + 20h]
@@ -40,7 +40,7 @@
aesdec xmm0, [ecx + 0B0h]
aesdeclast xmm0, [ecx + 0C0h]
ret
-@raw_aes192_decrypt@20 endp
+@raw_aes192_decrypt_block@20 endp
@raw_aes192_expand_key_schedule@36 proc
; A "word" (in terms of the FIPS 187 standard) is a 32-bit block.
diff --git a/src/aes192.c b/src/aes192.c
index 62f6ce7..fec8f06 100644
--- a/src/aes192.c
+++ b/src/aes192.c
@@ -11,7 +11,7 @@
#include <emmintrin.h>
#include <wmmintrin.h>
-AesBlock128 __fastcall raw_aes192_encrypt(
+AesBlock128 __fastcall raw_aes192_encrypt_block(
AesBlock128 plain,
Aes192KeySchedule* key_schedule)
{
@@ -30,7 +30,7 @@ AesBlock128 __fastcall raw_aes192_encrypt(
return _mm_aesenclast_si128(plain, key_schedule->keys[12]);
}
-AesBlock128 __fastcall raw_aes192_decrypt(
+AesBlock128 __fastcall raw_aes192_decrypt_block(
AesBlock128 cipher,
Aes192KeySchedule* inverted_schedule)
{
diff --git a/src/aes256.asm b/src/aes256.asm
index 3dfd4b2..413e67b 100644
--- a/src/aes256.asm
+++ b/src/aes256.asm
@@ -8,7 +8,7 @@
.code
-@raw_aes256_encrypt@20 proc
+@raw_aes256_encrypt_block@20 proc
pxor xmm0, [ecx]
aesenc xmm0, [ecx + 10h]
aesenc xmm0, [ecx + 20h]
@@ -25,9 +25,9 @@
aesenc xmm0, [ecx + 0D0h]
aesenclast xmm0, [ecx + 0E0h]
ret
-@raw_aes256_encrypt@20 endp
+@raw_aes256_encrypt_block@20 endp
-@raw_aes256_decrypt@20 proc
+@raw_aes256_decrypt_block@20 proc
pxor xmm0, [ecx]
aesdec xmm0, [ecx + 10h]
aesdec xmm0, [ecx + 20h]
@@ -44,7 +44,7 @@
aesdec xmm0, [ecx + 0D0h]
aesdeclast xmm0, [ecx + 0E0h]
ret
-@raw_aes256_decrypt@20 endp
+@raw_aes256_decrypt_block@20 endp
@raw_aes256_expand_key_schedule@36 proc
; A "word" (in terms of the FIPS 187 standard) is a 32-bit block.
diff --git a/src/aes256.c b/src/aes256.c
index 25cee25..be4f783 100644
--- a/src/aes256.c
+++ b/src/aes256.c
@@ -11,7 +11,7 @@
#include <emmintrin.h>
#include <wmmintrin.h>
-AesBlock128 __fastcall raw_aes256_encrypt(
+AesBlock128 __fastcall raw_aes256_encrypt_block(
AesBlock128 plain,
Aes256KeySchedule* key_schedule)
{
@@ -32,7 +32,7 @@ AesBlock128 __fastcall raw_aes256_encrypt(
return _mm_aesenclast_si128(plain, key_schedule->keys[14]);
}
-AesBlock128 __fastcall raw_aes256_decrypt(
+AesBlock128 __fastcall raw_aes256_decrypt_block(
AesBlock128 cipher,
Aes256KeySchedule* inverted_schedule)
{
diff --git a/src/file.c b/src/file.c
index 445d917..d8ff9c7 100644
--- a/src/file.c
+++ b/src/file.c
@@ -11,10 +11,11 @@
#include <stdlib.h>
#include <string.h>
-size_t aes128ecb_encrypt_file(const unsigned char* src,
- size_t src_size,
- unsigned char* dest,
- Aes128KeySchedule* key_schedule)
+size_t aes128ecb_encrypt_buffer(
+ const unsigned char* src,
+ size_t src_size,
+ unsigned char* dest,
+ Aes128KeySchedule* key_schedule)
{
size_t rem_size = src_size % 16;
size_t padding_size = 16 - rem_size;
@@ -28,7 +29,7 @@ size_t aes128ecb_encrypt_file(const unsigned char* src,
for (size_t i = 0; i < src_len; ++i, src += 16, dest += 16)
{
AesBlock128 plaintext = load_aes_block128(src);
- AesBlock128 ciphertext = aes128ecb_encrypt(plaintext, key_schedule);
+ AesBlock128 ciphertext = aes128ecb_encrypt_block(plaintext, key_schedule);
store_aes_block128(ciphertext, dest);
}
@@ -41,16 +42,17 @@ size_t aes128ecb_encrypt_file(const unsigned char* src,
}
AesBlock128 plaintext = load_aes_block128(padding);
- AesBlock128 ciphertext = aes128ecb_encrypt(plaintext, key_schedule);
+ AesBlock128 ciphertext = aes128ecb_encrypt_block(plaintext, key_schedule);
store_aes_block128(ciphertext, dest);
return dest_size;
}
-size_t aes128ecb_decrypt_file(const unsigned char* src,
- size_t src_size,
- unsigned char* dest,
- Aes128KeySchedule* inverted_schedule)
+size_t aes128ecb_decrypt_buffer(
+ const unsigned char* src,
+ size_t src_size,
+ unsigned char* dest,
+ Aes128KeySchedule* inverted_schedule)
{
size_t dest_size = src_size;
@@ -62,12 +64,12 @@ size_t aes128ecb_decrypt_file(const unsigned char* src,
for (size_t i = 0; i < src_len - 1; ++i, src += 16, dest += 16)
{
AesBlock128 ciphertext = load_aes_block128(src);
- AesBlock128 plaintext = aes128ecb_decrypt(ciphertext, inverted_schedule);
+ AesBlock128 plaintext = aes128ecb_decrypt_block(ciphertext, inverted_schedule);
store_aes_block128(plaintext, dest);
}
AesBlock128 ciphertext = load_aes_block128(src);
- AesBlock128 plaintext = aes128ecb_decrypt(ciphertext, inverted_schedule);
+ AesBlock128 plaintext = aes128ecb_decrypt_block(ciphertext, inverted_schedule);
unsigned char padding[16];
store_aes_block128(plaintext, padding);
diff --git a/test/aes128cbc_decrypt.c b/test/aes128cbc_decrypt.c
index a97d00b..f7ede57 100644
--- a/test/aes128cbc_decrypt.c
+++ b/test/aes128cbc_decrypt.c
@@ -53,7 +53,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aes128cbc_decrypt(cipher, &inverted_schedule, iv, &iv);
+ plain = aes128cbc_decrypt_block(cipher, &inverted_schedule, iv, &iv);
print_aes_block128(&plain);
}
}
diff --git a/test/aes128cbc_encrypt.c b/test/aes128cbc_encrypt.c
index 223ebdb..d7bb57c 100644
--- a/test/aes128cbc_encrypt.c
+++ b/test/aes128cbc_encrypt.c
@@ -52,7 +52,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aes128cbc_encrypt(plain, &key_schedule, iv, &iv);
+ cipher = aes128cbc_encrypt_block(plain, &key_schedule, iv, &iv);
print_aes_block128(&cipher);
}
}
diff --git a/test/aes128cfb_decrypt.c b/test/aes128cfb_decrypt.c
index 34ac44f..8d53888 100644
--- a/test/aes128cfb_decrypt.c
+++ b/test/aes128cfb_decrypt.c
@@ -52,7 +52,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aes128cfb_decrypt(cipher, &key_schedule, iv, &iv);
+ plain = aes128cfb_decrypt_block(cipher, &key_schedule, iv, &iv);
print_aes_block128(&plain);
}
}
diff --git a/test/aes128cfb_encrypt.c b/test/aes128cfb_encrypt.c
index a566922..922788b 100644
--- a/test/aes128cfb_encrypt.c
+++ b/test/aes128cfb_encrypt.c
@@ -52,7 +52,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aes128cfb_encrypt(plain, &key_schedule, iv, &iv);
+ cipher = aes128cfb_encrypt_block(plain, &key_schedule, iv, &iv);
print_aes_block128(&cipher);
}
}
diff --git a/test/aes128ctr_decrypt.c b/test/aes128ctr_decrypt.c
index 1cd8c92..2d4146c 100644
--- a/test/aes128ctr_decrypt.c
+++ b/test/aes128ctr_decrypt.c
@@ -54,7 +54,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aes128ctr_decrypt(cipher, &key_schedule, iv, ctr++);
+ plain = aes128ctr_decrypt_block(cipher, &key_schedule, iv, ctr++);
print_aes_block128(&plain);
}
}
diff --git a/test/aes128ctr_encrypt.c b/test/aes128ctr_encrypt.c
index 16b4403..ef82029 100644
--- a/test/aes128ctr_encrypt.c
+++ b/test/aes128ctr_encrypt.c
@@ -54,7 +54,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aes128ctr_encrypt(plain, &key_schedule, iv, ctr++);
+ cipher = aes128ctr_encrypt_block(plain, &key_schedule, iv, ctr++);
print_aes_block128(&cipher);
}
}
diff --git a/test/aes128ecb_decrypt.c b/test/aes128ecb_decrypt.c
index ce40314..dc85928 100644
--- a/test/aes128ecb_decrypt.c
+++ b/test/aes128ecb_decrypt.c
@@ -47,7 +47,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aes128ecb_decrypt(cipher, &inverted_schedule);
+ plain = aes128ecb_decrypt_block(cipher, &inverted_schedule);
print_aes_block128(&plain);
}
}
diff --git a/test/aes128ecb_encrypt.c b/test/aes128ecb_encrypt.c
index 6fde333..3dc8fdb 100644
--- a/test/aes128ecb_encrypt.c
+++ b/test/aes128ecb_encrypt.c
@@ -46,7 +46,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aes128ecb_encrypt(plain, &key_schedule);
+ cipher = aes128ecb_encrypt_block(plain, &key_schedule);
print_aes_block128(&cipher);
}
}
diff --git a/test/aes128ofb_decrypt.c b/test/aes128ofb_decrypt.c
index 0c3d7ad..ff3ea93 100644
--- a/test/aes128ofb_decrypt.c
+++ b/test/aes128ofb_decrypt.c
@@ -52,7 +52,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aes128ofb_decrypt(cipher, &key_schedule, iv, &iv);
+ plain = aes128ofb_decrypt_block(cipher, &key_schedule, iv, &iv);
print_aes_block128(&plain);
}
}
diff --git a/test/aes128ofb_encrypt.c b/test/aes128ofb_encrypt.c
index e77b121..9b640da 100644
--- a/test/aes128ofb_encrypt.c
+++ b/test/aes128ofb_encrypt.c
@@ -52,7 +52,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aes128ofb_encrypt(plain, &key_schedule, iv, &iv);
+ cipher = aes128ofb_encrypt_block(plain, &key_schedule, iv, &iv);
print_aes_block128(&cipher);
}
}
diff --git a/test/aes192cbc_decrypt.c b/test/aes192cbc_decrypt.c
index 2b2e235..d77a489 100644
--- a/test/aes192cbc_decrypt.c
+++ b/test/aes192cbc_decrypt.c
@@ -54,7 +54,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aes192cbc_decrypt(cipher, &inverted_schedule, iv, &iv);
+ plain = aes192cbc_decrypt_block(cipher, &inverted_schedule, iv, &iv);
print_aes_block128(&plain);
}
}
diff --git a/test/aes192cbc_encrypt.c b/test/aes192cbc_encrypt.c
index 7eadb6c..33c242e 100644
--- a/test/aes192cbc_encrypt.c
+++ b/test/aes192cbc_encrypt.c
@@ -53,7 +53,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aes192cbc_encrypt(plain, &key_schedule, iv, &iv);
+ cipher = aes192cbc_encrypt_block(plain, &key_schedule, iv, &iv);
print_aes_block128(&cipher);
}
}
diff --git a/test/aes192cfb_decrypt.c b/test/aes192cfb_decrypt.c
index 711cade..aec2840 100644
--- a/test/aes192cfb_decrypt.c
+++ b/test/aes192cfb_decrypt.c
@@ -53,7 +53,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aes192cfb_decrypt(cipher, &key_schedule, iv, &iv);
+ plain = aes192cfb_decrypt_block(cipher, &key_schedule, iv, &iv);
print_aes_block128(&plain);
}
}
diff --git a/test/aes192cfb_encrypt.c b/test/aes192cfb_encrypt.c
index ad2a30a..1fba837 100644
--- a/test/aes192cfb_encrypt.c
+++ b/test/aes192cfb_encrypt.c
@@ -53,7 +53,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aes192cfb_encrypt(plain, &key_schedule, iv, &iv);
+ cipher = aes192cfb_encrypt_block(plain, &key_schedule, iv, &iv);
print_aes_block128(&cipher);
}
}
diff --git a/test/aes192ctr_decrypt.c b/test/aes192ctr_decrypt.c
index e456fff..9508b8d 100644
--- a/test/aes192ctr_decrypt.c
+++ b/test/aes192ctr_decrypt.c
@@ -55,7 +55,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aes192ctr_decrypt(cipher, &key_schedule, iv, ctr++);
+ plain = aes192ctr_decrypt_block(cipher, &key_schedule, iv, ctr++);
print_aes_block128(&plain);
}
}
diff --git a/test/aes192ctr_encrypt.c b/test/aes192ctr_encrypt.c
index c9bf131..17eb1aa 100644
--- a/test/aes192ctr_encrypt.c
+++ b/test/aes192ctr_encrypt.c
@@ -55,7 +55,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aes192ctr_encrypt(plain, &key_schedule, iv, ctr++);
+ cipher = aes192ctr_encrypt_block(plain, &key_schedule, iv, ctr++);
print_aes_block128(&cipher);
}
}
diff --git a/test/aes192ecb_decrypt.c b/test/aes192ecb_decrypt.c
index b3cc257..373a4a3 100644
--- a/test/aes192ecb_decrypt.c
+++ b/test/aes192ecb_decrypt.c
@@ -48,7 +48,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aes192ecb_decrypt(cipher, &inverted_schedule);
+ plain = aes192ecb_decrypt_block(cipher, &inverted_schedule);
print_aes_block128(&plain);
}
}
diff --git a/test/aes192ecb_encrypt.c b/test/aes192ecb_encrypt.c
index ea7090e..16a0290 100644
--- a/test/aes192ecb_encrypt.c
+++ b/test/aes192ecb_encrypt.c
@@ -47,7 +47,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aes192ecb_encrypt(plain, &key_schedule);
+ cipher = aes192ecb_encrypt_block(plain, &key_schedule);
print_aes_block128(&cipher);
}
}
diff --git a/test/aes192ofb_decrypt.c b/test/aes192ofb_decrypt.c
index 7c09dfd..621031f 100644
--- a/test/aes192ofb_decrypt.c
+++ b/test/aes192ofb_decrypt.c
@@ -53,7 +53,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aes192ofb_decrypt(cipher, &key_schedule, iv, &iv);
+ plain = aes192ofb_decrypt_block(cipher, &key_schedule, iv, &iv);
print_aes_block128(&plain);
}
}
diff --git a/test/aes192ofb_encrypt.c b/test/aes192ofb_encrypt.c
index 109688e..f7cb8d0 100644
--- a/test/aes192ofb_encrypt.c
+++ b/test/aes192ofb_encrypt.c
@@ -53,7 +53,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aes192ofb_encrypt(plain, &key_schedule, iv, &iv);
+ cipher = aes192ofb_encrypt_block(plain, &key_schedule, iv, &iv);
print_aes_block128(&cipher);
}
}
diff --git a/test/aes256cbc_decrypt.c b/test/aes256cbc_decrypt.c
index 5efb0e4..bab00ab 100644
--- a/test/aes256cbc_decrypt.c
+++ b/test/aes256cbc_decrypt.c
@@ -54,7 +54,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aes256cbc_decrypt(cipher, &inverted_schedule, iv, &iv);
+ plain = aes256cbc_decrypt_block(cipher, &inverted_schedule, iv, &iv);
print_aes_block128(&plain);
}
}
diff --git a/test/aes256cbc_encrypt.c b/test/aes256cbc_encrypt.c
index 71484d7..51a80f3 100644
--- a/test/aes256cbc_encrypt.c
+++ b/test/aes256cbc_encrypt.c
@@ -53,7 +53,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aes256cbc_encrypt(plain, &key_schedule, iv, &iv);
+ cipher = aes256cbc_encrypt_block(plain, &key_schedule, iv, &iv);
print_aes_block128(&cipher);
}
}
diff --git a/test/aes256cfb_decrypt.c b/test/aes256cfb_decrypt.c
index fc30ba4..c192178 100644
--- a/test/aes256cfb_decrypt.c
+++ b/test/aes256cfb_decrypt.c
@@ -53,7 +53,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aes256cfb_decrypt(cipher, &key_schedule, iv, &iv);
+ plain = aes256cfb_decrypt_block(cipher, &key_schedule, iv, &iv);
print_aes_block128(&plain);
}
}
diff --git a/test/aes256cfb_encrypt.c b/test/aes256cfb_encrypt.c
index 666c605..96f59c5 100644
--- a/test/aes256cfb_encrypt.c
+++ b/test/aes256cfb_encrypt.c
@@ -53,7 +53,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aes256cfb_encrypt(plain, &key_schedule, iv, &iv);
+ cipher = aes256cfb_encrypt_block(plain, &key_schedule, iv, &iv);
print_aes_block128(&cipher);
}
}
diff --git a/test/aes256ctr_decrypt.c b/test/aes256ctr_decrypt.c
index 68bf1b7..d832a1f 100644
--- a/test/aes256ctr_decrypt.c
+++ b/test/aes256ctr_decrypt.c
@@ -55,7 +55,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aes256ctr_decrypt(cipher, &key_schedule, iv, ctr++);
+ plain = aes256ctr_decrypt_block(cipher, &key_schedule, iv, ctr++);
print_aes_block128(&plain);
}
}
diff --git a/test/aes256ctr_encrypt.c b/test/aes256ctr_encrypt.c
index 2552610..28857ac 100644
--- a/test/aes256ctr_encrypt.c
+++ b/test/aes256ctr_encrypt.c
@@ -55,7 +55,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aes256ctr_encrypt(plain, &key_schedule, iv, ctr++);
+ cipher = aes256ctr_encrypt_block(plain, &key_schedule, iv, ctr++);
print_aes_block128(&cipher);
}
}
diff --git a/test/aes256ecb_decrypt.c b/test/aes256ecb_decrypt.c
index c4ae001..eed5528 100644
--- a/test/aes256ecb_decrypt.c
+++ b/test/aes256ecb_decrypt.c
@@ -48,7 +48,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aes256ecb_decrypt(cipher, &inverted_schedule);
+ plain = aes256ecb_decrypt_block(cipher, &inverted_schedule);
print_aes_block128(&plain);
}
}
diff --git a/test/aes256ecb_encrypt.c b/test/aes256ecb_encrypt.c
index 7553362..cfcc74e 100644
--- a/test/aes256ecb_encrypt.c
+++ b/test/aes256ecb_encrypt.c
@@ -47,7 +47,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aes256ecb_encrypt(plain, &key_schedule);
+ cipher = aes256ecb_encrypt_block(plain, &key_schedule);
print_aes_block128(&cipher);
}
}
diff --git a/test/aes256ofb_decrypt.c b/test/aes256ofb_decrypt.c
index 7eaf7c3..8c324e9 100644
--- a/test/aes256ofb_decrypt.c
+++ b/test/aes256ofb_decrypt.c
@@ -53,7 +53,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- plain = aes256ofb_decrypt(cipher, &key_schedule, iv, &iv);
+ plain = aes256ofb_decrypt_block(cipher, &key_schedule, iv, &iv);
print_aes_block128(&plain);
}
}
diff --git a/test/aes256ofb_encrypt.c b/test/aes256ofb_encrypt.c
index dde7aa2..8d31fbe 100644
--- a/test/aes256ofb_encrypt.c
+++ b/test/aes256ofb_encrypt.c
@@ -53,7 +53,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
continue;
}
- cipher = aes256ofb_encrypt(plain, &key_schedule, iv, &iv);
+ cipher = aes256ofb_encrypt_block(plain, &key_schedule, iv, &iv);
print_aes_block128(&cipher);
}
}
diff --git a/utils/aes128ecb_decrypt_file.cpp b/utils/aes128ecb_decrypt_file.cpp
index 42432bb..a405882 100644
--- a/utils/aes128ecb_decrypt_file.cpp
+++ b/utils/aes128ecb_decrypt_file.cpp
@@ -66,12 +66,12 @@ int main(int argc, char** argv)
aes128_expand_key_schedule(key, &key_schedule);
aes128_invert_key_schedule(&key_schedule, &inverted_schedule);
- auto dest_size = aes128ecb_decrypt_file(
+ auto dest_size = aes128ecb_decrypt_buffer(
src_buf.data(), static_cast<std::size_t>(src_size), NULL, &inverted_schedule);
std::vector<unsigned char> dest_buf(static_cast<std::vector<char>::size_type>(dest_size));
- dest_size = aes128ecb_decrypt_file(
+ dest_size = aes128ecb_decrypt_buffer(
src_buf.data(), static_cast<std::size_t>(src_size), dest_buf.data(), &inverted_schedule);
std::ofstream dest_ofs;
diff --git a/utils/aes128ecb_encrypt_file.cpp b/utils/aes128ecb_encrypt_file.cpp
index aba8569..bcb5293 100644
--- a/utils/aes128ecb_encrypt_file.cpp
+++ b/utils/aes128ecb_encrypt_file.cpp
@@ -65,15 +65,19 @@ int main(int argc, char** argv)
aes128_expand_key_schedule(key, &key_schedule);
- const auto dest_size = aes128ecb_encrypt_file(
- src_buf.data(), static_cast<std::size_t>(src_size), NULL, &key_schedule);
+ const auto dest_size = aes128ecb_encrypt_buffer(
+ src_buf.data(),
+ static_cast<std::size_t>(src_size),
+ NULL,
+ &key_schedule);
std::vector<unsigned char> dest_buf(static_cast<std::vector<char>::size_type>(dest_size));
- aes128ecb_encrypt_file(src_buf.data(),
- static_cast<std::size_t>(src_size),
- dest_buf.data(),
- &key_schedule);
+ aes128ecb_encrypt_buffer(
+ src_buf.data(),
+ static_cast<std::size_t>(src_size),
+ dest_buf.data(),
+ &key_schedule);
std::ofstream dest_ofs;
dest_ofs.exceptions(std::ofstream::badbit | std::ofstream::failbit);