From 4fe7f88063702d7209ff9d46c0f544391f813dcd Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Wed, 15 Nov 2017 15:25:33 +0100 Subject: [PATCH] Re-merge previous test; add the correct prime --- test/default/core_ed25519.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/default/core_ed25519.c b/test/default/core_ed25519.c index ba5dc947..824448c0 100644 --- a/test/default/core_ed25519.c +++ b/test/default/core_ed25519.c @@ -1,6 +1,26 @@ #define TEST_NAME "core_ed25519" #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 main(void) { @@ -63,6 +83,8 @@ main(void) } 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); assert(crypto_core_ed25519_is_valid_point(p) == 0);