ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/doc/gvpe.protocol.7.pod
(Generate patch)

Comparing gvpe/doc/gvpe.protocol.7.pod (file contents):
Revision 1.9 by root, Wed Jul 10 01:51:40 2013 UTC vs.
Revision 1.12 by root, Fri Jul 19 21:13:44 2013 UTC

142 142
143RAND is a sequence of fully random bytes, used to increase the entropy of 143RAND is a sequence of fully random bytes, used to increase the entropy of
144the data for encryption purposes. 144the data for encryption purposes.
145 145
146SEQNO is a 32-bit sequence number. It is negotiated at every connection 146SEQNO is a 32-bit sequence number. It is negotiated at every connection
147initialization and starts at some random 31 bit value. VPE currently uses 147initialization and starts at some random 31 bit value. GVPE currently uses
148a sliding window of 512 packets/sequence numbers to detect reordering, 148a sliding window of 512 packets/sequence numbers to detect reordering,
149duplication and replay attacks. 149duplication and replay attacks.
150 150
151The encryption is done on RAND+SEQNO+DATA in CBC mode with zero IV (or,
152equivalently, the IV is RAND+SEQNO, encrypted with the block cipher,
153unless RAND size is decreased or increased over the default value).
154
155The random prefix itself is generated by using AES in CTR mode with a
156random key and starting value, which should make them unpredictable even
157before encrypting them again. The sequence number additionally ensures
158that the IV is unique.
159
151=head2 The authentication protocol 160=head2 The authentication/key exchange protocol
152 161
153Before nodes can exchange packets, they need to establish authenticity of 162Before nodes can exchange packets, they need to establish authenticity of
154the other side and a key. Every node has a private RSA key and the public 163the other side and a key. Every node has a private RSA key and the public
155RSA keys of all other nodes. 164RSA keys of all other nodes.
156 165
157A host establishes a simplex connection by sending the other node an RSA 166When a node wants to establish a connection to another node, it sends an
158encrypted challenge containing a random challenge (consisting of the 167RSA-OEAP-encrypted challenge and an ECDH key. The other node replies with
159encryption and authentication keys to use when sending packets, more 168it's own ECDH key and a HKDF of the challange and both ECDH keys to proof
160random data and PKCS1_OAEP padding) and a random 16 byte "challenge-id" 169it's identity.
161(used to detect duplicate auth packets). The destination node will respond
162by replying with an (unencrypted) hash of the decrypted challenge, which
163will authenticate that node. The destination node will also set the
164outgoing encryption parameters as given in the packet.
165 170
166When the source node receives a correct auth reply (by verifying the 171The remote node enganges in exactly the same protocol. When both nodes
167hash and the id, which will expire after 120 seconds), it will start to 172have exchanged their challenge and verified the response, they calculate a
168accept data packets from the destination node. 173cipher key and a HMAC key and start exchanging data packets.
169 174
170This means that a node can only initiate a simplex connection, telling the 175In detail, the challenge consist of:
171other side the key it has to use when it sends packets. The challenge
172reply is only used to set the current IP address of the other side and
173protocol parameters.
174 176
175This protocol is completely symmetric, so to be able to send packets the 177 RSA-OAEP (SEQNO MAC CIPHER SALT EXTRA-AUTH) ECDH1
176destination node must send a challenge in the exact same way as already 178
177described (so, in essence, two simplex connections are created per node 179That is, it encrypts (with the public key of the remote node) an initial
178pair). 180sequence number for data packets, key material for the HMAC key, key
181material for the cipher key, a salt used by the HKDF (as shown later) and
182some extra random bytes that are unused except for authentication. It also
183sends the public key of a curve25519 exchange.
184
185The remote node decrypts the RSA data, generates it's own ECDH key (ECDH2), and
186replies with:
187
188 HKDF-Expand (HKDF-Extract (ECDH2, RSA), ECDH1, AUTH_DIGEST_SIZE) ECDH2
189
190That is, it extracts from the decrypted RSA challenge, using it's ECDH
191key as salt, and then expands using the requesting node's ECDH1 key. The
192resulting has is returned as a proof that the node could decrypt the RSA
193challenge data, together with the ECDH key.
194
195After both nodes have done this to each other, they calculate the shared
196ECDH secrets, cipher and HMAC keys for the session (each
197node generates two cipher and HMAC keys, one for sending and one for
198receiving).
199
200The HMAC key for sending is generated as follow:
201
202 HMAC_KEY = HKDF-Expand (HKDF-Extract (REMOTE_SALT, MAC ECDH_SECRET), info, HMAC_MD_SIZE)
203
204It extracts from MAC and ECDH_SECRET using the I<remote> SALT, then
205expands using a static info string.
206
207The cipher key is generated in the same way, except using the CIPHER part
208of the original challenge.
209
210The result of this process is to authenticate each node to the other
211node, while exchanging keys using both RSA and ECDH, the latter providing
212perfect forward secrecy.
213
214The protocol has been overdesigned where this was possible without
215increasing implementation complexity, in an attempt to protect against
216implementation or protocol failures. For example, if the ECDH challenge
217was found to be flawed, perfect forward secrecy would be lost, but
218the data would still be protected. Likewise, standard algorithms and
219implementations are used where possible.
179 220
180=head2 Retrying 221=head2 Retrying
181 222
182When there is no response to an auth request, the node will send auth 223When there is no response to an auth request, the node will send auth
183requests in bursts with an exponential back-off. After some time it will 224requests in bursts with an exponential back-off. After some time it will

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines