mirror of
https://github.com/refraction-networking/utls.git
synced 2025-04-03 20:17:36 +03:00
crypto/tls: implement TLS 1.3 server handshake (base)
Implement a basic TLS 1.3 server handshake, only enabled if explicitly requested with MaxVersion. This CL intentionally leaves for future CLs: - PSK modes and resumption - client authentication - compatibility mode ChangeCipherSpecs - early data skipping - post-handshake messages - downgrade protection - KeyLogWriter support - TLS_FALLBACK_SCSV processing It also leaves a few areas up for a wider refactor (maybe in Go 1.13): - the certificate selection logic can be significantly improved, including supporting and surfacing signature_algorithms_cert, but this isn't new in TLS 1.3 (see comment in processClientHello) - handshake_server_tls13.go can be dried up and broken into more meaningful, smaller functions, but it felt premature to do before PSK and client auth support - the monstrous ClientHello equality check in doHelloRetryRequest can get both cleaner and more complete with collaboration from the parsing layer, which can come at the same time as extension duplicates detection Updates #9671 Change-Id: Id9db2b6ecc2eea21bf9b59b6d1d9c84a7435151c Reviewed-on: https://go-review.googlesource.com/c/147017 Run-TryBot: Filippo Valsorda <filippo@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Adam Langley <agl@golang.org>
This commit is contained in:
parent
2c3ff7ba06
commit
376ff45dc1
19 changed files with 1788 additions and 77 deletions
92
testdata/Server-TLSv13-ExportKeyingMaterial
vendored
Normal file
92
testdata/Server-TLSv13-ExportKeyingMaterial
vendored
Normal file
|
@ -0,0 +1,92 @@
|
|||
>>> Flow 1 (client to server)
|
||||
00000000 16 03 01 00 e4 01 00 00 e0 03 03 40 35 14 01 11 |...........@5...|
|
||||
00000010 ea 27 ee ac 2d 8b d9 de 62 2d 94 4e 4f c6 97 09 |.'..-...b-.NO...|
|
||||
00000020 8a 84 1d 96 ca 1e 1c a2 a5 9f 82 20 cf 5d fb ec |........... .]..|
|
||||
00000030 d8 3d 23 2d 89 77 a9 7b 1a 9a 72 e6 bd 17 50 53 |.=#-.w.{..r...PS|
|
||||
00000040 56 32 17 d3 50 38 0c 9d 0b e4 8d 9a 00 08 13 02 |V2..P8..........|
|
||||
00000050 13 03 13 01 00 ff 01 00 00 8f 00 00 00 0e 00 0c |................|
|
||||
00000060 00 00 09 31 32 37 2e 30 2e 30 2e 31 00 0b 00 04 |...127.0.0.1....|
|
||||
00000070 03 00 01 02 00 0a 00 0c 00 0a 00 1d 00 17 00 1e |................|
|
||||
00000080 00 19 00 18 00 23 00 00 00 16 00 00 00 17 00 00 |.....#..........|
|
||||
00000090 00 0d 00 1e 00 1c 04 03 05 03 06 03 08 07 08 08 |................|
|
||||
000000a0 08 09 08 0a 08 0b 08 04 08 05 08 06 04 01 05 01 |................|
|
||||
000000b0 06 01 00 2b 00 03 02 03 04 00 2d 00 02 01 01 00 |...+......-.....|
|
||||
000000c0 33 00 26 00 24 00 1d 00 20 99 33 07 c3 2f 4d 4d |3.&.$... .3../MM|
|
||||
000000d0 f1 3b 8a 93 f4 58 77 2b 69 e6 6e ae e8 1b 0a 30 |.;...Xw+i.n....0|
|
||||
000000e0 a2 35 f5 1f 9e ed 34 ed 0c |.5....4..|
|
||||
>>> Flow 2 (server to client)
|
||||
00000000 16 03 03 00 7a 02 00 00 76 03 03 00 00 00 00 00 |....z...v.......|
|
||||
00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
|
||||
00000020 00 00 00 00 00 00 00 00 00 00 00 20 cf 5d fb ec |........... .]..|
|
||||
00000030 d8 3d 23 2d 89 77 a9 7b 1a 9a 72 e6 bd 17 50 53 |.=#-.w.{..r...PS|
|
||||
00000040 56 32 17 d3 50 38 0c 9d 0b e4 8d 9a 13 02 00 00 |V2..P8..........|
|
||||
00000050 2e 00 2b 00 02 03 04 00 33 00 24 00 1d 00 20 2f |..+.....3.$... /|
|
||||
00000060 e5 7d a3 47 cd 62 43 15 28 da ac 5f bb 29 07 30 |.}.G.bC.(.._.).0|
|
||||
00000070 ff f6 84 af c4 cf c2 ed 90 99 5f 58 cb 3b 74 17 |.........._X.;t.|
|
||||
00000080 03 03 00 17 57 f0 44 ca 0f b9 92 0d 8f 6f 1f 11 |....W.D......o..|
|
||||
00000090 a1 03 28 76 f0 0c 46 87 5a c7 b5 17 03 03 02 6d |..(v..F.Z......m|
|
||||
000000a0 78 f0 92 2b 56 5d b9 62 95 1b 04 8b d0 49 63 31 |x..+V].b.....Ic1|
|
||||
000000b0 1f 1d 9a 37 b3 64 e5 11 21 58 4c e2 d2 da a4 e1 |...7.d..!XL.....|
|
||||
000000c0 1b 26 e7 11 3f b5 46 18 62 46 35 8a ae b1 88 93 |.&..?.F.bF5.....|
|
||||
000000d0 5c 97 6c 66 6e a7 5d 63 fb e2 07 07 f5 59 02 38 |\.lfn.]c.....Y.8|
|
||||
000000e0 78 d5 52 97 9b 2f 06 d3 91 c0 a3 62 9b 74 7e f8 |x.R../.....b.t~.|
|
||||
000000f0 41 0b 71 df f9 ed 42 1b 51 ec db 66 86 d7 db c0 |A.q...B.Q..f....|
|
||||
00000100 a1 27 9e 51 95 fe 54 66 4a f2 72 7b d7 91 cd 00 |.'.Q..TfJ.r{....|
|
||||
00000110 b1 fd 36 a1 6f c5 c4 31 3e b8 d8 ab 0b f5 57 bf |..6.o..1>.....W.|
|
||||
00000120 63 91 99 5e 04 63 c7 fa c9 73 b5 23 0e e9 45 3a |c..^.c...s.#..E:|
|
||||
00000130 15 2b a7 d3 f5 04 50 ab 17 65 40 d3 63 da 6e 2a |.+....P..e@.c.n*|
|
||||
00000140 66 45 2d 41 1f 09 fa 62 67 86 8f e6 c5 7e 02 d0 |fE-A...bg....~..|
|
||||
00000150 27 bf 43 e8 15 8e 4f 71 67 2e 9b 13 61 44 23 0b |'.C...Oqg...aD#.|
|
||||
00000160 29 06 81 0c 9c 28 c5 a9 f1 6e 49 84 b3 75 90 93 |)....(...nI..u..|
|
||||
00000170 0a f7 db 01 29 9f 73 5d 00 f5 41 a7 cb 0b b0 97 |....).s]..A.....|
|
||||
00000180 d7 b6 d0 71 31 56 88 88 7b 16 3b 54 5e 82 2b 87 |...q1V..{.;T^.+.|
|
||||
00000190 2c 74 2c 8f 0a ec 5f 2b ef a6 86 55 49 d9 a2 af |,t,..._+...UI...|
|
||||
000001a0 4a 34 48 a4 65 b6 4f f3 7f b6 30 e8 c2 f1 03 f4 |J4H.e.O...0.....|
|
||||
000001b0 89 90 02 b6 f2 6e 27 e8 33 5f c7 34 91 a7 fd 96 |.....n'.3_.4....|
|
||||
000001c0 58 a1 4b 3a e5 73 92 1c ed 01 dd 15 a2 b5 61 01 |X.K:.s........a.|
|
||||
000001d0 1b 1d 52 0d 10 1f 1e a8 3b a4 b8 cf 50 0b ff e6 |..R.....;...P...|
|
||||
000001e0 cf b7 59 cf 60 55 f7 2d ad 1d 7a 76 dc c0 4d d3 |..Y.`U.-..zv..M.|
|
||||
000001f0 5f 06 d2 1e 02 a8 23 12 6c ae 3a 90 d4 1a ef b1 |_.....#.l.:.....|
|
||||
00000200 31 c8 82 5c ca 92 1d db c3 0c 5e 9e 80 1c 1d b2 |1..\......^.....|
|
||||
00000210 f5 55 b5 55 92 94 9a 43 ef 60 86 ee f0 65 68 bd |.U.U...C.`...eh.|
|
||||
00000220 ad f8 5d f2 06 3f 2d b5 52 26 71 33 bb 0a f2 31 |..]..?-.R&q3...1|
|
||||
00000230 8a 98 41 8d 8d 59 d1 b7 c9 b1 3c e1 37 9e 70 0b |..A..Y....<.7.p.|
|
||||
00000240 da ae 25 34 49 93 ce f3 a0 c9 b6 7e 06 34 53 07 |..%4I......~.4S.|
|
||||
00000250 ef 61 43 9d 79 2c d0 02 5a 64 bd 4a 46 98 3c 42 |.aC.y,..Zd.JF.<B|
|
||||
00000260 85 65 fb a1 56 df 4a b1 8a c5 4f e7 04 40 8a 70 |.e..V.J...O..@.p|
|
||||
00000270 88 bc 31 a1 64 9a e6 e2 f4 cd 15 79 9c de 1e 0e |..1.d......y....|
|
||||
00000280 ae 84 c0 f3 a8 b0 ed 7b 7c a3 98 0b 19 76 b8 46 |.......{|....v.F|
|
||||
00000290 72 7f a8 32 cc f7 78 70 8f 28 43 69 df d7 53 8b |r..2..xp.(Ci..S.|
|
||||
000002a0 9c cd d5 73 4d 14 ad 60 73 f3 d7 5e cf 04 e8 a8 |...sM..`s..^....|
|
||||
000002b0 11 04 6d 8a 58 5a 49 ad 63 53 6c b6 09 38 42 b7 |..m.XZI.cSl..8B.|
|
||||
000002c0 9a 23 ff 5c 77 15 a3 83 2e 0e fe 8e 59 30 d1 33 |.#.\w.......Y0.3|
|
||||
000002d0 a5 32 35 1f 0c 42 01 ca 30 d2 16 c1 18 1d e9 27 |.25..B..0......'|
|
||||
000002e0 f7 fd 86 1c 1f f4 ce f2 d5 a4 81 e1 6c a7 6a 8b |............l.j.|
|
||||
000002f0 9a fd 1b 3c 4c d5 82 64 72 e2 b7 85 14 d1 2c d1 |...<L..dr.....,.|
|
||||
00000300 d6 d0 98 98 00 97 82 6b 27 1e 82 7b 59 17 03 03 |.......k'..{Y...|
|
||||
00000310 00 99 96 96 88 8a 74 73 12 90 3b b9 d6 85 6f be |......ts..;...o.|
|
||||
00000320 b0 e3 bd 17 fe b6 b9 8b 26 b9 8a 0d 54 e7 82 10 |........&...T...|
|
||||
00000330 21 e1 87 d8 e1 f2 a5 02 8e 4b 2b 06 61 28 3b 92 |!........K+.a(;.|
|
||||
00000340 41 e3 55 e5 86 d5 4d 21 cf 4f b1 97 f2 e6 de 43 |A.U...M!.O.....C|
|
||||
00000350 f4 b7 a7 ba af 05 b6 23 8a 8c 04 5d 4d ee 87 5f |.......#...]M.._|
|
||||
00000360 af 22 9d d1 68 ff 85 c8 a5 ca 15 bb 71 f8 ca b3 |."..h.......q...|
|
||||
00000370 bc fd 19 da 43 8d f1 c7 75 c2 2f 0e 97 04 bf a9 |....C...u./.....|
|
||||
00000380 a8 90 59 ab e6 90 86 a7 ff 24 d6 8b 87 5b 21 9c |..Y......$...[!.|
|
||||
00000390 d0 e5 f5 87 3e 67 8c cc 94 9a ce 19 a3 f1 f9 78 |....>g.........x|
|
||||
000003a0 3f eb 55 57 d9 7b 3a 31 c8 b9 d2 17 03 03 00 45 |?.UW.{:1.......E|
|
||||
000003b0 ec 76 02 21 7b 96 9c ff a5 ea e9 2e 92 a7 d6 f4 |.v.!{...........|
|
||||
000003c0 8e c0 a0 bc 21 11 44 df 84 dd 3c 21 5d cc 1b 2c |....!.D...<!]..,|
|
||||
000003d0 ed 5d bf af 55 20 51 19 43 e4 40 28 44 8c dc e7 |.]..U Q.C.@(D...|
|
||||
000003e0 f2 43 88 82 27 7c 25 30 01 96 81 92 71 ca 3e 8a |.C..'|%0....q.>.|
|
||||
000003f0 f0 29 1b 4b 6e |.).Kn|
|
||||
>>> Flow 3 (client to server)
|
||||
00000000 14 03 03 00 01 01 17 03 03 00 45 4a 89 ee af 15 |..........EJ....|
|
||||
00000010 db cf 58 6f f9 5a cd 28 a7 57 08 38 7a a4 1a a6 |..Xo.Z.(.W.8z...|
|
||||
00000020 d9 ed 5f f8 b1 f8 a9 aa 19 70 5f 8d 87 b9 d8 5c |.._......p_....\|
|
||||
00000030 b6 4d d6 04 4b 66 1b 6a 57 25 58 bf a1 b6 72 81 |.M..Kf.jW%X...r.|
|
||||
00000040 74 b9 c9 6f 02 c9 0b f6 b2 7f 70 72 78 a6 06 bd |t..o......prx...|
|
||||
>>> Flow 4 (server to client)
|
||||
00000000 17 03 03 00 1e ee 68 ad 7a 47 ba 93 80 26 01 37 |......h.zG...&.7|
|
||||
00000010 1b 3b b8 61 aa 60 a1 0f 21 a4 81 51 16 a5 b1 36 |.;.a.`..!..Q...6|
|
||||
00000020 b2 39 ca 17 03 03 00 13 5e 1c 9b a5 d1 02 68 96 |.9......^.....h.|
|
||||
00000030 99 41 8c a1 9e 49 38 1d 97 b6 c8 |.A...I8....|
|
Loading…
Add table
Add a link
Reference in a new issue