|
44 | 44 | from xmlrpc import client as xmlrpclib
|
45 | 45 | import ssl
|
46 | 46 | from tlslite import *
|
47 |
| -from tlslite.constants import KeyUpdateMessageType |
| 47 | +from tlslite.constants import KeyUpdateMessageType, ECPointFormat |
48 | 48 |
|
49 | 49 | try:
|
50 | 50 | from tack.structures.Tack import Tack
|
@@ -303,6 +303,76 @@ 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 | + |
| 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 | + connection.handshakeClientCert(settings=settings) |
| 330 | + testConnClient(connection) |
| 331 | + assert connection.session.ec_point_format == ECPointFormat.ansiX962_compressed_prime |
| 332 | + connection.close() |
| 333 | + |
| 334 | + test_no += 1 |
| 335 | + |
| 336 | + print("Test {0} - client missing uncompressed - error, TLSv1.2".format(test_no)) |
| 337 | + synchro.recv(1) |
| 338 | + connection = connect() |
| 339 | + settings = HandshakeSettings() |
| 340 | + settings.minVersion = (3, 3) |
| 341 | + settings.maxVersion = (3, 3) |
| 342 | + settings.ec_point_formats = [ECPointFormat.ansiX962_compressed_prime] |
| 343 | + settings.eccCurves = ["secp256r1", "secp384r1", "secp521r1", "x25519", "x448"] |
| 344 | + settings.keyShares = ["secp256r1"] |
| 345 | + try: |
| 346 | + connection.handshakeClientCert(settings=settings) |
| 347 | + assert False |
| 348 | + except ValueError as e: |
| 349 | + assert "Uncompressed EC point format is not provided" in str(e) |
| 350 | + except TLSAbruptCloseError as e: |
| 351 | + pass |
| 352 | + connection.close() |
| 353 | + |
| 354 | + test_no += 1 |
| 355 | + |
| 356 | + print("Test {0} - client comppressed char2 - error, TLSv1.2".format(test_no)) |
| 357 | + synchro.recv(1) |
| 358 | + connection = connect() |
| 359 | + settings = HandshakeSettings() |
| 360 | + settings.minVersion = (3, 3) |
| 361 | + settings.maxVersion = (3, 3) |
| 362 | + settings.ec_point_formats = [ECPointFormat.ansiX962_compressed_char2] |
| 363 | + settings.eccCurves = ["secp256r1", "secp384r1", "secp521r1", "x25519", "x448"] |
| 364 | + settings.keyShares = ["secp256r1"] |
| 365 | + try: |
| 366 | + connection.handshakeClientCert(settings=settings) |
| 367 | + assert False |
| 368 | + except ValueError as e: |
| 369 | + assert "Unknown EC point format provided: [2]" in str(e) |
| 370 | + except TLSAbruptCloseError as e: |
| 371 | + pass |
| 372 | + connection.close() |
| 373 | + |
| 374 | + test_no += 1 |
| 375 | + |
306 | 376 | print("Test {0} - mismatched ECDSA curve, TLSv1.2".format(test_no))
|
307 | 377 | synchro.recv(1)
|
308 | 378 | connection = connect()
|
@@ -2194,6 +2264,79 @@ def connect():
|
2194 | 2264 |
|
2195 | 2265 | test_no += 1
|
2196 | 2266 |
|
| 2267 | + print("Test {0} - server uncompressed ec format - uncompressed, TLSv1.2".format(test_no)) |
| 2268 | + synchro.send(b'R') |
| 2269 | + connection = connect() |
| 2270 | + settings = HandshakeSettings() |
| 2271 | + settings.minVersion = (3, 1) |
| 2272 | + settings.maxVersion = (3, 3) |
| 2273 | + settings.eccCurves = ["secp256r1", "secp384r1", "secp521r1", "x25519", "x448"] |
| 2274 | + settings.keyShares = ["secp256r1"] |
| 2275 | + settings.ec_point_formats = [ECPointFormat.uncompressed] |
| 2276 | + connection.handshakeServer(certChain=x509ecdsaChain, |
| 2277 | + privateKey=x509ecdsaKey, settings=settings) |
| 2278 | + testConnServer(connection) |
| 2279 | + assert connection.session.ec_point_format == ECPointFormat.uncompressed |
| 2280 | + connection.close() |
| 2281 | + |
| 2282 | + test_no += 1 |
| 2283 | + |
| 2284 | + print("Test {0} - server compressed ec format - compressed, TLSv1.2".format(test_no)) |
| 2285 | + synchro.send(b'R') |
| 2286 | + connection = connect() |
| 2287 | + settings = HandshakeSettings() |
| 2288 | + settings.minVersion = (3, 1) |
| 2289 | + settings.maxVersion = (3, 3) |
| 2290 | + settings.eccCurves = ["secp256r1", "secp384r1", "secp521r1", "x25519", "x448"] |
| 2291 | + settings.keyShares = ["secp256r1"] |
| 2292 | + connection.handshakeServer(certChain=x509ecdsaChain, |
| 2293 | + privateKey=x509ecdsaKey, settings=settings) |
| 2294 | + testConnServer(connection) |
| 2295 | + assert connection.session.ec_point_format == ECPointFormat.ansiX962_compressed_prime |
| 2296 | + connection.close() |
| 2297 | + |
| 2298 | + test_no +=1 |
| 2299 | + |
| 2300 | + print("Test {0} - server missing uncompressed in client - error, TLSv1.2".format(test_no)) |
| 2301 | + synchro.send(b'R') |
| 2302 | + connection = connect() |
| 2303 | + settings = HandshakeSettings() |
| 2304 | + settings.minVersion = (3, 1) |
| 2305 | + settings.maxVersion = (3, 3) |
| 2306 | + settings.eccCurves = ["secp256r1", "secp384r1", "secp521r1", "x25519", "x448"] |
| 2307 | + settings.keyShares = ["secp256r1"] |
| 2308 | + try: |
| 2309 | + connection.handshakeServer(certChain=x509ecdsaChain, |
| 2310 | + privateKey=x509ecdsaKey, settings=settings) |
| 2311 | + assert False |
| 2312 | + except ValueError as e: |
| 2313 | + assert "Uncompressed EC point format is not provided" in str(e) |
| 2314 | + except TLSAbruptCloseError as e: |
| 2315 | + pass |
| 2316 | + connection.close() |
| 2317 | + |
| 2318 | + test_no +=1 |
| 2319 | + |
| 2320 | + print("Test {0} - client compressed char2 - error, TLSv1.2".format(test_no)) |
| 2321 | + synchro.send(b'R') |
| 2322 | + connection = connect() |
| 2323 | + settings = HandshakeSettings() |
| 2324 | + settings.minVersion = (3, 1) |
| 2325 | + settings.maxVersion = (3, 3) |
| 2326 | + settings.eccCurves = ["secp256r1", "secp384r1", "secp521r1", "x25519", "x448"] |
| 2327 | + settings.keyShares = ["secp256r1"] |
| 2328 | + try: |
| 2329 | + connection.handshakeServer(certChain=x509ecdsaChain, |
| 2330 | + privateKey=x509ecdsaKey, settings=settings) |
| 2331 | + assert False |
| 2332 | + except ValueError as e: |
| 2333 | + assert "Unknown EC point format provided: [2]" in str(e) |
| 2334 | + except TLSAbruptCloseError as e: |
| 2335 | + pass |
| 2336 | + connection.close() |
| 2337 | + |
| 2338 | + test_no +=1 |
| 2339 | + |
2197 | 2340 | print("Test {0} - mismatched ECDSA curve, TLSv1.2".format(test_no))
|
2198 | 2341 | synchro.send(b'R')
|
2199 | 2342 | connection = connect()
|
@@ -3450,7 +3593,7 @@ def heartbeat_response_check(message):
|
3450 | 3593 | assert synchro.recv(1) == b'R'
|
3451 | 3594 | connection.close()
|
3452 | 3595 |
|
3453 |
| - test_no += 1 |
| 3596 | + test_no +=1 |
3454 | 3597 |
|
3455 | 3598 | print("Tests {0}-{1} - XMLRPXC server".format(test_no, test_no + 2))
|
3456 | 3599 |
|
@@ -3483,6 +3626,7 @@ def add(self, x, y): return x + y
|
3483 | 3626 |
|
3484 | 3627 | synchro.close()
|
3485 | 3628 | synchroSocket.close()
|
| 3629 | + |
3486 | 3630 | test_no += 2
|
3487 | 3631 |
|
3488 | 3632 | print("Test succeeded")
|
|
0 commit comments