aboutsummaryrefslogtreecommitdiff
path: root/src/or/onion_ntor.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-12-25 22:25:09 -0500
committerNick Mathewson <nickm@torproject.org>2013-01-03 11:29:48 -0500
commit5f219ddd029348df2d384fca5012d96957885cbc (patch)
tree436e9e85c7bc06fd31194cf63b021fa069762b21 /src/or/onion_ntor.c
parentf07a5125cb5bb9ee5968ded163cfdd73e5ad028c (diff)
downloadtor-5f219ddd029348df2d384fca5012d96957885cbc.tar
tor-5f219ddd029348df2d384fca5012d96957885cbc.tar.gz
Use safe_mem_is_zero for checking curve25519 output for 0-ness
This should make the intent more explicit. Probably needless, though.
Diffstat (limited to 'src/or/onion_ntor.c')
-rw-r--r--src/or/onion_ntor.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/src/or/onion_ntor.c b/src/or/onion_ntor.c
index 8eab55acf..b601d1ebb 100644
--- a/src/or/onion_ntor.c
+++ b/src/or/onion_ntor.c
@@ -167,18 +167,10 @@ onion_skin_ntor_server_handshake(const uint8_t *onion_skin,
/* build secret_input */
curve25519_handshake(si, &s.seckey_y, &s.pubkey_X);
- bad = tor_memeq(si,
- "\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00", 32);
+ bad = safe_mem_is_zero(si, CURVE25519_OUTPUT_LEN);
si += CURVE25519_OUTPUT_LEN;
curve25519_handshake(si, &keypair_bB->seckey, &s.pubkey_X);
- bad |= tor_memeq(si,
- "\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00", 32);
+ bad |= safe_mem_is_zero(si, CURVE25519_OUTPUT_LEN);
si += CURVE25519_OUTPUT_LEN;
APPEND(si, my_node_id, DIGEST_LEN);
@@ -257,19 +249,11 @@ onion_skin_ntor_client_handshake(
/* Compute secret_input */
curve25519_handshake(si, &handshake_state->seckey_x, &s.pubkey_Y);
- bad = tor_memeq(si,
- "\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00", 32);
+ bad = safe_mem_is_zero(si, CURVE25519_OUTPUT_LEN);
si += CURVE25519_OUTPUT_LEN;
curve25519_handshake(si, &handshake_state->seckey_x,
&handshake_state->pubkey_B);
- bad |= tor_memeq(si,
- "\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00", 32);
+ bad |= safe_mem_is_zero(si, CURVE25519_OUTPUT_LEN);
si += CURVE25519_OUTPUT_LEN;
APPEND(si, handshake_state->router_id, DIGEST_LEN);
APPEND(si, handshake_state->pubkey_B.public_key, CURVE25519_PUBKEY_LEN);