diff options
author | George Kadianakis <desnacked@riseup.net> | 2017-08-04 22:53:53 +0300 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-08-08 20:29:34 -0400 |
commit | a464d49aeb66ad2daa6b753c34ceadfe0b391490 (patch) | |
tree | c793a8407caa440a0975826b256e1edf586f24ab /src/test/test_hs_cell.c | |
parent | c62da5cf95de0958d28d2dfd8cdc66cf11498ebe (diff) | |
download | tor-a464d49aeb66ad2daa6b753c34ceadfe0b391490.tar.gz tor-a464d49aeb66ad2daa6b753c34ceadfe0b391490.zip |
prop224 tests: test_gen_establish_intro_cell() check cell contents.
Diffstat (limited to 'src/test/test_hs_cell.c')
-rw-r--r-- | src/test/test_hs_cell.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/test/test_hs_cell.c b/src/test/test_hs_cell.c index 1686fccee7..1b3c788a67 100644 --- a/src/test/test_hs_cell.c +++ b/src/test/test_hs_cell.c @@ -30,7 +30,6 @@ test_gen_establish_intro_cell(void *arg) ssize_t ret; char circ_nonce[DIGEST_LEN] = {0}; uint8_t buf[RELAY_PAYLOAD_SIZE]; - trn_cell_establish_intro_t *cell_out = NULL; trn_cell_establish_intro_t *cell_in = NULL; 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 attempt to parse it. */ { - cell_out = trn_cell_establish_intro_new(); /* We only need the auth key pair here. */ 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 @@ -46,9 +44,18 @@ test_gen_establish_intro_cell(void *arg) ret = hs_cell_build_establish_intro(circ_nonce, ip, buf); service_intro_point_free(ip); tt_u64_op(ret, OP_GT, 0); + } - ret = trn_cell_establish_intro_encode(buf, sizeof(buf), cell_out); - tt_u64_op(ret, OP_GT, 0); + /* Check the contents of the cell */ + { + /* 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 */ @@ -64,7 +71,6 @@ test_gen_establish_intro_cell(void *arg) done: trn_cell_establish_intro_free(cell_in); - trn_cell_establish_intro_free(cell_out); } /* Mocked ed25519_sign_prefixed() function that always fails :) */ |