projects
/
oweals
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add a CMAC test
[oweals/openssl.git]
/
test
/
ecstresstest.c
diff --git
a/test/ecstresstest.c
b/test/ecstresstest.c
index 1cdb12b228996ef8a4756373127f9d275db9e792..5a831e338ac822347ae3bf92513cd4567dcbe5b0 100644
(file)
--- a/
test/ecstresstest.c
+++ b/
test/ecstresstest.c
@@
-1,14
+1,14
@@
/*
/*
- * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2017
-2018
The OpenSSL Project Authors. All Rights Reserved.
*
*
- * Licensed under the
OpenSSL licenses,
(the "License");
+ * Licensed under the
Apache License 2.0
(the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* https://www.openssl.org/source/license.html
* or in the file LICENSE in the source distribution.
*/
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* https://www.openssl.org/source/license.html
* or in the file LICENSE in the source distribution.
*/
-#include "
e_os
.h"
+#include "
internal/nelem
.h"
#include "testutil.h"
#include <stdio.h>
#include "testutil.h"
#include <stdio.h>
@@
-18,7
+18,7
@@
#define NUM_REPEATS "1000000"
#define NUM_REPEATS "1000000"
-static int
64
_t num_repeats;
+static int
max
_t num_repeats;
static int print_mode = 0;
#ifndef OPENSSL_NO_EC
static int print_mode = 0;
#ifndef OPENSSL_NO_EC
@@
-39,22
+39,21
@@
static const char *kP256DefaultResult =
* point multiplication.
* Returns the X-coordinate of the end result or NULL on error.
*/
* point multiplication.
* Returns the X-coordinate of the end result or NULL on error.
*/
-static BIGNUM *walk_curve(const EC_GROUP *group, EC_POINT *point, int
64
_t num)
+static BIGNUM *walk_curve(const EC_GROUP *group, EC_POINT *point, int
max
_t num)
{
BIGNUM *scalar = NULL;
{
BIGNUM *scalar = NULL;
- int
64
_t i;
+ int
max
_t i;
if (!TEST_ptr(scalar = BN_new())
if (!TEST_ptr(scalar = BN_new())
- || !TEST_true(EC_POINT_get_affine_coordinates_GFp(group, point,
- scalar,
- NULL, NULL)))
+ || !TEST_true(EC_POINT_get_affine_coordinates(group, point, scalar,
+ NULL, NULL)))
goto err;
for (i = 0; i < num; i++) {
if (!TEST_true(EC_POINT_mul(group, point, NULL, point, scalar, NULL))
goto err;
for (i = 0; i < num; i++) {
if (!TEST_true(EC_POINT_mul(group, point, NULL, point, scalar, NULL))
- || !TEST_true(EC_POINT_get_affine_coordinates
_GFp
(group, point,
-
scalar,
-
NULL, NULL)))
+ || !TEST_true(EC_POINT_get_affine_coordinates(group, point,
+ scalar,
+ NULL, NULL)))
goto err;
}
return scalar;
goto err;
}
return scalar;
@@
-64,7
+63,7
@@
err:
return NULL;
}
return NULL;
}
-static int test_curve()
+static int test_curve(
void
)
{
EC_GROUP *group = NULL;
EC_POINT *point = NULL;
{
EC_GROUP *group = NULL;
EC_POINT *point = NULL;
@@
-102,20
+101,21
@@
err:
}
#endif
}
#endif
-static int atoi64(const char *in, int64_t *result)
-{
- int64_t ret = 0;
-
- for ( ; *in != '\0'; in++) {
-
char c = *in
;
+typedef enum OPTION_choice {
+ OPT_ERR = -1,
+ OPT_EOF = 0,
+ OPT_NUM_REPEATS,
+ OPT_TEST_ENUM
+
} OPTION_CHOICE
;
- if (!isdigit(c))
- return 0;
- ret *= 10;
- ret += (c - '0');
- }
- *result = ret;
- return 1;
+const OPTIONS *test_get_options(void)
+{
+ static const OPTIONS test_options[] = {
+ OPT_TEST_OPTIONS_DEFAULT_USAGE,
+ { "num", OPT_NUM_REPEATS, 'M', "Number of repeats" },
+ { NULL }
+ };
+ return test_options;
}
/*
}
/*
@@
-125,22
+125,27
@@
static int atoi64(const char *in, int64_t *result)
*/
int setup_tests(void)
{
*/
int setup_tests(void)
{
-
const char *p
;
+
OPTION_CHOICE o
;
- if (!
atoi64
(NUM_REPEATS, &num_repeats)) {
+ if (!
opt_imax
(NUM_REPEATS, &num_repeats)) {
TEST_error("Cannot parse " NUM_REPEATS);
return 0;
}
TEST_error("Cannot parse " NUM_REPEATS);
return 0;
}
- /*
- * TODO(openssl-team): code under test/ should be able to reuse the option
- * parsing framework currently in apps/.
- */
- p = test_get_option_argument("-num");
- if (p != NULL) {
- if (!atoi64(p, &num_repeats)
- || num_repeats < 0)
+
+ while ((o = opt_next()) != OPT_EOF) {
+ switch (o) {
+ case OPT_NUM_REPEATS:
+ if (!opt_imax(opt_arg(), &num_repeats)
+ || num_repeats < 0)
+ return 0;
+ print_mode = 1;
+ break;
+ case OPT_TEST_CASES:
+ break;
+ default:
+ case OPT_ERR:
return 0;
return 0;
- print_mode = 1;
+ }
}
#ifndef OPENSSL_NO_EC
}
#ifndef OPENSSL_NO_EC