| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
#include <stdint.h> |
| 6 |
#include <stdio.h> |
| 7 |
#include <string.h> |
| 8 |
|
| 9 |
extern void curve25519_donna(unsigned char *output, const unsigned char *a, |
| 10 |
const unsigned char *b); |
| 11 |
int |
| 12 |
main() |
| 13 |
{ |
| 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, |
| 19 |
}; |
| 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, |
| 25 |
}; |
| 26 |
static const uint8_t scalar[32] = { 1 }; |
| 27 |
uint8_t out1[32], out2[32]; |
| 28 |
|
| 29 |
curve25519_donna(out1, scalar, point1); |
| 30 |
curve25519_donna(out2, scalar, point2); |
| 31 |
|
| 32 |
if (0 == memcmp(out1, out2, sizeof(out1))) { |
| 33 |
fprintf(stderr, "Top bit not ignored.\n"); |
| 34 |
return 1; |
| 35 |
} |
| 36 |
|
| 37 |
fprintf(stderr, "Top bit correctly ignored.\n"); |
| 38 |
return 0; |
| 39 |
} |