We'll be using trunnel for all cells parsing in proposal 224. This ticket is to add a subdirectory in src/trunnel/hs that will contain one .trunnel file per cell and most likely a common file for shared binary structure.
This is the starting point for #17241 (moved) so if we can get this upstream as soon as possible, it makes thing much more easier to split the work between developers and branches instead of carrying a commit that adds that directory to the build system.
The plan is to add two cell definition at first ESTABLISH_INTRO and INTRODUCE1 and then add more as we implement them.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items 0
Show closed items
No child items are currently assigned. Use child items to break down this issue into smaller parts.
Linked items 0
Link issues together to show that they're related.
Learn more.
The HANDSHAKE_AUTH field contains the MAC of all earlier fields in the cell using as its key the shared per-circuit material ("KH") generated during the circuit extension protocol; see tor-spec.txt section 5.2, "Setting circuit keys". It prevents replays of ESTABLISH_INTRO cells.
In this case, end_mac_data should be right before the handshake_mac field and not in the end. Also, there should probably be another ptr called end_sig_data right before the sig. Or do you think the spec is wrong?
Here is how Alex had his pointers, and that's how I have it in my code. Let's keep the same ptr position if possible:
struct hs_establish_intro_cell { @ptr start_cell; u8 auth_key_type; u16 auth_key_len; u8 auth_key[auth_key_len]; u8 n_extensions; struct extension extensions[n_extensions]; @ptr end_mac_fields; /* Modify if any new handshake types are added */ union handshake[auth_key_type] { 2: u8 sha3_256[SHA3_256_MAC_LEN]; default: fail; }; u16 siglen; @ptr end_sig_fields; u8 sig[siglen];};
I think there is a problem with the linking as well. I'm getting the following errors when I try to compile my code on top of your branch:
src/or/libtor.a(hs_intropoint.o): In function `get_auth_key_from_establish_intro_cell':/home/tor/src/or/hs_intropoint.c:34: undefined reference to `hs_cell_establish_intro_getarray_auth_key'src/or/libtor.a(hs_intropoint.o): In function `handle_establish_intro':/home/tor/src/or/hs_intropoint.c:155: undefined reference to `hs_cell_establish_intro_parse'src/or/libtor.a(hs_intropoint.o): In function `verify_establish_intro_cell':/home/tor/src/or/hs_intropoint.c:74: undefined reference to `hs_cell_establish_intro_getarray_sig'
If I explicitly include the src/trunnel/hs/libor-trunnel-hs.a library in the gcc command it works. So maybe there is an issue with the LIBADD?
I fixed both issues above that is the missing end mac fields pointer. I renamed it to the above. Note that the union is gone though because not needed.
Linking issues should be resolved: ticket20004_029_02
(This required some changes to the commits so I had to rebase squash else it wouldn't have merged together nor fixup commit worked.)
I don't see anywhere the CLIENT_PK or MAC fields of the INTRODUCE1 cell as specified in section [NTOR-WITH-EXTRA-DATA]. Also, if we have a MAC we also need the appropriate ptrs.
s/Link specificer/Link specifier/
Also can we replace the magic number of rend_cookie[20] with some sort of name? The actual code is using REND_COOKIE_LEN, but I guess we can't reuse that. No worries if there is no good solution here, just leave it as is.
Pushed an initial branch here ticket20004_rebased which is basically David's branch rebased to latest tor git master, and also using latest trunnel git master.
It still does not address the issues from comment:11. I will take care of those soon.
please see my branch ticket20004_rebased. It's basically David's branch with the following changes:
It's rebased to latest tor git master.
It's rebased to latest trunnel git master.
It fixes the issues pointed out in comment:10 and comment:11.
(WRT comment:11, the patch does not actually add the MAC field to the encrypted part of INTRODUCE1, as the current format is:
CLIENT_PK [G_LEN bytes] ENCRYPTED_DATA [Padded to length of plaintext] MAC [MAC_LEN bytes]
and there is no way to specify Padded to length of plaintext in trunnel when it's not the last element in the struct AFAIK. During implementation, we can do this parsing on our own, or if we want trunnel to do it for us, we should probably add an ENCRYPTED_DATA_LEN field.)
Small fix I made with regard to the onion key type, I narrowed down the values with:
+ u8 onion_key_type IN [0x01];
The rest lgtmy! I think this is ready to merge as it has no impact on current tor code at all and we can make fixes if needed as we continue prop224 implementation. So I'm going to put that in merge_ready.
Branch is located in ticket20004_030_01, rebased on current master. My change is top fixup commit.
So, I think that using a generic cell_extensions mechanism is wrong long term but okay for now. Once we are using different cell extensions, we will want to have the actual body of the extension parsed based on the field_type's value, which means that using a generic "extension" type won't work.
But I think it's okay for now, since we don't have specified extensions yet, right?
Minor comments:
should sig_len be inside end_sig_fields? If this were RSA, we couldn't authenticate the signature len, since we wouldn't know it until we signed.