README 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. See http://code.google.com/p/curve25519-donna/ for details.
  2. BUILDING:
  3. If you run `make`, two .a archives will be built, similar to djb's curve25519
  4. code. Alternatively, read on:
  5. The C implementation is contained within curve25519-donna.c. It has no external
  6. dependancies and is BSD licenced. You can copy/include/link it directly in with
  7. your program. Recommended C flags: -O2
  8. The x86-64 bit implementation is contained within curve25519-donna-x86-64.c and
  9. curve25519-donna-x86-64.s. Build like this:
  10. % cpp curve25519-donna-x86-64.s > curve25519-donna-x86-64.s.pp
  11. % as -o curve25519-donna-x86-64.s.o curve25519-donna-x86-64.s.pp
  12. % gcc -O2 -c curve25519-donna-x86-64.c
  13. Then the two .o files can be linked in
  14. USAGE:
  15. The usage is exactly the same as djb's code (as described at
  16. http://cr.yp.to/ecdh.html) expect that the function is called curve25519_donna.
  17. In short,
  18. To generate a private key, generate 32 random bytes and:
  19. mysecret[0] &= 248;
  20. mysecret[31] &= 127;
  21. mysecret[31] |= 64;
  22. To generate the public key, just do
  23. static const uint8_t basepoint[32] = {9};
  24. curve25519_donna(mypublic, mysecret, basepoint);
  25. To generate an agreed key do:
  26. uint8_t shared_key[32];
  27. curve25519_donna(shared_key, mysecret, theirpublic);
  28. And hash the shared_key with a cryptographic hash function before using.