|
44 | 44 | from xmlrpc import client as xmlrpclib
|
45 | 45 | import ssl
|
46 | 46 | from tlslite import *
|
47 |
| -from tlslite.constants import KeyUpdateMessageType, SignatureScheme |
| 47 | +from tlslite.constants import KeyUpdateMessageType, ECPointFormat, SignatureScheme |
48 | 48 |
|
49 | 49 | try:
|
50 | 50 | from tack.structures.Tack import Tack
|
@@ -303,6 +303,77 @@ def connect():
|
303 | 303 |
|
304 | 304 | test_no += 1
|
305 | 305 |
|
| 306 | + print("Test {0} - client compressed/uncompressed - uncompressed, TLSv1.2".format(test_no)) |
| 307 | + synchro.recv(1) |
| 308 | + connection = connect() |
| 309 | + settings = HandshakeSettings() |
| 310 | + settings.minVersion = (3, 3) |
| 311 | + settings.maxVersion = (3, 3) |
| 312 | + settings.eccCurves = ["secp256r1", "secp384r1", "secp521r1", "x25519", "x448"] |
| 313 | + settings.keyShares = ["secp256r1"] |
| 314 | + connection.handshakeClientCert(settings=settings) |
| 315 | + testConnClient(connection) |
| 316 | + assert connection.session.ec_point_format == ECPointFormat.uncompressed |
| 317 | + connection.close() |
| 318 | + |
| 319 | + test_no += 1 |
| 320 | + |
| 321 | + print("Test {0} - client compressed - compressed, TLSv1.2".format(test_no)) |
| 322 | + synchro.recv(1) |
| 323 | + connection = connect() |
| 324 | + settings = HandshakeSettings() |
| 325 | + settings.minVersion = (3, 3) |
| 326 | + settings.maxVersion = (3, 3) |
| 327 | + settings.eccCurves = ["secp256r1", "secp384r1", "secp521r1", "x25519", "x448"] |
| 328 | + settings.keyShares = ["secp256r1"] |
| 329 | + settings.ec_point_formats = [ECPointFormat.ansiX962_compressed_prime, ECPointFormat.uncompressed] |
| 330 | + connection.handshakeClientCert(settings=settings) |
| 331 | + testConnClient(connection) |
| 332 | + assert connection.session.ec_point_format == ECPointFormat.ansiX962_compressed_prime |
| 333 | + connection.close() |
| 334 | + |
| 335 | + test_no += 1 |
| 336 | + |
| 337 | + print("Test {0} - client missing uncompressed - error, TLSv1.2".format(test_no)) |
| 338 | + synchro.recv(1) |
| 339 | + connection = connect() |
| 340 | + settings = HandshakeSettings() |
| 341 | + settings.minVersion = (3, 3) |
| 342 | + settings.maxVersion = (3, 3) |
| 343 | + settings.ec_point_formats = [ECPointFormat.ansiX962_compressed_prime] |
| 344 | + settings.eccCurves = ["secp256r1", "secp384r1", "secp521r1", "x25519", "x448"] |
| 345 | + settings.keyShares = ["secp256r1"] |
| 346 | + try: |
| 347 | + connection.handshakeClientCert(settings=settings) |
| 348 | + assert False |
| 349 | + except ValueError as e: |
| 350 | + assert "Uncompressed EC point format is not provided" in str(e) |
| 351 | + except TLSAbruptCloseError as e: |
| 352 | + pass |
| 353 | + connection.close() |
| 354 | + |
| 355 | + test_no += 1 |
| 356 | + |
| 357 | + print("Test {0} - client comppressed char2 - error, TLSv1.2".format(test_no)) |
| 358 | + synchro.recv(1) |
| 359 | + connection = connect() |
| 360 | + settings = HandshakeSettings() |
| 361 | + settings.minVersion = (3, 3) |
| 362 | + settings.maxVersion = (3, 3) |
| 363 | + settings.ec_point_formats = [ECPointFormat.ansiX962_compressed_char2] |
| 364 | + settings.eccCurves = ["secp256r1", "secp384r1", "secp521r1", "x25519", "x448"] |
| 365 | + settings.keyShares = ["secp256r1"] |
| 366 | + try: |
| 367 | + connection.handshakeClientCert(settings=settings) |
| 368 | + assert False |
| 369 | + except ValueError as e: |
| 370 | + assert "Unknown EC point format provided: ['ansiX962_compressed_char2']" in str(e) |
| 371 | + except TLSAbruptCloseError as e: |
| 372 | + pass |
| 373 | + connection.close() |
| 374 | + |
| 375 | + test_no += 1 |
| 376 | + |
306 | 377 | print("Test {0} - mismatched ECDSA curve, TLSv1.2".format(test_no))
|
307 | 378 | synchro.recv(1)
|
308 | 379 | connection = connect()
|
@@ -2220,6 +2291,79 @@ def connect():
|
2220 | 2291 |
|
2221 | 2292 | test_no += 1
|
2222 | 2293 |
|
| 2294 | + print("Test {0} - server uncompressed ec format - uncompressed, TLSv1.2".format(test_no)) |
| 2295 | + synchro.send(b'R') |
| 2296 | + connection = connect() |
| 2297 | + settings = HandshakeSettings() |
| 2298 | + settings.minVersion = (3, 1) |
| 2299 | + settings.maxVersion = (3, 3) |
| 2300 | + settings.eccCurves = ["secp256r1", "secp384r1", "secp521r1", "x25519", "x448"] |
| 2301 | + settings.keyShares = ["secp256r1"] |
| 2302 | + settings.ec_point_formats = [ECPointFormat.uncompressed] |
| 2303 | + connection.handshakeServer(certChain=x509ecdsaChain, |
| 2304 | + privateKey=x509ecdsaKey, settings=settings) |
| 2305 | + testConnServer(connection) |
| 2306 | + assert connection.session.ec_point_format == ECPointFormat.uncompressed |
| 2307 | + connection.close() |
| 2308 | + |
| 2309 | + test_no += 1 |
| 2310 | + |
| 2311 | + print("Test {0} - server compressed ec format - compressed, TLSv1.2".format(test_no)) |
| 2312 | + synchro.send(b'R') |
| 2313 | + connection = connect() |
| 2314 | + settings = HandshakeSettings() |
| 2315 | + settings.minVersion = (3, 1) |
| 2316 | + settings.maxVersion = (3, 3) |
| 2317 | + settings.eccCurves = ["secp256r1", "secp384r1", "secp521r1", "x25519", "x448"] |
| 2318 | + settings.keyShares = ["secp256r1"] |
| 2319 | + connection.handshakeServer(certChain=x509ecdsaChain, |
| 2320 | + privateKey=x509ecdsaKey, settings=settings) |
| 2321 | + testConnServer(connection) |
| 2322 | + assert connection.session.ec_point_format == ECPointFormat.ansiX962_compressed_prime |
| 2323 | + connection.close() |
| 2324 | + |
| 2325 | + test_no +=1 |
| 2326 | + |
| 2327 | + print("Test {0} - server missing uncompressed in client - error, TLSv1.2".format(test_no)) |
| 2328 | + synchro.send(b'R') |
| 2329 | + connection = connect() |
| 2330 | + settings = HandshakeSettings() |
| 2331 | + settings.minVersion = (3, 1) |
| 2332 | + settings.maxVersion = (3, 3) |
| 2333 | + settings.eccCurves = ["secp256r1", "secp384r1", "secp521r1", "x25519", "x448"] |
| 2334 | + settings.keyShares = ["secp256r1"] |
| 2335 | + try: |
| 2336 | + connection.handshakeServer(certChain=x509ecdsaChain, |
| 2337 | + privateKey=x509ecdsaKey, settings=settings) |
| 2338 | + assert False |
| 2339 | + except ValueError as e: |
| 2340 | + assert "Uncompressed EC point format is not provided" in str(e) |
| 2341 | + except TLSAbruptCloseError as e: |
| 2342 | + pass |
| 2343 | + connection.close() |
| 2344 | + |
| 2345 | + test_no +=1 |
| 2346 | + |
| 2347 | + print("Test {0} - client compressed char2 - error, TLSv1.2".format(test_no)) |
| 2348 | + synchro.send(b'R') |
| 2349 | + connection = connect() |
| 2350 | + settings = HandshakeSettings() |
| 2351 | + settings.minVersion = (3, 1) |
| 2352 | + settings.maxVersion = (3, 3) |
| 2353 | + settings.eccCurves = ["secp256r1", "secp384r1", "secp521r1", "x25519", "x448"] |
| 2354 | + settings.keyShares = ["secp256r1"] |
| 2355 | + try: |
| 2356 | + connection.handshakeServer(certChain=x509ecdsaChain, |
| 2357 | + privateKey=x509ecdsaKey, settings=settings) |
| 2358 | + assert False |
| 2359 | + except ValueError as e: |
| 2360 | + assert "Unknown EC point format provided: [2]" in str(e) |
| 2361 | + except TLSAbruptCloseError as e: |
| 2362 | + pass |
| 2363 | + connection.close() |
| 2364 | + |
| 2365 | + test_no +=1 |
| 2366 | + |
2223 | 2367 | print("Test {0} - mismatched ECDSA curve, TLSv1.2".format(test_no))
|
2224 | 2368 | synchro.send(b'R')
|
2225 | 2369 | connection = connect()
|
@@ -3509,7 +3653,7 @@ def heartbeat_response_check(message):
|
3509 | 3653 | assert synchro.recv(1) == b'R'
|
3510 | 3654 | connection.close()
|
3511 | 3655 |
|
3512 |
| - test_no += 1 |
| 3656 | + test_no +=1 |
3513 | 3657 |
|
3514 | 3658 | print("Tests {0}-{1} - XMLRPXC server".format(test_no, test_no + 2))
|
3515 | 3659 |
|
@@ -3542,6 +3686,7 @@ def add(self, x, y): return x + y
|
3542 | 3686 |
|
3543 | 3687 | synchro.close()
|
3544 | 3688 | synchroSocket.close()
|
| 3689 | + |
3545 | 3690 | test_no += 2
|
3546 | 3691 |
|
3547 | 3692 | print("Test succeeded")
|
|
0 commit comments