1
1
#!/usr/bin/env python
2
2
3
- # Authors:
3
+ # Authors:
4
4
# Trevor Perrin
5
5
# Marcelo Fernandez - bugfix and NPN support
6
6
# Martin von Loewis - python 3 port
38
38
from tlslite .utils .dns_utils import is_valid_hostname
39
39
from tlslite .utils .cryptomath import getRandomBytes
40
40
from tlslite .constants import KeyUpdateMessageType
41
+ from tlslite .utils .compression import compression_algo_impls
41
42
42
43
try :
43
44
from tack .structures .Tack import Tack
@@ -58,7 +59,7 @@ def printUsage(s=None):
58
59
if tackpyLoaded :
59
60
print (" tackpy : Loaded" )
60
61
else :
61
- print (" tackpy : Not Loaded" )
62
+ print (" tackpy : Not Loaded" )
62
63
if m2cryptoLoaded :
63
64
print (" M2Crypto : Loaded" )
64
65
else :
@@ -76,10 +77,30 @@ def printUsage(s=None):
76
77
else :
77
78
print (" GMPY2 : Not Loaded" )
78
79
80
+ print ("" )
81
+ print ("Compression:" )
82
+ print (" zlib compress : Loaded" )
83
+ print (" zlib decompress : Loaded" )
84
+ print (" brotli compress : {0}" .format (
85
+ "Loaded" if compression_algo_impls ["brotli_compress" ]
86
+ else "Not Loaded"
87
+ ))
88
+ print (" brotli decompress : {0}" .format (
89
+ "Loaded" if compression_algo_impls ["brotli_decompress" ]
90
+ else "Not Loaded"
91
+ ))
92
+ print (" zstd decompress : {0}" .format (
93
+ "Loaded" if compression_algo_impls ["zstd_compress" ]
94
+ else "Not Loaded"
95
+ ))
96
+ print (" zstd decompress : {0}" .format (
97
+ "Loaded" if compression_algo_impls ["zstd_decompress" ]
98
+ else "Not Loaded"
99
+ ))
79
100
print ("" )
80
101
print ("""Commands:
81
102
82
- server
103
+ server
83
104
[-c CERT] [-k KEY] [-t TACK] [-v VERIFIERDB] [-d DIR] [-l LABEL] [-L LENGTH]
84
105
[--reqcert] [--param DHFILE] [--psk PSK] [--psk-ident IDENTITY]
85
106
[--psk-sha384] [--ssl3] [--max-ver VER] [--tickets COUNT] [--cipherlist]
@@ -144,8 +165,8 @@ def handleArgs(argv, argString, flagsList=[]):
144
165
try :
145
166
opts , argv = getopt .getopt (argv , getOptArgString , flagsList )
146
167
except getopt .GetoptError as e :
147
- printError (e )
148
- # Default values if arg not present
168
+ printError (e )
169
+ # Default values if arg not present
149
170
privateKey = None
150
171
cert_chain = None
151
172
virtual_hosts = []
@@ -367,6 +388,12 @@ def printGoodConnection(connection, seconds):
367
388
print (" Extended Master Secret: {0}" .format (
368
389
connection .extendedMasterSecret ))
369
390
print (" Session Resumed: {0}" .format (connection .resumed ))
391
+ if connection .client_cert_compression_algo :
392
+ print (" Client compression algorithm used: {0}" .format (
393
+ connection .client_cert_compression_algo ))
394
+ if connection .server_cert_compression_algo :
395
+ print (" Server compression algorithm used: {0}" .format (
396
+ connection .server_cert_compression_algo ))
370
397
371
398
def printExporter (connection , expLabel , expLength ):
372
399
if expLabel is None :
@@ -378,7 +405,7 @@ def printExporter(connection, expLabel, expLength):
378
405
print (" Exporter length: {0}" .format (expLength ))
379
406
print (" Keying material: {0}" .format (exp ))
380
407
381
-
408
+
382
409
def clientCmd (argv ):
383
410
(address , privateKey , cert_chain , virtual_hosts , username , password ,
384
411
expLabel ,
@@ -387,7 +414,7 @@ def clientCmd(argv):
387
414
handleArgs (argv , "kcuplLa" , ["psk=" , "psk-ident=" , "psk-sha384" ,
388
415
"resumption" , "ssl3" , "max-ver=" ,
389
416
"cipherlist=" ])
390
-
417
+
391
418
if (cert_chain and not privateKey ) or (not cert_chain and privateKey ):
392
419
raise SyntaxError ("Must specify CERT and KEY together" )
393
420
if (username and not password ) or (not username and password ):
@@ -403,7 +430,7 @@ def clientCmd(argv):
403
430
sock .connect (address )
404
431
sock .setsockopt (socket .IPPROTO_TCP , socket .TCP_NODELAY , 1 )
405
432
connection = TLSConnection (sock )
406
-
433
+
407
434
settings = HandshakeSettings ()
408
435
if psk :
409
436
settings .pskConfigs = [(psk_ident , psk , psk_hash )]
@@ -418,13 +445,13 @@ def clientCmd(argv):
418
445
try :
419
446
start = time_stamp ()
420
447
if username and password :
421
- connection .handshakeClientSRP (username , password ,
448
+ connection .handshakeClientSRP (username , password ,
422
449
settings = settings , serverName = address [0 ])
423
450
else :
424
451
connection .handshakeClientCert (cert_chain , privateKey ,
425
452
settings = settings , serverName = address [0 ], alpn = alpn )
426
453
stop = time_stamp ()
427
- print ("Handshake success" )
454
+ print ("Handshake success" )
428
455
except TLSLocalAlert as a :
429
456
if a .description == AlertDescription .user_canceled :
430
457
print (str (a ))
@@ -544,7 +571,7 @@ def serverCmd(argv):
544
571
print ("Using Tacks..." )
545
572
if reqCert :
546
573
print ("Asking for client certificates..." )
547
-
574
+
548
575
#############
549
576
sessionCache = SessionCache ()
550
577
username = None
0 commit comments