1 #include "curve25519-donna.h"
2 
3 #if !defined(CURVE25519_SUFFIX)
4 #define CURVE25519_SUFFIX
5 #endif
6 
7 #define CURVE25519_FN3(fn,suffix) fn##suffix
8 #define CURVE25519_FN2(fn,suffix) CURVE25519_FN3(fn,suffix)
9 #define CURVE25519_FN(fn)         CURVE25519_FN2(fn,CURVE25519_SUFFIX)
10 
11 void
CURVE25519_FN(curve25519_donna)12 CURVE25519_FN(curve25519_donna) (curve25519_key mypublic, const curve25519_key secret, const curve25519_key basepoint) {
13 	curve25519_key e;
14 	size_t i;
15 
16 	for (i = 0;i < 32;++i) e[i] = secret[i];
17 	e[0] &= 0xf8;
18 	e[31] &= 0x7f;
19 	e[31] |= 0x40;
20 	curve25519_scalarmult_donna(mypublic, e, basepoint);
21 }
22 
23 void
CURVE25519_FN(curve25519_donna_basepoint)24 CURVE25519_FN(curve25519_donna_basepoint) (curve25519_key mypublic, const curve25519_key secret) {
25 	static const curve25519_key basepoint = {9};
26 	CURVE25519_FN(curve25519_donna)(mypublic, secret, basepoint);
27 }
28