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