diff options
author | Rob Austein <sra@hactrn.net> | 2015-09-23 16:31:28 -0400 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2015-09-23 16:31:28 -0400 |
commit | 026fc461d9791bc360036f1269d0f6d61c45d179 (patch) | |
tree | f1c86f833ac220c6e21a59d184558bf6e7a92789 /sw/modexps6_tester.c | |
parent | 99c3749c85b85b4865c4baafdd16b2cbb3ac52f2 (diff) |
Trailing whitespace cleanup.
Diffstat (limited to 'sw/modexps6_tester.c')
-rw-r--r-- | sw/modexps6_tester.c | 224 |
1 files changed, 112 insertions, 112 deletions
diff --git a/sw/modexps6_tester.c b/sw/modexps6_tester.c index a9e3b74..b76a6b3 100644 --- a/sw/modexps6_tester.c +++ b/sw/modexps6_tester.c @@ -23,10 +23,10 @@ int repeat = 0; int tc_width(off_t offset, uint32_t length) { length = htonl(length); // ! - + uint8_t width[4]; memcpy(width, &length, 4); - + return tc_write(offset, width, sizeof(width)); } @@ -79,7 +79,7 @@ int TC0(void) int TC1(void) { int ret; - + if (!quiet) printf("TC1: Sign 1024-bit message (fast & unsafe public mode).\n"); @@ -93,37 +93,37 @@ int TC1(void) /*uint8_t mode_slow_secure[] = {0, 0, 0, 0};*/ uint8_t mode_fast_unsafe[] = {0, 0, 0, 1}; tc_write(MODEXPS6_ADDR_MODE, mode_fast_unsafe, sizeof(mode_fast_unsafe)); - + /* Set new modulus size */ tc_width(MODEXPS6_ADDR_MODULUS_WIDTH, sizeof(modulus) * 8); // number of bits - + /* Write new modulus */ tc_write(MODEXPS6_ADDR_MODULUS, modulus, sizeof(modulus)); - + /* Pre-calculate speed-up coefficient */ tc_init(MODEXPS6_ADDR_CTRL); /* Wait while core is calculating */ tc_wait_ready(MODEXPS6_ADDR_STATUS); - + /* Write new message */ tc_write(MODEXPS6_ADDR_MESSAGE, message, sizeof(message)); - + /* Set new exponent length */ tc_width(MODEXPS6_ADDR_EXPONENT_WIDTH, sizeof(exponent) * 8); // number of bits - + /* Write new exponent */ tc_write(MODEXPS6_ADDR_EXPONENT, exponent, sizeof(exponent)); - + /* Start calculation */ tc_next(MODEXPS6_ADDR_CTRL); - + /* Wait while core is calculating */ - tc_wait_valid(MODEXPS6_ADDR_STATUS); - + tc_wait_valid(MODEXPS6_ADDR_STATUS); + /* Compare actual result with expected value */ ret = tc_expected(MODEXPS6_ADDR_RESULT, result, sizeof(result)); - + return ret; } @@ -131,7 +131,7 @@ int TC1(void) int TC2(void) { int ret; - + if (!quiet) printf("TC2: Sign 1024-bit message (slow & secure private mode).\n"); @@ -145,37 +145,37 @@ int TC2(void) uint8_t mode_slow_secure[] = {0, 0, 0, 0}; /*uint8_t mode_fast_unsafe[] = {0, 0, 0, 1};*/ tc_write(MODEXPS6_ADDR_MODE, mode_slow_secure, sizeof(mode_slow_secure)); - + /* Set new modulus size */ tc_width(MODEXPS6_ADDR_MODULUS_WIDTH, sizeof(modulus) * 8); // number of bits - + /* Write new modulus */ tc_write(MODEXPS6_ADDR_MODULUS, modulus, sizeof(modulus)); - + /* Pre-calculate speed-up coefficient */ tc_init(MODEXPS6_ADDR_CTRL); /* Wait while core is calculating */ tc_wait_ready(MODEXPS6_ADDR_STATUS); - + /* Write new message */ tc_write(MODEXPS6_ADDR_MESSAGE, message, sizeof(message)); - + /* Set new exponent length */ tc_width(MODEXPS6_ADDR_EXPONENT_WIDTH, sizeof(exponent) * 8); // number of bits - + /* Write new exponent */ tc_write(MODEXPS6_ADDR_EXPONENT, exponent, sizeof(exponent)); - + /* Start calculation */ tc_next(MODEXPS6_ADDR_CTRL); - + /* Wait while core is calculating */ - tc_wait_valid(MODEXPS6_ADDR_STATUS); - + tc_wait_valid(MODEXPS6_ADDR_STATUS); + /* Compare actual result with expected value */ ret = tc_expected(MODEXPS6_ADDR_RESULT, result, sizeof(result)); - + return ret; } @@ -183,7 +183,7 @@ int TC2(void) int TC3(void) { int ret; - + if (!quiet) printf("TC3: Sign 2048-bit message (fast & unsafe public mode).\n"); @@ -197,37 +197,37 @@ int TC3(void) /*uint8_t mode_slow_secure[] = {0, 0, 0, 0};*/ uint8_t mode_fast_unsafe[] = {0, 0, 0, 1}; tc_write(MODEXPS6_ADDR_MODE, mode_fast_unsafe, sizeof(mode_fast_unsafe)); - + /* Set new modulus size */ tc_width(MODEXPS6_ADDR_MODULUS_WIDTH, sizeof(modulus) * 8); // number of bits - + /* Write new modulus */ tc_write(MODEXPS6_ADDR_MODULUS, modulus, sizeof(modulus)); - + /* Pre-calculate speed-up coefficient */ tc_init(MODEXPS6_ADDR_CTRL); /* Wait while core is calculating */ tc_wait_ready(MODEXPS6_ADDR_STATUS); - + /* Write new message */ tc_write(MODEXPS6_ADDR_MESSAGE, message, sizeof(message)); - + /* Set new exponent length */ tc_width(MODEXPS6_ADDR_EXPONENT_WIDTH, sizeof(exponent) * 8); // number of bits - + /* Write new exponent */ tc_write(MODEXPS6_ADDR_EXPONENT, exponent, sizeof(exponent)); - + /* Start calculation */ tc_next(MODEXPS6_ADDR_CTRL); - + /* Wait while core is calculating */ - tc_wait_valid(MODEXPS6_ADDR_STATUS); - + tc_wait_valid(MODEXPS6_ADDR_STATUS); + /* Compare actual result with expected value */ ret = tc_expected(MODEXPS6_ADDR_RESULT, result, sizeof(result)); - + return ret; } @@ -235,7 +235,7 @@ int TC3(void) int TC4(void) { int ret; - + if (!quiet) printf("TC4: Sign 2048-bit message (slow & secure private mode).\n"); @@ -249,37 +249,37 @@ int TC4(void) uint8_t mode_slow_secure[] = {0, 0, 0, 0}; /*uint8_t mode_fast_unsafe[] = {0, 0, 0, 1};*/ tc_write(MODEXPS6_ADDR_MODE, mode_slow_secure, sizeof(mode_slow_secure)); - + /* Set new modulus size */ tc_width(MODEXPS6_ADDR_MODULUS_WIDTH, sizeof(modulus) * 8); // number of bits - + /* Write new modulus */ tc_write(MODEXPS6_ADDR_MODULUS, modulus, sizeof(modulus)); - + /* Pre-calculate speed-up coefficient */ tc_init(MODEXPS6_ADDR_CTRL); /* Wait while core is calculating */ tc_wait_ready(MODEXPS6_ADDR_STATUS); - + /* Write new message */ tc_write(MODEXPS6_ADDR_MESSAGE, message, sizeof(message)); - + /* Set new exponent length */ tc_width(MODEXPS6_ADDR_EXPONENT_WIDTH, sizeof(exponent) * 8); // number of bits - + /* Write new exponent */ tc_write(MODEXPS6_ADDR_EXPONENT, exponent, sizeof(exponent)); - + /* Start calculation */ tc_next(MODEXPS6_ADDR_CTRL); - + /* Wait while core is calculating */ - tc_wait_valid(MODEXPS6_ADDR_STATUS); - + tc_wait_valid(MODEXPS6_ADDR_STATUS); + /* Compare actual result with expected value */ ret = tc_expected(MODEXPS6_ADDR_RESULT, result, sizeof(result)); - + return ret; } @@ -287,7 +287,7 @@ int TC4(void) int TC5(void) { int ret; - + if (!quiet) printf("TC5: Sign 4096-bit message (fast & unsafe public mode).\n"); @@ -301,37 +301,37 @@ int TC5(void) /*uint8_t mode_slow_secure[] = {0, 0, 0, 0};*/ uint8_t mode_fast_unsafe[] = {0, 0, 0, 1}; tc_write(MODEXPS6_ADDR_MODE, mode_fast_unsafe, sizeof(mode_fast_unsafe)); - + /* Set new modulus size */ tc_width(MODEXPS6_ADDR_MODULUS_WIDTH, sizeof(modulus) * 8); // number of bits - + /* Write new modulus */ tc_write(MODEXPS6_ADDR_MODULUS, modulus, sizeof(modulus)); - + /* Pre-calculate speed-up coefficient */ tc_init(MODEXPS6_ADDR_CTRL); /* Wait while core is calculating */ tc_wait_ready(MODEXPS6_ADDR_STATUS); - + /* Write new message */ tc_write(MODEXPS6_ADDR_MESSAGE, message, sizeof(message)); - + /* Set new exponent length */ tc_width(MODEXPS6_ADDR_EXPONENT_WIDTH, sizeof(exponent) * 8); // number of bits - + /* Write new exponent */ tc_write(MODEXPS6_ADDR_EXPONENT, exponent, sizeof(exponent)); - + /* Start calculation */ tc_next(MODEXPS6_ADDR_CTRL); - + /* Wait while core is calculating */ - tc_wait_valid(MODEXPS6_ADDR_STATUS); - + tc_wait_valid(MODEXPS6_ADDR_STATUS); + /* Compare actual result with expected value */ ret = tc_expected(MODEXPS6_ADDR_RESULT, result, sizeof(result)); - + return ret; } @@ -339,7 +339,7 @@ int TC5(void) int TC6(void) { int ret; - + if (!quiet) printf("TC6: Sign 4096-bit message (slow & secure private mode).\n"); @@ -353,37 +353,37 @@ int TC6(void) uint8_t mode_slow_secure[] = {0, 0, 0, 0}; /*uint8_t mode_fast_unsafe[] = {0, 0, 0, 1};*/ tc_write(MODEXPS6_ADDR_MODE, mode_slow_secure, sizeof(mode_slow_secure)); - + /* Set new modulus size */ tc_width(MODEXPS6_ADDR_MODULUS_WIDTH, sizeof(modulus) * 8); // number of bits - + /* Write new modulus */ tc_write(MODEXPS6_ADDR_MODULUS, modulus, sizeof(modulus)); - + /* Pre-calculate speed-up coefficient */ tc_init(MODEXPS6_ADDR_CTRL); /* Wait while core is calculating */ tc_wait_ready(MODEXPS6_ADDR_STATUS); - + /* Write new message */ tc_write(MODEXPS6_ADDR_MESSAGE, message, sizeof(message)); - + /* Set new exponent length */ tc_width(MODEXPS6_ADDR_EXPONENT_WIDTH, sizeof(exponent) * 8); // number of bits - + /* Write new exponent */ tc_write(MODEXPS6_ADDR_EXPONENT, exponent, sizeof(exponent)); - + /* Start calculation */ tc_next(MODEXPS6_ADDR_CTRL); - + /* Wait while core is calculating */ - tc_wait_valid(MODEXPS6_ADDR_STATUS); - + tc_wait_valid(MODEXPS6_ADDR_STATUS); + /* Compare actual result with expected value */ ret = tc_expected(MODEXPS6_ADDR_RESULT, result, sizeof(result)); - + return ret; } @@ -391,7 +391,7 @@ int TC6(void) int TC7(void) { int ret; - + if (!quiet) printf("TC7: Sign several 1024-bit messages (without pre-calculation every time).\n"); @@ -406,40 +406,40 @@ int TC7(void) clone_reversed(result_1, s_1024_1); clone_reversed(result_2, s_1024_2); clone_reversed(result_3, s_1024_3); - + /* Set fast mode */ /*uint8_t mode_slow_secure[] = {0, 0, 0, 0};*/ uint8_t mode_fast_unsafe[] = {0, 0, 0, 1}; tc_write(MODEXPS6_ADDR_MODE, mode_fast_unsafe, sizeof(mode_fast_unsafe)); - + /* Set new modulus size */ tc_width(MODEXPS6_ADDR_MODULUS_WIDTH, sizeof(modulus) * 8); // number of bits - + /* Write new modulus */ tc_write(MODEXPS6_ADDR_MODULUS, modulus, sizeof(modulus)); - + /* Pre-calculate speed-up coefficient */ tc_init(MODEXPS6_ADDR_CTRL); /* Wait while core is calculating */ tc_wait_ready(MODEXPS6_ADDR_STATUS); - + /* Set new exponent length */ tc_width(MODEXPS6_ADDR_EXPONENT_WIDTH, sizeof(exponent) * 8); // number of bits /* Write new exponent */ - tc_write(MODEXPS6_ADDR_EXPONENT, exponent, sizeof(exponent)); - + tc_write(MODEXPS6_ADDR_EXPONENT, exponent, sizeof(exponent)); + { /* Write new message #0 */ tc_write(MODEXPS6_ADDR_MESSAGE, message_0, sizeof(message_0)); - + /* Start calculation */ tc_next(MODEXPS6_ADDR_CTRL); - + /* Wait while core is calculating */ - tc_wait_valid(MODEXPS6_ADDR_STATUS); - + tc_wait_valid(MODEXPS6_ADDR_STATUS); + /* Compare actual result with expected value */ ret = tc_expected(MODEXPS6_ADDR_RESULT, result_0, sizeof(result_0)); if (ret) return 1; @@ -447,13 +447,13 @@ int TC7(void) { /* Write new message #1 */ tc_write(MODEXPS6_ADDR_MESSAGE, message_1, sizeof(message_1)); - + /* Start calculation */ tc_next(MODEXPS6_ADDR_CTRL); - + /* Wait while core is calculating */ - tc_wait_valid(MODEXPS6_ADDR_STATUS); - + tc_wait_valid(MODEXPS6_ADDR_STATUS); + /* Compare actual result with expected value */ ret = tc_expected(MODEXPS6_ADDR_RESULT, result_1, sizeof(result_1)); if (ret) return 1; @@ -461,13 +461,13 @@ int TC7(void) { /* Write new message #2 */ tc_write(MODEXPS6_ADDR_MESSAGE, message_2, sizeof(message_2)); - + /* Start calculation */ tc_next(MODEXPS6_ADDR_CTRL); - + /* Wait while core is calculating */ - tc_wait_valid(MODEXPS6_ADDR_STATUS); - + tc_wait_valid(MODEXPS6_ADDR_STATUS); + /* Compare actual result with expected value */ ret = tc_expected(MODEXPS6_ADDR_RESULT, result_2, sizeof(result_2)); if (ret) return 1; @@ -475,18 +475,18 @@ int TC7(void) { /* Write new message #3 */ tc_write(MODEXPS6_ADDR_MESSAGE, message_3, sizeof(message_3)); - + /* Start calculation */ tc_next(MODEXPS6_ADDR_CTRL); - + /* Wait while core is calculating */ - tc_wait_valid(MODEXPS6_ADDR_STATUS); - + tc_wait_valid(MODEXPS6_ADDR_STATUS); + /* Compare actual result with expected value */ ret = tc_expected(MODEXPS6_ADDR_RESULT, result_3, sizeof(result_3)); if (ret) return 1; } - + return 0; } @@ -494,7 +494,7 @@ int TC7(void) int TC8(void) { int ret; - + if (!quiet) printf("TC8: Verify 4096-bit message (fast mode using public exponent).\n"); @@ -503,46 +503,46 @@ int TC8(void) clone_reversed(message, s_4096); clone_reversed(exponent, e_4096); clone_reversed(result, m_4096); - + /* Set fast mode */ /*uint8_t mode_slow_secure[] = {0, 0, 0, 0};*/ uint8_t mode_fast_unsafe[] = {0, 0, 0, 1}; tc_write(MODEXPS6_ADDR_MODE, mode_fast_unsafe, sizeof(mode_fast_unsafe)); - + /* Set new modulus size */ tc_width(MODEXPS6_ADDR_MODULUS_WIDTH, sizeof(modulus) * 8); // number of bits - + /* Write new modulus */ tc_write(MODEXPS6_ADDR_MODULUS, modulus, sizeof(modulus)); - + /* Pre-calculate speed-up coefficient */ tc_init(MODEXPS6_ADDR_CTRL); /* Wait while core is calculating */ tc_wait_ready(MODEXPS6_ADDR_STATUS); - + /* Write new message */ tc_write(MODEXPS6_ADDR_MESSAGE, message, sizeof(message)); - + /* Set new exponent length */ #if 1 tc_width(MODEXPS6_ADDR_EXPONENT_WIDTH, 18); // number of bits #else tc_width(MODEXPS6_ADDR_EXPONENT_WIDTH, 24); // number of bits #endif - + /* Write new exponent */ tc_write(MODEXPS6_ADDR_EXPONENT, exponent, sizeof(exponent)); - + /* Start calculation */ tc_next(MODEXPS6_ADDR_CTRL); - + /* Wait while core is calculating */ - tc_wait_valid(MODEXPS6_ADDR_STATUS); - + tc_wait_valid(MODEXPS6_ADDR_STATUS); + /* Compare actual result with expected value */ ret = tc_expected(MODEXPS6_ADDR_RESULT, result, sizeof(result)); - + return ret; } |