#ifndef OPENSSL_NO_MD5
# include <openssl/md5.h>
#endif
-#ifndef OPENSSL_NO_HMAC
# include <openssl/hmac.h>
-#endif
#include <openssl/evp.h>
# include <openssl/sha.h>
#ifndef OPENSSL_NO_RMD160
# include <openssl/dsa.h>
# include "./testdsa.h"
#endif
-#ifndef OPENSSL_NO_ECDSA
+#ifndef OPENSSL_NO_EC
# include <openssl/ecdsa.h>
-#endif
-#ifndef OPENSSL_NO_ECDH
# include <openssl/ecdh.h>
#endif
#include <openssl/modes.h>
#ifndef OPENSSL_NO_DSA
static double dsa_results[DSA_NUM][2];
#endif
-#ifndef OPENSSL_NO_ECDSA
+#ifndef OPENSSL_NO_EC
static double ecdsa_results[EC_NUM][2];
-#endif
-#ifndef OPENSSL_NO_ECDH
static double ecdh_results[EC_NUM][1];
#endif
-#if defined(OPENSSL_NO_DSA) && !(defined(OPENSSL_NO_ECDSA) && defined(OPENSSL_NO_ECDH))
+#if defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_EC)
static const char rnd_seed[] =
"string to make the random number generator think it has entropy";
static int rnd_fake = 0;
}
#endif
-#ifndef OPENSSL_NO_ECDH
+#ifndef OPENSSL_NO_EC
static const int KDF1_SHA1_len = 20;
static void *KDF1_SHA1(const void *in, size_t inlen, void *out,
size_t *outlen)
*outlen = SHA_DIGEST_LENGTH;
return SHA1(in, inlen, out);
}
-#endif /* OPENSSL_NO_ECDH */
+#endif /* OPENSSL_NO_EC */
static void multiblock_speed(const EVP_CIPHER *evp_cipher);
#endif
-#ifndef OPENSSL_NO_ECDSA
+#ifndef OPENSSL_NO_EC
unsigned char ecdsasig[256];
unsigned int ecdsasiglen;
EC_KEY *ecdsa[EC_NUM];
long ecdsa_c[EC_NUM][2];
-#endif
-
-#ifndef OPENSSL_NO_ECDH
EC_KEY *ecdh_a[EC_NUM], *ecdh_b[EC_NUM];
unsigned char secret_a[MAX_ECDH_SIZE], secret_b[MAX_ECDH_SIZE];
int secret_size_a, secret_size_b;
int ecdh_checks = 0;
int secret_idx = 0;
long ecdh_c[EC_NUM][2];
+ int ecdsa_doit[EC_NUM];
+ int ecdh_doit[EC_NUM];
#endif
int rsa_doit[RSA_NUM];
int dsa_doit[DSA_NUM];
-#ifndef OPENSSL_NO_ECDSA
- int ecdsa_doit[EC_NUM];
-#endif
-#ifndef OPENSSL_NO_ECDH
- int ecdh_doit[EC_NUM];
-#endif
int doit[ALGOR_NUM];
int pr_header = 0;
const EVP_CIPHER *evp_cipher = NULL;
#ifndef OPENSSL_NO_DSA
memset(dsa_key, 0, sizeof(dsa_key));
#endif
-#ifndef OPENSSL_NO_ECDSA
+#ifndef OPENSSL_NO_EC
for (i = 0; i < EC_NUM; i++)
ecdsa[i] = NULL;
-#endif
-#ifndef OPENSSL_NO_ECDH
for (i = 0; i < EC_NUM; i++) {
ecdh_a[i] = NULL;
ecdh_b[i] = NULL;
rsa_doit[i] = 0;
for (i = 0; i < DSA_NUM; i++)
dsa_doit[i] = 0;
-#ifndef OPENSSL_NO_ECDSA
+#ifndef OPENSSL_NO_EC
for (i = 0; i < EC_NUM; i++)
ecdsa_doit[i] = 0;
-#endif
-#ifndef OPENSSL_NO_ECDH
for (i = 0; i < EC_NUM; i++)
ecdh_doit[i] = 0;
#endif
else
#endif
#ifndef OPENSSL_NO_RSA
-# if 0 /* was: #ifdef RSAref */
- if (strcmp(*argv, "rsaref") == 0) {
- RSA_set_default_openssl_method(RSA_PKCS1_RSAref());
- j--;
- } else
-# endif
# ifndef RSA_NULL
if (strcmp(*argv, "openssl") == 0) {
RSA_set_default_method(RSA_PKCS1_SSLeay());
dsa_doit[R_DSA_2048] = 1;
} else
#endif
-#ifndef OPENSSL_NO_ECDSA
+#ifndef OPENSSL_NO_EC
if (strcmp(*argv, "ecdsap160") == 0)
ecdsa_doit[R_EC_P160] = 2;
else if (strcmp(*argv, "ecdsap192") == 0)
else if (strcmp(*argv, "ecdsa") == 0) {
for (i = 0; i < EC_NUM; i++)
ecdsa_doit[i] = 1;
- } else
-#endif
-#ifndef OPENSSL_NO_ECDH
- if (strcmp(*argv, "ecdhp160") == 0)
+ } else if (strcmp(*argv, "ecdhp160") == 0)
ecdh_doit[R_EC_P160] = 2;
else if (strcmp(*argv, "ecdhp192") == 0)
ecdh_doit[R_EC_P192] = 2;
#endif
#ifndef OPENSSL_NO_MD5
BIO_printf(bio_err, "md5 ");
-# ifndef OPENSSL_NO_HMAC
BIO_printf(bio_err, "hmac ");
-# endif
#endif
BIO_printf(bio_err, "sha1 ");
BIO_printf(bio_err, "sha256 ");
#ifndef OPENSSL_NO_DSA
BIO_printf(bio_err, "dsa512 dsa1024 dsa2048\n");
#endif
-#ifndef OPENSSL_NO_ECDSA
+#ifndef OPENSSL_NO_EC
BIO_printf(bio_err, "ecdsap160 ecdsap192 ecdsap224 "
"ecdsap256 ecdsap384 ecdsap521\n");
BIO_printf(bio_err,
BIO_printf(bio_err,
"ecdsab163 ecdsab233 ecdsab283 ecdsab409 ecdsab571\n");
BIO_printf(bio_err, "ecdsa\n");
-#endif
-#ifndef OPENSSL_NO_ECDH
BIO_printf(bio_err, "ecdhp160 ecdhp192 ecdhp224 "
"ecdhp256 ecdhp384 ecdhp521\n");
BIO_printf(bio_err,
rsa_doit[i] = 1;
for (i = 0; i < DSA_NUM; i++)
dsa_doit[i] = 1;
-#ifndef OPENSSL_NO_ECDSA
+#ifndef OPENSSL_NO_EC
for (i = 0; i < EC_NUM; i++)
ecdsa_doit[i] = 1;
-#endif
-#ifndef OPENSSL_NO_ECDH
for (i = 0; i < EC_NUM; i++)
ecdh_doit[i] = 1;
#endif
i);
goto end;
}
-# if 0
- else {
- BIO_printf(bio_err,
- mr ? "+RK:%d:"
- : "Loaded RSA key, %d bit modulus and e= 0x",
- BN_num_bits(rsa_key[i]->n));
- BN_print(bio_err, rsa_key[i]->e);
- BIO_printf(bio_err, "\n");
- }
-# endif
}
#endif
}
# endif
-# ifndef OPENSSL_NO_ECDSA
+# ifndef OPENSSL_NO_EC
ecdsa_c[R_EC_P160][0] = count / 1000;
ecdsa_c[R_EC_P160][1] = count / 1000 / 2;
for (i = R_EC_P192; i <= R_EC_P521; i++) {
}
}
}
-# endif
-
-# ifndef OPENSSL_NO_ECDH
ecdh_c[R_EC_P160][0] = count / 1000;
ecdh_c[R_EC_P160][1] = count / 1000;
for (i = R_EC_P192; i <= R_EC_P521; i++) {
}
#endif
-#if !defined(OPENSSL_NO_MD5) && !defined(OPENSSL_NO_HMAC)
+#if !defined(OPENSSL_NO_MD5)
if (doit[D_HMAC]) {
HMAC_CTX hctx;
}
#ifndef OPENSSL_SYS_WIN32
#endif
- RAND_pseudo_bytes(buf, 36);
+ RAND_bytes(buf, 36);
#ifndef OPENSSL_NO_RSA
for (j = 0; j < RSA_NUM; j++) {
int ret;
rsa_count = count;
}
-# if 1
ret = RSA_verify(NID_md5_sha1, buf, 36, buf2, rsa_num, rsa_key[j]);
if (ret <= 0) {
BIO_printf(bio_err,
count, rsa_bits[j], d);
rsa_results[j][1] = d / (double)count;
}
-# endif
if (rsa_count <= 1) {
/* if longer than 10s, don't do any more */
}
#endif
- RAND_pseudo_bytes(buf, 20);
+ RAND_bytes(buf, 20);
#ifndef OPENSSL_NO_DSA
if (RAND_status() != 1) {
RAND_seed(rnd_seed, sizeof rnd_seed);
RAND_cleanup();
#endif
-#ifndef OPENSSL_NO_ECDSA
+#ifndef OPENSSL_NO_EC
if (RAND_status() != 1) {
RAND_seed(rnd_seed, sizeof rnd_seed);
rnd_fake = 1;
ERR_print_errors(bio_err);
rsa_count = 1;
} else {
-# if 1
EC_KEY_precompute_mult(ecdsa[j], NULL);
-# endif
+
/* Perform ECDSA signature test */
EC_KEY_generate_key(ecdsa[j]);
ret = ECDSA_sign(0, buf, 20, ecdsasig, &ecdsasiglen, ecdsa[j]);
}
if (rnd_fake)
RAND_cleanup();
-#endif
-
-#ifndef OPENSSL_NO_ECDH
if (RAND_status() != 1) {
RAND_seed(rnd_seed, sizeof rnd_seed);
rnd_fake = 1;
1.0 / dsa_results[k][0], 1.0 / dsa_results[k][1]);
}
#endif
-#ifndef OPENSSL_NO_ECDSA
+#ifndef OPENSSL_NO_EC
j = 1;
for (k = 0; k < EC_NUM; k++) {
if (!ecdsa_doit[k])
ecdsa_results[k][0], ecdsa_results[k][1],
1.0 / ecdsa_results[k][0], 1.0 / ecdsa_results[k][1]);
}
-#endif
-
-#ifndef OPENSSL_NO_ECDH
j = 1;
for (k = 0; k < EC_NUM; k++) {
if (!ecdh_doit[k])
OPENSSL_free(buf2_malloc);
#ifndef OPENSSL_NO_RSA
for (i = 0; i < RSA_NUM; i++)
- if (rsa_key[i] != NULL)
- RSA_free(rsa_key[i]);
+ RSA_free(rsa_key[i]);
#endif
#ifndef OPENSSL_NO_DSA
for (i = 0; i < DSA_NUM; i++)
- if (dsa_key[i] != NULL)
- DSA_free(dsa_key[i]);
+ DSA_free(dsa_key[i]);
#endif
-#ifndef OPENSSL_NO_ECDSA
+#ifndef OPENSSL_NO_EC
for (i = 0; i < EC_NUM; i++)
if (ecdsa[i] != NULL)
EC_KEY_free(ecdsa[i]);
-#endif
-#ifndef OPENSSL_NO_ECDH
for (i = 0; i < EC_NUM; i++) {
if (ecdh_a[i] != NULL)
EC_KEY_free(ecdh_a[i]);
dsa_results[k][1] = d;
}
# endif
-# ifndef OPENSSL_NO_ECDSA
+# ifndef OPENSSL_NO_EC
else if (!strncmp(buf, "+F4:", 4)) {
int k;
double d;
else
ecdsa_results[k][1] = d;
}
-# endif
-
-# ifndef OPENSSL_NO_ECDH
else if (!strncmp(buf, "+F5:", 4)) {
int k;
double d;
inp = OPENSSL_malloc(mblengths[num - 1]);
out = OPENSSL_malloc(mblengths[num - 1] + 1024);
+ if(!inp || !out) {
+ BIO_printf(bio_err,"Out of memory\n");
+ goto end;
+ }
+
EVP_CIPHER_CTX_init(&ctx);
EVP_EncryptInit_ex(&ctx, evp_cipher, NULL, no_key, no_iv);
fprintf(stdout, "\n");
}
- OPENSSL_free(inp);
- OPENSSL_free(out);
+end:
+ if(inp)
+ OPENSSL_free(inp);
+ if(out)
+ OPENSSL_free(out);
}