1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-23 20:15:19 -07:00

Simplify scalarmult{2,5} tests

This commit is contained in:
Frank Denis 2020-04-26 20:06:51 +02:00
parent 7e2755166a
commit 26a7c82033
4 changed files with 13 additions and 37 deletions

View File

@ -8,25 +8,16 @@ static unsigned char bobsk[32] = { 0x5d, 0xab, 0x08, 0x7e, 0x62, 0x4a, 0x8a,
0x18, 0xb6, 0xfd, 0x1c, 0x2f, 0x8b, 0x27,
0xff, 0x88, 0xe0, 0xeb };
static unsigned char bobpk[32];
int
main(void)
{
unsigned char bobpk[32];
char hex[65];
int i;
crypto_scalarmult_base(bobpk, bobsk);
sodium_bin2hex(hex, sizeof hex, bobpk, sizeof bobpk);
printf("%s\n", hex);
for (i = 0; i < 32; ++i) {
if (i > 0) {
printf(",");
} else {
printf(" ");
}
printf("0x%02x", (unsigned int) bobpk[i]);
if (i % 8 == 7) {
printf("\n");
}
}
return 0;
}

View File

@ -1,4 +1 @@
0xde,0x9e,0xdb,0x7d,0x7b,0x7d,0xc1,0xb4
,0xd3,0x5b,0x61,0xc2,0xec,0xe4,0x35,0x37
,0x3f,0x83,0x43,0xc8,0x5b,0x78,0x67,0x4d
,0xad,0xfc,0x7e,0x14,0x6f,0x88,0x2b,0x4f
de9edb7d7b7dc1b4d35b61c2ece435373f8343c85b78674dadfc7e146f882b4f

View File

@ -14,27 +14,18 @@ static unsigned char bobpk[32] = { 0xde, 0x9e, 0xdb, 0x7d, 0x7b, 0x7d, 0xc1,
0x78, 0x67, 0x4d, 0xad, 0xfc, 0x7e, 0x14,
0x6f, 0x88, 0x2b, 0x4f };
static unsigned char k[32];
int
main(void)
{
unsigned char k[32];
char hex[65];
int i;
int ret;
ret = crypto_scalarmult(k, alicesk, bobpk);
assert(ret == 0);
sodium_bin2hex(hex, sizeof hex, k, sizeof k);
printf("%s\n", hex);
for (i = 0; i < 32; ++i) {
if (i > 0) {
printf(",");
} else {
printf(" ");
}
printf("0x%02x", (unsigned int) k[i]);
if (i % 8 == 7) {
printf("\n");
}
}
return 0;
}

View File

@ -1,4 +1 @@
0x4a,0x5d,0x9d,0x5b,0xa4,0xce,0x2d,0xe1
,0x72,0x8e,0x3b,0xf4,0x80,0x35,0x0f,0x25
,0xe0,0x7e,0x21,0xc9,0x47,0xd1,0x9e,0x33
,0x76,0xf0,0x9b,0x3c,0x1e,0x16,0x17,0x42
4a5d9d5ba4ce2de1728e3bf480350f25e07e21c947d19e3376f09b3c1e161742