OLD | NEW |
---|---|
(Empty) | |
1 See http://code.google.com/p/curve25519-donna/ for details. | |
Ryan Sleevi
2013/03/06 21:18:32
I do not believe you should be adding this to cryp
agl
2013/03/06 21:47:50
Alternatively, you can grab rev 234205ff from the
wtc
2013/03/07 03:28:39
I agree this is a good interim solution because Go
wtc
2013/03/07 03:28:39
I suggested crypto/third_party because I wanted to
| |
2 | |
3 BUILDING: | |
4 | |
5 If you run `make`, two .a archives will be built, similar to djb's curve25519 | |
6 code. Alternatively, read on: | |
7 | |
8 The C implementation is contained within curve25519-donna.c. It has no external | |
9 dependancies and is BSD licenced. You can copy/include/link it directly in with | |
10 your program. Recommended C flags: -O2 | |
11 | |
12 The x86-64 bit implementation is contained within curve25519-donna-x86-64.c and | |
13 curve25519-donna-x86-64.s. Build like this: | |
14 | |
15 % cpp curve25519-donna-x86-64.s > curve25519-donna-x86-64.s.pp | |
16 % as -o curve25519-donna-x86-64.s.o curve25519-donna-x86-64.s.pp | |
17 % gcc -O2 -c curve25519-donna-x86-64.c | |
18 | |
19 Then the two .o files can be linked in | |
20 | |
21 USAGE: | |
22 | |
23 The usage is exactly the same as djb's code (as described at | |
24 http://cr.yp.to/ecdh.html) expect that the function is called curve25519_donna. | |
25 | |
26 In short, | |
27 | |
28 To generate a private key, generate 32 random bytes and: | |
29 | |
30 mysecret[0] &= 248; | |
31 mysecret[31] &= 127; | |
32 mysecret[31] |= 64; | |
33 | |
34 To generate the public key, just do | |
35 | |
36 static const uint8_t basepoint[32] = {9}; | |
37 curve25519_donna(mypublic, mysecret, basepoint); | |
38 | |
39 To generate an agreed key do: | |
40 uint8_t shared_key[32]; | |
41 curve25519_donna(shared_key, mysecret, theirpublic); | |
42 | |
43 And hash the shared_key with a cryptographic hash function before using. | |
OLD | NEW |