summaryrefslogtreecommitdiff
path: root/src/ext/curve25519_donna/README
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-12-03 14:50:48 -0500
committerNick Mathewson <nickm@torproject.org>2013-01-02 14:10:48 -0500
commit9c3c571c0c51bc11717b795d800b6523ff4ccfd8 (patch)
treeca40541a1c002d8859781c9cf79ae1aeacb504d3 /src/ext/curve25519_donna/README
parentcfab9f0755e3f7f0b49879ed9771fd2d325051a2 (diff)
downloadtor-9c3c571c0c51bc11717b795d800b6523ff4ccfd8.tar.gz
tor-9c3c571c0c51bc11717b795d800b6523ff4ccfd8.zip
Add fallback implementations for curve25519: curve25519_donna
This is copied from Adam Langley's curve25519-donna package, as of commit 09427c9cab32075c06c3487aa01628030e1c5ae7.
Diffstat (limited to 'src/ext/curve25519_donna/README')
-rw-r--r--src/ext/curve25519_donna/README44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/ext/curve25519_donna/README b/src/ext/curve25519_donna/README
new file mode 100644
index 0000000000..9f77bd7d95
--- /dev/null
+++ b/src/ext/curve25519_donna/README
@@ -0,0 +1,44 @@
+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, generate 32 random bytes and:
+
+ mysecret[0] &= 248;
+ mysecret[31] &= 127;
+ mysecret[31] |= 64;
+
+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.
+