Merge branch 'master' of github.com:cyassl/cyassl
This commit is contained in:
commit
6bdbc83924
@ -221,13 +221,13 @@ int benchmark_test(void *args)
|
|||||||
#ifdef BENCH_EMBEDDED
|
#ifdef BENCH_EMBEDDED
|
||||||
const int numBlocks = 25; /* how many kB/megs to test (en/de)cryption */
|
const int numBlocks = 25; /* how many kB/megs to test (en/de)cryption */
|
||||||
const char blockType[] = "kB"; /* used in printf output */
|
const char blockType[] = "kB"; /* used in printf output */
|
||||||
const int times = 1; /* public key iterations */
|
const int ntimes = 1; /* public key iterations */
|
||||||
const int genTimes = 5;
|
const int genTimes = 5;
|
||||||
const int agreeTimes = 5;
|
const int agreeTimes = 5;
|
||||||
#else
|
#else
|
||||||
const int numBlocks = 5;
|
const int numBlocks = 5;
|
||||||
const char blockType[] = "megs";
|
const char blockType[] = "megs";
|
||||||
const int times = 100;
|
const int ntimes = 100;
|
||||||
const int genTimes = 100;
|
const int genTimes = 100;
|
||||||
const int agreeTimes = 100;
|
const int agreeTimes = 100;
|
||||||
#endif
|
#endif
|
||||||
@ -742,15 +742,15 @@ void bench_rsa(void)
|
|||||||
|
|
||||||
start = current_time(1);
|
start = current_time(1);
|
||||||
|
|
||||||
for (i = 0; i < times; i++)
|
for (i = 0; i < ntimes; i++)
|
||||||
ret = RsaPublicEncrypt(message,len,enc,sizeof(enc), &rsaKey, &rng);
|
ret = RsaPublicEncrypt(message,len,enc,sizeof(enc), &rsaKey, &rng);
|
||||||
|
|
||||||
total = current_time(0) - start;
|
total = current_time(0) - start;
|
||||||
each = total / times; /* per second */
|
each = total / ntimes; /* per second */
|
||||||
milliEach = each * 1000; /* milliseconds */
|
milliEach = each * 1000; /* milliseconds */
|
||||||
|
|
||||||
printf("RSA %d encryption took %6.2f milliseconds, avg over %d"
|
printf("RSA %d encryption took %6.2f milliseconds, avg over %d"
|
||||||
" iterations\n", rsaKeySz, milliEach, times);
|
" iterations\n", rsaKeySz, milliEach, ntimes);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
printf("Rsa Public Encrypt failed\n");
|
printf("Rsa Public Encrypt failed\n");
|
||||||
@ -759,17 +759,17 @@ void bench_rsa(void)
|
|||||||
|
|
||||||
start = current_time(1);
|
start = current_time(1);
|
||||||
|
|
||||||
for (i = 0; i < times; i++) {
|
for (i = 0; i < ntimes; i++) {
|
||||||
byte out[512]; /* for up to 4096 bit */
|
byte out[512]; /* for up to 4096 bit */
|
||||||
RsaPrivateDecrypt(enc, (word32)ret, out, sizeof(out), &rsaKey);
|
RsaPrivateDecrypt(enc, (word32)ret, out, sizeof(out), &rsaKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
total = current_time(0) - start;
|
total = current_time(0) - start;
|
||||||
each = total / times; /* per second */
|
each = total / ntimes; /* per second */
|
||||||
milliEach = each * 1000; /* milliseconds */
|
milliEach = each * 1000; /* milliseconds */
|
||||||
|
|
||||||
printf("RSA %d decryption took %6.2f milliseconds, avg over %d"
|
printf("RSA %d decryption took %6.2f milliseconds, avg over %d"
|
||||||
" iterations\n", rsaKeySz, milliEach, times);
|
" iterations\n", rsaKeySz, milliEach, ntimes);
|
||||||
|
|
||||||
FreeRsaKey(&rsaKey);
|
FreeRsaKey(&rsaKey);
|
||||||
#ifdef HAVE_CAVIUM
|
#ifdef HAVE_CAVIUM
|
||||||
@ -847,28 +847,28 @@ void bench_dh(void)
|
|||||||
|
|
||||||
start = current_time(1);
|
start = current_time(1);
|
||||||
|
|
||||||
for (i = 0; i < times; i++)
|
for (i = 0; i < ntimes; i++)
|
||||||
DhGenerateKeyPair(&dhKey, &rng, priv, &privSz, pub, &pubSz);
|
DhGenerateKeyPair(&dhKey, &rng, priv, &privSz, pub, &pubSz);
|
||||||
|
|
||||||
total = current_time(0) - start;
|
total = current_time(0) - start;
|
||||||
each = total / times; /* per second */
|
each = total / ntimes; /* per second */
|
||||||
milliEach = each * 1000; /* milliseconds */
|
milliEach = each * 1000; /* milliseconds */
|
||||||
|
|
||||||
printf("DH %d key generation %6.2f milliseconds, avg over %d"
|
printf("DH %d key generation %6.2f milliseconds, avg over %d"
|
||||||
" iterations\n", dhKeySz, milliEach, times);
|
" iterations\n", dhKeySz, milliEach, ntimes);
|
||||||
|
|
||||||
DhGenerateKeyPair(&dhKey, &rng, priv2, &privSz2, pub2, &pubSz2);
|
DhGenerateKeyPair(&dhKey, &rng, priv2, &privSz2, pub2, &pubSz2);
|
||||||
start = current_time(1);
|
start = current_time(1);
|
||||||
|
|
||||||
for (i = 0; i < times; i++)
|
for (i = 0; i < ntimes; i++)
|
||||||
DhAgree(&dhKey, agree, &agreeSz, priv, privSz, pub2, pubSz2);
|
DhAgree(&dhKey, agree, &agreeSz, priv, privSz, pub2, pubSz2);
|
||||||
|
|
||||||
total = current_time(0) - start;
|
total = current_time(0) - start;
|
||||||
each = total / times; /* per second */
|
each = total / ntimes; /* per second */
|
||||||
milliEach = each * 1000; /* milliseconds */
|
milliEach = each * 1000; /* milliseconds */
|
||||||
|
|
||||||
printf("DH %d key agreement %6.2f milliseconds, avg over %d"
|
printf("DH %d key agreement %6.2f milliseconds, avg over %d"
|
||||||
" iterations\n", dhKeySz, milliEach, times);
|
" iterations\n", dhKeySz, milliEach, ntimes);
|
||||||
|
|
||||||
#if !defined(USE_CERT_BUFFERS_1024) && !defined(USE_CERT_BUFFERS_2048)
|
#if !defined(USE_CERT_BUFFERS_1024) && !defined(USE_CERT_BUFFERS_2048)
|
||||||
fclose(file);
|
fclose(file);
|
||||||
@ -1087,7 +1087,22 @@ void bench_eccKeyAgree(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#elif defined CYASSL_MDK_ARM
|
#elif defined CYASSL_MDK_ARM
|
||||||
|
|
||||||
extern double current_time(int reset) ;
|
extern double current_time(int reset) ;
|
||||||
|
|
||||||
|
#elif defined FREERTOS
|
||||||
|
|
||||||
|
double current_time(int reset)
|
||||||
|
{
|
||||||
|
(void) reset;
|
||||||
|
|
||||||
|
portTickType tickCount;
|
||||||
|
|
||||||
|
/* tick count == ms, if configTICK_RATE_HZ is set to 1000 */
|
||||||
|
tickCount = xTaskGetTickCount();
|
||||||
|
return (double)tickCount / 1000;
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
@ -3226,6 +3226,8 @@ static void DecodeCertExtensions(DecodedCert* cert)
|
|||||||
word32 oid;
|
word32 oid;
|
||||||
byte critical;
|
byte critical;
|
||||||
|
|
||||||
|
(void)critical;
|
||||||
|
|
||||||
CYASSL_ENTER("DecodeCertExtensions");
|
CYASSL_ENTER("DecodeCertExtensions");
|
||||||
|
|
||||||
if (input == NULL || sz == 0) return;
|
if (input == NULL || sz == 0) return;
|
||||||
@ -4266,12 +4268,16 @@ static int SetName(byte* output, CertName* name)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* joint id */
|
/* joint id */
|
||||||
|
byte bType = GetNameId(i);
|
||||||
names[i].encoded[idx++] = 0x55;
|
names[i].encoded[idx++] = 0x55;
|
||||||
names[i].encoded[idx++] = 0x04;
|
names[i].encoded[idx++] = 0x04;
|
||||||
/* id type */
|
/* id type */
|
||||||
names[i].encoded[idx++] = GetNameId(i);
|
names[i].encoded[idx++] = bType;
|
||||||
/* str type */
|
/* str type */
|
||||||
names[i].encoded[idx++] = 0x13;
|
if (bType == ASN_COUNTRY_NAME)
|
||||||
|
names[i].encoded[idx++] = 0x13; /* printable */
|
||||||
|
else
|
||||||
|
names[i].encoded[idx++] = 0x0c; /* utf8 */
|
||||||
}
|
}
|
||||||
/* second length */
|
/* second length */
|
||||||
XMEMCPY(names[i].encoded + idx, secondLen, secondSz);
|
XMEMCPY(names[i].encoded + idx, secondLen, secondSz);
|
||||||
@ -4597,7 +4603,7 @@ int MakeNtruCert(Cert* cert, byte* derBuffer, word32 derSz,
|
|||||||
#endif /* HAVE_NTRU */
|
#endif /* HAVE_NTRU */
|
||||||
|
|
||||||
|
|
||||||
int SignCert(int requestSz, int sigType, byte* buffer, word32 buffSz,
|
int SignCert(int requestSz, int sType, byte* buffer, word32 buffSz,
|
||||||
RsaKey* rsaKey, ecc_key* eccKey, RNG* rng)
|
RsaKey* rsaKey, ecc_key* eccKey, RNG* rng)
|
||||||
{
|
{
|
||||||
byte sig[MAX_ENCODED_SIG_SZ];
|
byte sig[MAX_ENCODED_SIG_SZ];
|
||||||
@ -4607,14 +4613,14 @@ int SignCert(int requestSz, int sigType, byte* buffer, word32 buffSz,
|
|||||||
return requestSz;
|
return requestSz;
|
||||||
|
|
||||||
sigSz = MakeSignature(buffer, requestSz, sig, sizeof(sig), rsaKey, eccKey,
|
sigSz = MakeSignature(buffer, requestSz, sig, sizeof(sig), rsaKey, eccKey,
|
||||||
rng, sigType);
|
rng, sType);
|
||||||
if (sigSz < 0)
|
if (sigSz < 0)
|
||||||
return sigSz;
|
return sigSz;
|
||||||
|
|
||||||
if (requestSz + MAX_SEQ_SZ * 2 + sigSz > (int)buffSz)
|
if (requestSz + MAX_SEQ_SZ * 2 + sigSz > (int)buffSz)
|
||||||
return BUFFER_E;
|
return BUFFER_E;
|
||||||
|
|
||||||
return AddSignature(buffer, requestSz, sig, sigSz, sigType);
|
return AddSignature(buffer, requestSz, sig, sigSz, sType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user