aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test/aes128ecb_encrypt_block.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--test/aes128ecb_encrypt_block.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/test/aes128ecb_encrypt_block.c b/test/aes128ecb_encrypt_block.c
index 17bcce1..45a1123 100644
--- a/test/aes128ecb_encrypt_block.c
+++ b/test/aes128ecb_encrypt_block.c
@@ -18,8 +18,15 @@ static void exit_with_usage()
exit(EXIT_FAILURE);
}
+static void print_error(AesNI_StatusCode status)
+{
+ fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
+}
+
int main(int argc, char** argv)
{
+ AesNI_StatusCode status = AESNI_SUCCESS;
+
for (--argc, ++argv; argc > -1; --argc, ++argv)
{
AesNI_Block128 plaintext, ciphertext;
@@ -29,9 +36,9 @@ int main(int argc, char** argv)
if (argc < 1)
exit_with_usage();
- if (aesni_is_error(aesni_aes128_parse_key(&key, *argv, NULL)))
+ if (aesni_is_error(status = aesni_aes128_parse_key(&key, *argv, NULL)))
{
- fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ print_error(status);
exit_with_usage();
}
@@ -42,13 +49,19 @@ int main(int argc, char** argv)
if (strcmp("--", *argv) == 0)
break;
- if (aesni_is_error(aesni_aes_parse_block(&plaintext, *argv, NULL)))
+ if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL)))
{
- fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ print_error(status);
continue;
}
+
ciphertext = aesni_aes128_encrypt_block_ecb(plaintext, &encryption_keys);
- aesni_aes_print_block(&ciphertext, NULL);
+
+ if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL)))
+ {
+ print_error(status);
+ continue;
+ }
}
}