mirror of
https://github.com/sheumann/65816-crypto.git
synced 2024-11-25 10:30:45 +00:00
Usage message and indentation cleanups in test program.
This commit is contained in:
parent
4ffd064204
commit
d4baf7dbe4
20
aestest.c
20
aestest.c
@ -15,6 +15,8 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <MiscTool.h>
|
||||
#include <Memory.h>
|
||||
#include <orca.h>
|
||||
@ -133,9 +135,9 @@ unsigned long aes128_time_test(unsigned int iters) {
|
||||
};
|
||||
|
||||
aes_context_hndl = (struct aes_context **)NewHandle(sizeof(struct aes_context),
|
||||
userid(), attrFixed|attrPage|attrBank|attrNoCross, 0x000000);
|
||||
userid(), attrFixed|attrPage|attrBank|attrNoCross, 0x000000);
|
||||
if (toolerror())
|
||||
return 0;
|
||||
return 0;
|
||||
aes_context = *aes_context_hndl;
|
||||
*aes_context = aes_context_init;
|
||||
|
||||
@ -149,7 +151,7 @@ unsigned long aes128_time_test(unsigned int iters) {
|
||||
|
||||
bytes_per_sec = (long double)iters * 16 * 60 / tick_count;
|
||||
printf("Encryption: %u iterations takes %lu ticks (%lf bytes/sec)\n",
|
||||
iters, tick_count, bytes_per_sec);
|
||||
iters, tick_count, bytes_per_sec);
|
||||
|
||||
tick_count = GetTick();
|
||||
for (i = 0; i < iters; i++) {
|
||||
@ -159,7 +161,7 @@ unsigned long aes128_time_test(unsigned int iters) {
|
||||
|
||||
bytes_per_sec = (long double)iters * 16 * 60 / tick_count;
|
||||
printf("Decryption: %u iterations takes %lu ticks (%lf bytes/sec)\n",
|
||||
iters, tick_count, bytes_per_sec);
|
||||
iters, tick_count, bytes_per_sec);
|
||||
|
||||
print_hexbytes("Decrypted: ", aes_context->data, 16);
|
||||
}
|
||||
@ -167,8 +169,14 @@ unsigned long aes128_time_test(unsigned int iters) {
|
||||
int main(int argc, char **argv) {
|
||||
unsigned int test_iters = 0;
|
||||
|
||||
if (argc > 1)
|
||||
test_iters = strtoul(argv[1], NULL, 10);
|
||||
if (argc > 1) {
|
||||
errno = 0;
|
||||
test_iters = strtoul(argv[1], NULL, 10);
|
||||
if (argc > 2 || errno != 0) {
|
||||
fprintf(stderr, "Usage: aestest [test_iters]\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
printf("AES-128 test:\n");
|
||||
aes128_test();
|
||||
|
Loading…
Reference in New Issue
Block a user