示例#1
0
def createAESGCM(key, implList=None):
    """Create a new AESGCM object.

    @type key: bytearray
    @param key: A 16 or 32 byte byte array.

    @rtype: L{tlslite.utils.AESGCM}
    @return: An AESGCM object.
    """
    if implList is None:
        implList = ["pycrypto", "python"]

    for impl in implList:
        if impl == "pycrypto" and cryptomath.pycryptoLoaded:
            return pycrypto_aesgcm.new(key)
        if impl == "python":
            return python_aesgcm.new(key)
    raise NotImplementedError()
示例#2
0
def createAESGCM(key, implList=None):
    """Create a new AESGCM object.

    @type key: bytearray
    @param key: A 16 or 32 byte byte array.

    @rtype: L{tlslite.utils.AESGCM}
    @return: An AESGCM object.
    """
    if implList is None:
        implList = ["pycrypto", "python"]

    for impl in implList:
        if impl == "pycrypto" and cryptomath.pycryptoLoaded:
            return pycrypto_aesgcm.new(key)
        if impl == "python":
            return python_aesgcm.new(key)
    raise NotImplementedError()
示例#3
0
from tlslite.utils.cryptomath import *
import time
from tlslite.utils import pycrypto_aesgcm
from tlslite.tlsconnection import *
from tlslite.api import *

authdata = bytearray(6)
nonce = bytearray(12)

times = 10000
k = bytearray(32)
a = bytearray(32)
label = bytearray(b'derived')

aesgcm = pycrypto_aesgcm.new(k)
plaintext = bytearray(512)
ciphertext = bytearray(144)

print 'testing secureHMAC sha256'
time1 = time.time()
for i in range(times):
    result = secureHMAC(k, a, 'sha256')
time2 = time.time()
result = (time2 * 1000 - time1 * 1000) / times
print 'sha256 HMAC is ' + str(result) + ' milisecond'

print 'testing secureHMAC sha384'
time1 = time.time()
for i in range(times):
    result = secureHMAC(k, a, 'sha384')
time2 = time.time()