1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-20 02:25:14 -07:00

Re-merge previous test; add the correct prime

This commit is contained in:
Frank Denis 2017-11-15 15:25:33 +01:00
parent d8c36842eb
commit 4fe7f88063

View File

@ -1,6 +1,26 @@
#define TEST_NAME "core_ed25519" #define TEST_NAME "core_ed25519"
#include "cmptest.h" #include "cmptest.h"
static void
add_P(unsigned char * const S)
{
static const unsigned char P[32] = {
0xed, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f
};
unsigned char c = 0U;
unsigned int i;
unsigned int s;
for (i = 0U; i < 32U; i++) {
s = S[i] + P[i] + c;
S[i] = (unsigned char) s;
c = (s >> 8) & 1;
}
}
int int
main(void) main(void)
{ {
@ -63,6 +83,8 @@ main(void)
} }
assert(crypto_core_ed25519_is_valid_point(p) == 1); assert(crypto_core_ed25519_is_valid_point(p) == 1);
add_P(p);
assert(crypto_core_ed25519_is_valid_point(p) == 0);
memset(p, 0, crypto_core_ed25519_BYTES); memset(p, 0, crypto_core_ed25519_BYTES);
assert(crypto_core_ed25519_is_valid_point(p) == 0); assert(crypto_core_ed25519_is_valid_point(p) == 0);