forked from wolfSSL/wolfssl
ntru keygen is indepedent of additional cyassl keygen, use cyassl types, correct ntru benchmark output
This commit is contained in:
@@ -226,9 +226,10 @@ int benchmark_test(void *args)
|
|||||||
|
|
||||||
#if defined(CYASSL_KEY_GEN) && !defined(NO_RSA)
|
#if defined(CYASSL_KEY_GEN) && !defined(NO_RSA)
|
||||||
bench_rsaKeyGen();
|
bench_rsaKeyGen();
|
||||||
#ifdef HAVE_NTRU
|
#endif
|
||||||
bench_ntruKeyGen();
|
|
||||||
#endif
|
#ifdef HAVE_NTRU
|
||||||
|
bench_ntruKeyGen();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_ECC
|
#ifdef HAVE_ECC
|
||||||
@@ -1063,7 +1064,7 @@ void bench_ntruKeyGen(void)
|
|||||||
byte public_key[5951]; /* 2048 key equivalent to rsa */
|
byte public_key[5951]; /* 2048 key equivalent to rsa */
|
||||||
word16 public_key_len;
|
word16 public_key_len;
|
||||||
byte private_key[5951];
|
byte private_key[5951];
|
||||||
word16 private_key_len;
|
word16 private_key_len = sizeof(private_key);
|
||||||
|
|
||||||
DRBG_HANDLE drbg;
|
DRBG_HANDLE drbg;
|
||||||
static uint8_t const pers_str[] = {
|
static uint8_t const pers_str[] = {
|
||||||
@@ -1080,10 +1081,8 @@ void bench_ntruKeyGen(void)
|
|||||||
start = current_time(1);
|
start = current_time(1);
|
||||||
|
|
||||||
for(i = 0; i < genTimes; i++) {
|
for(i = 0; i < genTimes; i++) {
|
||||||
ntru_crypto_ntru_encrypt_keygen(drbg, NTRU_EES401EP2,
|
ntru_crypto_ntru_encrypt_keygen(drbg, NTRU_EES401EP2, &public_key_len,
|
||||||
&public_key_len, NULL, &private_key_len, NULL);
|
public_key, &private_key_len, private_key);
|
||||||
ntru_crypto_ntru_encrypt_keygen(drbg, NTRU_EES401EP2,
|
|
||||||
&public_key_len, public_key, &private_key_len, private_key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
total = current_time(0) - start;
|
total = current_time(0) - start;
|
||||||
@@ -1099,7 +1098,7 @@ void bench_ntruKeyGen(void)
|
|||||||
milliEach = each * 1000;
|
milliEach = each * 1000;
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("NTRU 2048 key generation %6.3f milliseconds, avg over %d"
|
printf("NTRU 112 key generation %6.3f milliseconds, avg over %d"
|
||||||
" iterations\n", milliEach, genTimes);
|
" iterations\n", milliEach, genTimes);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1662,16 +1662,14 @@ static int GetKey(DecodedCert* cert)
|
|||||||
byte* next = (byte*)key;
|
byte* next = (byte*)key;
|
||||||
word16 keyLen;
|
word16 keyLen;
|
||||||
word32 rc;
|
word32 rc;
|
||||||
|
word32 remaining = cert->maxIdx - cert->srcIdx;
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef CYASSL_SMALL_STACK
|
||||||
byte* keyBlob = NULL;
|
byte* keyBlob = NULL;
|
||||||
#else
|
#else
|
||||||
byte keyBlob[MAX_NTRU_KEY_SZ];
|
byte keyBlob[MAX_NTRU_KEY_SZ];
|
||||||
#endif
|
#endif
|
||||||
uint32_t remaining = (uint32_t)cert->maxIdx - cert->srcIdx;
|
|
||||||
|
|
||||||
rc = ntru_crypto_ntru_encrypt_subjectPublicKeyInfo2PublicKey(key,
|
rc = ntru_crypto_ntru_encrypt_subjectPublicKeyInfo2PublicKey(key,
|
||||||
&keyLen, NULL, &next, &remaining);
|
&keyLen, NULL, &next, &remaining);
|
||||||
|
|
||||||
if (rc != NTRU_OK)
|
if (rc != NTRU_OK)
|
||||||
return ASN_NTRU_KEY_E;
|
return ASN_NTRU_KEY_E;
|
||||||
if (keyLen > MAX_NTRU_KEY_SZ)
|
if (keyLen > MAX_NTRU_KEY_SZ)
|
||||||
|
Reference in New Issue
Block a user