aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/aes128cbc.c50
-rw-r--r--examples/aes128cfb.c46
-rw-r--r--examples/aes128ctr.c38
-rw-r--r--examples/aes128ecb.c36
-rw-r--r--examples/aes128ofb.c46
-rw-r--r--examples/aes192cbc.c52
-rw-r--r--examples/aes192cfb.c48
-rw-r--r--examples/aes192ctr.c40
-rw-r--r--examples/aes192ecb.c38
-rw-r--r--examples/aes192ofb.c48
-rw-r--r--examples/aes256cbc.c52
-rw-r--r--examples/aes256cfb.c48
-rw-r--r--examples/aes256ctr.c40
-rw-r--r--examples/aes256ecb.c38
-rw-r--r--examples/aes256ofb.c48
15 files changed, 334 insertions, 334 deletions
diff --git a/examples/aes128cbc.c b/examples/aes128cbc.c
index 986be2e..b2eb14a 100644
--- a/examples/aes128cbc.c
+++ b/examples/aes128cbc.c
@@ -12,55 +12,55 @@
int main()
{
- AesBlock128 plain, key, cipher, decrypted, iv, next_iv;
- Aes128KeySchedule key_schedule, inverted_schedule;
+ AesNI_Block128 plain, key, cipher, decrypted, iv, next_iv;
+ AesNI_KeySchedule128 key_schedule, inverted_schedule;
- plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
- key = make_aes_block128(0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
- iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
+ plain = aesni_make_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
+ key = aesni_make_block128(0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
+ iv = aesni_make_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
- printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_as_matrix(&plain);
+ printf("Plain: %s\n", aesni_format_block128(&plain).str);
+ aesni_print_block128_as_matrix(&plain);
printf("\n");
- printf("Key: %s\n", format_aes_block128(&key).str);
- print_aes_block128_as_matrix(&key);
+ printf("Key: %s\n", aesni_format_block128(&key).str);
+ aesni_print_block128_as_matrix(&key);
printf("\n");
- printf("Initialization vector: %s\n", format_aes_block128(&iv).str);
- print_aes_block128_as_matrix(&iv);
+ printf("Initialization vector: %s\n", aesni_format_block128(&iv).str);
+ aesni_print_block128_as_matrix(&iv);
- aes128_expand_key_schedule(key, &key_schedule);
+ aesni_expand_key_schedule128(key, &key_schedule);
printf("\n");
printf("Key schedule:\n");
for (int i = 0; i < 11; ++i)
- printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
+ printf("\t[%d]: %s\n", i, aesni_format_block128(&key_schedule.keys[i]).str);
- cipher = aes128cbc_encrypt_block(plain, &key_schedule, iv, &next_iv);
+ cipher = aesni_encrypt_block_cbc128(plain, &key_schedule, iv, &next_iv);
printf("\n");
- printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_as_matrix(&cipher);
+ printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
+ aesni_print_block128_as_matrix(&cipher);
printf("\n");
- printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_as_matrix(&next_iv);
+ printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
+ aesni_print_block128_as_matrix(&next_iv);
- aes128_invert_key_schedule(&key_schedule, &inverted_schedule);
+ aesni_invert_key_schedule128(&key_schedule, &inverted_schedule);
printf("\n");
printf("Inverted key schedule:\n");
for (int i = 0; i < 11; ++i)
- printf("\t[%d]: %s\n", i, format_aes_block128(&inverted_schedule.keys[i]).str);
+ printf("\t[%d]: %s\n", i, aesni_format_block128(&inverted_schedule.keys[i]).str);
- decrypted = aes128cbc_decrypt_block(cipher, &inverted_schedule, iv, &next_iv);
+ decrypted = aesni_decrypt_block_cbc128(cipher, &inverted_schedule, iv, &next_iv);
printf("\n");
- printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_as_matrix(&decrypted);
+ printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
+ aesni_print_block128_as_matrix(&decrypted);
printf("\n");
- printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_as_matrix(&next_iv);
+ printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
+ aesni_print_block128_as_matrix(&next_iv);
return 0;
}
diff --git a/examples/aes128cfb.c b/examples/aes128cfb.c
index 2d209ca..31ad748 100644
--- a/examples/aes128cfb.c
+++ b/examples/aes128cfb.c
@@ -12,48 +12,48 @@
int main()
{
- AesBlock128 plain, key, cipher, decrypted, iv, next_iv;
- Aes128KeySchedule key_schedule;
+ AesNI_Block128 plain, key, cipher, decrypted, iv, next_iv;
+ AesNI_KeySchedule128 key_schedule;
- plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
- key = make_aes_block128(0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
- iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
+ plain = aesni_make_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
+ key = aesni_make_block128(0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
+ iv = aesni_make_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
- printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_as_matrix(&plain);
+ printf("Plain: %s\n", aesni_format_block128(&plain).str);
+ aesni_print_block128_as_matrix(&plain);
printf("\n");
- printf("Key: %s\n", format_aes_block128(&key).str);
- print_aes_block128_as_matrix(&key);
+ printf("Key: %s\n", aesni_format_block128(&key).str);
+ aesni_print_block128_as_matrix(&key);
printf("\n");
- printf("Initialization vector: %s\n", format_aes_block128(&iv).str);
- print_aes_block128_as_matrix(&iv);
+ printf("Initialization vector: %s\n", aesni_format_block128(&iv).str);
+ aesni_print_block128_as_matrix(&iv);
- aes128_expand_key_schedule(key, &key_schedule);
+ aesni_expand_key_schedule128(key, &key_schedule);
printf("\n");
printf("Key schedule:\n");
for (int i = 0; i < 11; ++i)
- printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
+ printf("\t[%d]: %s\n", i, aesni_format_block128(&key_schedule.keys[i]).str);
- cipher = aes128cfb_encrypt_block(plain, &key_schedule, iv, &next_iv);
+ cipher = aesni_encrypt_block_cfb128(plain, &key_schedule, iv, &next_iv);
printf("\n");
- printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_as_matrix(&cipher);
+ printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
+ aesni_print_block128_as_matrix(&cipher);
printf("\n");
- printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_as_matrix(&next_iv);
+ printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
+ aesni_print_block128_as_matrix(&next_iv);
- decrypted = aes128cfb_decrypt_block(cipher, &key_schedule, iv, &next_iv);
+ decrypted = aesni_decrypt_block_cfb128(cipher, &key_schedule, iv, &next_iv);
printf("\n");
- printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_as_matrix(&decrypted);
+ printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
+ aesni_print_block128_as_matrix(&decrypted);
printf("\n");
- printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_as_matrix(&next_iv);
+ printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
+ aesni_print_block128_as_matrix(&next_iv);
return 0;
}
diff --git a/examples/aes128ctr.c b/examples/aes128ctr.c
index c645da7..1efe4e2 100644
--- a/examples/aes128ctr.c
+++ b/examples/aes128ctr.c
@@ -12,40 +12,40 @@
int main()
{
- AesBlock128 plain, key, cipher, decrypted, iv;
- Aes128KeySchedule key_schedule;
+ AesNI_Block128 plain, key, cipher, decrypted, iv;
+ AesNI_KeySchedule128 key_schedule;
- plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
- key = make_aes_block128(0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
- iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
+ plain = aesni_make_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
+ key = aesni_make_block128(0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
+ iv = aesni_make_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
- printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_as_matrix(&plain);
+ printf("Plain: %s\n", aesni_format_block128(&plain).str);
+ aesni_print_block128_as_matrix(&plain);
printf("\n");
- printf("Key: %s\n", format_aes_block128(&key).str);
- print_aes_block128_as_matrix(&key);
+ printf("Key: %s\n", aesni_format_block128(&key).str);
+ aesni_print_block128_as_matrix(&key);
printf("\n");
- printf("Initialization vector: %s\n", format_aes_block128(&iv).str);
- print_aes_block128_as_matrix(&iv);
+ printf("Initialization vector: %s\n", aesni_format_block128(&iv).str);
+ aesni_print_block128_as_matrix(&iv);
- aes128_expand_key_schedule(key, &key_schedule);
+ aesni_expand_key_schedule128(key, &key_schedule);
printf("\n");
printf("Key schedule:\n");
for (int i = 0; i < 11; ++i)
- printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
+ printf("\t[%d]: %s\n", i, aesni_format_block128(&key_schedule.keys[i]).str);
- cipher = aes128ctr_encrypt_block(plain, &key_schedule, iv, 0);
+ cipher = aesni_encrypt_block_ctr128(plain, &key_schedule, iv, 0);
printf("\n");
- printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_as_matrix(&cipher);
+ printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
+ aesni_print_block128_as_matrix(&cipher);
- decrypted = aes128ctr_decrypt_block(cipher, &key_schedule, iv, 0);
+ decrypted = aesni_decrypt_block_ctr128(cipher, &key_schedule, iv, 0);
printf("\n");
- printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_as_matrix(&decrypted);
+ printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
+ aesni_print_block128_as_matrix(&decrypted);
return 0;
}
diff --git a/examples/aes128ecb.c b/examples/aes128ecb.c
index e36cd66..4f999d4 100644
--- a/examples/aes128ecb.c
+++ b/examples/aes128ecb.c
@@ -12,42 +12,42 @@
int main()
{
- AesBlock128 plain, key, cipher, decrypted;
- Aes128KeySchedule key_schedule, inverted_schedule;
+ AesNI_Block128 plain, key, cipher, decrypted;
+ AesNI_KeySchedule128 key_schedule, inverted_schedule;
- plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
- key = make_aes_block128(0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
+ plain = aesni_make_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
+ key = aesni_make_block128(0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
- printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_as_matrix(&plain);
+ printf("Plain: %s\n", aesni_format_block128(&plain).str);
+ aesni_print_block128_as_matrix(&plain);
printf("\n");
- printf("Key: %s\n", format_aes_block128(&key).str);
- print_aes_block128_as_matrix(&key);
+ printf("Key: %s\n", aesni_format_block128(&key).str);
+ aesni_print_block128_as_matrix(&key);
- aes128_expand_key_schedule(key, &key_schedule);
+ aesni_expand_key_schedule128(key, &key_schedule);
printf("\n");
printf("Key schedule:\n");
for (int i = 0; i < 11; ++i)
- printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
+ printf("\t[%d]: %s\n", i, aesni_format_block128(&key_schedule.keys[i]).str);
- cipher = aes128ecb_encrypt_block(plain, &key_schedule);
+ cipher = aesni_encrypt_block_ecb128(plain, &key_schedule);
printf("\n");
- printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_as_matrix(&cipher);
+ printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
+ aesni_print_block128_as_matrix(&cipher);
- aes128_invert_key_schedule(&key_schedule, &inverted_schedule);
+ aesni_invert_key_schedule128(&key_schedule, &inverted_schedule);
printf("\n");
printf("Inverted key schedule:\n");
for (int i = 0; i < 11; ++i)
- printf("\t[%d]: %s\n", i, format_aes_block128(&inverted_schedule.keys[i]).str);
+ printf("\t[%d]: %s\n", i, aesni_format_block128(&inverted_schedule.keys[i]).str);
- decrypted = aes128ecb_decrypt_block(cipher, &inverted_schedule);
+ decrypted = aesni_decrypt_block_ecb128(cipher, &inverted_schedule);
printf("\n");
- printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_as_matrix(&decrypted);
+ printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
+ aesni_print_block128_as_matrix(&decrypted);
return 0;
}
diff --git a/examples/aes128ofb.c b/examples/aes128ofb.c
index 12ef468..49a97ed 100644
--- a/examples/aes128ofb.c
+++ b/examples/aes128ofb.c
@@ -12,48 +12,48 @@
int main()
{
- AesBlock128 plain, key, cipher, decrypted, iv, next_iv;
- Aes128KeySchedule key_schedule;
+ AesNI_Block128 plain, key, cipher, decrypted, iv, next_iv;
+ AesNI_KeySchedule128 key_schedule;
- plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
- key = make_aes_block128(0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
- iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
+ plain = aesni_make_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
+ key = aesni_make_block128(0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
+ iv = aesni_make_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
- printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_as_matrix(&plain);
+ printf("Plain: %s\n", aesni_format_block128(&plain).str);
+ aesni_print_block128_as_matrix(&plain);
printf("\n");
- printf("Key: %s\n", format_aes_block128(&key).str);
- print_aes_block128_as_matrix(&key);
+ printf("Key: %s\n", aesni_format_block128(&key).str);
+ aesni_print_block128_as_matrix(&key);
printf("\n");
- printf("Initialization vector: %s\n", format_aes_block128(&iv).str);
- print_aes_block128_as_matrix(&iv);
+ printf("Initialization vector: %s\n", aesni_format_block128(&iv).str);
+ aesni_print_block128_as_matrix(&iv);
- aes128_expand_key_schedule(key, &key_schedule);
+ aesni_expand_key_schedule128(key, &key_schedule);
printf("\n");
printf("Key schedule:\n");
for (int i = 0; i < 11; ++i)
- printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
+ printf("\t[%d]: %s\n", i, aesni_format_block128(&key_schedule.keys[i]).str);
- cipher = aes128ofb_encrypt_block(plain, &key_schedule, iv, &next_iv);
+ cipher = aesni_encrypt_block_ofb128(plain, &key_schedule, iv, &next_iv);
printf("\n");
- printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_as_matrix(&cipher);
+ printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
+ aesni_print_block128_as_matrix(&cipher);
printf("\n");
- printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_as_matrix(&next_iv);
+ printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
+ aesni_print_block128_as_matrix(&next_iv);
- decrypted = aes128ofb_decrypt_block(cipher, &key_schedule, iv, &next_iv);
+ decrypted = aesni_decrypt_block_ofb128(cipher, &key_schedule, iv, &next_iv);
printf("\n");
- printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_as_matrix(&decrypted);
+ printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
+ aesni_print_block128_as_matrix(&decrypted);
printf("\n");
- printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_as_matrix(&next_iv);
+ printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
+ aesni_print_block128_as_matrix(&next_iv);
return 0;
}
diff --git a/examples/aes192cbc.c b/examples/aes192cbc.c
index 406575c..67adf95 100644
--- a/examples/aes192cbc.c
+++ b/examples/aes192cbc.c
@@ -12,56 +12,56 @@
int main()
{
- AesBlock128 plain, cipher, decrypted, iv, next_iv;
- AesBlock192 key;
- Aes192KeySchedule key_schedule, inverted_schedule;
+ AesNI_Block128 plain, cipher, decrypted, iv, next_iv;
+ AesNI_Block192 key;
+ AesNI_KeySchedule192 key_schedule, inverted_schedule;
- plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
- key = make_aes_block192(0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
- iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
+ plain = aesni_make_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
+ key = aesni_make_block192(0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
+ iv = aesni_make_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
- printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_as_matrix(&plain);
+ printf("Plain: %s\n", aesni_format_block128(&plain).str);
+ aesni_print_block128_as_matrix(&plain);
printf("\n");
- printf("Key: %s\n", format_aes_block192(&key).str);
- print_aes_block192_as_matrix(&key);
+ printf("Key: %s\n", aesni_format_block192(&key).str);
+ aesni_print_block192_as_matrix(&key);
printf("\n");
- printf("Initialization vector: %s\n", format_aes_block128(&iv).str);
- print_aes_block128_as_matrix(&iv);
+ printf("Initialization vector: %s\n", aesni_format_block128(&iv).str);
+ aesni_print_block128_as_matrix(&iv);
- aes192_expand_key_schedule(&key, &key_schedule);
+ aesni_expand_key_schedule192(&key, &key_schedule);
printf("\n");
printf("Key schedule:\n");
for (int i = 0; i < 13; ++i)
- printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
+ printf("\t[%d]: %s\n", i, aesni_format_block128(&key_schedule.keys[i]).str);
- cipher = aes192cbc_encrypt_block(plain, &key_schedule, iv, &next_iv);
+ cipher = aesni_encrypt_block_cbc192(plain, &key_schedule, iv, &next_iv);
printf("\n");
- printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_as_matrix(&cipher);
+ printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
+ aesni_print_block128_as_matrix(&cipher);
printf("\n");
- printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_as_matrix(&next_iv);
+ printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
+ aesni_print_block128_as_matrix(&next_iv);
- aes192_invert_key_schedule(&key_schedule, &inverted_schedule);
+ aesni_invert_key_schedule192(&key_schedule, &inverted_schedule);
printf("\n");
printf("Inverted key schedule:\n");
for (int i = 0; i < 13; ++i)
- printf("\t[%d]: %s\n", i, format_aes_block128(&inverted_schedule.keys[i]).str);
+ printf("\t[%d]: %s\n", i, aesni_format_block128(&inverted_schedule.keys[i]).str);
- decrypted = aes192cbc_decrypt_block(cipher, &inverted_schedule, iv, &next_iv);
+ decrypted = aesni_decrypt_block_cbc192(cipher, &inverted_schedule, iv, &next_iv);
printf("\n");
- printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_as_matrix(&decrypted);
+ printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
+ aesni_print_block128_as_matrix(&decrypted);
printf("\n");
- printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_as_matrix(&next_iv);
+ printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
+ aesni_print_block128_as_matrix(&next_iv);
return 0;
}
diff --git a/examples/aes192cfb.c b/examples/aes192cfb.c
index 103ac12..d5bf554 100644
--- a/examples/aes192cfb.c
+++ b/examples/aes192cfb.c
@@ -12,49 +12,49 @@
int main()
{
- AesBlock128 plain, cipher, decrypted, iv, next_iv;
- AesBlock192 key;
- Aes192KeySchedule key_schedule;
+ AesNI_Block128 plain, cipher, decrypted, iv, next_iv;
+ AesNI_Block192 key;
+ AesNI_KeySchedule192 key_schedule;
- plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
- key = make_aes_block192(0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
- iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
+ plain = aesni_make_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
+ key = aesni_make_block192(0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
+ iv = aesni_make_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
- printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_as_matrix(&plain);
+ printf("Plain: %s\n", aesni_format_block128(&plain).str);
+ aesni_print_block128_as_matrix(&plain);
printf("\n");
- printf("Key: %s\n", format_aes_block192(&key).str);
- print_aes_block192_as_matrix(&key);
+ printf("Key: %s\n", aesni_format_block192(&key).str);
+ aesni_print_block192_as_matrix(&key);
printf("\n");
- printf("Initialization vector: %s\n", format_aes_block128(&iv).str);
- print_aes_block128_as_matrix(&iv);
+ printf("Initialization vector: %s\n", aesni_format_block128(&iv).str);
+ aesni_print_block128_as_matrix(&iv);
- aes192_expand_key_schedule(&key, &key_schedule);
+ aesni_expand_key_schedule192(&key, &key_schedule);
printf("\n");
printf("Key schedule:\n");
for (int i = 0; i < 13; ++i)
- printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
+ printf("\t[%d]: %s\n", i, aesni_format_block128(&key_schedule.keys[i]).str);
- cipher = aes192cfb_encrypt_block(plain, &key_schedule, iv, &next_iv);
+ cipher = aesni_encrypt_block_cfb192(plain, &key_schedule, iv, &next_iv);
printf("\n");
- printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_as_matrix(&cipher);
+ printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
+ aesni_print_block128_as_matrix(&cipher);
printf("\n");
- printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_as_matrix(&next_iv);
+ printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
+ aesni_print_block128_as_matrix(&next_iv);
- decrypted = aes192cfb_decrypt_block(cipher, &key_schedule, iv, &next_iv);
+ decrypted = aesni_decrypt_block_cfb192(cipher, &key_schedule, iv, &next_iv);
printf("\n");
- printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_as_matrix(&decrypted);
+ printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
+ aesni_print_block128_as_matrix(&decrypted);
printf("\n");
- printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_as_matrix(&next_iv);
+ printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
+ aesni_print_block128_as_matrix(&next_iv);
return 0;
}
diff --git a/examples/aes192ctr.c b/examples/aes192ctr.c
index 48d4b14..3ce7c76 100644
--- a/examples/aes192ctr.c
+++ b/examples/aes192ctr.c
@@ -12,41 +12,41 @@
int main()
{
- AesBlock128 plain, cipher, decrypted, iv;
- AesBlock192 key;
- Aes192KeySchedule key_schedule;
+ AesNI_Block128 plain, cipher, decrypted, iv;
+ AesNI_Block192 key;
+ AesNI_KeySchedule192 key_schedule;
- plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
- key = make_aes_block192(0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
- iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
+ plain = aesni_make_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
+ key = aesni_make_block192(0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
+ iv = aesni_make_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
- printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_as_matrix(&plain);
+ printf("Plain: %s\n", aesni_format_block128(&plain).str);
+ aesni_print_block128_as_matrix(&plain);
printf("\n");
- printf("Key: %s\n", format_aes_block192(&key).str);
- print_aes_block192_as_matrix(&key);
+ printf("Key: %s\n", aesni_format_block192(&key).str);
+ aesni_print_block192_as_matrix(&key);
printf("\n");
- printf("Initialization vector: %s\n", format_aes_block128(&iv).str);
- print_aes_block128_as_matrix(&iv);
+ printf("Initialization vector: %s\n", aesni_format_block128(&iv).str);
+ aesni_print_block128_as_matrix(&iv);
- aes192_expand_key_schedule(&key, &key_schedule);
+ aesni_expand_key_schedule192(&key, &key_schedule);
printf("\n");
printf("Key schedule:\n");
for (int i = 0; i < 13; ++i)
- printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
+ printf("\t[%d]: %s\n", i, aesni_format_block128(&key_schedule.keys[i]).str);
- cipher = aes192ctr_encrypt_block(plain, &key_schedule, iv, 0);
+ cipher = aesni_encrypt_block_ctr192(plain, &key_schedule, iv, 0);
printf("\n");
- printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_as_matrix(&cipher);
+ printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
+ aesni_print_block128_as_matrix(&cipher);
- decrypted = aes192ctr_decrypt_block(cipher, &key_schedule, iv, 0);
+ decrypted = aesni_decrypt_block_ctr192(cipher, &key_schedule, iv, 0);
printf("\n");
- printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_as_matrix(&decrypted);
+ printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
+ aesni_print_block128_as_matrix(&decrypted);
return 0;
}
diff --git a/examples/aes192ecb.c b/examples/aes192ecb.c
index f7a05af..775ca7d 100644
--- a/examples/aes192ecb.c
+++ b/examples/aes192ecb.c
@@ -12,43 +12,43 @@
int main()
{
- AesBlock128 plain, cipher, decrypted;
- AesBlock192 key;
- Aes192KeySchedule key_schedule, inverted_schedule;
+ AesNI_Block128 plain, cipher, decrypted;
+ AesNI_Block192 key;
+ AesNI_KeySchedule192 key_schedule, inverted_schedule;
- plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
- key = make_aes_block192(0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
+ plain = aesni_make_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
+ key = aesni_make_block192(0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
- printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_as_matrix(&plain);
+ printf("Plain: %s\n", aesni_format_block128(&plain).str);
+ aesni_print_block128_as_matrix(&plain);
printf("\n");
- printf("Key: %s\n", format_aes_block192(&key).str);
- print_aes_block192_as_matrix(&key);
+ printf("Key: %s\n", aesni_format_block192(&key).str);
+ aesni_print_block192_as_matrix(&key);
- aes192_expand_key_schedule(&key, &key_schedule);
+ aesni_expand_key_schedule192(&key, &key_schedule);
printf("\n");
printf("Key schedule:\n");
for (int i = 0; i < 13; ++i)
- printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
+ printf("\t[%d]: %s\n", i, aesni_format_block128(&key_schedule.keys[i]).str);
- cipher = aes192ecb_encrypt_block(plain, &key_schedule);
+ cipher = aesni_encrypt_block_ecb192(plain, &key_schedule);
printf("\n");
- printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_as_matrix(&cipher);
+ printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
+ aesni_print_block128_as_matrix(&cipher);
- aes192_invert_key_schedule(&key_schedule, &inverted_schedule);
+ aesni_invert_key_schedule192(&key_schedule, &inverted_schedule);
printf("\n");
printf("Inverted key schedule:\n");
for (int i = 0; i < 13; ++i)
- printf("\t[%d]: %s\n", i, format_aes_block128(&inverted_schedule.keys[i]).str);
+ printf("\t[%d]: %s\n", i, aesni_format_block128(&inverted_schedule.keys[i]).str);
- decrypted = aes192ecb_decrypt_block(cipher, &inverted_schedule);
+ decrypted = aesni_decrypt_block_ecb192(cipher, &inverted_schedule);
printf("\n");
- printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_as_matrix(&decrypted);
+ printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
+ aesni_print_block128_as_matrix(&decrypted);
return 0;
}
diff --git a/examples/aes192ofb.c b/examples/aes192ofb.c
index 3c4f025..33e9429 100644
--- a/examples/aes192ofb.c
+++ b/examples/aes192ofb.c
@@ -12,49 +12,49 @@
int main()
{
- AesBlock128 plain, cipher, decrypted, iv, next_iv;
- AesBlock192 key;
- Aes192KeySchedule key_schedule;
+ AesNI_Block128 plain, cipher, decrypted, iv, next_iv;
+ AesNI_Block192 key;
+ AesNI_KeySchedule192 key_schedule;
- plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
- key = make_aes_block192(0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
- iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
+ plain = aesni_make_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
+ key = aesni_make_block192(0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
+ iv = aesni_make_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
- printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_as_matrix(&plain);
+ printf("Plain: %s\n", aesni_format_block128(&plain).str);
+ aesni_print_block128_as_matrix(&plain);
printf("\n");
- printf("Key: %s\n", format_aes_block192(&key).str);
- print_aes_block192_as_matrix(&key);
+ printf("Key: %s\n", aesni_format_block192(&key).str);
+ aesni_print_block192_as_matrix(&key);
printf("\n");
- printf("Initialization vector: %s\n", format_aes_block128(&iv).str);
- print_aes_block128_as_matrix(&iv);
+ printf("Initialization vector: %s\n", aesni_format_block128(&iv).str);
+ aesni_print_block128_as_matrix(&iv);
- aes192_expand_key_schedule(&key, &key_schedule);
+ aesni_expand_key_schedule192(&key, &key_schedule);
printf("\n");
printf("Key schedule:\n");
for (int i = 0; i < 13; ++i)
- printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
+ printf("\t[%d]: %s\n", i, aesni_format_block128(&key_schedule.keys[i]).str);
- cipher = aes192ofb_encrypt_block(plain, &key_schedule, iv, &next_iv);
+ cipher = aesni_encrypt_block_ofb192(plain, &key_schedule, iv, &next_iv);
printf("\n");
- printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_as_matrix(&cipher);
+ printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
+ aesni_print_block128_as_matrix(&cipher);
printf("\n");
- printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_as_matrix(&next_iv);
+ printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
+ aesni_print_block128_as_matrix(&next_iv);
- decrypted = aes192ofb_decrypt_block(cipher, &key_schedule, iv, &next_iv);
+ decrypted = aesni_decrypt_block_ofb192(cipher, &key_schedule, iv, &next_iv);
printf("\n");
- printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_as_matrix(&decrypted);
+ printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
+ aesni_print_block128_as_matrix(&decrypted);
printf("\n");
- printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_as_matrix(&next_iv);
+ printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
+ aesni_print_block128_as_matrix(&next_iv);
return 0;
}
diff --git a/examples/aes256cbc.c b/examples/aes256cbc.c
index 0a148e1..3af1015 100644
--- a/examples/aes256cbc.c
+++ b/examples/aes256cbc.c
@@ -12,56 +12,56 @@
int main()
{
- AesBlock128 plain, cipher, decrypted, iv, next_iv;
- AesBlock256 key;
- Aes256KeySchedule key_schedule, inverted_schedule;
+ AesNI_Block128 plain, cipher, decrypted, iv, next_iv;
+ AesNI_Block256 key;
+ AesNI_KeySchedule256 key_schedule, inverted_schedule;
- plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
- key = make_aes_block256(0x1f1e1d1c, 0x1b1a1918, 0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
- iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
+ plain = aesni_make_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
+ key = aesni_make_block256(0x1f1e1d1c, 0x1b1a1918, 0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
+ iv = aesni_make_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
- printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_as_matrix(&plain);
+ printf("Plain: %s\n", aesni_format_block128(&plain).str);
+ aesni_print_block128_as_matrix(&plain);
printf("\n");
- printf("Key: %s\n", format_aes_block256(&key).str);
- print_aes_block256_as_matrix(&key);
+ printf("Key: %s\n", aesni_format_block256(&key).str);
+ aesni_print_block256_as_matrix(&key);
printf("\n");
- printf("Initialization vector: %s\n", format_aes_block128(&iv).str);
- print_aes_block128_as_matrix(&iv);
+ printf("Initialization vector: %s\n", aesni_format_block128(&iv).str);
+ aesni_print_block128_as_matrix(&iv);
- aes256_expand_key_schedule(&key, &key_schedule);
+ aesni_expand_key_schedule256(&key, &key_schedule);
printf("\n");
printf("Key schedule:\n");
for (int i = 0; i < 15; ++i)
- printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
+ printf("\t[%d]: %s\n", i, aesni_format_block128(&key_schedule.keys[i]).str);
- cipher = aes256cbc_encrypt_block(plain, &key_schedule, iv, &next_iv);
+ cipher = aesni_encrypt_block_cbc256(plain, &key_schedule, iv, &next_iv);
printf("\n");
- printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_as_matrix(&cipher);
+ printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
+ aesni_print_block128_as_matrix(&cipher);
printf("\n");
- printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_as_matrix(&next_iv);
+ printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
+ aesni_print_block128_as_matrix(&next_iv);
- aes256_invert_key_schedule(&key_schedule, &inverted_schedule);
+ aesni_invert_key_schedule256(&key_schedule, &inverted_schedule);
printf("\n");
printf("Inverted key schedule:\n");
for (int i = 0; i < 15; ++i)
- printf("\t[%d]: %s\n", i, format_aes_block128(&inverted_schedule.keys[i]).str);
+ printf("\t[%d]: %s\n", i, aesni_format_block128(&inverted_schedule.keys[i]).str);
- decrypted = aes256cbc_decrypt_block(cipher, &inverted_schedule, iv, &next_iv);
+ decrypted = aesni_decrypt_block_cbc256(cipher, &inverted_schedule, iv, &next_iv);
printf("\n");
- printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_as_matrix(&decrypted);
+ printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
+ aesni_print_block128_as_matrix(&decrypted);
printf("\n");
- printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_as_matrix(&next_iv);
+ printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
+ aesni_print_block128_as_matrix(&next_iv);
return 0;
}
diff --git a/examples/aes256cfb.c b/examples/aes256cfb.c
index 44d5f30..6ee1134 100644
--- a/examples/aes256cfb.c
+++ b/examples/aes256cfb.c
@@ -12,49 +12,49 @@
int main()
{
- AesBlock128 plain, cipher, decrypted, iv, next_iv;
- AesBlock256 key;
- Aes256KeySchedule key_schedule;
+ AesNI_Block128 plain, cipher, decrypted, iv, next_iv;
+ AesNI_Block256 key;
+ AesNI_KeySchedule256 key_schedule;
- plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
- key = make_aes_block256(0x1f1e1d1c, 0x1b1a1918, 0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
- iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
+ plain = aesni_make_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
+ key = aesni_make_block256(0x1f1e1d1c, 0x1b1a1918, 0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
+ iv = aesni_make_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
- printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_as_matrix(&plain);
+ printf("Plain: %s\n", aesni_format_block128(&plain).str);
+ aesni_print_block128_as_matrix(&plain);
printf("\n");
- printf("Key: %s\n", format_aes_block256(&key).str);
- print_aes_block256_as_matrix(&key);
+ printf("Key: %s\n", aesni_format_block256(&key).str);
+ aesni_print_block256_as_matrix(&key);
printf("\n");
- printf("Initialization vector: %s\n", format_aes_block128(&iv).str);
- print_aes_block128_as_matrix(&iv);
+ printf("Initialization vector: %s\n", aesni_format_block128(&iv).str);
+ aesni_print_block128_as_matrix(&iv);
- aes256_expand_key_schedule(&key, &key_schedule);
+ aesni_expand_key_schedule256(&key, &key_schedule);
printf("\n");
printf("Key schedule:\n");
for (int i = 0; i < 15; ++i)
- printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
+ printf("\t[%d]: %s\n", i, aesni_format_block128(&key_schedule.keys[i]).str);
- cipher = aes256cfb_encrypt_block(plain, &key_schedule, iv, &next_iv);
+ cipher = aesni_encrypt_block_cfb256(plain, &key_schedule, iv, &next_iv);
printf("\n");
- printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_as_matrix(&cipher);
+ printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
+ aesni_print_block128_as_matrix(&cipher);
printf("\n");
- printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_as_matrix(&next_iv);
+ printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
+ aesni_print_block128_as_matrix(&next_iv);
- decrypted = aes256cfb_decrypt_block(cipher, &key_schedule, iv, &next_iv);
+ decrypted = aesni_decrypt_block_cfb256(cipher, &key_schedule, iv, &next_iv);
printf("\n");
- printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_as_matrix(&decrypted);
+ printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
+ aesni_print_block128_as_matrix(&decrypted);
printf("\n");
- printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_as_matrix(&next_iv);
+ printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
+ aesni_print_block128_as_matrix(&next_iv);
return 0;
}
diff --git a/examples/aes256ctr.c b/examples/aes256ctr.c
index 0a47004..05c5090 100644
--- a/examples/aes256ctr.c
+++ b/examples/aes256ctr.c
@@ -12,41 +12,41 @@
int main()
{
- AesBlock128 plain, cipher, decrypted, iv;
- AesBlock256 key;
- Aes256KeySchedule key_schedule;
+ AesNI_Block128 plain, cipher, decrypted, iv;
+ AesNI_Block256 key;
+ AesNI_KeySchedule256 key_schedule;
- plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
- key = make_aes_block256(0x1f1e1d1c, 0x1b1a1918, 0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
- iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
+ plain = aesni_make_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
+ key = aesni_make_block256(0x1f1e1d1c, 0x1b1a1918, 0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
+ iv = aesni_make_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
- printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_as_matrix(&plain);
+ printf("Plain: %s\n", aesni_format_block128(&plain).str);
+ aesni_print_block128_as_matrix(&plain);
printf("\n");
- printf("Key: %s\n", format_aes_block256(&key).str);
- print_aes_block256_as_matrix(&key);
+ printf("Key: %s\n", aesni_format_block256(&key).str);
+ aesni_print_block256_as_matrix(&key);
printf("\n");
- printf("Initialization vector: %s\n", format_aes_block128(&iv).str);
- print_aes_block128_as_matrix(&iv);
+ printf("Initialization vector: %s\n", aesni_format_block128(&iv).str);
+ aesni_print_block128_as_matrix(&iv);
- aes256_expand_key_schedule(&key, &key_schedule);
+ aesni_expand_key_schedule256(&key, &key_schedule);
printf("\n");
printf("Key schedule:\n");
for (int i = 0; i < 15; ++i)
- printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
+ printf("\t[%d]: %s\n", i, aesni_format_block128(&key_schedule.keys[i]).str);
- cipher = aes256ctr_encrypt_block(plain, &key_schedule, iv, 0);
+ cipher = aesni_encrypt_block_ctr256(plain, &key_schedule, iv, 0);
printf("\n");
- printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_as_matrix(&cipher);
+ printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
+ aesni_print_block128_as_matrix(&cipher);
- decrypted = aes256ctr_decrypt_block(cipher, &key_schedule, iv, 0);
+ decrypted = aesni_decrypt_block_ctr256(cipher, &key_schedule, iv, 0);
printf("\n");
- printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_as_matrix(&decrypted);
+ printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
+ aesni_print_block128_as_matrix(&decrypted);
return 0;
}
diff --git a/examples/aes256ecb.c b/examples/aes256ecb.c
index f96a368..ead4c15 100644
--- a/examples/aes256ecb.c
+++ b/examples/aes256ecb.c
@@ -12,43 +12,43 @@
int main()
{
- AesBlock128 plain, cipher, decrypted;
- AesBlock256 key;
- Aes256KeySchedule key_schedule, inverted_schedule;
+ AesNI_Block128 plain, cipher, decrypted;
+ AesNI_Block256 key;
+ AesNI_KeySchedule256 key_schedule, inverted_schedule;
- plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
- key = make_aes_block256(0x1f1e1d1c, 0x1b1a1918, 0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
+ plain = aesni_make_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
+ key = aesni_make_block256(0x1f1e1d1c, 0x1b1a1918, 0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
- printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_as_matrix(&plain);
+ printf("Plain: %s\n", aesni_format_block128(&plain).str);
+ aesni_print_block128_as_matrix(&plain);
printf("\n");
- printf("Key: %s\n", format_aes_block256(&key).str);
- print_aes_block256_as_matrix(&key);
+ printf("Key: %s\n", aesni_format_block256(&key).str);
+ aesni_print_block256_as_matrix(&key);
- aes256_expand_key_schedule(&key, &key_schedule);
+ aesni_expand_key_schedule256(&key, &key_schedule);
printf("\n");
printf("Key schedule:\n");
for (int i = 0; i < 15; ++i)
- printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
+ printf("\t[%d]: %s\n", i, aesni_format_block128(&key_schedule.keys[i]).str);
- cipher = aes256ecb_encrypt_block(plain, &key_schedule);
+ cipher = aesni_encrypt_block_ecb256(plain, &key_schedule);
printf("\n");
- printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_as_matrix(&cipher);
+ printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
+ aesni_print_block128_as_matrix(&cipher);
- aes256_invert_key_schedule(&key_schedule, &inverted_schedule);
+ aesni_invert_key_schedule256(&key_schedule, &inverted_schedule);
printf("\n");
printf("Inverted key schedule:\n");
for (int i = 0; i < 15; ++i)
- printf("\t[%d]: %s\n", i, format_aes_block128(&inverted_schedule.keys[i]).str);
+ printf("\t[%d]: %s\n", i, aesni_format_block128(&inverted_schedule.keys[i]).str);
- decrypted = aes256ecb_decrypt_block(cipher, &inverted_schedule);
+ decrypted = aesni_decrypt_block_ecb256(cipher, &inverted_schedule);
printf("\n");
- printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_as_matrix(&decrypted);
+ printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
+ aesni_print_block128_as_matrix(&decrypted);
return 0;
}
diff --git a/examples/aes256ofb.c b/examples/aes256ofb.c
index 1104438..098b321 100644
--- a/examples/aes256ofb.c
+++ b/examples/aes256ofb.c
@@ -12,49 +12,49 @@
int main()
{
- AesBlock128 plain, cipher, decrypted, iv, next_iv;
- AesBlock256 key;
- Aes256KeySchedule key_schedule;
+ AesNI_Block128 plain, cipher, decrypted, iv, next_iv;
+ AesNI_Block256 key;
+ AesNI_KeySchedule256 key_schedule;
- plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
- key = make_aes_block256(0x1f1e1d1c, 0x1b1a1918, 0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
- iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
+ plain = aesni_make_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
+ key = aesni_make_block256(0x1f1e1d1c, 0x1b1a1918, 0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
+ iv = aesni_make_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
- printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_as_matrix(&plain);
+ printf("Plain: %s\n", aesni_format_block128(&plain).str);
+ aesni_print_block128_as_matrix(&plain);
printf("\n");
- printf("Key: %s\n", format_aes_block256(&key).str);
- print_aes_block256_as_matrix(&key);
+ printf("Key: %s\n", aesni_format_block256(&key).str);
+ aesni_print_block256_as_matrix(&key);
printf("\n");
- printf("Initialization vector: %s\n", format_aes_block128(&iv).str);
- print_aes_block128_as_matrix(&iv);
+ printf("Initialization vector: %s\n", aesni_format_block128(&iv).str);
+ aesni_print_block128_as_matrix(&iv);
- aes256_expand_key_schedule(&key, &key_schedule);
+ aesni_expand_key_schedule256(&key, &key_schedule);
printf("\n");
printf("Key schedule:\n");
for (int i = 0; i < 15; ++i)
- printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str);
+ printf("\t[%d]: %s\n", i, aesni_format_block128(&key_schedule.keys[i]).str);
- cipher = aes256ofb_encrypt_block(plain, &key_schedule, iv, &next_iv);
+ cipher = aesni_encrypt_block_ofb256(plain, &key_schedule, iv, &next_iv);
printf("\n");
- printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_as_matrix(&cipher);
+ printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
+ aesni_print_block128_as_matrix(&cipher);
printf("\n");
- printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_as_matrix(&next_iv);
+ printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
+ aesni_print_block128_as_matrix(&next_iv);
- decrypted = aes256ofb_decrypt_block(cipher, &key_schedule, iv, &next_iv);
+ decrypted = aesni_decrypt_block_ofb256(cipher, &key_schedule, iv, &next_iv);
printf("\n");
- printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_as_matrix(&decrypted);
+ printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
+ aesni_print_block128_as_matrix(&decrypted);
printf("\n");
- printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_as_matrix(&next_iv);
+ printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
+ aesni_print_block128_as_matrix(&next_iv);
return 0;
}