|
44 | 44 | from xmlrpc import client as xmlrpclib |
45 | 45 | import ssl |
46 | 46 | from tlslite import * |
| 47 | +from tlslite.constants import KeyUpdateMessageType |
47 | 48 |
|
48 | 49 | try: |
49 | 50 | from tack.structures.Tack import Tack |
@@ -77,10 +78,18 @@ def testConnClient(conn): |
77 | 78 | conn.write(b10) |
78 | 79 | conn.write(b100) |
79 | 80 | conn.write(b1000) |
80 | | - assert(conn.read(min=1, max=1) == b1) |
81 | | - assert(conn.read(min=10, max=10) == b10) |
82 | | - assert(conn.read(min=100, max=100) == b100) |
83 | | - assert(conn.read(min=1000, max=1000) == b1000) |
| 81 | + r1 = conn.read(min=1, max=1) |
| 82 | + assert len(r1) == 1 |
| 83 | + assert r1 == b1 |
| 84 | + r10 = conn.read(min=10, max=10) |
| 85 | + assert len(r10) == 10 |
| 86 | + assert r10 == b10 |
| 87 | + r100 = conn.read(min=100, max=100) |
| 88 | + assert len(r100) == 100 |
| 89 | + assert r100 == b100 |
| 90 | + r1000 = conn.read(min=1000, max=1000) |
| 91 | + assert len(r1000) == 1000 |
| 92 | + assert r1000 == b1000 |
84 | 93 |
|
85 | 94 | def clientTestCmd(argv): |
86 | 95 |
|
@@ -1203,6 +1212,51 @@ def heartbeat_response_check(message): |
1203 | 1212 |
|
1204 | 1213 | test_no += 1 |
1205 | 1214 |
|
| 1215 | + print("Test {0} - KeyUpdate from client in TLSv1.3".format(test_no)) |
| 1216 | + assert synchro.recv(1) == b'R' |
| 1217 | + connection = connect() |
| 1218 | + settings = HandshakeSettings() |
| 1219 | + settings.maxVersion = (3, 4) |
| 1220 | + connection.handshakeClientCert(serverName=address[0], settings=settings) |
| 1221 | + assert synchro.recv(1) == b'K' |
| 1222 | + for i in connection.send_keyupdate_request(KeyUpdateMessageType.update_requested): |
| 1223 | + assert i in (0, 1) |
| 1224 | + assert synchro.recv(1) == b'K' |
| 1225 | + testConnClient(connection) |
| 1226 | + connection.close() |
| 1227 | + |
| 1228 | + test_no += 1 |
| 1229 | + |
| 1230 | + print("Test {0} - mutual KeyUpdates in TLSv1.3".format(test_no)) |
| 1231 | + assert synchro.recv(1) == b'R' |
| 1232 | + connection = connect() |
| 1233 | + settings = HandshakeSettings() |
| 1234 | + settings.maxVersion = (3, 4) |
| 1235 | + connection.handshakeClientCert(serverName=address[0], settings=settings) |
| 1236 | + for i in connection.send_keyupdate_request(KeyUpdateMessageType.update_requested): |
| 1237 | + assert i in (0, 1) |
| 1238 | + testConnClient(connection) |
| 1239 | + synchro.send(b'R') |
| 1240 | + connection.close() |
| 1241 | + |
| 1242 | + test_no += 1 |
| 1243 | + |
| 1244 | + print("Test {0} - multiple mutual KeyUpdates in TLSv1.3".format(test_no)) |
| 1245 | + assert synchro.recv(1) == b'R' |
| 1246 | + connection = connect() |
| 1247 | + settings = HandshakeSettings() |
| 1248 | + settings.maxVersion = (3, 4) |
| 1249 | + connection.handshakeClientCert(serverName=address[0], settings=settings) |
| 1250 | + for i in connection.send_keyupdate_request(KeyUpdateMessageType.update_requested): |
| 1251 | + assert i in (0, 1) |
| 1252 | + for i in connection.send_keyupdate_request(KeyUpdateMessageType.update_requested): |
| 1253 | + assert i in (0, 1) |
| 1254 | + testConnClient(connection) |
| 1255 | + synchro.send(b'R') |
| 1256 | + connection.close() |
| 1257 | + |
| 1258 | + test_no += 1 |
| 1259 | + |
1206 | 1260 | print('Test {0} - good standard XMLRPC https client'.format(test_no)) |
1207 | 1261 | address = address[0], address[1]+1 |
1208 | 1262 | synchro.recv(1) |
@@ -2274,8 +2328,53 @@ def heartbeat_response_check(message): |
2274 | 2328 |
|
2275 | 2329 | test_no += 1 |
2276 | 2330 |
|
| 2331 | + print("Test {0} - KeyUpdate from client in TLSv1.3".format(test_no)) |
| 2332 | + synchro.send(b'R') |
| 2333 | + connection = connect() |
| 2334 | + settings = HandshakeSettings() |
| 2335 | + settings.maxVersion = (3, 4) |
| 2336 | + connection.handshakeServer(certChain=x509Chain, privateKey=x509Key, |
| 2337 | + settings=settings) |
| 2338 | + synchro.send(b'K') |
| 2339 | + synchro.send(b'K') |
| 2340 | + testConnServer(connection) |
| 2341 | + connection.close() |
| 2342 | + |
| 2343 | + test_no += 1 |
| 2344 | + |
| 2345 | + print("Test {0} - mutual KeyUpdates in TLSv1.3".format(test_no)) |
| 2346 | + synchro.send(b'R') |
| 2347 | + connection = connect() |
| 2348 | + settings = HandshakeSettings() |
| 2349 | + settings.maxVersion = (3, 4) |
| 2350 | + connection.handshakeServer(certChain=x509Chain, privateKey=x509Key, |
| 2351 | + settings=settings) |
| 2352 | + for i in connection.send_keyupdate_request(KeyUpdateMessageType.update_requested): |
| 2353 | + assert i in (0, 1) |
| 2354 | + testConnServer(connection) |
| 2355 | + assert synchro.recv(1) == b'R' |
| 2356 | + connection.close() |
| 2357 | + |
| 2358 | + test_no += 1 |
| 2359 | + |
| 2360 | + print("Test {0} - multiple mutual KeyUpdates in TLSv1.3".format(test_no)) |
| 2361 | + synchro.send(b'R') |
| 2362 | + connection = connect() |
| 2363 | + settings = HandshakeSettings() |
| 2364 | + settings.maxVersion = (3, 4) |
| 2365 | + connection.handshakeServer(certChain=x509Chain, privateKey=x509Key, |
| 2366 | + settings=settings) |
| 2367 | + for i in connection.send_keyupdate_request(KeyUpdateMessageType.update_requested): |
| 2368 | + assert i in (0, 1) |
| 2369 | + for i in connection.send_keyupdate_request(KeyUpdateMessageType.update_requested): |
| 2370 | + assert i in (0, 1) |
| 2371 | + testConnServer(connection) |
| 2372 | + assert synchro.recv(1) == b'R' |
| 2373 | + connection.close() |
| 2374 | + |
| 2375 | + test_no += 1 |
| 2376 | + |
2277 | 2377 | print("Tests {0}-{1} - XMLRPXC server".format(test_no, test_no + 2)) |
2278 | | - test_no += 2 |
2279 | 2378 |
|
2280 | 2379 | address = address[0], address[1]+1 |
2281 | 2380 | class Server(TLSXMLRPCServer): |
@@ -2306,6 +2405,7 @@ def add(self, x, y): return x + y |
2306 | 2405 |
|
2307 | 2406 | synchro.close() |
2308 | 2407 | synchroSocket.close() |
| 2408 | + test_no += 2 |
2309 | 2409 |
|
2310 | 2410 | print("Test succeeded") |
2311 | 2411 |
|
|
0 commit comments