Skip to content

Commit d64fb45

Browse files
committed
tests
1 parent 7856693 commit d64fb45

File tree

2 files changed

+57
-91
lines changed

2 files changed

+57
-91
lines changed

src/Servers/Kestrel/Core/src/Middleware/TlsListenerMiddleware.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ private static ClientHelloParseState TryParseClientHello(ReadOnlySequence<byte>
134134
}
135135

136136
private static bool IsValidProtocolVersion(short version)
137-
=> version is 0x0002 // SSL 2.0 (0x0002)
138-
or 0x0300 // SSL 3.0 (0x0300)
137+
=> version is 0x0300 // SSL 3.0 (0x0300)
139138
or 0x0301 // TLS 1.0 (0x0301)
140139
or 0x0302 // TLS 1.1 (0x0302)
141140
or 0x0303 // TLS 1.2 (0x0303)

src/Servers/Kestrel/Core/test/TlsListenerMiddlewareTests.cs

Lines changed: 56 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -278,99 +278,64 @@ public static IEnumerable<object[]> InvalidClientHelloData_Segmented()
278278
0
279279
};
280280

281-
private static byte[] valid_ClientHelloStandard =
281+
private static byte[] valid_Ssl3ClientHello =
282282
{
283-
// SslPlainText.(ContentType+ProtocolVersion)
284-
0x16, 0x03, 0x03,
285-
// SslPlainText.length
286-
0x00, 0xCB,
287-
// Handshake.msg_type (client hello)
288-
0x01,
289-
// Handshake.length
290-
0x00, 0x00, 0xC7,
291-
// ClientHello.client_version
292-
0x03, 0x03,
293-
// ClientHello.random
294-
0x0C, 0x3C, 0x85, 0x78, 0xCA,
295-
0x67, 0x70, 0xAA, 0x38, 0xCB,
296-
0x28, 0xBC, 0xDC, 0x3E, 0x30,
297-
0xBF, 0x11, 0x96, 0x95, 0x1A,
298-
0xB9, 0xF0, 0x99, 0xA4, 0x91,
299-
0x09, 0x13, 0xB4, 0x89, 0x94,
300-
0x27, 0x2E,
301-
// ClientHello.SessionId
302-
0x00,
303-
// ClientHello.cipher_suites
304-
0x00, 0x2A, 0xC0, 0x2C, 0xC0,
305-
0x2B, 0xC0, 0x30, 0xC0, 0x2F,
306-
0x00, 0x9F, 0x00, 0x9E, 0xC0,
307-
0x24, 0xC0, 0x23, 0xC0, 0x28,
308-
0xC0, 0x27, 0xC0, 0x0A, 0xC0,
309-
0x09, 0xC0, 0x14, 0xC0, 0x13,
310-
0x00, 0x9D, 0x00, 0x9C, 0x00,
311-
0x3D, 0x00, 0x3C, 0x00, 0x35,
312-
0x00, 0x2F, 0x00, 0x0A,
313-
// ClientHello.compression_methods
314-
0x01, 0x01,
315-
// ClientHello.extension_list_length
316-
0x00, 0x74,
317-
// Extension.extension_type (server_name)
318-
0x00, 0x00,
319-
// ServerNameListExtension.length
320-
0x00, 0x39,
321-
// ServerName.length
322-
0x00, 0x37,
323-
// ServerName.type
324-
0x00,
325-
// HostName.length
326-
0x00, 0x34,
327-
// HostName.bytes
328-
0x61, 0x61, 0x61, 0x61, 0x61,
329-
0x61, 0x61, 0x61, 0x61, 0x61,
330-
0x61, 0x61, 0x61, 0x61, 0x61,
331-
0x61, 0x61, 0x61, 0x61, 0x61,
332-
0x61, 0x61, 0x61, 0x61, 0x61,
333-
0x61, 0x61, 0x61, 0x61, 0x61,
334-
0x61, 0x61, 0x61, 0x61, 0x61,
335-
0x61, 0x61, 0x61, 0x61, 0x61,
336-
0x61, 0x61, 0x61, 0x61, 0x61,
337-
0x61, 0x61, 0x61, 0x61, 0x61,
338-
0x61, 0x61,
339-
// Extension.extension_type (00 0A)
340-
0x00, 0x0A,
341-
// Extension 0A
342-
0x00, 0x08, 0x00, 0x06, 0x00,
343-
0x1D, 0x00, 0x17, 0x00, 0x18,
344-
// Extension.extension_type (00 0B)
345-
0x00, 0x0B,
346-
// Extension 0B
347-
0x00, 0x02, 0x01, 0x00,
348-
// Extension.extension_type (00 0D)
349-
0x00, 0x0D,
350-
// Extension 0D
351-
0x00, 0x14, 0x00, 0x12, 0x04,
352-
0x01, 0x05, 0x01, 0x02, 0x01,
353-
0x04, 0x03, 0x05, 0x03, 0x02,
354-
0x03, 0x02, 0x02, 0x06, 0x01,
355-
0x06, 0x03,
356-
// Extension.extension_type (00 23)
357-
0x00, 0x23,
358-
// Extension 00 23
359-
0x00, 0x00,
360-
// Extension.extension_type (00 17)
361-
0x00, 0x17,
362-
// Extension 17
363-
0x00, 0x00,
364-
// Extension.extension_type (FF 01)
365-
0xFF, 0x01,
366-
// Extension FF01
367-
0x00, 0x01, 0x00
283+
0x16, 0x03, 0x00, // ContentType: Handshake, Version: SSL 3.0
284+
0x00, 0x2F, // Length: 47 bytes
285+
0x01, // Handshake Type: ClientHello
286+
0x00, 0x00, 0x2B, // Length: 43 bytes
287+
0x03, 0x00, // Client Version: SSL 3.0
288+
// Random (32 bytes)
289+
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
290+
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
291+
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
292+
0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
293+
0x00, // Session ID Length
294+
0x00, 0x04, // Cipher Suites Length
295+
0x00, 0x2F, 0x00, 0x35, // Cipher Suites
296+
0x01, 0x00 // Compression Methods: null
297+
};
298+
299+
private static byte[] valid_Tls10ClientHello =
300+
{
301+
0x16, 0x03, 0x01, // ContentType: Handshake, Version: TLS 1.0
302+
0x00, 0x2F, // Length: 47 bytes
303+
0x01, // Handshake Type: ClientHello
304+
0x00, 0x00, 0x2B, // Length: 43 bytes
305+
0x03, 0x01, // Client Version: TLS 1.0
306+
// Random (32 bytes)
307+
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
308+
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
309+
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
310+
0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
311+
0x00, // Session ID Length
312+
0x00, 0x04, // Cipher Suites Length
313+
0x00, 0x2F, 0x00, 0x35, // Cipher Suites
314+
0x01, 0x00 // Compression Methods: null
315+
};
316+
317+
private static byte[] valid_Tls11ClientHello =
318+
{
319+
0x16, 0x03, 0x02, // ContentType: Handshake, Version: TLS 1.1
320+
0x00, 0x2F, // Length: 47 bytes
321+
0x01, // Handshake Type: ClientHello
322+
0x00, 0x00, 0x2B, // Length: 43 bytes
323+
0x03, 0x02, // Client Version: TLS 1.1
324+
// Random (32 bytes)
325+
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
326+
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
327+
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
328+
0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
329+
0x00, // Session ID Length
330+
0x00, 0x04, // Cipher Suites Length
331+
0x00, 0x2F, 0x00, 0x35, // Cipher Suites: TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA
332+
0x01, 0x00 // Compression Methods: null
368333
};
369334

370335
private static byte[] valid_Tls12ClientHello =
371336
{
372337
// SslPlainText.(ContentType+ProtocolVersion)
373-
0x16, 0x03, 0x01,
338+
0x16, 0x03, 0x03,
374339
// SslPlainText.length
375340
0x00, 0xD1,
376341
// Handshake.msg_type (client hello)
@@ -429,7 +394,7 @@ public static IEnumerable<object[]> InvalidClientHelloData_Segmented()
429394
private static byte[] valid_Tls13ClientHello =
430395
{
431396
// SslPlainText.(ContentType+ProtocolVersion)
432-
0x16, 0x03, 0x01,
397+
0x16, 0x03, 0x04,
433398
// SslPlainText.length
434399
0x01, 0x08,
435400
// Handshake.msg_type (client hello)
@@ -591,7 +556,9 @@ public static IEnumerable<object[]> InvalidClientHelloData_Segmented()
591556

592557
private static List<byte[]> valid_collection = new List<byte[]>()
593558
{
594-
valid_clientHelloHeader, valid_ClientHelloStandard, valid_Tls12ClientHello, valid_Tls13ClientHello, valid_TlsClientHelloNoExtensions
559+
valid_clientHelloHeader, valid_Ssl3ClientHello, valid_Tls10ClientHello,
560+
valid_Tls11ClientHello, valid_Tls12ClientHello, valid_Tls13ClientHello,
561+
valid_TlsClientHelloNoExtensions
595562
};
596563

597564
private static List<byte[]> invalid_collection = new List<byte[]>()

0 commit comments

Comments
 (0)