aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2015-06-04 17:05:24 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2015-06-04 17:05:24 +0300
commita497b83f80508747151dacf660f7d5de48d0464f (patch)
treeb2ded10280830aa31b3be10e2b81fc1a42df65e0
parentrefactoring (diff)
downloadaes-tools-a497b83f80508747151dacf660f7d5de48d0464f.tar.gz
aes-tools-a497b83f80508747151dacf660f7d5de48d0464f.zip
explicitly separate BE vs. LE block I/O functions
Diffstat (limited to '')
-rw-r--r--examples/aes128cbc.c14
-rw-r--r--examples/aes128cfb.c14
-rw-r--r--examples/aes128ctr.c10
-rw-r--r--examples/aes128ecb.c8
-rw-r--r--examples/aes128ofb.c14
-rw-r--r--examples/aes192cbc.c14
-rw-r--r--examples/aes192cfb.c14
-rw-r--r--examples/aes192ctr.c10
-rw-r--r--examples/aes192ecb.c8
-rw-r--r--examples/aes192ofb.c14
-rw-r--r--examples/aes256cbc.c14
-rw-r--r--examples/aes256cfb.c14
-rw-r--r--examples/aes256ctr.c10
-rw-r--r--examples/aes256ecb.c8
-rw-r--r--examples/aes256ofb.c14
-rw-r--r--include/aesni/data.h50
-rw-r--r--src/common.c169
17 files changed, 247 insertions, 152 deletions
diff --git a/examples/aes128cbc.c b/examples/aes128cbc.c
index ab12df8..05b91b0 100644
--- a/examples/aes128cbc.c
+++ b/examples/aes128cbc.c
@@ -20,15 +20,15 @@ int main()
iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_fips_matrix_style(&plain);
+ print_aes_block128_as_matrix(&plain);
printf("\n");
printf("Key: %s\n", format_aes_block128(&key).str);
- print_aes_block128_fips_matrix_style(&key);
+ print_aes_block128_as_matrix(&key);
printf("\n");
printf("Initialization vector: %s\n", format_aes_block128(&iv).str);
- print_aes_block128_fips_matrix_style(&iv);
+ print_aes_block128_as_matrix(&iv);
aes128_expand_key_schedule(key, &key_schedule);
@@ -40,11 +40,11 @@ int main()
cipher = aes128cbc_encrypt(plain, &key_schedule, iv, &next_iv);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_fips_matrix_style(&cipher);
+ print_aes_block128_as_matrix(&cipher);
printf("\n");
printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_fips_matrix_style(&next_iv);
+ print_aes_block128_as_matrix(&next_iv);
aes128_invert_key_schedule(&key_schedule, &inverted_schedule);
@@ -56,11 +56,11 @@ int main()
decrypted = aes128cbc_decrypt(cipher, &inverted_schedule, iv, &next_iv);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_fips_matrix_style(&decrypted);
+ print_aes_block128_as_matrix(&decrypted);
printf("\n");
printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_fips_matrix_style(&next_iv);
+ print_aes_block128_as_matrix(&next_iv);
return 0;
}
diff --git a/examples/aes128cfb.c b/examples/aes128cfb.c
index 5071019..4c6daa2 100644
--- a/examples/aes128cfb.c
+++ b/examples/aes128cfb.c
@@ -20,15 +20,15 @@ int main()
iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_fips_matrix_style(&plain);
+ print_aes_block128_as_matrix(&plain);
printf("\n");
printf("Key: %s\n", format_aes_block128(&key).str);
- print_aes_block128_fips_matrix_style(&key);
+ print_aes_block128_as_matrix(&key);
printf("\n");
printf("Initialization vector: %s\n", format_aes_block128(&iv).str);
- print_aes_block128_fips_matrix_style(&iv);
+ print_aes_block128_as_matrix(&iv);
aes128_expand_key_schedule(key, &key_schedule);
@@ -40,20 +40,20 @@ int main()
cipher = aes128cfb_encrypt(plain, &key_schedule, iv, &next_iv);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_fips_matrix_style(&cipher);
+ print_aes_block128_as_matrix(&cipher);
printf("\n");
printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_fips_matrix_style(&next_iv);
+ print_aes_block128_as_matrix(&next_iv);
decrypted = aes128cfb_decrypt(cipher, &key_schedule, iv, &next_iv);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_fips_matrix_style(&decrypted);
+ print_aes_block128_as_matrix(&decrypted);
printf("\n");
printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_fips_matrix_style(&next_iv);
+ print_aes_block128_as_matrix(&next_iv);
return 0;
}
diff --git a/examples/aes128ctr.c b/examples/aes128ctr.c
index 0291032..d798e70 100644
--- a/examples/aes128ctr.c
+++ b/examples/aes128ctr.c
@@ -20,15 +20,15 @@ int main()
iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_fips_matrix_style(&plain);
+ print_aes_block128_as_matrix(&plain);
printf("\n");
printf("Key: %s\n", format_aes_block128(&key).str);
- print_aes_block128_fips_matrix_style(&key);
+ print_aes_block128_as_matrix(&key);
printf("\n");
printf("Initialization vector: %s\n", format_aes_block128(&iv).str);
- print_aes_block128_fips_matrix_style(&iv);
+ print_aes_block128_as_matrix(&iv);
aes128_expand_key_schedule(key, &key_schedule);
@@ -40,12 +40,12 @@ int main()
cipher = aes128ctr_encrypt(plain, &key_schedule, iv, 0);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_fips_matrix_style(&cipher);
+ print_aes_block128_as_matrix(&cipher);
decrypted = aes128ctr_decrypt(cipher, &key_schedule, iv, 0);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_fips_matrix_style(&decrypted);
+ print_aes_block128_as_matrix(&decrypted);
return 0;
}
diff --git a/examples/aes128ecb.c b/examples/aes128ecb.c
index a96f937..8d8f990 100644
--- a/examples/aes128ecb.c
+++ b/examples/aes128ecb.c
@@ -19,11 +19,11 @@ int main()
key = make_aes_block128(0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_fips_matrix_style(&plain);
+ print_aes_block128_as_matrix(&plain);
printf("\n");
printf("Key: %s\n", format_aes_block128(&key).str);
- print_aes_block128_fips_matrix_style(&key);
+ print_aes_block128_as_matrix(&key);
aes128_expand_key_schedule(key, &key_schedule);
@@ -35,7 +35,7 @@ int main()
cipher = aes128ecb_encrypt(plain, &key_schedule);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_fips_matrix_style(&cipher);
+ print_aes_block128_as_matrix(&cipher);
aes128_invert_key_schedule(&key_schedule, &inverted_schedule);
@@ -47,7 +47,7 @@ int main()
decrypted = aes128ecb_decrypt(cipher, &inverted_schedule);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_fips_matrix_style(&decrypted);
+ print_aes_block128_as_matrix(&decrypted);
return 0;
}
diff --git a/examples/aes128ofb.c b/examples/aes128ofb.c
index e786cd0..9b263ed 100644
--- a/examples/aes128ofb.c
+++ b/examples/aes128ofb.c
@@ -20,15 +20,15 @@ int main()
iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_fips_matrix_style(&plain);
+ print_aes_block128_as_matrix(&plain);
printf("\n");
printf("Key: %s\n", format_aes_block128(&key).str);
- print_aes_block128_fips_matrix_style(&key);
+ print_aes_block128_as_matrix(&key);
printf("\n");
printf("Initialization vector: %s\n", format_aes_block128(&iv).str);
- print_aes_block128_fips_matrix_style(&iv);
+ print_aes_block128_as_matrix(&iv);
aes128_expand_key_schedule(key, &key_schedule);
@@ -40,20 +40,20 @@ int main()
cipher = aes128ofb_encrypt(plain, &key_schedule, iv, &next_iv);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_fips_matrix_style(&cipher);
+ print_aes_block128_as_matrix(&cipher);
printf("\n");
printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_fips_matrix_style(&next_iv);
+ print_aes_block128_as_matrix(&next_iv);
decrypted = aes128ofb_decrypt(cipher, &key_schedule, iv, &next_iv);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_fips_matrix_style(&decrypted);
+ print_aes_block128_as_matrix(&decrypted);
printf("\n");
printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_fips_matrix_style(&next_iv);
+ print_aes_block128_as_matrix(&next_iv);
return 0;
}
diff --git a/examples/aes192cbc.c b/examples/aes192cbc.c
index 5afece9..e6d844d 100644
--- a/examples/aes192cbc.c
+++ b/examples/aes192cbc.c
@@ -21,15 +21,15 @@ int main()
iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_fips_matrix_style(&plain);
+ print_aes_block128_as_matrix(&plain);
printf("\n");
printf("Key: %s\n", format_aes_block192(&key).str);
- print_aes_block192_fips_matrix_style(&key);
+ print_aes_block192_as_matrix(&key);
printf("\n");
printf("Initialization vector: %s\n", format_aes_block128(&iv).str);
- print_aes_block128_fips_matrix_style(&iv);
+ print_aes_block128_as_matrix(&iv);
aes192_expand_key_schedule(&key, &key_schedule);
@@ -41,11 +41,11 @@ int main()
cipher = aes192cbc_encrypt(plain, &key_schedule, iv, &next_iv);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_fips_matrix_style(&cipher);
+ print_aes_block128_as_matrix(&cipher);
printf("\n");
printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_fips_matrix_style(&next_iv);
+ print_aes_block128_as_matrix(&next_iv);
aes192_invert_key_schedule(&key_schedule, &inverted_schedule);
@@ -57,11 +57,11 @@ int main()
decrypted = aes192cbc_decrypt(cipher, &inverted_schedule, iv, &next_iv);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_fips_matrix_style(&decrypted);
+ print_aes_block128_as_matrix(&decrypted);
printf("\n");
printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_fips_matrix_style(&next_iv);
+ print_aes_block128_as_matrix(&next_iv);
return 0;
}
diff --git a/examples/aes192cfb.c b/examples/aes192cfb.c
index 363a24f..e530c13 100644
--- a/examples/aes192cfb.c
+++ b/examples/aes192cfb.c
@@ -21,15 +21,15 @@ int main()
iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_fips_matrix_style(&plain);
+ print_aes_block128_as_matrix(&plain);
printf("\n");
printf("Key: %s\n", format_aes_block192(&key).str);
- print_aes_block192_fips_matrix_style(&key);
+ print_aes_block192_as_matrix(&key);
printf("\n");
printf("Initialization vector: %s\n", format_aes_block128(&iv).str);
- print_aes_block128_fips_matrix_style(&iv);
+ print_aes_block128_as_matrix(&iv);
aes192_expand_key_schedule(&key, &key_schedule);
@@ -41,20 +41,20 @@ int main()
cipher = aes192cfb_encrypt(plain, &key_schedule, iv, &next_iv);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_fips_matrix_style(&cipher);
+ print_aes_block128_as_matrix(&cipher);
printf("\n");
printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_fips_matrix_style(&next_iv);
+ print_aes_block128_as_matrix(&next_iv);
decrypted = aes192cfb_decrypt(cipher, &key_schedule, iv, &next_iv);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_fips_matrix_style(&decrypted);
+ print_aes_block128_as_matrix(&decrypted);
printf("\n");
printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_fips_matrix_style(&next_iv);
+ print_aes_block128_as_matrix(&next_iv);
return 0;
}
diff --git a/examples/aes192ctr.c b/examples/aes192ctr.c
index b6fb82a..eccbc2e 100644
--- a/examples/aes192ctr.c
+++ b/examples/aes192ctr.c
@@ -21,15 +21,15 @@ int main()
iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_fips_matrix_style(&plain);
+ print_aes_block128_as_matrix(&plain);
printf("\n");
printf("Key: %s\n", format_aes_block192(&key).str);
- print_aes_block192_fips_matrix_style(&key);
+ print_aes_block192_as_matrix(&key);
printf("\n");
printf("Initialization vector: %s\n", format_aes_block128(&iv).str);
- print_aes_block128_fips_matrix_style(&iv);
+ print_aes_block128_as_matrix(&iv);
aes192_expand_key_schedule(&key, &key_schedule);
@@ -41,12 +41,12 @@ int main()
cipher = aes192ctr_encrypt(plain, &key_schedule, iv, 0);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_fips_matrix_style(&cipher);
+ print_aes_block128_as_matrix(&cipher);
decrypted = aes192ctr_decrypt(cipher, &key_schedule, iv, 0);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_fips_matrix_style(&decrypted);
+ print_aes_block128_as_matrix(&decrypted);
return 0;
}
diff --git a/examples/aes192ecb.c b/examples/aes192ecb.c
index 6d51fb8..2bf0fdb 100644
--- a/examples/aes192ecb.c
+++ b/examples/aes192ecb.c
@@ -20,11 +20,11 @@ int main()
key = make_aes_block192(0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_fips_matrix_style(&plain);
+ print_aes_block128_as_matrix(&plain);
printf("\n");
printf("Key: %s\n", format_aes_block192(&key).str);
- print_aes_block192_fips_matrix_style(&key);
+ print_aes_block192_as_matrix(&key);
aes192_expand_key_schedule(&key, &key_schedule);
@@ -36,7 +36,7 @@ int main()
cipher = aes192ecb_encrypt(plain, &key_schedule);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_fips_matrix_style(&cipher);
+ print_aes_block128_as_matrix(&cipher);
aes192_invert_key_schedule(&key_schedule, &inverted_schedule);
@@ -48,7 +48,7 @@ int main()
decrypted = aes192ecb_decrypt(cipher, &inverted_schedule);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_fips_matrix_style(&decrypted);
+ print_aes_block128_as_matrix(&decrypted);
return 0;
}
diff --git a/examples/aes192ofb.c b/examples/aes192ofb.c
index b95f45e..aed3c0c 100644
--- a/examples/aes192ofb.c
+++ b/examples/aes192ofb.c
@@ -21,15 +21,15 @@ int main()
iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_fips_matrix_style(&plain);
+ print_aes_block128_as_matrix(&plain);
printf("\n");
printf("Key: %s\n", format_aes_block192(&key).str);
- print_aes_block192_fips_matrix_style(&key);
+ print_aes_block192_as_matrix(&key);
printf("\n");
printf("Initialization vector: %s\n", format_aes_block128(&iv).str);
- print_aes_block128_fips_matrix_style(&iv);
+ print_aes_block128_as_matrix(&iv);
aes192_expand_key_schedule(&key, &key_schedule);
@@ -41,20 +41,20 @@ int main()
cipher = aes192ofb_encrypt(plain, &key_schedule, iv, &next_iv);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_fips_matrix_style(&cipher);
+ print_aes_block128_as_matrix(&cipher);
printf("\n");
printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_fips_matrix_style(&next_iv);
+ print_aes_block128_as_matrix(&next_iv);
decrypted = aes192ofb_decrypt(cipher, &key_schedule, iv, &next_iv);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_fips_matrix_style(&decrypted);
+ print_aes_block128_as_matrix(&decrypted);
printf("\n");
printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_fips_matrix_style(&next_iv);
+ print_aes_block128_as_matrix(&next_iv);
return 0;
}
diff --git a/examples/aes256cbc.c b/examples/aes256cbc.c
index f91188c..302bb37 100644
--- a/examples/aes256cbc.c
+++ b/examples/aes256cbc.c
@@ -21,15 +21,15 @@ int main()
iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_fips_matrix_style(&plain);
+ print_aes_block128_as_matrix(&plain);
printf("\n");
printf("Key: %s\n", format_aes_block256(&key).str);
- print_aes_block256_fips_matrix_style(&key);
+ print_aes_block256_as_matrix(&key);
printf("\n");
printf("Initialization vector: %s\n", format_aes_block128(&iv).str);
- print_aes_block128_fips_matrix_style(&iv);
+ print_aes_block128_as_matrix(&iv);
aes256_expand_key_schedule(&key, &key_schedule);
@@ -41,11 +41,11 @@ int main()
cipher = aes256cbc_encrypt(plain, &key_schedule, iv, &next_iv);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_fips_matrix_style(&cipher);
+ print_aes_block128_as_matrix(&cipher);
printf("\n");
printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_fips_matrix_style(&next_iv);
+ print_aes_block128_as_matrix(&next_iv);
aes256_invert_key_schedule(&key_schedule, &inverted_schedule);
@@ -57,11 +57,11 @@ int main()
decrypted = aes256cbc_decrypt(cipher, &inverted_schedule, iv, &next_iv);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_fips_matrix_style(&decrypted);
+ print_aes_block128_as_matrix(&decrypted);
printf("\n");
printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_fips_matrix_style(&next_iv);
+ print_aes_block128_as_matrix(&next_iv);
return 0;
}
diff --git a/examples/aes256cfb.c b/examples/aes256cfb.c
index 2872fa2..3ebf702 100644
--- a/examples/aes256cfb.c
+++ b/examples/aes256cfb.c
@@ -21,15 +21,15 @@ int main()
iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_fips_matrix_style(&plain);
+ print_aes_block128_as_matrix(&plain);
printf("\n");
printf("Key: %s\n", format_aes_block256(&key).str);
- print_aes_block256_fips_matrix_style(&key);
+ print_aes_block256_as_matrix(&key);
printf("\n");
printf("Initialization vector: %s\n", format_aes_block128(&iv).str);
- print_aes_block128_fips_matrix_style(&iv);
+ print_aes_block128_as_matrix(&iv);
aes256_expand_key_schedule(&key, &key_schedule);
@@ -41,20 +41,20 @@ int main()
cipher = aes256cfb_encrypt(plain, &key_schedule, iv, &next_iv);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_fips_matrix_style(&cipher);
+ print_aes_block128_as_matrix(&cipher);
printf("\n");
printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_fips_matrix_style(&next_iv);
+ print_aes_block128_as_matrix(&next_iv);
decrypted = aes256cfb_decrypt(cipher, &key_schedule, iv, &next_iv);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_fips_matrix_style(&decrypted);
+ print_aes_block128_as_matrix(&decrypted);
printf("\n");
printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_fips_matrix_style(&next_iv);
+ print_aes_block128_as_matrix(&next_iv);
return 0;
}
diff --git a/examples/aes256ctr.c b/examples/aes256ctr.c
index 3e06364..42267d2 100644
--- a/examples/aes256ctr.c
+++ b/examples/aes256ctr.c
@@ -21,15 +21,15 @@ int main()
iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_fips_matrix_style(&plain);
+ print_aes_block128_as_matrix(&plain);
printf("\n");
printf("Key: %s\n", format_aes_block256(&key).str);
- print_aes_block256_fips_matrix_style(&key);
+ print_aes_block256_as_matrix(&key);
printf("\n");
printf("Initialization vector: %s\n", format_aes_block128(&iv).str);
- print_aes_block128_fips_matrix_style(&iv);
+ print_aes_block128_as_matrix(&iv);
aes256_expand_key_schedule(&key, &key_schedule);
@@ -41,12 +41,12 @@ int main()
cipher = aes256ctr_encrypt(plain, &key_schedule, iv, 0);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_fips_matrix_style(&cipher);
+ print_aes_block128_as_matrix(&cipher);
decrypted = aes256ctr_decrypt(cipher, &key_schedule, iv, 0);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_fips_matrix_style(&decrypted);
+ print_aes_block128_as_matrix(&decrypted);
return 0;
}
diff --git a/examples/aes256ecb.c b/examples/aes256ecb.c
index 18e9e88..e1e2488 100644
--- a/examples/aes256ecb.c
+++ b/examples/aes256ecb.c
@@ -20,11 +20,11 @@ int main()
key = make_aes_block256(0x1f1e1d1c, 0x1b1a1918, 0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_fips_matrix_style(&plain);
+ print_aes_block128_as_matrix(&plain);
printf("\n");
printf("Key: %s\n", format_aes_block256(&key).str);
- print_aes_block256_fips_matrix_style(&key);
+ print_aes_block256_as_matrix(&key);
aes256_expand_key_schedule(&key, &key_schedule);
@@ -36,7 +36,7 @@ int main()
cipher = aes256ecb_encrypt(plain, &key_schedule);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_fips_matrix_style(&cipher);
+ print_aes_block128_as_matrix(&cipher);
aes256_invert_key_schedule(&key_schedule, &inverted_schedule);
@@ -48,7 +48,7 @@ int main()
decrypted = aes256ecb_decrypt(cipher, &inverted_schedule);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_fips_matrix_style(&decrypted);
+ print_aes_block128_as_matrix(&decrypted);
return 0;
}
diff --git a/examples/aes256ofb.c b/examples/aes256ofb.c
index 6ed4621..0ef42fd 100644
--- a/examples/aes256ofb.c
+++ b/examples/aes256ofb.c
@@ -21,15 +21,15 @@ int main()
iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
printf("Plain: %s\n", format_aes_block128(&plain).str);
- print_aes_block128_fips_matrix_style(&plain);
+ print_aes_block128_as_matrix(&plain);
printf("\n");
printf("Key: %s\n", format_aes_block256(&key).str);
- print_aes_block256_fips_matrix_style(&key);
+ print_aes_block256_as_matrix(&key);
printf("\n");
printf("Initialization vector: %s\n", format_aes_block128(&iv).str);
- print_aes_block128_fips_matrix_style(&iv);
+ print_aes_block128_as_matrix(&iv);
aes256_expand_key_schedule(&key, &key_schedule);
@@ -41,20 +41,20 @@ int main()
cipher = aes256ofb_encrypt(plain, &key_schedule, iv, &next_iv);
printf("\n");
printf("Cipher: %s\n", format_aes_block128(&cipher).str);
- print_aes_block128_fips_matrix_style(&cipher);
+ print_aes_block128_as_matrix(&cipher);
printf("\n");
printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_fips_matrix_style(&next_iv);
+ print_aes_block128_as_matrix(&next_iv);
decrypted = aes256ofb_decrypt(cipher, &key_schedule, iv, &next_iv);
printf("\n");
printf("Decrypted: %s\n", format_aes_block128(&decrypted).str);
- print_aes_block128_fips_matrix_style(&decrypted);
+ print_aes_block128_as_matrix(&decrypted);
printf("\n");
printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str);
- print_aes_block128_fips_matrix_style(&next_iv);
+ print_aes_block128_as_matrix(&next_iv);
return 0;
}
diff --git a/include/aesni/data.h b/include/aesni/data.h
index 1a192fc..44c499a 100644
--- a/include/aesni/data.h
+++ b/include/aesni/data.h
@@ -80,34 +80,54 @@ AesBlockString128 format_aes_block128(AesBlock128*);
AesBlockString192 format_aes_block192(AesBlock192*);
AesBlockString256 format_aes_block256(AesBlock256*);
-AesBlockString128 format_aes_block128_fips_style(AesBlock128*);
-AesBlockString192 format_aes_block192_fips_style(AesBlock192*);
-AesBlockString256 format_aes_block256_fips_style(AesBlock256*);
+AesBlockString128 format_aes_block128_le(AesBlock128*);
+AesBlockString192 format_aes_block192_le(AesBlock192*);
+AesBlockString256 format_aes_block256_le(AesBlock256*);
+
+AesBlockString128 format_aes_block128_be(AesBlock128*);
+AesBlockString192 format_aes_block192_be(AesBlock192*);
+AesBlockString256 format_aes_block256_be(AesBlock256*);
typedef struct { char str[49]; } AesBlockMatrixString128;
typedef struct { char str[73]; } AesBlockMatrixString192;
typedef struct { char str[97]; } AesBlockMatrixString256;
-AesBlockMatrixString128 format_aes_block128_fips_matrix_style(AesBlock128*);
-AesBlockMatrixString192 format_aes_block192_fips_matrix_style(AesBlock192*);
-AesBlockMatrixString256 format_aes_block256_fips_matrix_style(AesBlock256*);
+AesBlockMatrixString128 format_aes_block128_as_matrix(AesBlock128*);
+AesBlockMatrixString192 format_aes_block192_as_matrix(AesBlock192*);
+AesBlockMatrixString256 format_aes_block256_as_matrix(AesBlock256*);
+
+AesBlockMatrixString128 format_aes_block128_be_as_matrix(AesBlock128*);
+AesBlockMatrixString192 format_aes_block192_be_as_matrix(AesBlock192*);
+AesBlockMatrixString256 format_aes_block256_be_as_matrix(AesBlock256*);
void print_aes_block128(AesBlock128*);
void print_aes_block192(AesBlock192*);
void print_aes_block256(AesBlock256*);
-void print_aes_block128_fips_style(AesBlock128*);
-void print_aes_block192_fips_style(AesBlock192*);
-void print_aes_block256_fips_style(AesBlock256*);
+void print_aes_block128_le(AesBlock128*);
+void print_aes_block192_le(AesBlock192*);
+void print_aes_block256_le(AesBlock256*);
+
+void print_aes_block128_be(AesBlock128*);
+void print_aes_block192_be(AesBlock192*);
+void print_aes_block256_be(AesBlock256*);
-void print_aes_block128_fips_matrix_style(AesBlock128*);
-void print_aes_block192_fips_matrix_style(AesBlock192*);
-void print_aes_block256_fips_matrix_style(AesBlock256*);
+void print_aes_block128_as_matrix(AesBlock128*);
+void print_aes_block192_as_matrix(AesBlock192*);
+void print_aes_block256_as_matrix(AesBlock256*);
+
+void print_aes_block128_be_as_matrix(AesBlock128*);
+void print_aes_block192_be_as_matrix(AesBlock192*);
+void print_aes_block256_be_as_matrix(AesBlock256*);
int parse_aes_block128(AesBlock128*, const char*);
int parse_aes_block192(AesBlock192*, const char*);
int parse_aes_block256(AesBlock256*, const char*);
-int parse_aes_block128_fips_style(AesBlock128*, const char*);
-int parse_aes_block192_fips_style(AesBlock192*, const char*);
-int parse_aes_block256_fips_style(AesBlock256*, const char*);
+int parse_aes_block128_le(AesBlock128*, const char*);
+int parse_aes_block192_le(AesBlock192*, const char*);
+int parse_aes_block256_le(AesBlock256*, const char*);
+
+int parse_aes_block128_be(AesBlock128*, const char*);
+int parse_aes_block192_be(AesBlock192*, const char*);
+int parse_aes_block256_be(AesBlock256*, const char*);
diff --git a/src/common.c b/src/common.c
index bd628d5..36edac0 100644
--- a/src/common.c
+++ b/src/common.c
@@ -15,9 +15,33 @@
AesBlockString128 format_aes_block128(AesBlock128* block)
{
-#ifdef AESNI_FIPS_STYLE_IO_BY_DEFAULT
- return format_aes_block128_fips_style(block);
+#if defined LIBAESNI_BE_IO_BY_DEFAULT && LIBAESNI_BE_IO_BY_DEFAULT
+ return format_aes_block128_be(block);
#else
+ return format_aes_block128_le(block);
+#endif
+}
+
+AesBlockString192 format_aes_block192(AesBlock192* block)
+{
+#if defined LIBAESNI_BE_IO_BY_DEFAULT && LIBAESNI_BE_IO_BY_DEFAULT
+ return format_aes_block192_be(block);
+#else
+ return format_aes_block192_le(block);
+#endif
+}
+
+AesBlockString256 format_aes_block256(AesBlock256* block)
+{
+#if defined LIBAESNI_BE_IO_BY_DEFAULT && LIBAESNI_BE_IO_BY_DEFAULT
+ return format_aes_block256_be(block);
+#else
+ return format_aes_block256_le(block);
+#endif
+}
+
+AesBlockString128 format_aes_block128_le(AesBlock128* block)
+{
AesBlockString128 result;
char *cursor = result.str;
@@ -26,14 +50,10 @@ AesBlockString128 format_aes_block128(AesBlock128* block)
*cursor = '\0';
return result;
-#endif
}
-AesBlockString192 format_aes_block192(AesBlock192* block)
+AesBlockString192 format_aes_block192_le(AesBlock192* block)
{
-#ifdef AESNI_FIPS_STYLE_IO_BY_DEFAULT
- return format_aes_block192_fips_style(block);
-#else
AesBlockString192 result;
char *cursor = result.str;
@@ -44,14 +64,10 @@ AesBlockString192 format_aes_block192(AesBlock192* block)
*cursor = '\0';
return result;
-#endif
}
-AesBlockString256 format_aes_block256(AesBlock256* block)
+AesBlockString256 format_aes_block256_le(AesBlock256* block)
{
-#ifdef AESNI_FIPS_STYLE_IO_BY_DEFAULT
- return format_aes_block256_fips_style(block);
-#else
AesBlockString256 result;
char *cursor = result.str;
@@ -62,10 +78,9 @@ AesBlockString256 format_aes_block256(AesBlock256* block)
*cursor = '\0';
return result;
-#endif
}
-AesBlockString128 format_aes_block128_fips_style(AesBlock128* block)
+AesBlockString128 format_aes_block128_be(AesBlock128* block)
{
AesBlockString128 result;
char *cursor = result.str;
@@ -77,7 +92,7 @@ AesBlockString128 format_aes_block128_fips_style(AesBlock128* block)
return result;
}
-AesBlockString192 format_aes_block192_fips_style(AesBlock192* block)
+AesBlockString192 format_aes_block192_be(AesBlock192* block)
{
AesBlockString192 result;
char *cursor = result.str;
@@ -91,7 +106,7 @@ AesBlockString192 format_aes_block192_fips_style(AesBlock192* block)
return result;
}
-AesBlockString256 format_aes_block256_fips_style(AesBlock256* block)
+AesBlockString256 format_aes_block256_be(AesBlock256* block)
{
AesBlockString256 result;
char *cursor = result.str;
@@ -105,7 +120,22 @@ AesBlockString256 format_aes_block256_fips_style(AesBlock256* block)
return result;
}
-AesBlockMatrixString128 format_aes_block128_fips_matrix_style(AesBlock128* block)
+AesBlockMatrixString128 format_aes_block128_as_matrix(AesBlock128* block)
+{
+ return format_aes_block128_be_as_matrix(block);
+}
+
+AesBlockMatrixString192 format_aes_block192_as_matrix(AesBlock192* block)
+{
+ return format_aes_block192_be_as_matrix(block);
+}
+
+AesBlockMatrixString256 format_aes_block256_as_matrix(AesBlock256* block)
+{
+ return format_aes_block256_be_as_matrix(block);
+}
+
+AesBlockMatrixString128 format_aes_block128_be_as_matrix(AesBlock128* block)
{
__declspec(align(16)) unsigned char bytes[4][4];
AesBlockMatrixString128 result;
@@ -124,7 +154,7 @@ AesBlockMatrixString128 format_aes_block128_fips_matrix_style(AesBlock128* block
return result;
}
-AesBlockMatrixString192 format_aes_block192_fips_matrix_style(AesBlock192* block)
+AesBlockMatrixString192 format_aes_block192_be_as_matrix(AesBlock192* block)
{
__declspec(align(16)) unsigned char bytes[8][4];
AesBlockMatrixString192 result;
@@ -144,7 +174,7 @@ AesBlockMatrixString192 format_aes_block192_fips_matrix_style(AesBlock192* block
return result;
}
-AesBlockMatrixString256 format_aes_block256_fips_matrix_style(AesBlock256* block)
+AesBlockMatrixString256 format_aes_block256_be_as_matrix(AesBlock256* block)
{
__declspec(align(16)) unsigned char bytes[8][4];
AesBlockMatrixString256 result;
@@ -179,79 +209,124 @@ void print_aes_block256(AesBlock256* block)
printf("%s\n", format_aes_block256(block).str);
}
-void print_aes_block128_fips_style(AesBlock128* block)
+void print_aes_block128_le(AesBlock128* block)
+{
+ printf("%s\n", format_aes_block128_le(block).str);
+}
+
+void print_aes_block192_le(AesBlock192* block)
+{
+ printf("%s\n", format_aes_block192_le(block).str);
+}
+
+void print_aes_block256_le(AesBlock256* block)
{
- printf("%s\n", format_aes_block128_fips_style(block).str);
+ printf("%s\n", format_aes_block256_le(block).str);
}
-void print_aes_block192_fips_style(AesBlock192* block)
+void print_aes_block128_be(AesBlock128* block)
{
- printf("%s\n", format_aes_block192_fips_style(block).str);
+ printf("%s\n", format_aes_block128_be(block).str);
}
-void print_aes_block256_fips_style(AesBlock256* block)
+void print_aes_block192_be(AesBlock192* block)
{
- printf("%s\n", format_aes_block256_fips_style(block).str);
+ printf("%s\n", format_aes_block192_be(block).str);
}
-void print_aes_block128_fips_matrix_style(AesBlock128* block)
+void print_aes_block256_be(AesBlock256* block)
{
- printf("%s", format_aes_block128_fips_matrix_style(block).str);
+ printf("%s\n", format_aes_block256_be(block).str);
}
-void print_aes_block192_fips_matrix_style(AesBlock192* block)
+void print_aes_block128_as_matrix(AesBlock128* block)
{
- printf("%s", format_aes_block192_fips_matrix_style(block).str);
+ printf("%s\n", format_aes_block128(block).str);
+}
+
+void print_aes_block192_as_matrix(AesBlock192* block)
+{
+ printf("%s\n", format_aes_block192(block).str);
}
-void print_aes_block256_fips_matrix_style(AesBlock256* block)
+void print_aes_block256_as_matrix(AesBlock256* block)
{
- printf("%s", format_aes_block256_fips_matrix_style(block).str);
+ printf("%s\n", format_aes_block256(block).str);
+}
+
+void print_aes_block128_be_as_matrix(AesBlock128* block)
+{
+ printf("%s", format_aes_block128_be_as_matrix(block).str);
+}
+
+void print_aes_block192_be_as_matrix(AesBlock192* block)
+{
+ printf("%s", format_aes_block192_be_as_matrix(block).str);
+}
+
+void print_aes_block256_be_as_matrix(AesBlock256* block)
+{
+ printf("%s", format_aes_block256_be_as_matrix(block).str);
}
int parse_aes_block128(AesBlock128* block, const char* src)
{
-#if defined AESNI_FIPS_STYLE_IO_BY_DEFAULT && AESNI_FIPS_STYLE_IO_BY_DEFAULT
- return parse_aes_block128_fips_style(block, src);
+#if defined LIBAESNI_BE_IO_BY_DEFAULT && LIBAESNI_BE_IO_BY_DEFAULT
+ return parse_aes_block128_be(block, src);
+#else
+ return parse_aes_block128_le(block, src);
+#endif
+}
+
+int parse_aes_block192(AesBlock192* block, const char* src)
+{
+#if defined LIBAESNI_BE_IO_BY_DEFAULT && LIBAESNI_BE_IO_BY_DEFAULT
+ return parse_aes_block192_be(block, src);
+#else
+ return parse_aes_block192_le(block, src);
+#endif
+}
+
+int parse_aes_block256(AesBlock256* block, const char* src)
+{
+#if defined LIBAESNI_BE_IO_BY_DEFAULT && LIBAESNI_BE_IO_BY_DEFAULT
+ return parse_aes_block256_be(block, src);
#else
+ return parse_aes_block256_le(block, src);
+#endif
+}
+
+int parse_aes_block128_le(AesBlock128* block, const char* src)
+{
int n, xs[4];
if (sscanf(src, "%8x%8x%8x%8x%n", &xs[0], &xs[1], &xs[2], &xs[3], &n) != 4
|| n != strlen(src))
return 1;
*block = make_aes_block128(xs[0], xs[1], xs[2], xs[3]);
return 0;
-#endif
}
-int parse_aes_block192(AesBlock192* block, const char* src)
+int parse_aes_block192_le(AesBlock192* block, const char* src)
{
-#if defined AESNI_FIPS_STYLE_IO_BY_DEFAULT && AESNI_FIPS_STYLE_IO_BY_DEFAULT
- return parse_aes_block192_fips_style(block, src);
-#else
int n, xs[6];
if (sscanf(src, "%8x%8x%8x%8x%8x%8x%n", &xs[0], &xs[1], &xs[2], &xs[3], &xs[4], &xs[5], &n) != 6
|| n != strlen(src))
return 1;
*block = make_aes_block192(xs[0], xs[1], xs[2], xs[3], xs[4], xs[5]);
return 0;
-#endif
}
-int parse_aes_block256(AesBlock256* block, const char* src)
+int parse_aes_block256_le(AesBlock256* block, const char* src)
{
-#if defined AESNI_FIPS_STYLE_IO_BY_DEFAULT && AESNI_FIPS_STYLE_IO_BY_DEFAULT
- return parse_aes_block256_fips_style(block, src);
-#else
int n, xs[8];
if (sscanf(src, "%8x%8x%8x%8x%8x%8x%8x%8x%n", &xs[0], &xs[1], &xs[2], &xs[3], &xs[4], &xs[5], &xs[6], &xs[7], &n) != 8
|| n != strlen(src))
return 1;
*block = make_aes_block256(xs[0], xs[1], xs[2], xs[3], xs[4], xs[5], xs[6], xs[7]);
return 0;
-#endif
}
-int parse_aes_block128_fips_style(AesBlock128* block, const char* src)
+int parse_aes_block128_be(AesBlock128* block, const char* src)
{
unsigned char bytes[16];
@@ -269,7 +344,7 @@ int parse_aes_block128_fips_style(AesBlock128* block, const char* src)
return 0;
}
-int parse_aes_block192_fips_style(AesBlock192* block, const char* src)
+int parse_aes_block192_be(AesBlock192* block, const char* src)
{
AesBlock128 lo, hi;
unsigned char lo_bytes[16], hi_bytes[16] = { 0 };
@@ -303,7 +378,7 @@ int parse_aes_block192_fips_style(AesBlock192* block, const char* src)
return 0;
}
-int parse_aes_block256_fips_style(AesBlock256* block, const char* src)
+int parse_aes_block256_be(AesBlock256* block, const char* src)
{
AesBlock128 lo, hi;
unsigned char lo_bytes[16], hi_bytes[16];