olm/lib/curve25519-donna
Matthew Hodgson 28622db92f switch from /usr/bin/python to /usr/bin/env python. this doesn't help folks whose python path points at python3 (e.g. Arch linux) though, but I see no choice than they have to change the shebangs, as we do on Synapse. For instance, OSX doesn't have a python2 symlink, otherwise we'd use /usr/bin/env python2 shebang. 2015-11-01 13:05:51 +00:00
..
contrib Merge commit 'e50ac707316ea6d8059f7036322450727773952d' as 'lib/curve25519-donna' 2015-02-26 16:40:56 +00:00
python-src/curve25519 switch from /usr/bin/python to /usr/bin/env python. this doesn't help folks whose python path points at python3 (e.g. Arch linux) though, but I see no choice than they have to change the shebangs, as we do on Synapse. For instance, OSX doesn't have a python2 symlink, otherwise we'd use /usr/bin/env python2 shebang. 2015-11-01 13:05:51 +00:00
.gitignore Merge commit 'e50ac707316ea6d8059f7036322450727773952d' as 'lib/curve25519-donna' 2015-02-26 16:40:56 +00:00
LICENSE.md Merge commit 'e50ac707316ea6d8059f7036322450727773952d' as 'lib/curve25519-donna' 2015-02-26 16:40:56 +00:00
Makefile Merge commit 'e50ac707316ea6d8059f7036322450727773952d' as 'lib/curve25519-donna' 2015-02-26 16:40:56 +00:00
README Merge commit 'e50ac707316ea6d8059f7036322450727773952d' as 'lib/curve25519-donna' 2015-02-26 16:40:56 +00:00
curve25519-donna-c64.c Merge commit 'e50ac707316ea6d8059f7036322450727773952d' as 'lib/curve25519-donna' 2015-02-26 16:40:56 +00:00
curve25519-donna.c Merge commit 'e50ac707316ea6d8059f7036322450727773952d' as 'lib/curve25519-donna' 2015-02-26 16:40:56 +00:00
curve25519-donna.podspec Merge commit 'e50ac707316ea6d8059f7036322450727773952d' as 'lib/curve25519-donna' 2015-02-26 16:40:56 +00:00
setup.py switch from /usr/bin/python to /usr/bin/env python. this doesn't help folks whose python path points at python3 (e.g. Arch linux) though, but I see no choice than they have to change the shebangs, as we do on Synapse. For instance, OSX doesn't have a python2 symlink, otherwise we'd use /usr/bin/env python2 shebang. 2015-11-01 13:05:51 +00:00
speed-curve25519.c Merge commit 'e50ac707316ea6d8059f7036322450727773952d' as 'lib/curve25519-donna' 2015-02-26 16:40:56 +00:00
test-curve25519.c Merge commit 'e50ac707316ea6d8059f7036322450727773952d' as 'lib/curve25519-donna' 2015-02-26 16:40:56 +00:00
test-noncanon.c Merge commit 'e50ac707316ea6d8059f7036322450727773952d' as 'lib/curve25519-donna' 2015-02-26 16:40:56 +00:00
test-sc-curve25519.c Merge commit 'e50ac707316ea6d8059f7036322450727773952d' as 'lib/curve25519-donna' 2015-02-26 16:40:56 +00:00
test-sc-curve25519.s Merge commit 'e50ac707316ea6d8059f7036322450727773952d' as 'lib/curve25519-donna' 2015-02-26 16:40:56 +00:00

README

See http://code.google.com/p/curve25519-donna/ for details.

BUILDING:

If you run `make`, two .a archives will be built, similar to djb's curve25519
code. Alternatively, read on:

The C implementation is contained within curve25519-donna.c. It has no external
dependancies and is BSD licenced. You can copy/include/link it directly in with
your program. Recommended C flags: -O2

The x86-64 bit implementation is contained within curve25519-donna-x86-64.c and
curve25519-donna-x86-64.s. Build like this:

% cpp curve25519-donna-x86-64.s > curve25519-donna-x86-64.s.pp
% as -o curve25519-donna-x86-64.s.o curve25519-donna-x86-64.s.pp
% gcc -O2 -c curve25519-donna-x86-64.c

Then the two .o files can be linked in

USAGE:

The usage is exactly the same as djb's code (as described at
http://cr.yp.to/ecdh.html) expect that the function is called curve25519_donna.

In short,

To generate a private key just generate 32 random bytes.

To generate the public key, just do:

  static const uint8_t basepoint[32] = {9};
  curve25519_donna(mypublic, mysecret, basepoint);

To generate an agreed key do:

  uint8_t shared_key[32];
  curve25519_donna(shared_key, mysecret, theirpublic);

And hash the shared_key with a cryptographic hash function before using.