本文整理汇总了Python中tlslite.HandshakeSettings.cipherImplementations方法的典型用法代码示例。如果您正苦于以下问题:Python HandshakeSettings.cipherImplementations方法的具体用法?Python HandshakeSettings.cipherImplementations怎么用?Python HandshakeSettings.cipherImplementations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tlslite.HandshakeSettings
的用法示例。
在下文中一共展示了HandshakeSettings.cipherImplementations方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: clientTestCmd
# 需要导入模块: from tlslite import HandshakeSettings [as 别名]
# 或者: from tlslite.HandshakeSettings import cipherImplementations [as 别名]
#.........这里部分代码省略.........
for x in range(3):
synchro.recv(1)
h.request("GET", "/index.html")
r = h.getresponse()
assert(r.status == 200)
b = bytearray(r.read())
assert(b == htmlBody)
fingerprint = h.tlsSession.serverCertChain.getFingerprint()
assert(fingerprint)
break
except timeoutEx:
print("timeout, retrying...")
pass
address = address[0], address[1]+1
implementations = []
if m2cryptoLoaded:
implementations.append("openssl")
if pycryptoLoaded:
implementations.append("pycrypto")
implementations.append("python")
print("Test 22 - different ciphers, TLSv1.0")
for implementation in implementations:
for cipher in ["aes128", "aes256", "rc4"]:
print("Test 22:", end=' ')
synchro.recv(1)
connection = connect()
settings = HandshakeSettings()
settings.cipherNames = [cipher]
settings.cipherImplementations = [implementation, "python"]
settings.minVersion = (3,1)
settings.maxVersion = (3,1)
connection.handshakeClientCert(settings=settings)
testConnClient(connection)
print("%s %s" % (connection.getCipherName(), connection.getCipherImplementation()))
connection.close()
print("Test 23 - throughput test")
for implementation in implementations:
for cipher in ["aes128", "aes256", "3des", "rc4"]:
if cipher == "3des" and implementation not in ("openssl", "pycrypto"):
continue
print("Test 23:", end=' ')
synchro.recv(1)
connection = connect()
settings = HandshakeSettings()
settings.cipherNames = [cipher]
settings.cipherImplementations = [implementation, "python"]
connection.handshakeClientCert(settings=settings)
print("%s %s:" % (connection.getCipherName(), connection.getCipherImplementation()), end=' ')
startTime = time.clock()
connection.write(b"hello"*10000)
h = connection.read(min=50000, max=50000)
stopTime = time.clock()
if stopTime-startTime:
print("100K exchanged at rate of %d bytes/sec" % int(100000/(stopTime-startTime)))
else:
print("100K exchanged very fast")
示例2: connect
# 需要导入模块: from tlslite import HandshakeSettings [as 别名]
# 或者: from tlslite.HandshakeSettings import cipherImplementations [as 别名]
if m2cryptoLoaded:
implementations.append("openssl")
if pycryptoLoaded:
implementations.append("pycrypto")
implementations.append("python")
print "Test 22 - different ciphers, TLSv1.0"
for implementation in implementations:
for cipher in ["aes128", "aes256", "rc4"]:
print "Test 22:",
connection = connect()
settings = HandshakeSettings()
settings.cipherNames = [cipher]
settings.cipherImplementations = [implementation, "python"]
settings.minVersion = (3,1)
settings.maxVersion = (3,1)
connection.handshakeClientCert(settings=settings)
testConnClient(connection)
print ("%s %s" % (connection.getCipherName(), connection.getCipherImplementation()))
connection.close()
print "Test 23 - throughput test"
for implementation in implementations:
for cipher in ["aes128", "aes256", "3des", "rc4"]:
if cipher == "3des" and implementation not in ("openssl", "pycrypto"):
continue
print "Test 23:",
connection = connect()
示例3: serverTestCmd
# 需要导入模块: from tlslite import HandshakeSettings [as 别名]
# 或者: from tlslite.HandshakeSettings import cipherImplementations [as 别名]
#.........这里部分代码省略.........
os.chdir(dir)
address = address[0], address[1]+1
httpd = MyHTTPServer(address, SimpleHTTPRequestHandler)
for x in range(6):
synchro.send(b'R')
httpd.handle_request()
httpd.server_close()
cd = os.chdir(cd)
#Re-connect the listening socket
lsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
lsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
address = address[0], address[1]+1
lsock.bind(address)
lsock.listen(5)
implementations = []
if m2cryptoLoaded:
implementations.append("openssl")
if pycryptoLoaded:
implementations.append("pycrypto")
implementations.append("python")
print("Test 22 - different ciphers")
for implementation in ["python"] * len(implementations):
for cipher in ["aes128", "aes256", "rc4"]:
print("Test 22:", end=' ')
synchro.send(b'R')
connection = connect()
settings = HandshakeSettings()
settings.cipherNames = [cipher]
settings.cipherImplementations = [implementation, "python"]
connection.handshakeServer(certChain=x509Chain, privateKey=x509Key,
settings=settings)
print(connection.getCipherName(), connection.getCipherImplementation())
testConnServer(connection)
connection.close()
print("Test 23 - throughput test")
for implementation in implementations:
for cipher in ["aes128", "aes256", "3des", "rc4"]:
if cipher == "3des" and implementation not in ("openssl", "pycrypto"):
continue
print("Test 23:", end=' ')
synchro.send(b'R')
connection = connect()
settings = HandshakeSettings()
settings.cipherNames = [cipher]
settings.cipherImplementations = [implementation, "python"]
connection.handshakeServer(certChain=x509Chain, privateKey=x509Key,
settings=settings)
print(connection.getCipherName(), connection.getCipherImplementation())
h = connection.read(min=50000, max=50000)
assert(h == b"hello"*10000)
connection.write(h)
connection.close()
print("Test 24.a - Next-Protocol Server Negotiation")
synchro.send(b'R')
connection = connect()
示例4: serverTestCmd
# 需要导入模块: from tlslite import HandshakeSettings [as 别名]
# 或者: from tlslite.HandshakeSettings import cipherImplementations [as 别名]
#.........这里部分代码省略.........
synchro.send(b'R')
httpd.handle_request()
httpd.server_close()
cd = os.chdir(cd)
#Re-connect the listening socket
lsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
lsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
address = address[0], address[1]+1
lsock.bind(address)
lsock.listen(5)
implementations = []
if m2cryptoLoaded:
implementations.append("openssl")
if pycryptoLoaded:
implementations.append("pycrypto")
implementations.append("python")
test_no += 1
print("Test {0} - different ciphers".format(test_no))
for implementation in ["python"] * len(implementations):
for cipher in ["aes128", "aes256", "rc4"]:
test_no += 1
print("Test {0}:".format(test_no), end=' ')
synchro.send(b'R')
connection = connect()
settings = HandshakeSettings()
settings.cipherNames = [cipher]
settings.cipherImplementations = [implementation, "python"]
connection.handshakeServer(certChain=x509Chain, privateKey=x509Key,
settings=settings)
print(connection.getCipherName(), connection.getCipherImplementation())
testConnServer(connection)
connection.close()
test_no += 1
print("Test {0} - throughput test".format(test_no))
for implementation in implementations:
for cipher in ["aes128gcm", "aes256gcm", "aes128", "aes256", "3des",
"rc4", "chacha20-poly1305_draft00",
"chacha20-poly1305"]:
# skip tests with implementations that don't support them
if cipher == "3des" and implementation not in ("openssl",
"pycrypto"):
continue
if cipher in ("aes128gcm", "aes256gcm") and \
implementation not in ("pycrypto",
"python"):
continue
if cipher in ("chacha20-poly1305_draft00", "chacha20-poly1305") \
and implementation not in ("python", ):
continue
test_no += 1
print("Test {0}:".format(test_no), end=' ')
synchro.send(b'R')
connection = connect()
示例5: HandshakeSettings
# 需要导入模块: from tlslite import HandshakeSettings [as 别名]
# 或者: from tlslite.HandshakeSettings import cipherImplementations [as 别名]
#!/usr/bin/env python
from __future__ import print_function
from tlslite import HTTPTLSConnection, HandshakeSettings
from optparse import OptionParser
settings = HandshakeSettings()
settings.cipherNames = ['aes128gcm']
settings.keyExchangeNames = ['ecdhe_rsa']
settings.cipherImplementations = ["python"]
#settings.macNames = ['sha256']
settings.minVersion = (3,3)
settings.maxVersion = (3,3)
settings.useExperimentalTackExtension = True
def main():
parser = OptionParser(usage='%prog host filename [options]', description='A Simple https client used with tlslite-ng')
parser.add_option("--port", dest="port", help="port", default = 4443, type="int", metavar="4443")
parser.add_option("--algo", dest="algo", help="algo", default = "speck128")
parser.add_option("--keyEx", dest="keyEx", help="Key Exchange", default="ecdhe_rsa")
(options, arguments) = parser.parse_args()
if len(arguments) < 1:
parser.print_help()
exit(1)
示例6: clientTestCmd
# 需要导入模块: from tlslite import HandshakeSettings [as 别名]
# 或者: from tlslite.HandshakeSettings import cipherImplementations [as 别名]
#.........这里部分代码省略.........
h.request("GET", "/index.html")
r = h.getresponse()
assert(r.status == 200)
b = bytearray(r.read())
assert(b == htmlBody)
fingerprint = h.tlsSession.serverCertChain.getFingerprint()
assert(fingerprint)
time.sleep(2)
break
except timeoutEx:
print("timeout, retrying...")
pass
address = address[0], address[1]+1
implementations = []
if m2cryptoLoaded:
implementations.append("openssl")
if tlscryptoLoaded:
implementations.append("tlscrypto")
if pycryptoLoaded:
implementations.append("pycrypto")
implementations.append("python")
print("Test 22 - different ciphers, TLSv1.0")
for implementation in implementations:
for cipher in ["aes128", "aes256", "rc4"]:
print("Test 22:", end=' ')
connection = connect()
settings = HandshakeSettings()
settings.cipherNames = [cipher]
settings.cipherImplementations = [implementation, "python"]
settings.minVersion = (3,1)
settings.maxVersion = (3,1)
connection.handshakeClientCert(settings=settings)
testConnClient(connection)
print("%s %s" % (connection.getCipherName(), connection.getCipherImplementation()))
connection.close()
print("Test 23 - throughput test")
for implementation in implementations:
for cipher in ["aes128", "aes256", "3des", "rc4"]:
if cipher == "3des" and implementation not in ("openssl", "pycrypto"):
continue
print("Test 23:", end=' ')
connection = connect()
settings = HandshakeSettings()
settings.cipherNames = [cipher]
settings.cipherImplementations = [implementation, "python"]
connection.handshakeClientCert(settings=settings)
print("%s %s:" % (connection.getCipherName(), connection.getCipherImplementation()), end=' ')
startTime = time.clock()
connection.write(b"hello"*10000)
h = connection.read(min=50000, max=50000)
stopTime = time.clock()
if stopTime-startTime:
print("100K exchanged at rate of %d bytes/sec" % int(100000/(stopTime-startTime)))
else:
print("100K exchanged very fast")
assert(h == b"hello"*10000)
示例7: clientTestCmd
# 需要导入模块: from tlslite import HandshakeSettings [as 别名]
# 或者: from tlslite.HandshakeSettings import cipherImplementations [as 别名]
def clientTestCmd(argv):
address = argv[0]
dir = argv[1]
datasize = argv[2]
#Split address into hostname/port tuple
address = address.split(":")
address = ( address[0], int(address[1]) )
#open synchronisation FIFO
synchro = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
synchro.settimeout(40)
synchro.connect((address[0], address[1]-1))
def connect():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if hasattr(sock, 'settimeout'): #It's a python 2.3 feature
sock.settimeout(25)
sock.connect(address)
c = TLSConnection(sock)
return c
test_no = 0
badFault = False
message = dataRandomizer(datasize)
for cipher in [ "aes128gcm","aes128", "aes256",
"rc4", "chacha20-poly1305", "speck128", "speck128gcm","speck192gcm"]:
test_no += 1
t1 = time.time()
print("Test {0}:".format(test_no), end=' ')
synchro.recv(1)
connection = connect()
t2 = time.time()
settings = HandshakeSettings()
settings.cipherNames = [cipher]
settings.cipherImplementations = ["python"]
connection.handshakeClientCert(settings=settings)
t3 = time.time()
print("%s %s:" % (connection.getCipherName(), connection.getCipherImplementation()), end=' ')
if datasize == "3MB":
t3 = time.time()
connection.write(message)
h = connection.read(min=1500000, max=1500000)
t4 = time.time()
if t4-t3:
print("3MB exchanged at rate of %d bytes/sec" % int(3000000/(t4-t3)))
print ('Raw timers:','t1=', t1,'t2=', t2,'t3=', t3,'t4=', t4)
print ('Intervals:', t2-t1, t3-t2, t4-t3)
sizeInBytes = sys.getsizeof(h)*2
print("Tranmsitted data size:", sizeInBytes)
print("Throughput is bytes/sec:", round(sizeInBytes / (t4-t3), 3))
else:
print("3MB exchanged very fast")
assert(h == message)
elif datasize == "2MB":
t3 = time.time()
connection.write(message)
h = connection.read(min=1000000, max=1000000)
t4 = time.time()
if t4-t3:
print("2MB exchanged at rate of %d bytes/sec" % int(2000000/(t4-t3)))
print ('Raw timers:','t1=', t1,'t2=', t2,'t3=', t3,'t4=', t4)
print ('Intervals:', t2-t1, t3-t2, t4-t3)
sizeInBytes = sys.getsizeof(h)*2
print("Tranmsitted data size:", sizeInBytes)
print("Throughput:", round(sizeInBytes / (t4-t3), 3))
else:
print("2MB exchanged very fast")
assert(h == message)
elif datasize == "1MB":
t3 = time.time()
connection.write(message)
h = connection.read(min=500000, max=500000)
t4 = time.time()
if t4-t3:
print("1MB exchanged at rate of %d bytes/sec" % int(1000000/(t4-t3)))
print ('Raw timers:','t1=', t1,'t2=', t2,'t3=', t3,'t4=', t4)
print ('Intervals:', t2-t1, t3-t2, t4-t3)
sizeInBytes = sys.getsizeof(h)*2
print("Tranmsitted data size:", sizeInBytes)
print("Throughput:", round(sizeInBytes / (t4-t3), 3))
else:
print("1MB exchanged very fast")
assert(h == message)
#.........这里部分代码省略.........
示例8: serverTestCmd
# 需要导入模块: from tlslite import HandshakeSettings [as 别名]
# 或者: from tlslite.HandshakeSettings import cipherImplementations [as 别名]
def serverTestCmd(argv):
address = argv[0]
dir = argv[1]
datasize = argv[2]
#Split address into hostname/port tuple
address = address.split(":")
address = ( address[0], int(address[1]) )
#Create synchronisation FIFO
synchroSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
synchroSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
synchroSocket.bind((address[0], address[1]-1))
synchroSocket.listen(2)
#Connect to server
lsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
lsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
lsock.bind(address)
lsock.listen(5)
# following is blocking until the other side doesn't open
synchro = synchroSocket.accept()[0]
def connect():
return TLSConnection(lsock.accept()[0])
x509Cert = X509().parse(open(os.path.join(dir, "serverX509Cert.pem")).read())
x509Chain = X509CertChain([x509Cert])
s = open(os.path.join(dir, "serverX509Key.pem")).read()
x509Key = parsePEMKey(s, private=True)
test_no = 0
for cipher in ["aes128gcm", "aes128", "aes256", "rc4","chacha20-poly1305","speck128", "speck128gcm", "speck192gcm"]:
test_no += 1
print("Test {0}:".format(test_no), end=' ')
synchro.send(b'R')
connection = connect()
settings = HandshakeSettings()
settings.cipherNames = [cipher]
settings.cipherImplementations = ["python"]
connection.handshakeServer(certChain=x509Chain, privateKey=x509Key,
settings=settings)
print(connection.getCipherName(), connection.getCipherImplementation())
if datasize == "3MB":
h = connection.read(min=1500000, max=1500000)
elif datasize == "2MB":
h = connection.read(min=1000000, max=1000000)
elif datasize == "1MB":
h = connection.read(min=500000, max=500000)
elif datasize == "500k":
h = connection.read(min=250000, max=250000)
elif datasize == "100k":
h = connection.read(min=50000, max=50000)
elif datasize == "2k":
h = connection.read(min=1000, max=1000)
else:
print("Datasize not supported or syntax error! Exiting...")
exit(1)
connection.write(h)
connection.close()
synchro.close()
synchroSocket.close()
print("Test succeeded")