mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-14 07:03:44 +01:00
prop224 tests: test_gen_establish_intro_cell() check cell contents.
This commit is contained in:
parent
c62da5cf95
commit
a464d49aeb
@ -30,7 +30,6 @@ test_gen_establish_intro_cell(void *arg)
|
|||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
char circ_nonce[DIGEST_LEN] = {0};
|
char circ_nonce[DIGEST_LEN] = {0};
|
||||||
uint8_t buf[RELAY_PAYLOAD_SIZE];
|
uint8_t buf[RELAY_PAYLOAD_SIZE];
|
||||||
trn_cell_establish_intro_t *cell_out = NULL;
|
|
||||||
trn_cell_establish_intro_t *cell_in = NULL;
|
trn_cell_establish_intro_t *cell_in = NULL;
|
||||||
|
|
||||||
crypto_rand(circ_nonce, sizeof(circ_nonce));
|
crypto_rand(circ_nonce, sizeof(circ_nonce));
|
||||||
@ -38,7 +37,6 @@ test_gen_establish_intro_cell(void *arg)
|
|||||||
/* Create outgoing ESTABLISH_INTRO cell and extract its payload so that we
|
/* Create outgoing ESTABLISH_INTRO cell and extract its payload so that we
|
||||||
attempt to parse it. */
|
attempt to parse it. */
|
||||||
{
|
{
|
||||||
cell_out = trn_cell_establish_intro_new();
|
|
||||||
/* We only need the auth key pair here. */
|
/* We only need the auth key pair here. */
|
||||||
hs_service_intro_point_t *ip = service_intro_point_new(NULL, 0);
|
hs_service_intro_point_t *ip = service_intro_point_new(NULL, 0);
|
||||||
/* Auth key pair is generated in the constructor so we are all set for
|
/* Auth key pair is generated in the constructor so we are all set for
|
||||||
@ -46,9 +44,18 @@ test_gen_establish_intro_cell(void *arg)
|
|||||||
ret = hs_cell_build_establish_intro(circ_nonce, ip, buf);
|
ret = hs_cell_build_establish_intro(circ_nonce, ip, buf);
|
||||||
service_intro_point_free(ip);
|
service_intro_point_free(ip);
|
||||||
tt_u64_op(ret, OP_GT, 0);
|
tt_u64_op(ret, OP_GT, 0);
|
||||||
|
}
|
||||||
|
|
||||||
ret = trn_cell_establish_intro_encode(buf, sizeof(buf), cell_out);
|
/* Check the contents of the cell */
|
||||||
tt_u64_op(ret, OP_GT, 0);
|
{
|
||||||
|
/* First byte is the auth key type: make sure its correct */
|
||||||
|
tt_int_op(buf[0], OP_EQ, HS_INTRO_AUTH_KEY_TYPE_ED25519);
|
||||||
|
/* Next two bytes is auth key len */
|
||||||
|
tt_int_op(ntohs(get_uint16(buf+1)), OP_EQ, ED25519_PUBKEY_LEN);
|
||||||
|
/* Skip to the number of extensions: no extensions */
|
||||||
|
tt_int_op(buf[35], OP_EQ, 0);
|
||||||
|
/* Skip to the sig len. Make sure it's the size of an ed25519 sig */
|
||||||
|
tt_int_op(ntohs(get_uint16(buf+35+1+32)), OP_EQ, ED25519_SIG_LEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse it as the receiver */
|
/* Parse it as the receiver */
|
||||||
@ -64,7 +71,6 @@ test_gen_establish_intro_cell(void *arg)
|
|||||||
|
|
||||||
done:
|
done:
|
||||||
trn_cell_establish_intro_free(cell_in);
|
trn_cell_establish_intro_free(cell_in);
|
||||||
trn_cell_establish_intro_free(cell_out);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mocked ed25519_sign_prefixed() function that always fails :) */
|
/* Mocked ed25519_sign_prefixed() function that always fails :) */
|
||||||
|
Loading…
Reference in New Issue
Block a user