mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 13:53:31 +01:00
Avoid a malloc/free pair for each (server-side) ntor handshake
Closes ticket 25150
This commit is contained in:
parent
f0d7905bc9
commit
e3d4154486
4
changes/feature25150
Normal file
4
changes/feature25150
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
o Minor features (performance, allocation):
|
||||||
|
- Avoid a needless malloc()/free() pair every time we handle an ntor
|
||||||
|
handshake. Closes ticket 25150.
|
||||||
|
|
@ -563,20 +563,19 @@ onion_skin_server_handshake(int type,
|
|||||||
return -1;
|
return -1;
|
||||||
{
|
{
|
||||||
size_t keys_tmp_len = keys_out_len + DIGEST_LEN;
|
size_t keys_tmp_len = keys_out_len + DIGEST_LEN;
|
||||||
uint8_t *keys_tmp = tor_malloc(keys_out_len + DIGEST_LEN);
|
uint8_t keys_tmp[keys_tmp_len];
|
||||||
|
|
||||||
if (onion_skin_ntor_server_handshake(
|
if (onion_skin_ntor_server_handshake(
|
||||||
onion_skin, keys->curve25519_key_map,
|
onion_skin, keys->curve25519_key_map,
|
||||||
keys->junk_keypair,
|
keys->junk_keypair,
|
||||||
keys->my_identity,
|
keys->my_identity,
|
||||||
reply_out, keys_tmp, keys_tmp_len)<0) {
|
reply_out, keys_tmp, keys_tmp_len)<0) {
|
||||||
tor_free(keys_tmp);
|
/* no need to memwipe here, since the output will never be used */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
memcpy(keys_out, keys_tmp, keys_out_len);
|
memcpy(keys_out, keys_tmp, keys_out_len);
|
||||||
memcpy(rend_nonce_out, keys_tmp+keys_out_len, DIGEST_LEN);
|
memcpy(rend_nonce_out, keys_tmp+keys_out_len, DIGEST_LEN);
|
||||||
memwipe(keys_tmp, 0, keys_tmp_len);
|
memwipe(keys_tmp, 0, keys_tmp_len);
|
||||||
tor_free(keys_tmp);
|
|
||||||
r = NTOR_REPLY_LEN;
|
r = NTOR_REPLY_LEN;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user