| OLD | NEW |
| 1 #! python | 1 #! python |
| 2 | 2 |
| 3 import sys | 3 import sys |
| 4 import os | 4 import os |
| 5 import os.path | 5 import os.path |
| 6 import socket | 6 import socket |
| 7 import thread | 7 import thread |
| 8 import time | 8 import time |
| 9 import httplib | 9 import httplib |
| 10 import BaseHTTPServer | 10 import BaseHTTPServer |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 connection = connect() | 84 connection = connect() |
| 85 connection.fault = fault | 85 connection.fault = fault |
| 86 try: | 86 try: |
| 87 connection.handshakeClientSRP("test", "password") | 87 connection.handshakeClientSRP("test", "password") |
| 88 print " Good Fault %s" % (Fault.faultNames[fault]) | 88 print " Good Fault %s" % (Fault.faultNames[fault]) |
| 89 except TLSFaultError, e: | 89 except TLSFaultError, e: |
| 90 print " BAD FAULT %s: %s" % (Fault.faultNames[fault], str(e)) | 90 print " BAD FAULT %s: %s" % (Fault.faultNames[fault], str(e)) |
| 91 badFault = True | 91 badFault = True |
| 92 connection.sock.close() | 92 connection.sock.close() |
| 93 | 93 |
| 94 print "Test 5 - good SRP: unknown_srp_username idiom" | 94 print "Test 5 - good SRP: unknown_psk_identity idiom" |
| 95 def srpCallback(): | 95 def srpCallback(): |
| 96 return ("test", "password") | 96 return ("test", "password") |
| 97 connection = connect() | 97 connection = connect() |
| 98 connection.handshakeClientUnknown(srpCallback=srpCallback) | 98 connection.handshakeClientUnknown(srpCallback=srpCallback) |
| 99 connection.close() | 99 connection.close() |
| 100 connection.sock.close() | 100 connection.sock.close() |
| 101 | 101 |
| 102 print "Test 6 - good SRP: with X.509 certificate" | 102 print "Test 6 - good SRP: with X.509 certificate" |
| 103 connection = connect() | 103 connection = connect() |
| 104 connection.handshakeClientSRP("test", "password") | 104 connection.handshakeClientSRP("test", "password") |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 for fault in Fault.clientSrpFaults + Fault.genericFaults: | 458 for fault in Fault.clientSrpFaults + Fault.genericFaults: |
| 459 connection = connect() | 459 connection = connect() |
| 460 connection.fault = fault | 460 connection.fault = fault |
| 461 try: | 461 try: |
| 462 connection.handshakeServer(verifierDB=verifierDB) | 462 connection.handshakeServer(verifierDB=verifierDB) |
| 463 assert() | 463 assert() |
| 464 except: | 464 except: |
| 465 pass | 465 pass |
| 466 connection.sock.close() | 466 connection.sock.close() |
| 467 | 467 |
| 468 print "Test 5 - good SRP: unknown_srp_username idiom" | 468 print "Test 5 - good SRP: unknown_psk_identity idiom" |
| 469 connection = connect() | 469 connection = connect() |
| 470 connection.handshakeServer(verifierDB=verifierDB) | 470 connection.handshakeServer(verifierDB=verifierDB) |
| 471 connection.close() | 471 connection.close() |
| 472 connection.sock.close() | 472 connection.sock.close() |
| 473 | 473 |
| 474 print "Test 6 - good SRP: with X.509 cert" | 474 print "Test 6 - good SRP: with X.509 cert" |
| 475 x509Cert = X509().parse(open(os.path.join(dir, "serverX509Cert.pem")).read()
) | 475 x509Cert = X509().parse(open(os.path.join(dir, "serverX509Cert.pem")).read()
) |
| 476 x509Chain = X509CertChain([x509Cert]) | 476 x509Chain = X509CertChain([x509Cert]) |
| 477 s = open(os.path.join(dir, "serverX509Key.pem")).read() | 477 s = open(os.path.join(dir, "serverX509Key.pem")).read() |
| 478 x509Key = parsePEMKey(s, private=True) | 478 x509Key = parsePEMKey(s, private=True) |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 if cmd == "clientsharedkey": | 886 if cmd == "clientsharedkey": |
| 887 print "Bad sharedkey password" | 887 print "Bad sharedkey password" |
| 888 else: | 888 else: |
| 889 raise | 889 raise |
| 890 elif a.description == AlertDescription.user_canceled: | 890 elif a.description == AlertDescription.user_canceled: |
| 891 print str(a) | 891 print str(a) |
| 892 else: | 892 else: |
| 893 raise | 893 raise |
| 894 sys.exit() | 894 sys.exit() |
| 895 except TLSRemoteAlert, a: | 895 except TLSRemoteAlert, a: |
| 896 if a.description == AlertDescription.unknown_srp_username: | 896 if a.description == AlertDescription.unknown_psk_identity: |
| 897 if cmd == "clientsrp": | 897 if cmd == "clientsrp": |
| 898 print "Unknown username" | 898 print "Unknown username" |
| 899 else: | 899 else: |
| 900 raise | 900 raise |
| 901 elif a.description == AlertDescription.bad_record_mac: | 901 elif a.description == AlertDescription.bad_record_mac: |
| 902 if cmd == "clientsrp": | 902 if cmd == "clientsrp": |
| 903 print "Bad username or password" | 903 print "Bad username or password" |
| 904 else: | 904 else: |
| 905 raise | 905 raise |
| 906 elif a.description == AlertDescription.handshake_failure: | 906 elif a.description == AlertDescription.handshake_failure: |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 s = "" | 1020 s = "" |
| 1021 while 1: | 1021 while 1: |
| 1022 newS = connection.read() | 1022 newS = connection.read() |
| 1023 if not newS: | 1023 if not newS: |
| 1024 break | 1024 break |
| 1025 s += newS | 1025 s += newS |
| 1026 if s[-1]=='\n': | 1026 if s[-1]=='\n': |
| 1027 connection.write(s) | 1027 connection.write(s) |
| 1028 s = "" | 1028 s = "" |
| 1029 except TLSLocalAlert, a: | 1029 except TLSLocalAlert, a: |
| 1030 if a.description == AlertDescription.unknown_srp_username: | 1030 if a.description == AlertDescription.unknown_psk_identity: |
| 1031 print "Unknown SRP username" | 1031 print "Unknown SRP username" |
| 1032 elif a.description == AlertDescription.bad_record_mac: | 1032 elif a.description == AlertDescription.bad_record_mac: |
| 1033 if cmd == "serversrp" or cmd == "serversrpcert": | 1033 if cmd == "serversrp" or cmd == "serversrpcert": |
| 1034 print "Bad SRP password for:", connection.allegedSrpUser
name | 1034 print "Bad SRP password for:", connection.allegedSrpUser
name |
| 1035 else: | 1035 else: |
| 1036 raise | 1036 raise |
| 1037 elif a.description == AlertDescription.handshake_failure: | 1037 elif a.description == AlertDescription.handshake_failure: |
| 1038 print "Unable to negotiate mutually acceptable parameters" | 1038 print "Unable to negotiate mutually acceptable parameters" |
| 1039 else: | 1039 else: |
| 1040 raise | 1040 raise |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1065 else: | 1065 else: |
| 1066 print "Bad command: '%s'" % cmd | 1066 print "Bad command: '%s'" % cmd |
| 1067 except TLSRemoteAlert, a: | 1067 except TLSRemoteAlert, a: |
| 1068 print str(a) | 1068 print str(a) |
| 1069 raise | 1069 raise |
| 1070 | 1070 |
| 1071 | 1071 |
| 1072 | 1072 |
| 1073 | 1073 |
| 1074 | 1074 |
| OLD | NEW |