ed25519_cert.trunnel 1.6 KB

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