summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-03-28 22:57:16 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-03-28 22:57:16 +0200
commitf67c3f36b9c4a2ab90bf7cf1380ecdb58528a133 (patch)
treeaef88bca6a3afa49e98fa9f48bbc7987443f341d /src
parentf1d5eb1da9900ab1435d8bd2f4fdb2353717809b (diff)
downloadlibuecc-f67c3f36b9c4a2ab90bf7cf1380ecdb58528a133.tar
libuecc-f67c3f36b9c4a2ab90bf7cf1380ecdb58528a133.zip
Use the same key sanitization as Curve25519v0.1
Diffstat (limited to 'src')
-rw-r--r--src/ec25519_secret.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/ec25519_secret.c b/src/ec25519_secret.c
index 9108613..7f3d987 100644
--- a/src/ec25519_secret.c
+++ b/src/ec25519_secret.c
@@ -176,12 +176,13 @@ void ecc_25519_secret_mult(ecc_secret_key_256 *out, const ecc_secret_key_256 *in
montgomery(out->s, R, C);
}
-/* TODO implement properly, rule out zero etc. */
void ecc_25519_secret_sanitize(ecc_secret_key_256 *out, const ecc_secret_key_256 *in) {
int i;
for (i = 0; i < 32; i++)
out->s[i] = in->s[i];
- out->s[31] |= 0x80;
+ out->s[0] &= 0xf8;
+ out->s[31] &= 0x7f;
+ out->s[31] |= 0x40;
}