Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mike Perry
Tor
Commits
5f219ddd
Commit
5f219ddd
authored
Dec 25, 2012
by
Nick Mathewson
🎨
Browse files
Use safe_mem_is_zero for checking curve25519 output for 0-ness
This should make the intent more explicit. Probably needless, though.
parent
f07a5125
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/common/crypto_curve25519.c
View file @
5f219ddd
...
...
@@ -49,11 +49,7 @@ curve25519_impl(uint8_t *output, const uint8_t *secret,
int
curve25519_public_key_is_ok
(
const
curve25519_public_key_t
*
key
)
{
static
const
uint8_t
zero
[]
=
"
\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0
"
"
\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0
"
;
return
tor_memneq
(
key
->
public_key
,
zero
,
CURVE25519_PUBKEY_LEN
);
return
!
safe_mem_is_zero
(
key
->
public_key
,
CURVE25519_PUBKEY_LEN
);
}
/** Generate a new keypair and return the secret key. If <b>extra_strong</b>
...
...
src/or/onion_ntor.c
View file @
5f219ddd
...
...
@@ -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
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment