aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/aes128cbc.c76
-rw-r--r--examples/aes128cfb.c70
-rw-r--r--examples/aes128ctr.c52
-rw-r--r--examples/aes128ecb.c49
-rw-r--r--examples/aes128ofb.c70
-rw-r--r--examples/aes192cbc.c76
-rw-r--r--examples/aes192cfb.c70
-rw-r--r--examples/aes192ctr.c52
-rw-r--r--examples/aes192ecb.c49
-rw-r--r--examples/aes192ofb.c70
-rw-r--r--examples/aes256cbc.c76
-rw-r--r--examples/aes256cfb.c70
-rw-r--r--examples/aes256ctr.c52
-rw-r--r--examples/aes256ecb.c49
-rw-r--r--examples/aes256ofb.c70
15 files changed, 750 insertions, 201 deletions
diff --git a/examples/aes128cbc.c b/examples/aes128cbc.c
index b2eb14a..5d828a3 100644
--- a/examples/aes128cbc.c
+++ b/examples/aes128cbc.c
@@ -19,48 +19,92 @@ int main()
key = aesni_make_block128(0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
iv = aesni_make_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
- printf("Plain: %s\n", aesni_format_block128(&plain).str);
- aesni_print_block128_as_matrix(&plain);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &plain, NULL);
+ printf("Plain: %s\n", str.str);
+ aesni_print_block128_as_matrix(&plain, NULL);
+ }
printf("\n");
- printf("Key: %s\n", aesni_format_block128(&key).str);
- aesni_print_block128_as_matrix(&key);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &key, NULL);
+ printf("Key: %s\n", str.str);
+ aesni_print_block128_as_matrix(&key, NULL);
+ }
printf("\n");
- printf("Initialization vector: %s\n", aesni_format_block128(&iv).str);
- aesni_print_block128_as_matrix(&iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &iv, NULL);
+ printf("Initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&iv, NULL);
+ }
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, aesni_format_block128(&key_schedule.keys[i]).str);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &key_schedule.keys[i], NULL);
+ printf("\t[%d]: %s\n", i, str.str);
+ }
cipher = aesni_encrypt_block_cbc128(plain, &key_schedule, iv, &next_iv);
+
printf("\n");
- printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
- aesni_print_block128_as_matrix(&cipher);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &cipher, NULL);
+ printf("Cipher: %s\n", str.str);
+ aesni_print_block128_as_matrix(&cipher, NULL);
+ }
printf("\n");
- printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
- aesni_print_block128_as_matrix(&next_iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &next_iv, NULL);
+ printf("Next initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&next_iv, NULL);
+ }
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, aesni_format_block128(&inverted_schedule.keys[i]).str);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &inverted_schedule.keys[i], NULL);
+ printf("\t[%d]: %s\n", i, str.str);
+ }
decrypted = aesni_decrypt_block_cbc128(cipher, &inverted_schedule, iv, &next_iv);
+
printf("\n");
- printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
- aesni_print_block128_as_matrix(&decrypted);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &decrypted, NULL);
+ printf("Decrypted: %s\n", str.str);
+ aesni_print_block128_as_matrix(&decrypted, NULL);
+ }
printf("\n");
- printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
- aesni_print_block128_as_matrix(&next_iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &next_iv, NULL);
+ printf("Next initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&next_iv, NULL);
+ }
return 0;
}
diff --git a/examples/aes128cfb.c b/examples/aes128cfb.c
index 31ad748..06c77b3 100644
--- a/examples/aes128cfb.c
+++ b/examples/aes128cfb.c
@@ -19,41 +19,81 @@ int main()
key = aesni_make_block128(0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
iv = aesni_make_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
- printf("Plain: %s\n", aesni_format_block128(&plain).str);
- aesni_print_block128_as_matrix(&plain);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &plain, NULL);
+ printf("Plain: %s\n", str.str);
+ aesni_print_block128_as_matrix(&plain, NULL);
+ }
printf("\n");
- printf("Key: %s\n", aesni_format_block128(&key).str);
- aesni_print_block128_as_matrix(&key);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &key, NULL);
+ printf("Key: %s\n", str.str);
+ aesni_print_block128_as_matrix(&key, NULL);
+ }
printf("\n");
- printf("Initialization vector: %s\n", aesni_format_block128(&iv).str);
- aesni_print_block128_as_matrix(&iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &iv, NULL);
+ printf("Initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&iv, NULL);
+ }
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, aesni_format_block128(&key_schedule.keys[i]).str);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &key_schedule.keys[i], NULL);
+ printf("\t[%d]: %s\n", i, str.str);
+ }
cipher = aesni_encrypt_block_cfb128(plain, &key_schedule, iv, &next_iv);
+
printf("\n");
- printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
- aesni_print_block128_as_matrix(&cipher);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &cipher, NULL);
+ printf("Cipher: %s\n", str.str);
+ aesni_print_block128_as_matrix(&cipher, NULL);
+ }
printf("\n");
- printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
- aesni_print_block128_as_matrix(&next_iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &next_iv, NULL);
+ printf("Next initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&next_iv, NULL);
+ }
decrypted = aesni_decrypt_block_cfb128(cipher, &key_schedule, iv, &next_iv);
+
printf("\n");
- printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
- aesni_print_block128_as_matrix(&decrypted);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &decrypted, NULL);
+ printf("Decrypted: %s\n", str.str);
+ aesni_print_block128_as_matrix(&decrypted, NULL);
+ }
printf("\n");
- printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
- aesni_print_block128_as_matrix(&next_iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &next_iv, NULL);
+ printf("Next initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&next_iv, NULL);
+ }
return 0;
}
diff --git a/examples/aes128ctr.c b/examples/aes128ctr.c
index 1efe4e2..a9bcda6 100644
--- a/examples/aes128ctr.c
+++ b/examples/aes128ctr.c
@@ -19,33 +19,63 @@ int main()
key = aesni_make_block128(0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
iv = aesni_make_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
- printf("Plain: %s\n", aesni_format_block128(&plain).str);
- aesni_print_block128_as_matrix(&plain);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &plain, NULL);
+ printf("Plain: %s\n", str.str);
+ aesni_print_block128_as_matrix(&plain, NULL);
+ }
printf("\n");
- printf("Key: %s\n", aesni_format_block128(&key).str);
- aesni_print_block128_as_matrix(&key);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &key, NULL);
+ printf("Key: %s\n", str.str);
+ aesni_print_block128_as_matrix(&key, NULL);
+ }
printf("\n");
- printf("Initialization vector: %s\n", aesni_format_block128(&iv).str);
- aesni_print_block128_as_matrix(&iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &iv, NULL);
+ printf("Initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&iv, NULL);
+ }
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, aesni_format_block128(&key_schedule.keys[i]).str);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &key_schedule.keys[i], NULL);
+ printf("\t[%d]: %s\n", i, str.str);
+ }
cipher = aesni_encrypt_block_ctr128(plain, &key_schedule, iv, 0);
+
printf("\n");
- printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
- aesni_print_block128_as_matrix(&cipher);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &cipher, NULL);
+ printf("Cipher: %s\n", str.str);
+ aesni_print_block128_as_matrix(&cipher, NULL);
+ }
decrypted = aesni_decrypt_block_ctr128(cipher, &key_schedule, iv, 0);
+
printf("\n");
- printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
- aesni_print_block128_as_matrix(&decrypted);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &decrypted, NULL);
+ printf("Decrypted: %s\n", str.str);
+ aesni_print_block128_as_matrix(&decrypted, NULL);
+ }
return 0;
}
diff --git a/examples/aes128ecb.c b/examples/aes128ecb.c
index 4f999d4..6c98f32 100644
--- a/examples/aes128ecb.c
+++ b/examples/aes128ecb.c
@@ -18,36 +18,65 @@ int main()
plain = aesni_make_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
key = aesni_make_block128(0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
- printf("Plain: %s\n", aesni_format_block128(&plain).str);
- aesni_print_block128_as_matrix(&plain);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &plain, NULL);
+ printf("Plain: %s\n", str.str);
+ aesni_print_block128_as_matrix(&plain, NULL);
+ }
printf("\n");
- printf("Key: %s\n", aesni_format_block128(&key).str);
- aesni_print_block128_as_matrix(&key);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &key, NULL);
+ printf("Key: %s\n", str.str);
+ aesni_print_block128_as_matrix(&key, NULL);
+ }
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, aesni_format_block128(&key_schedule.keys[i]).str);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &key_schedule.keys[i], NULL);
+ printf("\t[%d]: %s\n", i, str.str);
+ }
cipher = aesni_encrypt_block_ecb128(plain, &key_schedule);
+
printf("\n");
- printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
- aesni_print_block128_as_matrix(&cipher);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &cipher, NULL);
+ printf("Cipher: %s\n", str.str);
+ aesni_print_block128_as_matrix(&cipher, NULL);
+ }
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, aesni_format_block128(&inverted_schedule.keys[i]).str);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &inverted_schedule.keys[i], NULL);
+ printf("\t[%d]: %s\n", i, str.str);
+ }
decrypted = aesni_decrypt_block_ecb128(cipher, &inverted_schedule);
+
printf("\n");
- printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
- aesni_print_block128_as_matrix(&decrypted);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &decrypted, NULL);
+ printf("Decrypted: %s\n", str.str);
+ aesni_print_block128_as_matrix(&decrypted, NULL);
+ }
return 0;
}
diff --git a/examples/aes128ofb.c b/examples/aes128ofb.c
index 49a97ed..541ec41 100644
--- a/examples/aes128ofb.c
+++ b/examples/aes128ofb.c
@@ -19,41 +19,81 @@ int main()
key = aesni_make_block128(0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
iv = aesni_make_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
- printf("Plain: %s\n", aesni_format_block128(&plain).str);
- aesni_print_block128_as_matrix(&plain);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &plain, NULL);
+ printf("Plain: %s\n", str.str);
+ aesni_print_block128_as_matrix(&plain, NULL);
+ }
printf("\n");
- printf("Key: %s\n", aesni_format_block128(&key).str);
- aesni_print_block128_as_matrix(&key);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &key, NULL);
+ printf("Key: %s\n", str.str);
+ aesni_print_block128_as_matrix(&key, NULL);
+ }
printf("\n");
- printf("Initialization vector: %s\n", aesni_format_block128(&iv).str);
- aesni_print_block128_as_matrix(&iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &iv, NULL);
+ printf("Initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&iv, NULL);
+ }
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, aesni_format_block128(&key_schedule.keys[i]).str);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &key_schedule.keys[i], NULL);
+ printf("\t[%d]: %s\n", i, str.str);
+ }
cipher = aesni_encrypt_block_ofb128(plain, &key_schedule, iv, &next_iv);
+
printf("\n");
- printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
- aesni_print_block128_as_matrix(&cipher);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &cipher, NULL);
+ printf("Cipher: %s\n", str.str);
+ aesni_print_block128_as_matrix(&cipher, NULL);
+ }
printf("\n");
- printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
- aesni_print_block128_as_matrix(&next_iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &next_iv, NULL);
+ printf("Next initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&next_iv, NULL);
+ }
decrypted = aesni_decrypt_block_ofb128(cipher, &key_schedule, iv, &next_iv);
+
printf("\n");
- printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
- aesni_print_block128_as_matrix(&decrypted);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &decrypted, NULL);
+ printf("Decrypted: %s\n", str.str);
+ aesni_print_block128_as_matrix(&decrypted, NULL);
+ }
printf("\n");
- printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
- aesni_print_block128_as_matrix(&next_iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &next_iv, NULL);
+ printf("Next initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&next_iv, NULL);
+ }
return 0;
}
diff --git a/examples/aes192cbc.c b/examples/aes192cbc.c
index 67adf95..c17ec0f 100644
--- a/examples/aes192cbc.c
+++ b/examples/aes192cbc.c
@@ -20,48 +20,92 @@ int main()
key = aesni_make_block192(0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
iv = aesni_make_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
- printf("Plain: %s\n", aesni_format_block128(&plain).str);
- aesni_print_block128_as_matrix(&plain);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &plain, NULL);
+ printf("Plain: %s\n", str.str);
+ aesni_print_block128_as_matrix(&plain, NULL);
+ }
printf("\n");
- printf("Key: %s\n", aesni_format_block192(&key).str);
- aesni_print_block192_as_matrix(&key);
+
+ {
+ AesNI_BlockString192 str;
+ aesni_format_block192(&str, &key, NULL);
+ printf("Key: %s\n", str.str);
+ aesni_print_block192_as_matrix(&key, NULL);
+ }
printf("\n");
- printf("Initialization vector: %s\n", aesni_format_block128(&iv).str);
- aesni_print_block128_as_matrix(&iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &iv, NULL);
+ printf("Initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&iv, NULL);
+ }
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, aesni_format_block128(&key_schedule.keys[i]).str);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &key_schedule.keys[i], NULL);
+ printf("\t[%d]: %s\n", i, str.str);
+ }
cipher = aesni_encrypt_block_cbc192(plain, &key_schedule, iv, &next_iv);
+
printf("\n");
- printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
- aesni_print_block128_as_matrix(&cipher);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &cipher, NULL);
+ printf("Cipher: %s\n", str.str);
+ aesni_print_block128_as_matrix(&cipher, NULL);
+ }
printf("\n");
- printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
- aesni_print_block128_as_matrix(&next_iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &next_iv, NULL);
+ printf("Next initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&next_iv, NULL);
+ }
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, aesni_format_block128(&inverted_schedule.keys[i]).str);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &inverted_schedule.keys[i], NULL);
+ printf("\t[%d]: %s\n", i, str.str);
+ }
decrypted = aesni_decrypt_block_cbc192(cipher, &inverted_schedule, iv, &next_iv);
+
printf("\n");
- printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
- aesni_print_block128_as_matrix(&decrypted);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &decrypted, NULL);
+ printf("Decrypted: %s\n", str.str);
+ aesni_print_block128_as_matrix(&decrypted, NULL);
+ }
printf("\n");
- printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
- aesni_print_block128_as_matrix(&next_iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &next_iv, NULL);
+ printf("Next initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&next_iv, NULL);
+ }
return 0;
}
diff --git a/examples/aes192cfb.c b/examples/aes192cfb.c
index d5bf554..17480e3 100644
--- a/examples/aes192cfb.c
+++ b/examples/aes192cfb.c
@@ -20,41 +20,81 @@ int main()
key = aesni_make_block192(0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
iv = aesni_make_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
- printf("Plain: %s\n", aesni_format_block128(&plain).str);
- aesni_print_block128_as_matrix(&plain);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &plain, NULL);
+ printf("Plain: %s\n", str.str);
+ aesni_print_block128_as_matrix(&plain, NULL);
+ }
printf("\n");
- printf("Key: %s\n", aesni_format_block192(&key).str);
- aesni_print_block192_as_matrix(&key);
+
+ {
+ AesNI_BlockString192 str;
+ aesni_format_block192(&str, &key, NULL);
+ printf("Key: %s\n", str.str);
+ aesni_print_block192_as_matrix(&key, NULL);
+ }
printf("\n");
- printf("Initialization vector: %s\n", aesni_format_block128(&iv).str);
- aesni_print_block128_as_matrix(&iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &iv, NULL);
+ printf("Initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&iv, NULL);
+ }
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, aesni_format_block128(&key_schedule.keys[i]).str);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &key_schedule.keys[i], NULL);
+ printf("\t[%d]: %s\n", i, str.str);
+ }
cipher = aesni_encrypt_block_cfb192(plain, &key_schedule, iv, &next_iv);
+
printf("\n");
- printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
- aesni_print_block128_as_matrix(&cipher);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &cipher, NULL);
+ printf("Cipher: %s\n", str.str);
+ aesni_print_block128_as_matrix(&cipher, NULL);
+ }
printf("\n");
- printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
- aesni_print_block128_as_matrix(&next_iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &next_iv, NULL);
+ printf("Next initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&next_iv, NULL);
+ }
decrypted = aesni_decrypt_block_cfb192(cipher, &key_schedule, iv, &next_iv);
+
printf("\n");
- printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
- aesni_print_block128_as_matrix(&decrypted);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &decrypted, NULL);
+ printf("Decrypted: %s\n", str.str);
+ aesni_print_block128_as_matrix(&decrypted, NULL);
+ }
printf("\n");
- printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
- aesni_print_block128_as_matrix(&next_iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &next_iv, NULL);
+ printf("Next initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&next_iv, NULL);
+ }
return 0;
}
diff --git a/examples/aes192ctr.c b/examples/aes192ctr.c
index 3ce7c76..82b41cf 100644
--- a/examples/aes192ctr.c
+++ b/examples/aes192ctr.c
@@ -20,33 +20,63 @@ int main()
key = aesni_make_block192(0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
iv = aesni_make_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
- printf("Plain: %s\n", aesni_format_block128(&plain).str);
- aesni_print_block128_as_matrix(&plain);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &plain, NULL);
+ printf("Plain: %s\n", str.str);
+ aesni_print_block128_as_matrix(&plain, NULL);
+ }
printf("\n");
- printf("Key: %s\n", aesni_format_block192(&key).str);
- aesni_print_block192_as_matrix(&key);
+
+ {
+ AesNI_BlockString192 str;
+ aesni_format_block192(&str, &key, NULL);
+ printf("Key: %s\n", str.str);
+ aesni_print_block192_as_matrix(&key, NULL);
+ }
printf("\n");
- printf("Initialization vector: %s\n", aesni_format_block128(&iv).str);
- aesni_print_block128_as_matrix(&iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &iv, NULL);
+ printf("Initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&iv, NULL);
+ }
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, aesni_format_block128(&key_schedule.keys[i]).str);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &key_schedule.keys[i], NULL);
+ printf("\t[%d]: %s\n", i, str.str);
+ }
cipher = aesni_encrypt_block_ctr192(plain, &key_schedule, iv, 0);
+
printf("\n");
- printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
- aesni_print_block128_as_matrix(&cipher);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &cipher, NULL);
+ printf("Cipher: %s\n", str.str);
+ aesni_print_block128_as_matrix(&cipher, NULL);
+ }
decrypted = aesni_decrypt_block_ctr192(cipher, &key_schedule, iv, 0);
+
printf("\n");
- printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
- aesni_print_block128_as_matrix(&decrypted);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &decrypted, NULL);
+ printf("Decrypted: %s\n", str.str);
+ aesni_print_block128_as_matrix(&decrypted, NULL);
+ }
return 0;
}
diff --git a/examples/aes192ecb.c b/examples/aes192ecb.c
index 775ca7d..bdc048c 100644
--- a/examples/aes192ecb.c
+++ b/examples/aes192ecb.c
@@ -19,36 +19,65 @@ int main()
plain = aesni_make_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
key = aesni_make_block192(0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
- printf("Plain: %s\n", aesni_format_block128(&plain).str);
- aesni_print_block128_as_matrix(&plain);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &plain, NULL);
+ printf("Plain: %s\n", str.str);
+ aesni_print_block128_as_matrix(&plain, NULL);
+ }
printf("\n");
- printf("Key: %s\n", aesni_format_block192(&key).str);
- aesni_print_block192_as_matrix(&key);
+
+ {
+ AesNI_BlockString192 str;
+ aesni_format_block192(&str, &key, NULL);
+ printf("Key: %s\n", str.str);
+ aesni_print_block192_as_matrix(&key, NULL);
+ }
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, aesni_format_block128(&key_schedule.keys[i]).str);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &key_schedule.keys[i], NULL);
+ printf("\t[%d]: %s\n", i, str.str);
+ }
cipher = aesni_encrypt_block_ecb192(plain, &key_schedule);
+
printf("\n");
- printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
- aesni_print_block128_as_matrix(&cipher);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &cipher, NULL);
+ printf("Cipher: %s\n", str.str);
+ aesni_print_block128_as_matrix(&cipher, NULL);
+ }
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, aesni_format_block128(&inverted_schedule.keys[i]).str);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &inverted_schedule.keys[i], NULL);
+ printf("\t[%d]: %s\n", i, str.str);
+ }
decrypted = aesni_decrypt_block_ecb192(cipher, &inverted_schedule);
+
printf("\n");
- printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
- aesni_print_block128_as_matrix(&decrypted);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &decrypted, NULL);
+ printf("Decrypted: %s\n", str.str);
+ aesni_print_block128_as_matrix(&decrypted, NULL);
+ }
return 0;
}
diff --git a/examples/aes192ofb.c b/examples/aes192ofb.c
index 33e9429..de347ae 100644
--- a/examples/aes192ofb.c
+++ b/examples/aes192ofb.c
@@ -20,41 +20,81 @@ int main()
key = aesni_make_block192(0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
iv = aesni_make_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
- printf("Plain: %s\n", aesni_format_block128(&plain).str);
- aesni_print_block128_as_matrix(&plain);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &plain, NULL);
+ printf("Plain: %s\n", str.str);
+ aesni_print_block128_as_matrix(&plain, NULL);
+ }
printf("\n");
- printf("Key: %s\n", aesni_format_block192(&key).str);
- aesni_print_block192_as_matrix(&key);
+
+ {
+ AesNI_BlockString192 str;
+ aesni_format_block192(&str, &key, NULL);
+ printf("Key: %s\n", str.str);
+ aesni_print_block192_as_matrix(&key, NULL);
+ }
printf("\n");
- printf("Initialization vector: %s\n", aesni_format_block128(&iv).str);
- aesni_print_block128_as_matrix(&iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &iv, NULL);
+ printf("Initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&iv, NULL);
+ }
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, aesni_format_block128(&key_schedule.keys[i]).str);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &key_schedule.keys[i], NULL);
+ printf("\t[%d]: %s\n", i, str.str);
+ }
cipher = aesni_encrypt_block_ofb192(plain, &key_schedule, iv, &next_iv);
+
printf("\n");
- printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
- aesni_print_block128_as_matrix(&cipher);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &cipher, NULL);
+ printf("Cipher: %s\n", str.str);
+ aesni_print_block128_as_matrix(&cipher, NULL);
+ }
printf("\n");
- printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
- aesni_print_block128_as_matrix(&next_iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &next_iv, NULL);
+ printf("Next initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&next_iv, NULL);
+ }
decrypted = aesni_decrypt_block_ofb192(cipher, &key_schedule, iv, &next_iv);
+
printf("\n");
- printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
- aesni_print_block128_as_matrix(&decrypted);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &decrypted, NULL);
+ printf("Decrypted: %s\n", str.str);
+ aesni_print_block128_as_matrix(&decrypted, NULL);
+ }
printf("\n");
- printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
- aesni_print_block128_as_matrix(&next_iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &next_iv, NULL);
+ printf("Next initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&next_iv, NULL);
+ }
return 0;
}
diff --git a/examples/aes256cbc.c b/examples/aes256cbc.c
index 3af1015..f62fc84 100644
--- a/examples/aes256cbc.c
+++ b/examples/aes256cbc.c
@@ -20,48 +20,92 @@ int main()
key = aesni_make_block256(0x1f1e1d1c, 0x1b1a1918, 0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
iv = aesni_make_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
- printf("Plain: %s\n", aesni_format_block128(&plain).str);
- aesni_print_block128_as_matrix(&plain);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &plain, NULL);
+ printf("Plain: %s\n", str.str);
+ aesni_print_block128_as_matrix(&plain, NULL);
+ }
printf("\n");
- printf("Key: %s\n", aesni_format_block256(&key).str);
- aesni_print_block256_as_matrix(&key);
+
+ {
+ AesNI_BlockString256 str;
+ aesni_format_block256(&str, &key, NULL);
+ printf("Key: %s\n", str.str);
+ aesni_print_block256_as_matrix(&key, NULL);
+ }
printf("\n");
- printf("Initialization vector: %s\n", aesni_format_block128(&iv).str);
- aesni_print_block128_as_matrix(&iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &iv, NULL);
+ printf("Initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&iv, NULL);
+ }
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, aesni_format_block128(&key_schedule.keys[i]).str);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &key_schedule.keys[i], NULL);
+ printf("\t[%d]: %s\n", i, str.str);
+ }
cipher = aesni_encrypt_block_cbc256(plain, &key_schedule, iv, &next_iv);
+
printf("\n");
- printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
- aesni_print_block128_as_matrix(&cipher);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &cipher, NULL);
+ printf("Cipher: %s\n", str.str);
+ aesni_print_block128_as_matrix(&cipher, NULL);
+ }
printf("\n");
- printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
- aesni_print_block128_as_matrix(&next_iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &next_iv, NULL);
+ printf("Next initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&next_iv, NULL);
+ }
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, aesni_format_block128(&inverted_schedule.keys[i]).str);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &inverted_schedule.keys[i], NULL);
+ printf("\t[%d]: %s\n", i, str.str);
+ }
decrypted = aesni_decrypt_block_cbc256(cipher, &inverted_schedule, iv, &next_iv);
+
printf("\n");
- printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
- aesni_print_block128_as_matrix(&decrypted);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &decrypted, NULL);
+ printf("Decrypted: %s\n", str.str);
+ aesni_print_block128_as_matrix(&decrypted, NULL);
+ }
printf("\n");
- printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
- aesni_print_block128_as_matrix(&next_iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &next_iv, NULL);
+ printf("Next initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&next_iv, NULL);
+ }
return 0;
}
diff --git a/examples/aes256cfb.c b/examples/aes256cfb.c
index 6ee1134..950585d 100644
--- a/examples/aes256cfb.c
+++ b/examples/aes256cfb.c
@@ -20,41 +20,81 @@ int main()
key = aesni_make_block256(0x1f1e1d1c, 0x1b1a1918, 0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
iv = aesni_make_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
- printf("Plain: %s\n", aesni_format_block128(&plain).str);
- aesni_print_block128_as_matrix(&plain);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &plain, NULL);
+ printf("Plain: %s\n", str.str);
+ aesni_print_block128_as_matrix(&plain, NULL);
+ }
printf("\n");
- printf("Key: %s\n", aesni_format_block256(&key).str);
- aesni_print_block256_as_matrix(&key);
+
+ {
+ AesNI_BlockString256 str;
+ aesni_format_block256(&str, &key, NULL);
+ printf("Key: %s\n", str.str);
+ aesni_print_block256_as_matrix(&key, NULL);
+ }
printf("\n");
- printf("Initialization vector: %s\n", aesni_format_block128(&iv).str);
- aesni_print_block128_as_matrix(&iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &iv, NULL);
+ printf("Initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&iv, NULL);
+ }
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, aesni_format_block128(&key_schedule.keys[i]).str);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &key_schedule.keys[i], NULL);
+ printf("\t[%d]: %s\n", i, str.str);
+ }
cipher = aesni_encrypt_block_cfb256(plain, &key_schedule, iv, &next_iv);
+
printf("\n");
- printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
- aesni_print_block128_as_matrix(&cipher);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &cipher, NULL);
+ printf("Cipher: %s\n", str.str);
+ aesni_print_block128_as_matrix(&cipher, NULL);
+ }
printf("\n");
- printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
- aesni_print_block128_as_matrix(&next_iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &next_iv, NULL);
+ printf("Next initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&next_iv, NULL);
+ }
decrypted = aesni_decrypt_block_cfb256(cipher, &key_schedule, iv, &next_iv);
+
printf("\n");
- printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
- aesni_print_block128_as_matrix(&decrypted);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &decrypted, NULL);
+ printf("Decrypted: %s\n", str.str);
+ aesni_print_block128_as_matrix(&decrypted, NULL);
+ }
printf("\n");
- printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
- aesni_print_block128_as_matrix(&next_iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &next_iv, NULL);
+ printf("Next initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&next_iv, NULL);
+ }
return 0;
}
diff --git a/examples/aes256ctr.c b/examples/aes256ctr.c
index 05c5090..efb36e4 100644
--- a/examples/aes256ctr.c
+++ b/examples/aes256ctr.c
@@ -20,33 +20,63 @@ int main()
key = aesni_make_block256(0x1f1e1d1c, 0x1b1a1918, 0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
iv = aesni_make_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
- printf("Plain: %s\n", aesni_format_block128(&plain).str);
- aesni_print_block128_as_matrix(&plain);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &plain, NULL);
+ printf("Plain: %s\n", str.str);
+ aesni_print_block128_as_matrix(&plain, NULL);
+ }
printf("\n");
- printf("Key: %s\n", aesni_format_block256(&key).str);
- aesni_print_block256_as_matrix(&key);
+
+ {
+ AesNI_BlockString256 str;
+ aesni_format_block256(&str, &key, NULL);
+ printf("Key: %s\n", str.str);
+ aesni_print_block256_as_matrix(&key, NULL);
+ }
printf("\n");
- printf("Initialization vector: %s\n", aesni_format_block128(&iv).str);
- aesni_print_block128_as_matrix(&iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &iv, NULL);
+ printf("Initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&iv, NULL);
+ }
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, aesni_format_block128(&key_schedule.keys[i]).str);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &key_schedule.keys[i], NULL);
+ printf("\t[%d]: %s\n", i, str.str);
+ }
cipher = aesni_encrypt_block_ctr256(plain, &key_schedule, iv, 0);
+
printf("\n");
- printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
- aesni_print_block128_as_matrix(&cipher);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &cipher, NULL);
+ printf("Cipher: %s\n", str.str);
+ aesni_print_block128_as_matrix(&cipher, NULL);
+ }
decrypted = aesni_decrypt_block_ctr256(cipher, &key_schedule, iv, 0);
+
printf("\n");
- printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
- aesni_print_block128_as_matrix(&decrypted);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &decrypted, NULL);
+ printf("Decrypted: %s\n", str.str);
+ aesni_print_block128_as_matrix(&decrypted, NULL);
+ }
return 0;
}
diff --git a/examples/aes256ecb.c b/examples/aes256ecb.c
index ead4c15..ddb90ca 100644
--- a/examples/aes256ecb.c
+++ b/examples/aes256ecb.c
@@ -19,36 +19,65 @@ int main()
plain = aesni_make_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
key = aesni_make_block256(0x1f1e1d1c, 0x1b1a1918, 0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
- printf("Plain: %s\n", aesni_format_block128(&plain).str);
- aesni_print_block128_as_matrix(&plain);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &plain, NULL);
+ printf("Plain: %s\n", str.str);
+ aesni_print_block128_as_matrix(&plain, NULL);
+ }
printf("\n");
- printf("Key: %s\n", aesni_format_block256(&key).str);
- aesni_print_block256_as_matrix(&key);
+
+ {
+ AesNI_BlockString256 str;
+ aesni_format_block256(&str, &key, NULL);
+ printf("Key: %s\n", str.str);
+ aesni_print_block256_as_matrix(&key, NULL);
+ }
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, aesni_format_block128(&key_schedule.keys[i]).str);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &key_schedule.keys[i], NULL);
+ printf("\t[%d]: %s\n", i, str.str);
+ }
cipher = aesni_encrypt_block_ecb256(plain, &key_schedule);
+
printf("\n");
- printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
- aesni_print_block128_as_matrix(&cipher);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &cipher, NULL);
+ printf("Cipher: %s\n", str.str);
+ aesni_print_block128_as_matrix(&cipher, NULL);
+ }
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, aesni_format_block128(&inverted_schedule.keys[i]).str);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &inverted_schedule.keys[i], NULL);
+ printf("\t[%d]: %s\n", i, str.str);
+ }
decrypted = aesni_decrypt_block_ecb256(cipher, &inverted_schedule);
+
printf("\n");
- printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
- aesni_print_block128_as_matrix(&decrypted);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &decrypted, NULL);
+ printf("Decrypted: %s\n", str.str);
+ aesni_print_block128_as_matrix(&decrypted, NULL);
+ }
return 0;
}
diff --git a/examples/aes256ofb.c b/examples/aes256ofb.c
index 098b321..8a7bf32 100644
--- a/examples/aes256ofb.c
+++ b/examples/aes256ofb.c
@@ -20,41 +20,81 @@ int main()
key = aesni_make_block256(0x1f1e1d1c, 0x1b1a1918, 0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
iv = aesni_make_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
- printf("Plain: %s\n", aesni_format_block128(&plain).str);
- aesni_print_block128_as_matrix(&plain);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &plain, NULL);
+ printf("Plain: %s\n", str.str);
+ aesni_print_block128_as_matrix(&plain, NULL);
+ }
printf("\n");
- printf("Key: %s\n", aesni_format_block256(&key).str);
- aesni_print_block256_as_matrix(&key);
+
+ {
+ AesNI_BlockString256 str;
+ aesni_format_block256(&str, &key, NULL);
+ printf("Key: %s\n", str.str);
+ aesni_print_block256_as_matrix(&key, NULL);
+ }
printf("\n");
- printf("Initialization vector: %s\n", aesni_format_block128(&iv).str);
- aesni_print_block128_as_matrix(&iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &iv, NULL);
+ printf("Initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&iv, NULL);
+ }
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, aesni_format_block128(&key_schedule.keys[i]).str);
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &key_schedule.keys[i], NULL);
+ printf("\t[%d]: %s\n", i, str.str);
+ }
cipher = aesni_encrypt_block_ofb256(plain, &key_schedule, iv, &next_iv);
+
printf("\n");
- printf("Cipher: %s\n", aesni_format_block128(&cipher).str);
- aesni_print_block128_as_matrix(&cipher);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &cipher, NULL);
+ printf("Cipher: %s\n", str.str);
+ aesni_print_block128_as_matrix(&cipher, NULL);
+ }
printf("\n");
- printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
- aesni_print_block128_as_matrix(&next_iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &next_iv, NULL);
+ printf("Next initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&next_iv, NULL);
+ }
decrypted = aesni_decrypt_block_ofb256(cipher, &key_schedule, iv, &next_iv);
+
printf("\n");
- printf("Decrypted: %s\n", aesni_format_block128(&decrypted).str);
- aesni_print_block128_as_matrix(&decrypted);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &decrypted, NULL);
+ printf("Decrypted: %s\n", str.str);
+ aesni_print_block128_as_matrix(&decrypted, NULL);
+ }
printf("\n");
- printf("Next initialization vector: %s\n", aesni_format_block128(&next_iv).str);
- aesni_print_block128_as_matrix(&next_iv);
+
+ {
+ AesNI_BlockString128 str;
+ aesni_format_block128(&str, &next_iv, NULL);
+ printf("Next initialization vector: %s\n", str.str);
+ aesni_print_block128_as_matrix(&next_iv, NULL);
+ }
return 0;
}