@@ -76,3 +76,82 @@ No payload.
76
76
Response to PEX_MSG_PING.
77
77
No payload.
78
78
79
+ ## Unencrypted messages (outside of the tunnel)
80
+
81
+ These are only supported for networks using signed network data that can be updated dynamically.
82
+ The struct pex_hdr header is followed by a second header:
83
+
84
+ struct pex_ext_hdr {
85
+ uint64_t nonce;
86
+ uint8_t auth_id[8];
87
+ };
88
+
89
+ - nonce: nonce for id hash
90
+ - auth_id: first 8 bytes of the auth public key
91
+
92
+ In these messages, pex_hdr::id is XORed with siphash(req_id || req_id, auth_key)
93
+
94
+ ### opcode=5: PEX_MSG_UPDATE_REQUEST
95
+
96
+ This message can be used outside of the wireguard tunnel in order to request signed network data
97
+ It is used to ask a peer for the latest signed network data
98
+
99
+ Payload:
100
+ struct pex_update_request {
101
+ uint64_t cur_version;
102
+ uint32_t req_id;
103
+ };
104
+
105
+ - cur_version: latest version of the network data that the sender already has
106
+ - req_id: request id copied to response messages
107
+
108
+ ### opcode=6: PEX_MSG_UPDATE_RESPONSE
109
+
110
+ Used to send updated signed network data to a peer
111
+
112
+ Payload:
113
+ struct pex_update_response {
114
+ uint64_t req_id;
115
+ uint32_t data_len;
116
+ uint8_t e_key[ 32] ;
117
+ };
118
+
119
+ followed by the first chunk of network data.
120
+
121
+ - req_id: request id of the PEX_MSG_UPDATE_REQUEST message
122
+ - data_len: total length of the network data
123
+ - e_key: ephemeral curve25519 public key
124
+
125
+ The network data is chacha20 encrypted with the following key:
126
+ DH(e_key_priv, peer_key)
127
+ And using req_id as nonce.
128
+
129
+ - e_key_priv: private key belonging to e_key
130
+ - peer_key: public key belonging to the receiver (from the network data)
131
+
132
+ ### opcode=7: PEX_MSG_UPDATE_RESPONSE_DATA
133
+
134
+ Continuation of PEX_MSG_UPDATE_RESPONSE network data
135
+
136
+ Payload:
137
+ struct pex_update_response_data {
138
+ uint64_t req_id;
139
+ uint32_t offset;
140
+ };
141
+
142
+ followed by encrypted network data
143
+
144
+ ### opcode=8: PEX_MSG_UPDATE_RESPONSE_NO_DATA
145
+
146
+ Indicates that the network data with the timestamp given in PEX_MSG_UPDATE_REQUEST
147
+ is up to date
148
+
149
+ Payload:
150
+
151
+ struct pex_update_response_no_data {
152
+ uint64_t req_id;
153
+ uint64_t cur_version;
154
+ };
155
+
156
+ - req_id: request id of the PEX_MSG_UPDATE_REQUEST message
157
+ - cur_version: latest version of the network data
0 commit comments