Fix Curve25519 test

This commit is contained in:
Ludovic FLAMENT 2015-08-03 09:05:02 +02:00 committed by Jacob Barthelmeh
parent d050c10581
commit aa0852bf71
1 changed files with 8 additions and 0 deletions

View File

@ -5461,9 +5461,11 @@ int curve25519_test(void)
return -1003;
/* find shared secret key */
x = sizeof(sharedA);
if (wc_curve25519_shared_secret(&userA, &userB, sharedA, &x) != 0)
return -1004;
y = sizeof(sharedB);
if (wc_curve25519_shared_secret(&userB, &userA, sharedB, &y) != 0)
return -1005;
@ -5475,6 +5477,7 @@ int curve25519_test(void)
return -1007;
/* export a public key and import it for another user */
x = sizeof(exportBuf);
if (wc_curve25519_export_public(&userA, exportBuf, &x) != 0)
return -1008;
@ -5483,6 +5486,7 @@ int curve25519_test(void)
/* test shared key after importing a public key */
XMEMSET(sharedB, 0, sizeof(sharedB));
y = sizeof(sharedB);
if (wc_curve25519_shared_secret(&userB, &pubKey, sharedB, &y) != 0)
return -1010;
@ -5500,6 +5504,7 @@ int curve25519_test(void)
/* test against known test vector */
XMEMSET(sharedB, 0, sizeof(sharedB));
y = sizeof(sharedB);
if (wc_curve25519_shared_secret(&userA, &userB, sharedB, &y) != 0)
return -1014;
@ -5508,6 +5513,7 @@ int curve25519_test(void)
/* test swaping roles of keys and generating same shared key */
XMEMSET(sharedB, 0, sizeof(sharedB));
y = sizeof(sharedB);
if (wc_curve25519_shared_secret(&userB, &userA, sharedB, &y) != 0)
return -1016;
@ -5522,9 +5528,11 @@ int curve25519_test(void)
if (wc_curve25519_make_key(&rng, 32, &userB) != 0)
return -1019;
x = sizeof(sharedA);
if (wc_curve25519_shared_secret(&userA, &userB, sharedA, &x) != 0)
return -1020;
y = sizeof(sharedB);
if (wc_curve25519_shared_secret(&userB, &userA, sharedB, &y) != 0)
return -1021;