1 /* This file can be used to test whether the code handles non-canonical curve
2 * points (i.e. points with the 256th bit set) in the same way as the reference
9 extern void curve25519_donna(unsigned char *output, const unsigned char *a,
10 const unsigned char *b);
14 static const uint8_t point1[32] = {
15 0x25,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
16 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
17 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
18 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
20 static const uint8_t point2[32] = {
21 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
22 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
23 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
24 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
26 static const uint8_t scalar[32] = { 1 };
27 uint8_t out1[32], out2[32];
29 curve25519_donna(out1, scalar, point1);
30 curve25519_donna(out2, scalar, point2);
32 if (0 == memcmp(out1, out2, sizeof(out1))) {
33 fprintf(stderr, "Top bit not ignored.\n");
37 fprintf(stderr, "Top bit correctly ignored.\n");