@@ -1493,22 +1493,26 @@ def connect():
14931493 testConnClient (connection )
14941494 assert (isinstance (connection .session .serverCertChain , X509CertChain ))
14951495 assert (connection .session .serverName == address [0 ])
1496+ assert (connection .version == (3 , 3 ))
14961497 assert (not connection .resumed )
14971498 assert (connection .encryptThenMAC )
1499+ assert (connection .session .tls_1_0_tickets )
14981500 connection .close ()
14991501 session = connection .session
15001502
15011503 # resume
15021504 synchro .recv (1 )
15031505 connection = connect ()
15041506 settings = HandshakeSettings ()
1507+ settings .macNames .remove ("aead" )
15051508 settings .maxVersion = (3 , 3 )
15061509 connection .handshakeClientCert (serverName = address [0 ], session = session ,
15071510 settings = settings )
15081511 testConnClient (connection )
15091512 assert (isinstance (connection .session .serverCertChain , X509CertChain ))
15101513 assert (connection .session .serverName == address [0 ])
15111514 assert (connection .resumed )
1515+ assert (connection .session .encryptThenMAC )
15121516 assert (connection .encryptThenMAC )
15131517 connection .close ()
15141518
@@ -1548,6 +1552,53 @@ def connect():
15481552
15491553 test_no += 1
15501554
1555+ print ("Test {0} - session_ticket resumption in TLSv1.2" .format (test_no ))
1556+ synchro .recv (1 )
1557+ connection = connect ()
1558+ settings = HandshakeSettings ()
1559+ connection .handshakeClientCert (serverName = address [0 ], settings = settings )
1560+ testConnClient (connection )
1561+ assert isinstance (connection .session .serverCertChain , X509CertChain )
1562+ assert connection .session .serverName == address [0 ]
1563+ assert not connection .resumed
1564+ session = connection .session
1565+ connection .close ()
1566+
1567+ # resume
1568+ synchro .recv (1 )
1569+ settings = HandshakeSettings ()
1570+ connection = connect ()
1571+ connection .handshakeClientCert (serverName = address [0 ], settings = settings , session = session )
1572+ testConnClient (connection )
1573+ assert connection .resumed
1574+ connection .close ()
1575+
1576+ test_no += 1
1577+
1578+ print ("Test {0} - session_ticket resumption in TLSv1.2 "
1579+ "with expired ticket" .format (test_no ))
1580+ synchro .recv (1 )
1581+ connection = connect ()
1582+ settings = HandshakeSettings ()
1583+ connection .handshakeClientCert (serverName = address [0 ], settings = settings )
1584+ testConnClient (connection )
1585+ assert isinstance (connection .session .serverCertChain , X509CertChain )
1586+ assert connection .session .serverName == address [0 ]
1587+ assert not connection .resumed
1588+ session = connection .session
1589+ connection .close ()
1590+
1591+ # resume
1592+ synchro .recv (1 )
1593+ settings = HandshakeSettings ()
1594+ connection = connect ()
1595+ connection .handshakeClientCert (serverName = address [0 ], settings = settings , session = session )
1596+ testConnClient (connection )
1597+ assert not connection .resumed
1598+ connection .close ()
1599+
1600+ test_no += 1
1601+
15511602 print ("Test {0} - resumption in TLSv1.3" .format (test_no ))
15521603 synchro .recv (1 )
15531604 connection = connect ()
@@ -3069,6 +3120,7 @@ def server_bind(self):
30693120 connection .handshakeServer (certChain = x509Chain , privateKey = x509Key ,
30703121 settings = settings )
30713122 testConnServer (connection )
3123+ assert (not connection .encryptThenMAC )
30723124 connection .close ()
30733125
30743126 test_no += 1
@@ -3078,24 +3130,28 @@ def server_bind(self):
30783130 connection = connect ()
30793131 connection .handshakeServer (certChain = x509Chain , privateKey = x509Key )
30803132 testConnServer (connection )
3133+ assert (not connection .encryptThenMAC )
30813134 connection .close ()
30823135
30833136 test_no += 1
30843137
30853138 print ("Test {0} - resumption with EtM" .format (test_no ))
30863139 synchro .send (b'R' )
30873140 sessionCache = SessionCache ()
3141+ settings = HandshakeSettings ()
3142+ settings .ticketKeys = [getRandomBytes (32 )]
30883143 connection = connect ()
30893144 connection .handshakeServer (certChain = x509Chain , privateKey = x509Key ,
3090- sessionCache = sessionCache )
3145+ sessionCache = sessionCache , settings = settings )
30913146 testConnServer (connection )
3147+ assert (connection .encryptThenMAC )
30923148 connection .close ()
30933149
30943150 # resume
30953151 synchro .send (b'R' )
30963152 connection = connect ()
30973153 connection .handshakeServer (certChain = x509Chain , privateKey = x509Key ,
3098- sessionCache = sessionCache )
3154+ sessionCache = sessionCache , settings = settings )
30993155 testConnServer (connection )
31003156 connection .close ()
31013157
@@ -3125,6 +3181,52 @@ def server_bind(self):
31253181
31263182 test_no += 1
31273183
3184+ print ("Test {0} - session_ticket resumption in TLSv1.2" .format (test_no ))
3185+ synchro .send (b'R' )
3186+ connection = connect ()
3187+ settings = HandshakeSettings ()
3188+ settings .maxVersion = (3 , 3 )
3189+ settings .ticketKeys = [getRandomBytes (32 )]
3190+ connection .handshakeServer (certChain = x509Chain , privateKey = x509Key ,
3191+ settings = settings )
3192+ testConnServer (connection )
3193+ connection .close ()
3194+
3195+ # resume
3196+ synchro .send (b'R' )
3197+ connection = connect ()
3198+ connection .handshakeServer (certChain = x509Chain , privateKey = x509Key ,
3199+ settings = settings )
3200+ testConnServer (connection )
3201+ connection .close ()
3202+
3203+ test_no += 1
3204+
3205+ print ("Test {0} - session_ticket resumption in TLSv1.2 "
3206+ "with expired ticket" .format (test_no ))
3207+ synchro .send (b'R' )
3208+ connection = connect ()
3209+ settings = HandshakeSettings ()
3210+ settings .ticketLifetime = 1
3211+ settings .maxVersion = (3 , 3 )
3212+ settings .ticketKeys = [getRandomBytes (32 )]
3213+ connection .handshakeServer (certChain = x509Chain , privateKey = x509Key ,
3214+ settings = settings )
3215+ testConnServer (connection )
3216+ connection .close ()
3217+
3218+ time .sleep (2 )
3219+
3220+ # resume
3221+ synchro .send (b'R' )
3222+ connection = connect ()
3223+ connection .handshakeServer (certChain = x509Chain , privateKey = x509Key ,
3224+ settings = settings )
3225+ testConnServer (connection )
3226+ connection .close ()
3227+
3228+ test_no += 1
3229+
31283230 print ("Test {0} - resumption in TLSv1.3" .format (test_no ))
31293231 synchro .send (b'R' )
31303232 connection = connect ()
@@ -3155,6 +3257,7 @@ def server_bind(self):
31553257 connection .handshakeServer (certChain = x509Chain , privateKey = x509Key ,
31563258 reqCert = True , settings = settings )
31573259 testConnServer (connection )
3260+ assert connection .session .clientCertChain
31583261 connection .close ()
31593262
31603263 # resume
0 commit comments