diff options
author | Emilia Kasper <emilia@openssl.org> | 2014-09-04 13:04:42 +0200 |
---|---|---|
committer | Emilia Kasper <emilia@openssl.org> | 2014-09-24 15:35:02 +0200 |
commit | 455b65dfab0de51c9f67b3c909311770f2b3f801 (patch) | |
tree | 06ce4bbf1548dd2b3775b9cd14219dea8c71893c /crypto/constant_time_test.c | |
parent | RT3066: rewrite RSA padding checks to be slightly more constant time. (diff) | |
download | openssl-455b65dfab0de51c9f67b3c909311770f2b3f801.tar.xz openssl-455b65dfab0de51c9f67b3c909311770f2b3f801.zip |
RT3067: simplify patch
(Original commit adb46dbc6dd7347750df2468c93e8c34bcb93a4b)
Use the new constant-time methods consistently in s3_srvr.c
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Diffstat (limited to 'crypto/constant_time_test.c')
-rw-r--r-- | crypto/constant_time_test.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/crypto/constant_time_test.c b/crypto/constant_time_test.c index 0e51892af5..1b4b18d199 100644 --- a/crypto/constant_time_test.c +++ b/crypto/constant_time_test.c @@ -196,6 +196,45 @@ static int test_select_int(int a, int b) return 0; } +static int test_eq_int(int a, int b) + { + unsigned int equal = constant_time_eq_int(a, b); + if (a == b && equal != CONSTTIME_TRUE) + { + fprintf(stderr, "Test failed for constant_time_select(%d, %d): " + "expected %du(TRUE), got %du\n", + a, b, CONSTTIME_TRUE, equal); + return 1; + } + else if (a != b && equal != CONSTTIME_FALSE) + { + fprintf(stderr, "Test failed for constant_time_select(%d, %d): " + "expected %du(FALSE), got %du\n", + a, b, CONSTTIME_FALSE, equal); + return 1; + } + return 0; + } + +static int test_eq_int_8(int a, int b) + { + unsigned char equal = constant_time_eq_int_8(a, b); + if (a == b && equal != CONSTTIME_TRUE_8) + { + fprintf(stderr, "Test failed for constant_time_select(%d, %d): " + "expected %u(TRUE), got %u\n", + a, b, CONSTTIME_TRUE_8, equal); + return 1; + } + else if (a != b && equal != CONSTTIME_FALSE_8) + { + fprintf(stderr, "Test failed for constant_time_select(%d, %d): " + "expected %u(FALSE), got %u\n", + a, b, CONSTTIME_FALSE_8, equal); + return 1; + } + return 0; + } static unsigned int test_values[] = {0, 1, 1024, 12345, 32000, UINT_MAX/2-1, UINT_MAX/2, UINT_MAX/2+1, UINT_MAX-1, |