Use ((x + 7) >> 3) instead of (x >> 3) when converting from bits to bytes.
[tor.git] / src / trunnel / ed25519_cert.trunnel
blob8d6483d558b58bb54c2531e41e1c0b1cfcb42352
2 struct ed25519_cert {
3   u8 version IN [1];
4   u8 cert_type;
5   u32 exp_field;
6   u8 cert_key_type;
7   u8 certified_key[32];
8   u8 n_extensions;
9   struct ed25519_cert_extension ext[n_extensions];
10   u8 signature[64];
13 const CERTEXT_SIGNED_WITH_KEY = 4;
14 const CERTEXT_FLAG_AFFECTS_VALIDATION = 1;
16 struct ed25519_cert_extension {
17   u16 ext_length;
18   u8 ext_type;
19   u8 ext_flags;
20   union un[ext_type] with length ext_length {
21     CERTEXT_SIGNED_WITH_KEY : u8 signing_key[32];
22     default: u8 unparsed[];
23   };
26 const LS_IPV4 = 0x00;
27 const LS_IPV6 = 0x01;
28 const LS_LEGACY_ID = 0x02;
29 const LS_ED25519_ID = 0x03;
31 // XXX hs_link_specifier_dup() violates the opaqueness of link_specifier_t by
32 //  taking its sizeof(). If we ever want to turn on TRUNNEL_OPAQUE, or
33 //  if we ever make link_specifier contain other types, we will
34 //  need to refactor that function to do the copy by encoding and decoding the
35 //  object.
37 // amended from tor.trunnel
38 struct link_specifier {
39   u8 ls_type;
40   u8 ls_len;
41   union un[ls_type] with length ls_len {
42     LS_IPV4: u32 ipv4_addr; u16 ipv4_port;
43     LS_IPV6: u8 ipv6_addr[16]; u16 ipv6_port;
44     LS_LEGACY_ID: u8 legacy_id[20];
45     LS_ED25519_ID: u8 ed25519_id[32];
46     default: u8 unrecognized[];
47   };
50 struct link_specifier_list {
51   u8 n_spec;
52   struct link_specifier spec[n_spec];
55 struct extend1_cell_body {
56   u32 ipv4addr;
57   u16 port;
58   u8 onionskin[186];
59   u8 identity[20];
62 struct create2_cell_body {
63   u16 handshake_type;
64   u16 handshake_len;
65   u8 handshake_data[handshake_len];
68 struct extend2_cell_body {
69   u8 n_spec;
70   struct link_specifier ls[n_spec];
71   struct create2_cell_body create2;