summaryrefslogtreecommitdiff
path: root/donna_32.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2018-12-12 03:56:09 -0500
committerJeffrey Walton <noloader@gmail.com>2018-12-12 03:56:09 -0500
commite97d6d0ff5c5ae428d70954116f1587d09227772 (patch)
treebbb40e52b26e377000155db35414812534c8ca33 /donna_32.cpp
parent80776453f8187ad704e69886b856ee65115d3b25 (diff)
downloadcryptopp-git-e97d6d0ff5c5ae428d70954116f1587d09227772.tar.gz
Fix failed self test when NO_OS_DEPENDENCE (GH #761)
Add is_clamped for secret key validation. Cleanup paramter names in Donna::curve25519 to follow function. Overload Donna::curve25519 to implicitly use base point if not provided. Add additional asserts to let the code debug itself. Update documentation.
Diffstat (limited to 'donna_32.cpp')
-rw-r--r--donna_32.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/donna_32.cpp b/donna_32.cpp
index 08bff4dd..69c7e2f8 100644
--- a/donna_32.cpp
+++ b/donna_32.cpp
@@ -873,23 +873,29 @@ ANONYMOUS_NAMESPACE_END
NAMESPACE_BEGIN(CryptoPP)
NAMESPACE_BEGIN(Donna)
-int curve25519(byte pubkey[32], const byte seckey[32], const byte basepoint[32])
+int curve25519(byte publicKey[32], const byte secretKey[32])
+{
+ const byte basePoint[32] = {9};
+ return curve25519(publicKey, secretKey, basePoint);
+}
+
+int curve25519(byte sharedKey[32], const byte secretKey[32], const byte othersKey[32])
{
limb bp[10], x[10], z[11], zmone[10];
- byte e[32]; int i;
+ byte e[32];
- for (i = 0; i < 32; ++i)
- e[i] = seckey[i];
+ for (unsigned int i = 0; i < 32; ++i)
+ e[i] = secretKey[i];
e[0] &= 248;
e[31] &= 127;
e[31] |= 64;
- fexpand(bp, basepoint);
+ fexpand(bp, othersKey);
cmult(x, z, e, bp);
crecip(zmone, z);
fmul(z, x, zmone);
- fcontract(pubkey, z);
+ fcontract(sharedKey, z);
return 0;
}