mirror of
https://github.com/refraction-networking/utls.git
synced 2025-04-04 04:27: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
95
testdata/Server-TLSv13-P256
vendored
Normal file
95
testdata/Server-TLSv13-P256
vendored
Normal file
|
@ -0,0 +1,95 @@
|
|||
>>> Flow 1 (client to server)
|
||||
00000000 16 03 01 00 f9 01 00 00 f5 03 03 9b 17 e9 d1 ef |................|
|
||||
00000010 4d bc 9c 08 44 87 d5 43 09 b5 bd f3 7c a6 52 59 |M...D..C....|.RY|
|
||||
00000020 ae d3 af 09 c4 24 18 12 7f 4a 03 20 af 3e 04 1d |.....$...J. .>..|
|
||||
00000030 3a 26 d4 bb 9c 02 71 32 c4 19 a6 ef 46 26 0f d6 |:&....q2....F&..|
|
||||
00000040 ab 9e 49 4f b5 06 37 92 7a 0a 37 5e 00 08 13 02 |..IO..7.z.7^....|
|
||||
00000050 13 03 13 01 00 ff 01 00 00 a4 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 04 00 02 00 17 00 16 00 00 |................|
|
||||
00000080 00 17 00 00 00 0d 00 1e 00 1c 04 03 05 03 06 03 |................|
|
||||
00000090 08 07 08 08 08 09 08 0a 08 0b 08 04 08 05 08 06 |................|
|
||||
000000a0 04 01 05 01 06 01 00 2b 00 03 02 03 04 00 2d 00 |.......+......-.|
|
||||
000000b0 02 01 01 00 33 00 47 00 45 00 17 00 41 04 ec c3 |....3.G.E...A...|
|
||||
000000c0 f4 ab c7 58 b2 1c b4 8d d9 62 5f eb b9 b8 8f 33 |...X.....b_....3|
|
||||
000000d0 e3 77 4a e5 57 1d 03 ce 2b bb 9d e6 b3 e4 b6 b6 |.wJ.W...+.......|
|
||||
000000e0 10 01 03 df c6 b4 ac 26 c8 58 9a a8 97 1d e7 92 |.......&.X......|
|
||||
000000f0 15 d3 78 a4 40 12 8f e1 c0 0a 80 2b 06 c5 |..x.@......+..|
|
||||
>>> Flow 2 (server to client)
|
||||
00000000 16 03 03 00 9b 02 00 00 97 03 03 00 00 00 00 00 |................|
|
||||
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 af 3e 04 1d |........... .>..|
|
||||
00000030 3a 26 d4 bb 9c 02 71 32 c4 19 a6 ef 46 26 0f d6 |:&....q2....F&..|
|
||||
00000040 ab 9e 49 4f b5 06 37 92 7a 0a 37 5e 13 02 00 00 |..IO..7.z.7^....|
|
||||
00000050 4f 00 2b 00 02 03 04 00 33 00 45 00 17 00 41 04 |O.+.....3.E...A.|
|
||||
00000060 1e 18 37 ef 0d 19 51 88 35 75 71 b5 e5 54 5b 12 |..7...Q.5uq..T[.|
|
||||
00000070 2e 8f 09 67 fd a7 24 20 3e b2 56 1c ce 97 28 5e |...g..$ >.V...(^|
|
||||
00000080 f8 2b 2d 4f 9e f1 07 9f 6c 4b 5b 83 56 e2 32 42 |.+-O....lK[.V.2B|
|
||||
00000090 e9 58 b6 d7 49 a6 b5 68 1a 41 03 56 6b dc 5a 89 |.X..I..h.A.Vk.Z.|
|
||||
000000a0 17 03 03 00 17 42 79 da 18 8e 38 c1 2c a4 2a 9c |.....By...8.,.*.|
|
||||
000000b0 fd 94 6a a6 b3 08 51 aa 7b 2d 19 a7 17 03 03 02 |..j...Q.{-......|
|
||||
000000c0 6d 57 f7 92 34 01 09 13 e8 f8 ef 75 ad ba e8 a5 |mW..4......u....|
|
||||
000000d0 9b cd e9 6c ab 48 b5 4d 33 1e 0b 95 47 74 78 9d |...l.H.M3...Gtx.|
|
||||
000000e0 3c bb 27 a8 87 1c fb 11 80 91 93 ad 0f 0d 1c 98 |<.'.............|
|
||||
000000f0 44 cc 36 bc 00 0d eb c0 8b 73 40 11 dd c5 9a a9 |D.6......s@.....|
|
||||
00000100 90 55 81 e8 55 69 e0 73 97 49 c3 2b ee 56 3c c0 |.U..Ui.s.I.+.V<.|
|
||||
00000110 c3 b7 4a 18 a3 e4 45 c9 7f 0c 7d ba b4 52 9a a8 |..J...E...}..R..|
|
||||
00000120 b1 26 4e 57 3b fb 5b 30 28 b0 95 c9 72 35 2d 10 |.&NW;.[0(...r5-.|
|
||||
00000130 24 8e 70 bb c6 2a 33 83 1c 78 c1 91 c4 6b 06 c0 |$.p..*3..x...k..|
|
||||
00000140 d0 65 b5 d5 21 21 02 21 86 df 24 d0 99 90 24 12 |.e..!!.!..$...$.|
|
||||
00000150 9f c8 a4 8d e9 29 5c 84 52 82 4b 11 a6 de 7f 88 |.....)\.R.K.....|
|
||||
00000160 d9 35 b3 1b d5 c9 0a 54 f2 64 a7 43 13 19 61 0f |.5.....T.d.C..a.|
|
||||
00000170 28 11 39 3f b1 2a 49 f7 0f de cb f8 ff ad b6 90 |(.9?.*I.........|
|
||||
00000180 5a af 2a 17 9a 40 c7 c8 32 88 5d e1 af 54 92 3a |Z.*..@..2.]..T.:|
|
||||
00000190 8b b9 8a 50 93 dd 73 89 cf 0f bf ae 7e ad ba bf |...P..s.....~...|
|
||||
000001a0 ed 2a f1 47 e0 e5 77 92 27 e5 5b bd 7f 7e a5 47 |.*.G..w.'.[..~.G|
|
||||
000001b0 af dd d7 ab 72 db 1a bb 83 f8 18 ba 46 92 74 a2 |....r.......F.t.|
|
||||
000001c0 9e 7a 5c 4d e8 b9 c0 6e ed 20 6d ec 8f 3d 65 d6 |.z\M...n. m..=e.|
|
||||
000001d0 d5 48 4b 24 14 00 10 2c f2 31 c1 94 ce b6 f8 e2 |.HK$...,.1......|
|
||||
000001e0 e1 d3 8c e7 38 3c 4b 34 1f 78 8d e0 9b d3 9d 21 |....8<K4.x.....!|
|
||||
000001f0 44 c7 02 59 47 5b c1 25 83 19 f3 7c 0c b3 ca a6 |D..YG[.%...|....|
|
||||
00000200 1f 64 1b 4d 37 24 a8 b3 e4 e2 b9 be 68 c9 8a 80 |.d.M7$......h...|
|
||||
00000210 15 6d 71 70 7d 15 51 26 b5 e8 cc 99 51 ee a6 34 |.mqp}.Q&....Q..4|
|
||||
00000220 ab 5d 7b 0a f6 3c 30 9e a5 e1 fe ff 38 fb 5c 09 |.]{..<0.....8.\.|
|
||||
00000230 28 84 d2 67 52 5a 79 b6 9e a0 9a fe d2 93 cc 9b |(..gRZy.........|
|
||||
00000240 31 90 a1 b4 c6 0f b9 50 73 b2 52 39 ff 6e 16 a1 |1......Ps.R9.n..|
|
||||
00000250 78 29 1c 30 c1 8f 76 81 08 e9 96 a2 3c 8e 17 94 |x).0..v.....<...|
|
||||
00000260 05 15 2c 46 11 b7 23 1d 10 75 43 68 f2 97 49 12 |..,F..#..uCh..I.|
|
||||
00000270 d3 e2 a9 08 25 e8 c1 2b b8 ee 5f a3 bc 9e 88 92 |....%..+.._.....|
|
||||
00000280 21 1b da 9a c4 cd f1 53 8b a7 ca d3 4b de d4 61 |!......S....K..a|
|
||||
00000290 64 8b 67 42 43 99 fd cc c6 6f ac c0 9d 48 2c 79 |d.gBC....o...H,y|
|
||||
000002a0 89 cf f2 3a 88 86 3d 40 a3 a6 07 6e 05 88 3d 60 |...:..=@...n..=`|
|
||||
000002b0 e7 b1 5b a5 47 5d 36 b2 1e 68 c7 d2 8d 5f 1e 1d |..[.G]6..h..._..|
|
||||
000002c0 2c c3 77 f1 31 7c 2f bc a1 4b f3 96 cd a9 45 18 |,.w.1|/..K....E.|
|
||||
000002d0 9c 19 72 52 39 2d bf 84 05 b8 d0 2b 3c 5d f5 c7 |..rR9-.....+<]..|
|
||||
000002e0 cc 7b f7 ca 17 68 e3 53 f8 64 68 01 a3 76 5a a1 |.{...h.S.dh..vZ.|
|
||||
000002f0 e9 65 95 72 bc 89 98 7a e4 d4 d6 12 e7 83 23 4c |.e.r...z......#L|
|
||||
00000300 03 28 b4 62 0d c9 16 16 cd 85 7e 87 5f ac f7 62 |.(.b......~._..b|
|
||||
00000310 04 d3 9d 99 a4 e9 93 16 39 c5 88 b5 52 21 8f 87 |........9...R!..|
|
||||
00000320 82 bb 77 32 10 36 2a ca d7 7b ab 8a 42 e0 17 03 |..w2.6*..{..B...|
|
||||
00000330 03 00 99 3a bf a3 34 93 48 fb 05 37 66 85 cd 71 |...:..4.H..7f..q|
|
||||
00000340 03 a1 6a 3a 67 f7 f8 12 ce 2e e6 21 08 b9 68 c1 |..j:g......!..h.|
|
||||
00000350 f3 21 20 fe 5f 43 dc 29 5b 15 70 04 25 26 db ae |.! ._C.)[.p.%&..|
|
||||
00000360 c9 52 03 1d d7 82 77 73 9f 18 76 07 db 48 85 f4 |.R....ws..v..H..|
|
||||
00000370 cb d7 cb 26 ce 74 2d 92 74 67 5c 59 d7 ec 35 a1 |...&.t-.tg\Y..5.|
|
||||
00000380 59 e6 24 1b 16 a0 7b 3a 71 80 a4 53 af 84 9b 63 |Y.$...{:q..S...c|
|
||||
00000390 bd 50 38 0f da aa b6 da c8 d2 12 94 f2 83 12 d7 |.P8.............|
|
||||
000003a0 9b e6 7b d2 91 b0 e7 dd 27 ec 47 19 94 0e 7e a2 |..{.....'.G...~.|
|
||||
000003b0 43 07 78 ed 73 c9 33 55 52 9a 34 c1 64 c0 a7 5d |C.x.s.3UR.4.d..]|
|
||||
000003c0 82 8b c0 c7 da c9 9f cf 64 06 d4 1e 17 03 03 00 |........d.......|
|
||||
000003d0 45 bf 5b 5a 59 de 6a 6a 69 5c f0 9d 1c e1 5c b9 |E.[ZY.jji\....\.|
|
||||
000003e0 e3 3c d1 64 b3 83 d0 3c 7b 11 e4 db 34 00 2a f7 |.<.d...<{...4.*.|
|
||||
000003f0 3a 15 ca 90 0f e9 37 39 ac d0 c6 aa fd ef 3b 5d |:.....79......;]|
|
||||
00000400 29 97 4c 24 cb 4a 56 a1 db 77 80 b3 75 f5 1b 2f |).L$.JV..w..u../|
|
||||
00000410 4a 54 8f 2e 0c c2 |JT....|
|
||||
>>> Flow 3 (client to server)
|
||||
00000000 14 03 03 00 01 01 17 03 03 00 45 b1 15 d9 f0 b0 |..........E.....|
|
||||
00000010 cf 81 8f de 00 84 97 be 1b 6f af 52 3b d2 34 1b |.........o.R;.4.|
|
||||
00000020 4d bb d3 b8 c2 09 60 21 e1 61 d3 d9 a1 80 68 77 |M.....`!.a....hw|
|
||||
00000030 6c 37 6a 87 0e e7 b7 de fe b6 70 eb d3 36 92 c3 |l7j.......p..6..|
|
||||
00000040 e9 e9 02 e9 cf d0 d4 be 75 9b f3 84 51 fe da 78 |........u...Q..x|
|
||||
>>> Flow 4 (server to client)
|
||||
00000000 17 03 03 00 1e 7f 61 7b 92 ca 8f 9e c7 96 b0 a5 |......a{........|
|
||||
00000010 9b 3f cf c3 0e 7a 8d 2c 9f 5c 40 8a 99 6d 71 45 |.?...z.,.\@..mqE|
|
||||
00000020 9a 9c 96 17 03 03 00 13 01 42 62 3a 49 1a b5 5b |.........Bb:I..[|
|
||||
00000030 43 0f ec 5b 46 0a e9 1c 6f a6 e2 |C..[F...o..|
|
Loading…
Add table
Add a link
Reference in a new issue