diff options
author | George Kadianakis <desnacked@riseup.net> | 2017-06-28 14:10:10 +0300 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2017-06-28 14:58:22 +0300 |
commit | 0d9873ac0daa82fa9d43c1eb7e93ec75758f2063 (patch) | |
tree | 19d611ce4abd0c6c3e97b86ec29ab40bbd5f0c11 /src | |
parent | 559195ea82bf1c0610898fd96cd5a835b2e4f9a7 (diff) | |
download | tor-0d9873ac0daa82fa9d43c1eb7e93ec75758f2063.tar.gz tor-0d9873ac0daa82fa9d43c1eb7e93ec75758f2063.zip |
ed25519: Check retval of unpack_negative_vartime in donna.
Diffstat (limited to 'src')
-rw-r--r-- | src/common/crypto_ed25519.c | 10 | ||||
-rw-r--r-- | src/ext/ed25519/donna/ed25519_tor.c | 4 |
2 files changed, 9 insertions, 5 deletions
diff --git a/src/common/crypto_ed25519.c b/src/common/crypto_ed25519.c index 1a6d19b97b..d61549b797 100644 --- a/src/common/crypto_ed25519.c +++ b/src/common/crypto_ed25519.c @@ -497,7 +497,8 @@ ed25519_public_key_from_curve25519_public_key(ed25519_public_key_t *pubkey, * service descriptors are encrypted with a key derived from the service's * long-term public key, and then signed with (and stored at a position * indexed by) a short-term key derived by blinding the long-term keys. - */ + * + * Return 0 if blinding was successful, else return -1. */ int ed25519_keypair_blind(ed25519_keypair_t *out, const ed25519_keypair_t *inp, @@ -508,7 +509,9 @@ ed25519_keypair_blind(ed25519_keypair_t *out, get_ed_impl()->blind_secret_key(out->seckey.seckey, inp->seckey.seckey, param); - ed25519_public_blind(&pubkey_check, &inp->pubkey, param); + if (ed25519_public_blind(&pubkey_check, &inp->pubkey, param) < 0) { + return -1; + } ed25519_public_key_generate(&out->pubkey, &out->seckey); tor_assert(fast_memeq(pubkey_check.pubkey, out->pubkey.pubkey, 32)); @@ -528,8 +531,7 @@ ed25519_public_blind(ed25519_public_key_t *out, const ed25519_public_key_t *inp, const uint8_t *param) { - get_ed_impl()->blind_public_key(out->pubkey, inp->pubkey, param); - return 0; + return get_ed_impl()->blind_public_key(out->pubkey, inp->pubkey, param); } /** diff --git a/src/ext/ed25519/donna/ed25519_tor.c b/src/ext/ed25519/donna/ed25519_tor.c index bd11027efa..6bc22675ae 100644 --- a/src/ext/ed25519/donna/ed25519_tor.c +++ b/src/ext/ed25519/donna/ed25519_tor.c @@ -304,7 +304,9 @@ ed25519_donna_blind_public_key(unsigned char *out, const unsigned char *inp, /* No "ge25519_unpack", negate the public key. */ memcpy(pkcopy, inp, 32); pkcopy[31] ^= (1<<7); - ge25519_unpack_negative_vartime(&A, pkcopy); + if (!ge25519_unpack_negative_vartime(&A, pkcopy)) { + return -1; + } /* A' = [tweak] * A + [0] * basepoint. */ ge25519_double_scalarmult_vartime(&Aprime, &A, t, zero); |