]> Cypherpunks.ru repositories - govpn.git/blob - doc/handshake.texi
[DOC] Add various concept indexes
[govpn.git] / doc / handshake.texi
1 @node Handshake
2 @cindex Handshake
3 @cindex Handshake protocol
4 @cindex Diffie-Hellman
5 @cindex ed25519
6 @cindex curve25519
7 @cindex Elligator
8 @cindex Perfect Forward Secrecy
9 @cindex PFS
10 @cindex IDtag
11 @cindex Shared key
12 @cindex DH-EKE
13 @cindex DH
14 @cindex EKE
15 @cindex A-EKE
16 @cindex DH-A-EKE
17 @section Handshake protocol
18
19 @verbatiminclude handshake.utxt
20
21 Each handshake message ends with so called @code{IDtag}: it is an XTEA
22 encrypted first 64 bits of each message with client's @ref{Identity} as
23 a key. It is used to transmit identity and to mark packet as handshake
24 message.
25
26 If @ref{Noise, noise} is enabled, then data is padded to fill up packet
27 to MTU's size.
28
29 @strong{Preparation stage}:
30
31 @enumerate
32 @item
33 Client knows only his identity and passphrase written somewhere in the
34 human readable form. Server knows his identity and
35 @ref{Verifier structure, verifier}: @code{DSAPub}.
36 @item
37 Client computes verifier which produces @code{DSAPriv} and
38 @code{DSAPub}. @code{H()} is @emph{BLAKE2b-256} hash function.
39 @item
40 Client generates DH keypair: @code{CDHPub} and @code{CDHPriv}.
41 Also it generates random 64-bit @code{R} that is used as a nonce for
42 symmetric encryption. @code{El()} is Elligator point encoding (and vice
43 versa) algorithm.
44 @end enumerate
45
46 @strong{Interaction stage}:
47
48 @enumerate
49 @item
50 @verb{|R + enc(H(DSAPub), R, El(CDHPub)) + IDtag -> Server|} [48 bytes]
51
52 @item
53 @itemize
54 @item Server remembers client address.
55 @item Decrypts @code{El(CDHPub)}.
56 @item Inverts @code{El()} encoding and gets @code{CDHPub}.
57 @item Generates DH keypair: @code{SDHPriv}/@code{SDHPub}.
58 @item Computes common shared key @code{K = H(DH(SDHPriv, CDHPub))}.
59 @item Generates 64-bit random number @code{RS}.
60 @item Generates 256-bit pre-master secret @code{SS}.
61 @end itemize
62
63 @item
64 @verb{|enc(H(DSAPub), R+1, El(SDHPub)) + enc(K, R, RS + SS) + IDtag -> Client|} [80 bytes]
65
66 @item
67 @itemize
68 @item Client decrypts @code{El(SDHPub)}.
69 @item Inverts @code{El()} encoding and gets @code{SDHPub}.
70 @item Computes @code{K}.
71 @item Decrypts @code{RS} and @code{SS}.
72 @item Remembers @code{SS}.
73 @item Generates 64-bit random number @code{RC}.
74 @item Generates 256-bit pre-master secret @code{SC}.
75 @item Signs with @code{DSAPriv} key @code{K}.
76 @end itemize
77
78 @item
79 @verb{|enc(K, R+1, RS + RC + SC + Sign(DSAPriv, K)) + IDtag -> Server|} [120 bytes]
80
81 @item
82 @itemize
83     @item Server decrypts @code{RS}, @code{RC}, @code{SC},
84     @code{Sign(DSAPriv, K)}.
85
86     @item Compares @code{RS} with its own one sent before. Server
87     decrypts @code{RS}, @code{RC}, @code{SC} with key @code{K}, compares
88     @code{RS} with its own one sent before.
89
90     @item Verifies @code{K} signature with verifier @code{DSAPub}.
91
92     @item Computes final session encryption key:
93     @code{MasterKey=SS XOR SC}.
94 @end itemize
95
96 @item
97 @verb{|ENC(K, R+2, RC) + IDtag -> Client|} [16 bytes]
98
99 @item
100 @itemize
101 @item Client decrypts @code{RC}
102 @item Compares with its own one sent before.
103 @item Computes final session encryption key as server did.
104 @end itemize
105
106 @end enumerate
107
108 @code{MasterKey} is high entropy 256-bit key. @code{K} DH-derived one
109 has 128-bit security margin and that is why are not in use except in
110 handshake process. @code{R*} are required for handshake randomization
111 and two-way authentication.
112
113 In @ref{Encless, encryptionless mode} each @code{enc()} is replaced with
114 AONT and chaffing function over the noised data.