/*
- * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
*
* Licensed under the OpenSSL license (the "License"). You may not use
#include <string.h>
#include <math.h>
#include "apps.h"
+#include "progs.h"
#include <openssl/crypto.h>
#include <openssl/rand.h>
#include <openssl/err.h>
#define RSA_NUM 7
#define DSA_NUM 3
-#define EC_NUM 17
+#define EC_NUM 18
#define MAX_ECDH_SIZE 256
#define MISALIGN 64
-typedef struct sec_st {
+typedef struct openssl_speed_sec_st {
int sym;
int rsa;
int dsa;
int ecdsa;
int ecdh;
-} SEC;
+} openssl_speed_sec_t;
static volatile int run = 0;
#endif
static void multiblock_speed(const EVP_CIPHER *evp_cipher,
- const SEC *seconds);
+ const openssl_speed_sec_t *seconds);
static int found(const char *name, const OPT_PAIR *pairs, int *result)
{
#define R_EC_B409 14
#define R_EC_B571 15
#define R_EC_X25519 16
+#define R_EC_X448 17
#ifndef OPENSSL_NO_EC
static OPT_PAIR ecdsa_choices[] = {
{"ecdsap160", R_EC_P160},
{"ecdhb409", R_EC_B409},
{"ecdhb571", R_EC_B571},
{"ecdhx25519", R_EC_X25519},
+ {"ecdhx448", R_EC_X448},
{NULL}
};
#endif
long count = 0;
int size_num = OSSL_NELEM(lengths_list);
int keylen;
+ int buflen;
#ifndef NO_FORK
int multi = 0;
#endif
|| !defined(OPENSSL_NO_EC)
long rsa_count = 1;
#endif
+#ifndef OPENSSL_NO_EC
+ size_t loop;
+#endif
/* What follows are the buffers and key material. */
#ifndef OPENSSL_NO_RC5
NID_sect233r1, NID_sect283r1, NID_sect409r1,
NID_sect571r1,
/* Other */
- NID_X25519
+ NID_X25519, NID_X448
};
static const char *test_curves_names[EC_NUM] = {
/* Prime Curves */
"nistb233", "nistb283", "nistb409",
"nistb571",
/* Other */
- "X25519"
+ "X25519", "X448"
};
static const int test_curves_bits[EC_NUM] = {
160, 192, 224,
163, 233, 283,
409, 571, 163,
233, 283, 409,
- 571, 253 /* X25519 */
+ 571, 253, 448
};
int ecdsa_doit[EC_NUM] = { 0 };
int ecdh_doit[EC_NUM] = { 0 };
#endif /* ndef OPENSSL_NO_EC */
- SEC seconds = {SECONDS, RSA_SECONDS, DSA_SECONDS, ECDSA_SECONDS,
- ECDH_SECONDS};
+ openssl_speed_sec_t seconds = { SECONDS, RSA_SECONDS, DSA_SECONDS,
+ ECDSA_SECONDS, ECDH_SECONDS };
prog = opt_init(argc, argv, speed_options);
while ((o = opt_next()) != OPT_EOF) {
#endif
#ifndef OPENSSL_NO_EC
if (strcmp(*argv, "ecdsa") == 0) {
- for (i = 0; i < EC_NUM; i++)
- ecdsa_doit[i] = 1;
+ for (loop = 0; loop < OSSL_NELEM(ecdsa_choices); loop++)
+ ecdsa_doit[ecdsa_choices[loop].retval] = 1;
continue;
}
if (found(*argv, ecdsa_choices, &i)) {
continue;
}
if (strcmp(*argv, "ecdh") == 0) {
- for (i = 0; i < EC_NUM; i++)
- ecdh_doit[i] = 1;
+ for (loop = 0; loop < OSSL_NELEM(ecdh_choices); loop++)
+ ecdh_doit[ecdh_choices[loop].retval] = 1;
continue;
}
if (found(*argv, ecdh_choices, &i)) {
}
}
- loopargs[i].buf_malloc =
- app_malloc(lengths[size_num - 1] + MAX_MISALIGNMENT + 1,
- "input buffer");
- loopargs[i].buf2_malloc =
- app_malloc(lengths[size_num - 1] + MAX_MISALIGNMENT + 1,
- "input buffer");
+ buflen = lengths[size_num - 1] + MAX_MISALIGNMENT + 1;
+ loopargs[i].buf_malloc = app_malloc(buflen, "input buffer");
+ loopargs[i].buf2_malloc = app_malloc(buflen, "input buffer");
+ memset(loopargs[i].buf_malloc, 0, buflen);
+ memset(loopargs[i].buf2_malloc, 0, buflen);
+
/* Align the start of buffers on a 64 byte boundary */
loopargs[i].buf = loopargs[i].buf_malloc + misalign;
loopargs[i].buf2 = loopargs[i].buf2_malloc + misalign;
dsa_doit[i] = 1;
#endif
#ifndef OPENSSL_NO_EC
- for (i = 0; i < EC_NUM; i++)
- ecdsa_doit[i] = 1;
- for (i = 0; i < EC_NUM; i++)
- ecdh_doit[i] = 1;
+ for (loop = 0; loop < OSSL_NELEM(ecdsa_choices); loop++)
+ ecdsa_doit[ecdsa_choices[loop].retval] = 1;
+ for (loop = 0; loop < OSSL_NELEM(ecdh_choices); loop++)
+ ecdh_doit[ecdh_choices[loop].retval] = 1;
#endif
}
for (i = 0; i < ALGOR_NUM; i++)
}
#endif
-static void multiblock_speed(const EVP_CIPHER *evp_cipher, const SEC *seconds)
+static void multiblock_speed(const EVP_CIPHER *evp_cipher,
+ const openssl_speed_sec_t *seconds)
{
static const int mblengths_list[] =
{ 8 * 1024, 2 * 8 * 1024, 4 * 8 * 1024, 8 * 8 * 1024, 8 * 16 * 1024 };