/relevation/ext/cryptopy-1.2.5.patched/crypto/common.py |
---|
0,0 → 1,21 |
""" crypto.common |
Common utility routines for crypto modules |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
""" |
def xorS(a,b): |
""" XOR two strings """ |
assert len(a)==len(b) |
x = [] |
for i in range(len(a)): |
x.append( chr(ord(a[i])^ord(b[i]))) |
return ''.join(x) |
def xor(a,b): |
""" XOR two strings """ |
x = [] |
for i in range(min(len(a),len(b))): |
x.append( chr(ord(a[i])^ord(b[i]))) |
return ''.join(x) |
/relevation/ext/cryptopy-1.2.5.patched/crypto/app/__init__.py |
---|
0,0 → 1,8 |
""" crypto.app |
Sample applications of CryptoPy |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
""" |
/relevation/ext/cryptopy-1.2.5.patched/crypto/app/filecrypt.py |
---|
0,0 → 1,87 |
#!/usr/bin/env python |
""" cipher.app.filecrypt |
File encryption script. |
Current uses an 'extended' AES algorithm. |
2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
""" |
import sys, getpass, getopt, os |
from crypto.cipher.trolldoll import Trolldoll |
from crypto.errors import DecryptNotBlockAlignedError |
from binascii_plus import * |
def main(): |
""" Main is the command line interface to filecrypt """ |
path, progName = os.path.split(sys.argv[0]) |
usage = """Usage: %s [-d | -e][a][?] [-k <passPhrase>] [-i <infile>] [-o <outfile>]\n""" % progName |
try: |
# use get opt to parse and validate command line |
optlist, args = getopt.getopt( sys.argv[1:], 'edk:i:o:' ) |
except getopt.GetoptError, err : |
sys.exit( "Error: %s\n%s" % (err,usage) ) |
print optlist,'\n------\n',args |
# make a dictionary and check for one occurance of each option |
optdict = {} |
for option in optlist: |
if not optdict.has_key(option[0]): |
optdict[option[0]] = option[1] |
else: |
sys.exit( "Error: duplicate option '%s'\n%s" % (option[0],usage) ) |
if optdict.has_key('-e') and optdict.has_key('-d'): |
sys.exit( "Error: Can not do both encrypt and decrypt, pick either '-e' or '-d'\n%s" % usage ) |
if not(optdict.has_key('-e') or optdict.has_key('-d')): |
sys.exit( "Error: Must select encrypt or decrypt, pick either '-e' or '-d'\n%s" % usage ) |
# determine the passphrase from the command line or by keyboard input |
if optdict.has_key('-k'): |
passPhrase = optdict['-k'] |
else: |
passPhrase = getpass.getpass('Key: ') |
# should really test for a good passphrase ................... |
# get input from file or stdin |
if optdict.has_key('-i'): |
infile = open(optdict['-i'],'rb') |
input = infile.read() |
else: |
input = sys.stdin.read() |
print "input (%d bytes): %s" % (len(input),b2a_pt(input)) |
alg=Trolldoll(ivSize=160) |
alg.setPassphrase( passPhrase ) |
# Encrypt or decrypt depending on the option selected |
if optdict.has_key('-e'): |
output = alg.encrypt(input) |
elif optdict.has_key('-d'): |
try: |
output = alg.decrypt(input) |
except DecryptNotBlockAlignedError, errMessage : |
sys.exit("""Error: %s\n Note this can be caused by inappropriate modification \n of binary files (Win issue with CR/LFs). Try -a mode. """ % errMessage ) |
# should check for integrity failure |
else: |
sys.exit( "Error: Must select encrypt or decrypt, pick either '-e' or '-d'\n%s" % usage ) |
print "output (%d bytes): %s" % (len(output),b2a_pt(output)) |
# put output to file or stdout |
if optdict.has_key('-o'): |
outfile = open(optdict['-o'],'wb') |
outfile.write( output ) |
else: |
sys.stdout.write( output ) |
sys.exit() # normal termination |
if __name__ == "__main__": |
""" Called when run from the command line """ |
main() |
/relevation/ext/cryptopy-1.2.5.patched/crypto/app |
---|
Property changes: |
Added: bugtraq:number |
+true |
\ No newline at end of property |
/relevation/ext/cryptopy-1.2.5.patched/crypto/entropy/__init__.py |
---|
0,0 → 1,8 |
""" crypto.entropy |
Entropy package of CryptoPy |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
""" |
/relevation/ext/cryptopy-1.2.5.patched/crypto/entropy/pagingEntropy.py |
---|
0,0 → 1,75 |
""" crypto.entropy.pagingEntropy |
Uses variations in disk access time to generator entropy. A long string is |
created that is bigger than available memory. Virtual memory access' create |
random variations in retrieval time. |
Just an experiment, not recommended for use at this time. |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
""" |
import struct |
class PagingEntropyCollector: |
""" collect entropy from memory paging """ |
def __init__(self, memSize=500000000L): #? how should this be picked? |
""" Initialize paging entropy collector, |
memSize must be larger than allocated memory """ |
self.size = memSize |
self.memBlock = self.size*chr(0) # long string of length self.size |
self.index = 0 |
import random |
self.rand = random.Random(1555551) |
def randomBytes(self, numberOfBytes, secondsPerBit=.05): |
byteString = '' |
for b in range(numberOfBytes): |
aByte = 0 |
for bit in range(8): |
aByte = aByte << 1 |
aByte = aByte ^ self.collectBit(secondsPerBit) |
byteString += chr(aByte) |
return byteString |
def collectBit(self, secondsPerBit=1.0): |
""" Collect an entropy bit by jumping around a long string and |
collecting the variation in time and number of samples per |
time interval """ |
t1 = time() |
count = 0 |
while (time()-t1) < secondsPerBit: # seconds per sample |
# use random to sample various virtual memory locations |
sample = self.memBlock[int(self.rand.random()*self.size)] |
count += 1 |
randomBit = intToParity(count)^floatToParity(time()-t1) |
return randomBit |
def intToParity(integer): |
s = struct.pack('i',integer) |
parity = 0 |
for character in s: |
byte = ord(character) |
parity = parity^(0x01&(byte^(byte>>1)^(byte>>2)^(byte>>3)^(byte>>4)^(byte>>5)^(byte>>6)^(byte>>7))) |
return parity |
def floatToParity(float): |
s = struct.pack('d',float) |
parity = 0 |
for character in s: |
byte = ord(character) |
parity = parity^(0x01&(byte^(byte>>1)^(byte>>2)^(byte>>3)^(byte>>4)^(byte>>5)^(byte>>6)^(byte>>7))) |
return parity |
if __name__ == "__main__": |
from binascii import b2a_hex |
e = PagingEntropyCollector() |
for i in range(20): |
e.rand.seed(1) # make each sample set the same to allow examination of statistics |
print b2a_hex( e.randomBytes(16) ) |
/relevation/ext/cryptopy-1.2.5.patched/crypto/entropy/prn_rijndael_test.py |
---|
0,0 → 1,31 |
#! /usr/bin/env python |
""" crypto.entropy.prn_rijndael_test |
Unit test for prn_rijndael |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
""" |
from crypto.entropy.prn_rijndael import PRN_Rijndael |
from binascii import b2a_hex |
""" Not much of a test yet .... """ |
if __name__ == "__main__": |
r = PRN_Rijndael() |
for i in range(20): |
print b2a_hex(r.getSomeBytes()) |
for i in range (20): |
r.getBytes(i) |
for i in range(40): |
c=r.getBytes(i) |
print b2a_hex(r.getBytes(i)) |
r.reseed(c) |
/relevation/ext/cryptopy-1.2.5.patched/crypto/entropy/prn_rijndael.py |
---|
0,0 → 1,62 |
""" crypto.entropy.prn_rijndael |
A Psudeo Random Number Generator based on Rijndael_256k_256b |
The algorithm is based on Section 13.4 of: |
"AES Proposal: Rijndael", Joan Daemen, Vincent Rijmen |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
""" |
from crypto.cipher.rijndael import Rijndael |
from crypto.cipher.base import noPadding |
from binascii import b2a_hex |
defaultSeed = "An arbirary 32 byte string!!!!!!" # can be changed by the truely paranoid |
class PRN_Rijndael: |
""" A Psudeo Random Number Generator based on Rijndael_256k_256b |
The algorithm is based on Section 13.4 of: |
"AES Proposal: Rijndael", Joan Daemen, Vincent Rijmen |
""" |
def __init__(self, seed=defaultSeed): |
self.__algorithm = Rijndael(padding=noPadding(),keySize=32, blockSize=32) |
self.reset() |
self.reseed(seed) |
def reset(self): |
self.__algorithm.setKey(self.__algorithm.keySize*chr(0)) # set key to all zeros |
self.__state = self.__algorithm.blockSize*chr(0) # a single block of zeros |
def reseed(self,seed): |
while len(seed) > 0 : |
if len(seed) < self.__algorithm.blockSize: |
block = seed + (self.__algorithm.blockSize-len(seed))*chr(0) |
seed = '' |
else: |
block = seed[:self.__algorithm.blockSize] |
seed = seed[self.__algorithm.blockSize:] |
self.__algorithm.setKey( self.__algorithm.encrypt(block) ) |
def getBytes(self, numBytes): |
""" Return a psuedo random byte string of length numBytes """ |
bytes = '' |
while len(bytes)< numBytes : |
bytes = bytes + self.getSomeBytes() |
return bytes[:numBytes] # truncate to the requested length |
def getSomeBytes(self): |
""" Psuedo random bytes are generated 16 bytes at a time. |
The state is updated by applying Rijndael using the Cipher |
Key. The first 128 bits of the state are output as a pseudorandom number. |
""" |
self.__state = self.__algorithm.encrypt(self.__state) |
return self.__state[:16] |
/relevation/ext/cryptopy-1.2.5.patched/crypto/entropy |
---|
Property changes: |
Added: bugtraq:number |
+true |
\ No newline at end of property |
/relevation/ext/cryptopy-1.2.5.patched/crypto/icedoll_test.py |
---|
0,0 → 1,51 |
#! /usr/bin/env python |
""" crypto.cipher.icedoll_test |
Tests for icedoll encryption algorithm |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
""" |
from crypto.cipher.icedoll import Icedoll |
from crypto.cipher.base import noPadding |
from binascii import a2b_hex |
from binascii_plus import b2a_p, a2b_p |
import unittest |
class Icedoll_Basic_Tests(unittest.TestCase): |
""" Test Icedoll algorithm """ |
def testDctEqPt(self): |
""" test of plaintext = decrypt(encrypt(plaintext)) """ |
alg = Icedoll( 16*chr(0), padding=noPadding()) |
pt = 16*4*'a' # block aligned |
ct = alg.encrypt(pt) |
print 'ct = ',b2a_p(ct) |
dct = alg.decrypt(ct) |
print 'dct = ',b2a_p(dct) |
assert(pt == dct), 'pt != dct' |
alg = Icedoll( 16*chr(0)) # autoPad |
pt = 17*4*'a' # non-block aligned |
ct = alg.encrypt(pt) |
print 'ct = ',b2a_p(ct) |
dct = alg.decrypt(ct) |
print 'dct = ',b2a_p(dct) |
assert(pt == dct), 'pt != dct' |
def testEncrcptDecryptMultiSizesPt(self): |
""" Encrypt decrypt multiple sizes """ |
alg = Icedoll( 16*chr(0)) |
for size in range(100): |
pt = size*'a' |
ct = alg.encrypt(pt) |
#print 'ct = ',b2a_p(ct) |
dct = alg.decrypt(ct) |
#print 'dct = ',b2a_p(dct) |
assert(pt == dct), 'pt != dct' |
# Make this test module runnable from the command prompt |
if __name__ == "__main__": |
unittest.main() |
/relevation/ext/cryptopy-1.2.5.patched/crypto/errors.py |
---|
0,0 → 1,26 |
""" errors |
Error classes for cryptographic modules |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
""" |
class CryptoError(Exception): |
""" Base class for crypto exceptions """ |
def __init__(self,errorMessage='Error!'): |
self.message = errorMessage |
def __str__(self): |
return self.message |
class InitCryptoError(CryptoError): |
""" Crypto errors during algorithm initialization """ |
class BadKeySizeError(InitCryptoError): |
""" Bad key size error """ |
class EncryptError(CryptoError): |
""" Error in encryption processing """ |
class DecryptError(CryptoError): |
""" Error in decryption processing """ |
class DecryptNotBlockAlignedError(DecryptError): |
""" Error in decryption processing """ |
class IntegrityCheckError(DecryptError): |
""" Bad integrity detected during decryption (integrity aware algorithms) """ |
/relevation/ext/cryptopy-1.2.5.patched/crypto/hash/__init__.py |
---|
0,0 → 1,3 |
""" The crypto.hash package. |
Part of the CryptoPy framework. |
""" |
/relevation/ext/cryptopy-1.2.5.patched/crypto/hash/sha1Hash_test.py |
---|
0,0 → 1,51 |
#!/usr/bin/env python |
""" sha1Hash_test.py |
Unit tests for sha1.py |
""" |
from crypto.hash.sha1Hash import SHA1 |
import unittest |
import struct |
assert struct.calcsize('!IIIII') == 20, '5 integers should be 20 bytes' |
class SHA1_FIPS180_TestCases(unittest.TestCase): |
""" SHA-1 tests from FIPS180-1 Appendix A, B and C """ |
def testFIPS180_1_Appendix_A(self): |
""" APPENDIX A. A SAMPLE MESSAGE AND ITS MESSAGE DIGEST """ |
hashAlg = SHA1() |
message = 'abc' |
message_digest = 0xA9993E36L, 0x4706816AL, 0xBA3E2571L, 0x7850C26CL, 0x9CD0D89DL |
md_string = _toBString(message_digest) |
assert( hashAlg(message) == md_string ), 'FIPS180 Appendix A test Failed' |
def testFIPS180_1_Appendix_B(self): |
""" APPENDIX B. A SECOND SAMPLE MESSAGE AND ITS MESSAGE DIGEST """ |
hashAlg = SHA1() |
message = 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq' |
message_digest = 0x84983E44L, 0x1C3BD26EL, 0xBAAE4AA1L, 0xF95129E5L, 0xE54670F1L |
md_string = _toBString(message_digest) |
assert( hashAlg(message) == md_string ), 'FIPS180 Appendix B test Failed' |
def testFIPS180_1_Appendix_C(self): |
""" APPENDIX C. A THIRD SAMPLE MESSAGE AND ITS MESSAGE DIGEST |
Let the message be the binary-coded form of the ASCII string which consists |
of 1,000,000 repetitions of "a". """ |
hashAlg = SHA1() |
message = 1000000*'a' |
message_digest = 0x34AA973CL, 0xD4C4DAA4L, 0xF61EEB2BL, 0xDBAD2731L, 0x6534016FL |
md_string = _toBString(message_digest) |
assert( hashAlg(message) == md_string ), 'FIPS180 Appendix C test Failed' |
def _toBlock(binaryString): |
""" Convert binary string to blocks of 5 words of uint32() """ |
return [uint32(word) for word in struct.unpack('!IIIII', binaryString)] |
def _toBString(block): |
""" Convert block (5 words of 32 bits to binary string """ |
return ''.join([struct.pack('!I',word) for word in block]) |
if __name__ == '__main__': |
# Run the tests from the command line |
unittest.main() |
/relevation/ext/cryptopy-1.2.5.patched/crypto/hash/sha1Hash.py |
---|
0,0 → 1,37 |
""" crypto.hash.sha1Hash |
Wrapper for python sha module to support crypo module standard interface |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
""" |
import sha |
from crypto.hash.hash import Hash |
class SHA1(Hash): |
def __init__( self ): |
self.name = 'SHA1' |
self.blocksize = 1 # single octets can be hashed by padding to raw block size |
self.raw_block_size = 64 # SHA1 operates on 512 bit / 64 byte blocks |
self.digest_size = 20 # or 160 bits |
self.reset() |
def reset(self): |
self.pysha1 = sha.new() |
def update(self,data): |
""" Update the sha object with the string arg. Repeated calls are |
equivalent to a single call with the concatenation of all the |
arguments: m.update(a); m.update(b) is equivalent to m.update(a+b). |
""" |
self.pysha1.update(data) |
def digest(self): |
""" Return the digest of the strings passed to the update() |
method so far. This is a 20-byte string which may contain |
non-ASCII characters, including null bytes. |
""" |
return self.pysha1.digest() |
/relevation/ext/cryptopy-1.2.5.patched/crypto/hash/hash.py |
---|
0,0 → 1,36 |
""" crypto.cipher.hash |
Base class for cryptographic hash algorithms |
An alternate interface (no 'new'). |
Copyright © (c) 2002 by Paul A. Lambert. |
""" |
from binascii import b2a_hex |
class Hash: |
def __init__( self ): |
raise 'must overload' |
def reset(self): |
raise 'must overload' |
def __call__(self, data, more=None): |
return self.hash(data,more) |
def hash(self,data,more=None): |
self.update(data) |
digest = self.digest() |
if more==None: |
self.reset() # no more data, reset |
return digest |
def update(self,data): |
""" Update the hash object with the data. Repeated calls are |
equivalent to a single call with the concatenation of all the |
arguments: m.update(a); m.update(b) is equivalent to m.update(a+b). |
""" |
raise 'must overload' |
def digest(self): |
raise 'must overload' |
def final(self,data): |
return self.hash(data) |
def hexdigest(self): |
""" Return the digest of the data in ascii-hex format """ |
return b2a_hex(self.digest()) |
# def hexdigest(self): not supported yet |
# def copy(self): not supported yet ... may change |
/relevation/ext/cryptopy-1.2.5.patched/crypto/hash/md5Hash_test.py |
---|
0,0 → 1,26 |
#!/usr/bin/env python |
""" md5Hash_test.py |
Unit tests for md5Hash.py (not the default python library!) |
MD5 defined in RFC 1321 |
""" |
from crypto.hash.md5Hash import MD5 |
import unittest |
from binascii import a2b_hex |
class MD5_TestCases(unittest.TestCase): |
""" MD5 tests from ...""" |
def testFIPS180_1_Appendix_A(self): |
""" APPENDIX A. A SAMPLE MESSAGE AND ITS MESSAGE DIGEST """ |
hashAlg = MD5() |
message = 'abc' |
message_digest = '900150983cd24fb0d6963f7d28e17f72' |
md_string = a2b_hex(message_digest) |
assert( hashAlg(message) == md_string ), 'md5 test Failed' |
if __name__ == '__main__': |
# Run the tests from the command line |
unittest.main() |
/relevation/ext/cryptopy-1.2.5.patched/crypto/hash/md5Hash.py |
---|
0,0 → 1,31 |
""" md5Hash.py |
Wrapper for python md5 module to support crypo module standard interface |
""" |
import md5 |
from crypto.hash.hash import Hash |
class MD5(Hash): |
def __init__( self ): |
self.name = 'MD5' |
self.blocksize = 1 # single octets can be hashed by padding to raw block size |
self.raw_block_size = 64 # MD5 operates on 512 bits or 64 byte blocks |
self.digest_size = 16 # or 128 bits |
self.reset() |
def reset(self): |
self.pymd5 = md5.new() |
def update(self,data): |
""" Update the md5 object with the string arg. Repeated calls are |
equivalent to a single call with the concatenation of all the |
arguments: m.update(a); m.update(b) is equivalent to m.update(a+b). |
""" |
self.pymd5.update(data) |
def digest(self): |
""" Return the digest of the strings passed to the update() |
method so far. This is a 20-byte string which may contain |
non-ASCII characters, including null bytes. |
""" |
return self.pymd5.digest() |
/relevation/ext/cryptopy-1.2.5.patched/crypto/hash |
---|
Property changes: |
Added: bugtraq:number |
+true |
\ No newline at end of property |
/relevation/ext/cryptopy-1.2.5.patched/crypto/keyedHash/prf_dot11_test.py |
---|
0,0 → 1,54 |
#!/usr/bin/env python |
""" crypto.keyedHash.prf_dot11_test |
Tests of the IEEE 802.11 PRF functions |
""" |
from crypto.keyedHash.prf_dot11 import PRF |
import unittest |
from binascii_plus import b2a_hex, a2b_hex, b2a_p, a2b_p |
class prf_TestVectors(unittest.TestCase): |
""" PRF from IEEE 802.11 testing known values """ |
def testKnowValues(self): |
""" Test vectors from 11-02-298r0-I-suggested-changes-to-RSN.doc |
Modified to show prefix and correct length. |
""" |
for [key,data,digest,prf_know_value] in prfTestVectors: |
# the 298r test vectors do not include the prefix :-( |
prefix = 'prefix' |
# remove white spaces and convert to binary string |
prf_value = a2b_p(prf_know_value) |
lengthInBits=8*len(prf_value) |
a_prf = PRF(key,prefix,data,lengthInBits) |
print 'key = ', b2a_p(key) |
print 'prefix = ', '"'+prefix+'"' |
print 'data = ', b2a_p(data) |
print 'PRF = ', b2a_p(a_prf) |
print 'PRF_v = ', b2a_p(prf_value) |
print 'len prf= ', len(a_prf)* 8 |
self.assertEqual(a_prf, prf_value) |
""" -------------- (key, data, digest, prf_value) ------------------ """ |
prfTestVectors =((a2b_hex('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b'), |
'Hi There', |
'b617318655057264e28bc0b6fb378c8ef146be00', |
'bcd4c650b30b9684951829e0d75f9d54'), |
('Jefe', |
'what do ya want for nothing?', |
'effcdf6ae5eb2fa2d27416d5f184df9c259a7c79', |
"""51f4de5b33f249adf81aeb713a3c20f4fe631446fabdfa58 |
244759ae58ef9009a99abf4eac2ca5fa87e692c440eb40023e |
7babb206d61de7b92f41529092b8fc"""), |
(20*chr(0xaa), |
50*chr(0xdd), #0xdd repeated 50 times |
'125d7342b9ac11cd91a39af48aa17b4f63f175d3', |
"""e1ac546ec4cb636f9976487be5c86be17a0252ca5d8d8df12c |
fb0473525249ce9dd8d177ead710bc9b590547239107aef7b4ab |
d43d87f0a68f1cbd9e2b6f7607""")) |
# Make this test module runnable from the command prompt |
if __name__ == "__main__": |
unittest.main() |
/relevation/ext/cryptopy-1.2.5.patched/crypto/keyedHash/tkip_mic_test.py |
---|
0,0 → 1,83 |
#!/usr/bin/env python |
""" Testing of TKIP_MIC Class |
""" |
from crypto.keyedHash.tkip_mic import TKIP_MIC |
from binascii_plus import * |
from struct import pack, unpack |
import unittest |
class TKIP_MIC_Tests(unittest.TestCase): |
""" Test MIC algorithm using know values """ |
def testAdrianExample1(self): |
""" Test 1 from Adrian 2002-12-12""" |
print "==== Test 1 Adrian ====" |
# raw data |
k0 = 0x00000000L # assume is a 'dword' |
k1 = 0x00000000L |
key = pack('<II', k0, k1 ) # pack two integers into string little-endian |
a1 = a2b_p('161514131211') |
a2 = a2b_p('262524232221') |
a3 = a2b_p('363534333231') # assumed to be TA |
a4 = a2b_p('464544434241') |
tcid = 2 |
payload = a2b_p('10 11 12 13 14 15 16 17 18 19 1a 1b 1c') |
# this looks like a 4 addresses example do: |
sa = a2 # a4 |
da = a1 # a3 |
print "key =", b2a_p(key) |
print "sa =", b2a_p(sa) |
print "da =", b2a_p(da) |
print "tcid =", tcid |
print "payload =", b2a_p(payload) |
v0 = 0x85a3fe4cL |
v1 = 0x20f4105fL |
micResultAdrian = pack('<II', v0, v1) # pack little-endian dwords into 8 octets |
tkipMic = TKIP_MIC(key) |
micResult = tkipMic.hash(sa, da, tcid, payload ) |
print "expected MIC =", b2a_p(micResultAdrian) |
print "MIC Result =", b2a_p(micResult) |
v0Result, v1Result = unpack('<II', micResult) |
self.assertEqual( v0, v0Result ), 'failed vo' |
self.assertEqual( v1, v1Result ), 'failed v1' |
def testParagExample1(self): |
""" Test 2 from Parag 2002-12-16""" |
print "==== Test 2 ====" |
# raw data |
k0 = 0x01234567L |
k1 = 0x89abcdefL |
key = pack('<II', k0, k1 ) # pack two integers into string little-endian |
da = a2b_p('aaaaaaaaaaaa') |
sa = a2b_p('bbbbbbbbbbbb') |
priority = 0x03 |
payload = pack('<IIIIIIIIIII',0xdeaf0005L, 0xdeaf0006L, 0xdeaf0007L, 0xdeaf0008L, 0xdeaf0009L, 0xdeaf000aL, 0xdeaf000bL, 0xdeaf000cL, 0xdeaf000dL, 0xdeaf000eL, 0x00ccdd00L) |
payload = payload[:-1] # trim off last octet |
print "key =", b2a_p(key) |
print "sa =", b2a_p(sa) |
print "da =", b2a_p(da) |
print "priority =", priority |
print "payload =", b2a_p(payload) |
# The know MIC is |
v0 = 0xe597b391L |
v1 = 0xb8c4a7b7L |
micResultParag = pack('<II', v0, v1) # pack little-endian dwords into 8 octets |
tkipMic = TKIP_MIC(key) |
tcid = priority |
micResult = tkipMic.hash(sa, da, tcid, payload ) |
print "expected MIC =", b2a_p(micResultParag) |
print "MIC Result =", b2a_p(micResult) |
v0Result, v1Result = unpack('<II', micResult) |
self.assertEqual( v0, v0Result ), 'failed vo' |
self.assertEqual( v1, v1Result ), 'failed v1' |
if __name__ == '__main__': |
unittest.main() # run all the tests |
/relevation/ext/cryptopy-1.2.5.patched/crypto/keyedHash/__init__.py |
---|
0,0 → 1,7 |
""" crypto.keyedHash |
The keyedHash package. |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
""" |
/relevation/ext/cryptopy-1.2.5.patched/crypto/keyedHash/prf_dot11.py |
---|
0,0 → 1,38 |
""" prf_dot11.py |
The PRF function is used in a number of places in 802.11i |
to create psuedo random octet strings. |
The parameter 'prefix' is a string that shall be a unique label for each |
different purpose of the PRF. |
""" |
import hmac, sha # available in any Python 2.x |
def PRF( key, prefix, data, number_of_bits): |
""" Key, prefix and data are arbitrary strings . |
number_of_bits must be a multiple of 8 |
HMAC_SHA1 generates 20 byte blocks. Enough are generated to get the |
requested number of octets and the reslut is truncated to the requested size. |
""" |
number_of_octets, remainder = divmod(number_of_bits,8) |
if remainder != 0: |
raise ValueError, 'requested bits not multiple of 8' |
R = '' |
i = 0 |
while len(R) <= number_of_octets : |
hmac_sha_1= hmac.new( key, prefix + chr(0x00) + data + chr(i), sha ) |
i = i + 1 |
R = R + hmac_sha_1.digest() # concatenate latest hash to result string |
return R[:number_of_octets] # return R truncated to 'number_of_octets' |
def PRF_128(key,A,B): return PRF(key,A,B,128) |
def PRF_192(key,A,B): return PRF(key,A,B,192) |
def PRF_256(key,A,B): return PRF(key,A,B,256) |
def PRF_384(key,A,B): return PRF(key,A,B,384) |
def PRF_512(key,A,B): return PRF(key,A,B,512) |
def PRF_768(key,A,B): return PRF(key,A,B,768) |
/relevation/ext/cryptopy-1.2.5.patched/crypto/keyedHash/tkip_mic.py |
---|
0,0 → 1,40 |
""" crypto.keyedHash.tkip_mic |
A reference implementation of the TKIP Message Integrety Chek (MIC) |
that is defined in IEEE 802.11i |
The MIC is based on Michael, a 64-bit MIC, with a design strength of 20 bits. |
(c) 2002 Paul A. Lambert |
""" |
from crypto.keyedHash.michael import Michael |
class TKIP_MIC(Michael): |
""" The TKIP MIC Calculation for IEEE 802.11 TGi |
This MIC algorithm uses the Michael Message Integrity Check (MIC) |
and incorporates the DA, SA, priority and padding as |
part of the MIC calculation |
""" |
def __init__(self, key=None, version='D3'): |
""" """ |
self.version = version |
Michael.__init__(self,key) |
def hash(self, sa, da, priority, msduData ): |
""" The TKIP MIC appends sa, da and priority to msduData |
and uses the result in the Michael keyed hash |
to create an 8 octet MIC value |
""" |
assert( 0 <= priority <= 15 ), 'Priority must be 4 bit value' |
assert( (len(sa)==6) and (len(da)==6) ), 'Addresses must be 6 octets' |
if self.version == 'D3': |
micData = da + sa + chr(priority) + 3*chr(0) + msduData |
elif self.version == 'D2': |
micData = da + sa + msduData |
else: |
raise 'bad version' |
return Michael.hash(self, micData) |
/relevation/ext/cryptopy-1.2.5.patched/crypto/keyedHash/michael_test.py |
---|
0,0 → 1,57 |
#!/usr/bin/env python |
""" crypto.keyedHash.michael_test |
Tests of the Michael Message Integrity Check Algorithm |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
""" |
from crypto.keyedHash.michael import Michael |
from binascii import * |
import unittest |
class Michael_TestVectors(unittest.TestCase): |
""" Test MIC algorithm using know values """ |
def testIEEE_BaseKnowValues(self): |
""" Test using vectors from IEEE P802.11i/D2.0 """ |
def runSingleTest(key,data,micResult): |
print "=============================" |
key = a2b_hex(key) |
knownMICResult = a2b_hex(micResult) |
print "key: ",b2a_hex(key) |
print "data: ",b2a_hex(data) |
print "knownMIC: ", b2a_hex(knownMICResult) |
micAlg = Michael(key) |
calculatedMIC = micAlg.hash(data) |
print "CalcMIC: ", b2a_hex(calculatedMIC) |
self.assertEqual( calculatedMIC, knownMICResult ) |
# alternate calling sequence |
micAlg = Michael() |
micAlg.setKey(key) |
calculatedMIC = micAlg.hash(data) |
self.assertEqual( calculatedMIC, knownMICResult ) |
# yet another way to use algorithm |
calculatedMIC = micAlg(data) |
self.assertEqual( calculatedMIC, knownMICResult ) |
runSingleTest( "0000000000000000", "" , "82925c1ca1d130b8" ) |
runSingleTest( "82925c1ca1d130b8", "M" , "434721ca40639b3f" ) |
runSingleTest( "434721ca40639b3f", "Mi" , "e8f9becae97e5d29" ) |
runSingleTest( "e8f9becae97e5d29", "Mic" , "90038fc6cf13c1db" ) |
runSingleTest( "90038fc6cf13c1db", "Mich" , "d55e100510128986" ) |
runSingleTest( "d55e100510128986", "Michael" , "0a942b124ecaa546" ) |
class Michael_Check_Corners(unittest.TestCase): |
def testShortKey(self): |
""" Check for assertion on short key """ |
pass |
def testLongKey(self): |
""" Check for assertion on too long key """ |
pass |
if __name__ == '__main__': |
unittest.main() # run all the tests |
/relevation/ext/cryptopy-1.2.5.patched/crypto/keyedHash/michael.py |
---|
0,0 → 1,69 |
""" crypto.keyedHash.michael |
A reference implementation of the Michael Message Integrety Chek (MIC) |
that is defined in IEEE 802.11 Task Group 'i' |
Michael is a 64-bit MIC, with a design strength of 20 bits. |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
""" |
from struct import pack, unpack |
from binascii_plus import * |
class Michael: |
""" The Michael keyed hash as defined in IEEE 802.11i D2.0 """ |
def __init__(self, key = None): |
self.name = 'Michael' |
self.blocksize = 1 # single octets can be hashed by padding to raw block size |
self.raw_block_size = 4 # operates on 32 bits or 4 byte blocks |
self.digest_size = 8 # MIC size of 64 bits or 8 bytes |
self.keySize = 8 # key size is 8 octets |
self.strength = 20 |
if key != None: |
self.setKey(key) |
def __del__(self): |
self.setKey(8*chr(0)) # feable attempt to clear keys on exit |
def setKey(self,key): |
""" setKey(key) ... key is binary string """ |
assert( len(key)== self.keySize), 'Key must be 8 octets' |
self._key = unpack('<II', key) # unpack into 2 32bit integers |
def __call__(self,data,more=None): |
return self.hash(data) |
def hash(self,data): |
""" Michael keyed hash """ |
fullBlocks, extraOctets = divmod(len(data),4) |
paddedData = data + chr(0x5a) + chr(0)*(7-extraOctets) |
l, r = self._key |
for i in range(fullBlocks+2): |
mSub_i = unpack('<I', paddedData[i*4:i*4+4])[0] # ith block as 32 bit integer |
l = l ^ mSub_i |
l, r = b(l,r) |
digest = pack('<II', l, r ) |
return digest |
def update(self,data): |
raise 'No update method supported for Michael keyed hash' |
def digest(self): |
raise 'No digest method supported for Michael keyed hash' |
def final(self,data): |
raise 'No final method supported for Michael keyed hash' |
def b(l,r): |
""" The 'b' block function for the IEEE 802.11i Michael Integrity Check """ |
r ^= (((l<<17) & 0xffffffffL)|((l>>15) & 0x1ffffL)) # r = r ^ (l <<< 17) |
l = (l+r) & 0xffffffffL # l = (l+r) mod 2**32 |
r ^= ((l & 0xff00ff00L)>>8)|((l & 0x00ff00ffL)<<8) # r = r ^ XSWAP(l) |
l = (l+r) & 0xffffffffL # l = (l+r) mod 2**32 |
r ^= (((l<<3) & 0xffffffffL) | ((l>>29)& 0x7)) # r = r ^ (l <<< 3) |
l = (l+r) & 0xffffffffL # l = (l+r) mod 2**32 |
r ^= (((l<<30L) & 0xffffffffL)|((l>>2) & 0x3fffffff)) # r = r ^ (l >>> 2) |
l = (l+r) & 0xffffffffL # l = (l+r) mod 2**32 |
return (l,r) |
/relevation/ext/cryptopy-1.2.5.patched/crypto/keyedHash/pbkdf2_test.py |
---|
0,0 → 1,83 |
#!/usr/bin/env python |
""" crypto.keyedHash.pbkdf2_test |
Unit tests for crypto.keyedHash.pbkdf2 |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
""" |
from crypto.keyedHash.pbkdf2 import pbkdf2, dot11PassPhraseToPSK |
import unittest |
from binascii_plus import a2b_p, b2a_p, b2a_hex,b2a_pter |
class PBDKDF22_KnowAnswerTests(unittest.TestCase): |
""" """ |
def pbkdf2KAT(self,testDescription, password, salt, iterations, keySize, ka): |
""" Know Answer Tests from IEEE """ |
knownAnswer = a2b_p(ka) # convert ascii 2 binary |
derivedKey = pbkdf2(password, salt, iterations, keySize) |
print "========== %s ==========" % testDescription |
print 'password = "%s"' % password |
print "salt/ssid = %s" % b2a_pter(salt, frnt=' ')[15:] |
print "iterations =", iterations |
print "keySize =", keySize |
print "derivedKey =", b2a_p(derivedKey, frnt=' ')[15:] |
#print "knownAnswer =", b2a_p(knownAnswer, frnt=' ')[15:] |
self.assertEqual(derivedKey, knownAnswer), "KAT Failed-> %s "% testDescription |
def testKnownAnswerRFC3211_1(self): |
description = "RFC3211 KAT Test 1" |
password = "password" |
salt = a2b_p("12 34 56 78 78 56 34 12") |
iterations = 5 |
keySize = 8 |
knownAnswer = "D1 DA A7 86 15 F2 87 E6" |
self.pbkdf2KAT(description, password, salt, iterations, keySize, knownAnswer) |
def testknownAnswerTGi_1(self): |
description = "pbkdf2 IEEE 802.11 TGi Test 1" |
password = "password" |
ssid = "IEEE" |
iterations = 4096 # IEEE 802.11 TGi spcification |
keySize = 32 # 32 bytes, 256 bits |
knownAnswer = """f4 2c 6f c5 2d f0 eb ef 9e bb 4b 90 b3 8a 5f 90 |
2e 83 fe 1b 13 5a 70 e2 3a ed 76 2e 97 10 a1 2e""" |
self.pbkdf2KAT(description, password, ssid, iterations, keySize, knownAnswer) |
def testknownAnswerTGi_2(self): |
description = "pbkdf2 IEEE 802.11 TGi Test 2" |
password = "ThisIsAPassword" |
ssid = "ThisIsASSID" |
iterations = 4096 # IEEE 802.11 TGi spcification |
keySize = 32 # 32 bytes, 256 bits |
knownAnswer = """0d c0 d6 eb 90 55 5e d6 41 97 56 b9 a1 5e c3 e3 |
20 9b 63 df 70 7d d5 08 d1 45 81 f8 98 27 21 af""" |
self.pbkdf2KAT(description, password, ssid, iterations, keySize, knownAnswer) |
def testknownAnswerTGi_3(self): |
description = "pbkdf2 IEEE 802.11 TGi Test 3" |
password = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" |
ssid = "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ" |
iterations = 4096 # IEEE 802.11 TGi spcification |
keySize = 32 # 32 bytes, 256 bits |
knownAnswer = """be cb 93 86 6b b8 c3 83 2c b7 77 c2 f5 59 80 7c |
8c 59 af cb 6e ae 73 48 85 00 13 00 a9 81 cc 62""" |
self.pbkdf2KAT(description, password, ssid, iterations, keySize, knownAnswer) |
def testDot11PassPhraseToPSK(self): |
passPhrase = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" |
ssid = "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ" |
knownAnswer = """be cb 93 86 6b b8 c3 83 2c b7 77 c2 f5 59 80 7c |
8c 59 af cb 6e ae 73 48 85 00 13 00 a9 81 cc 62""" |
key = dot11PassPhraseToPSK( passPhrase, ssid ) |
self.assertEqual( a2b_p(knownAnswer), key ) |
if __name__ == '__main__': |
# Run the tests from the command line |
unittest.main() |
/relevation/ext/cryptopy-1.2.5.patched/crypto/keyedHash/pbkdf2.py |
---|
0,0 → 1,43 |
""" crypto.keyedHash.pbkdf2 |
Password Based Key Derivation Function 2 |
References: RFC2898, B. Kaliski, September 2000, PKCS #5 |
This function is used for IEEE 802.11/WPA passphrase to key hashing |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
""" |
from crypto.keyedHash.hmacHash import HMAC_SHA1 |
from crypto.common import xor |
from math import ceil |
from struct import pack |
def pbkdf2(password, salt, iterations, keySize, PRF=HMAC_SHA1): |
""" Create key of size keySize from password and salt """ |
if len(password)>63: |
raise 'Password too long for pbkdf2' |
#if len(password)<8 : raise 'Password too short for pbkdf2' |
if (keySize > 10000): # spec says >4294967295L*digestSize |
raise 'keySize too long for PBKDF2' |
prf = PRF(key=password) # HMAC_SHA1 |
numBlocks = ceil(1.*keySize/prf.digest_size) # ceiling function |
key = '' |
for block in range(1,numBlocks+1): |
# Calculate F(P, salt, iterations, i) |
F = prf(salt+pack('>i',block)) # i is packed into 4 big-endian bytes |
U = prf(salt+pack('>i',block)) # i is packed into 4 big-endian bytes |
for count in range(2,iterations+1): |
U = prf(U) |
F = xor(F,U) |
key = key + F |
return key[:keySize] |
def dot11PassPhraseToPSK(passPhrase,ssid): |
""" The 802.11 TGi recommended pass-phrase-to-preshared-key mapping. |
This function simply uses pbkdf2 with interations=4096 and keySize=32 |
""" |
assert( 7<len(passPhrase)<64 ), 'Passphrase must be greater than 7 or less than 64 characters' |
return pbkdf2(passPhrase, ssid, iterations=4096, keySize=32) |
/relevation/ext/cryptopy-1.2.5.patched/crypto/keyedHash/tkip_key_mixing_test.py |
---|
0,0 → 1,214 |
#! /usr/bin/env python |
""" crypto.keyedHash.tkip_key_mixing |
Tests for TKIP key mixing function |
Paul Lambert |
November 4, 2002 |
""" |
import unittest |
from crypto.keyedHash.tkip_key_mixing import TKIP_Mixer |
from struct import pack, unpack |
from binascii_plus import a2b_p, b2a_p, b2a_hex |
class TKIP_Mixer_Know_Answer_Tests(unittest.TestCase): |
""" Test TKIP Mixing using know values (aka test vectors) """ |
def testTKIP_Mixer_KnowValues(self): |
""" Test using vectors from IEEE 802.11TGi D2.4.2 """ |
for testCase in TKIP_MixerTestCases: |
description = testCase['testCase'] |
tk = a2b_p(testCase['TK']) |
ta = a2b_p(testCase['TA']) |
iv32 = a2b_p(testCase['IV32']) # last 4 octets of PN/IV field |
iv16 = a2b_p(testCase['IV16']) |
# NOTE - iv16 and iv32 are confused notation from early drafts |
# may not match notation in the future |
pnField = iv16[1]+iv16[0] + iv32[3]+iv32[2]+iv32[1]+iv32[0] |
pn = unpack('<Q', pnField + 2*chr(0) )[0] |
knownP1key = a2b_p(testCase['P1K']) |
knownRC4Key = a2b_p(testCase['RC4KEY']) |
print '===========================================================' |
print 'testCase:%s'%description |
print 'TK: %s'%b2a_p(tk)[9:] |
print 'TA: %s'%b2a_p(ta)[9:] |
print 'IV32: %s'%b2a_p(iv32)[9:] |
print 'IV16: %s'%b2a_p(iv16)[9:] |
keyId = 0 |
eh1 = chr((ord(pnField[1])|0x20)&0x7f) |
eh = pnField[0]+eh1+pnField[1]+chr((keyId<<6)|0x20)+pnField[2:] |
print 'EncHdr: %s (with KeyId=0)' % b2a_p(eh)[9:] |
print 'PNfield: %s' % b2a_p(pnField)[9:] |
print 'PNvalue: hex 0x%012X decimal %d' % (pn,pn) |
#print 'TSC: [0x%04x, 0x%04x, 0x%04x]' % (unpack('<H',pnField[0:2])[0],\ |
# unpack('<H',pnField[2:4])[0],unpack('<H',pnField[4:6])[0]) |
mixer = TKIP_Mixer(tk,ta) |
newRC4Key = mixer.newKey(pnField) |
p1kstring = ''.join([pack('>H',i) for i in mixer.phase1Key]) # a list of int's |
print 'TTAK: [0x%04x, 0x%04x, 0x%04x, 0x%04x, 0x%04x]' % (mixer.phase1Key[0], \ |
mixer.phase1Key[1],mixer.phase1Key[2],mixer.phase1Key[3],mixer.phase1Key[4]) |
print 'P1K: %s'%b2a_p(p1kstring)[9:] |
#print 'knownP1K:%s'%b2a_p(knownP1key)[9:] |
self.assertEqual( p1kstring, knownP1key),'Phase1 Keys dont match' |
print 'RC4Key: %s'% b2a_p(newRC4Key)[9:] |
#print 'knownRC4Key: %s'% b2a_p(knownRC4Key)[9:] |
self.assertEqual( newRC4Key, knownRC4Key ),'Final Key does not match' |
print '===========================================================' |
def xtestTKIP_Mixer_Sequence(self): |
""" Test TKIP Mixing using alternate calling approaches """ |
key = 16*chr(0) |
ta = 6*chr(0) |
tscOctets = 6*chr(0) |
keyMixer = TKIP_Mixer(key) |
keyMixer.setTA(ta) |
newKey = keyMixer.newKey(tscOctets) |
keyMixer = TKIP_Mixer() |
keyMixer.setTA(ta) |
keyMixer.setKey(key) |
newKey = keyMixer.newKey(tscOctets) |
keyMixer = TKIP_Mixer(transmitterAddress=ta) |
keyMixer.setKey(key) |
newKey = keyMixer.newKey(tscOctets) |
def xtestGunarExample1(self): |
""" Test example from Gunnar 2003-01-27 """ |
tk1 = a2b_p( "A9 90 6D C8 3E 78 92 3F 86 04 E9 9E F6 CD BA BB" ) |
ta = a2b_p( "50 30 F1 84 44 08" ) |
iv32 = a2b_p( "B5039776" ) # [transmitted as B5 03 97 76] |
iv16 = a2b_p( "E70C" ) |
p1k = a2b_p( "26D5 F1E1 2A59 2021 0E8E" ) |
rc4Key = a2b_p( "E7 67 0C 68 15 E0 2E 3F 1C 15 92 92 D4 E2 78 82" ) |
mixer = TKIP_Mixer(tk1,ta) |
newRC4Key = mixer.newKey(iv16+iv32) |
print "=== Gunnar Example ===" |
print "rc4Key = ", b2a_p( rc4Key ) |
print "newRC4Key = ", b2a_p( newRC4Key ) |
print "knownp1K = ", b2a_p( p1k ) |
print "calcp1K = %04X %04X %04x %04x %04x" % (mixer.phase1Key[0],mixer.phase1Key[1],mixer.phase1Key[2],mixer.phase1Key[3],mixer.phase1Key[4]) |
self.assertEqual(rc4Key,newRC4Key) |
def xtestTKIP_Mixer_TV_values(self): |
""" Test using vectors from IEEE 802.11TGi D2.4.2 """ |
for testCase in TKIP_TestVector: |
description = testCase['testCase'] |
tk = a2b_p(testCase['TK']) |
ta = a2b_p(testCase['TA']) |
pn = testCase['PN'] |
pnField = pack('<Q', pn)[:6] |
print '===========================================================' |
print 'testCase:%s'%description |
print 'TK: %s'%b2a_p(tk)[9:] |
print 'TA: %s'%b2a_p(ta)[9:] |
keyId = 0 |
eh1 = chr((ord(pnField[1])|0x20)&0x7f) |
eh = pnField[0]+eh1+pnField[1]+chr((keyId<<6)|0x20)+pnField[2:] |
print 'EncHdr: %s (with KeyId=0)' % b2a_p(eh)[9:] |
print 'PNfield: %s' % b2a_p(pnField)[9:] |
print 'PNvalue: 0x%06X' % pn |
print 'TSC?: [0x%04x, 0x%04x, 0x%04x]' % (unpack('<H',pnField[0:2])[0],\ |
unpack('<H',pnField[2:4])[0],unpack('<H',pnField[4:6])[0]) |
mixer = TKIP_Mixer(tk,ta) |
newRC4Key = mixer.newKey(pnField) |
p1kstring = ''.join([pack('>H',i) for i in mixer.phase1Key]) # a list of int's |
print 'TTAK: [0x%04x, 0x%04x, 0x%04x, 0x%04x, 0x%04x]' % (mixer.phase1Key[0], \ |
mixer.phase1Key[1],mixer.phase1Key[2],mixer.phase1Key[3],mixer.phase1Key[4]) |
print 'P1K: %s'%b2a_p(p1kstring)[9:] |
print 'RC4Key: %s' % b2a_p( newRC4Key )[9:] |
print 'kRC4Key: %s' % b2a_p( a2b_p(testCase['RC4KEY']))[9:] |
self.assertEqual(newRC4Key, a2b_p(testCase['RC4KEY'])) |
print '===========================================================' |
""" TKIP_Mixer Know Answer Tests from IEEE TGi """ |
TKIP_MixerTestCases = [ |
{'testCase': "IEEE TGi TKIP_Mixer Test vector #1", |
'TK' : "00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F", |
'TA' : "10 22 33 44 55 66", |
'IV32' : "00000000", |
'IV16' : "0000", |
'P1K' : "3DD2 016E 76F4 8697 B2E8", |
'RC4KEY': "00 20 00 33 EA 8D 2F 60 CA 6D 13 74 23 4A 66 0B"}, |
{'testCase': "IEEE TGi TKIP_Mixer Test vector #2", |
'TK' : "00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F", |
'TA' : "10 22 33 44 55 66", |
'IV32' : "00000000", #[transmitted as 00 00 00 00] |
'IV16' : "0001", |
'P1K' : "3DD2 016E 76F4 8697 B2E8", |
'RC4KEY': "00 20 01 90 FF DC 31 43 89 A9 D9 D0 74 FD 20 AA"}, |
{'testCase':"IEEE TGi TKIP_Mixer Test vector #3", |
'TK' : "63 89 3B 25 08 40 B8 AE 0B D0 FA 7E 61 D2 78 3E", |
'TA' : "64 F2 EA ED DC 25", |
'IV32' : "20DCFD43", |
'IV16' : "FFFF", |
'P1K' : "7C67 49D7 9724 B5E9 B4F1", |
'RC4KEY': "FF 7F FF 93 81 0F C6 E5 8F 5D D3 26 25 15 44 CE"}, |
{'testCase': "IEEE TGi TKIP_Mixer Test vector #4", |
'TK' : "63 89 3B 25 08 40 B8 AE 0B D0 FA 7E 61 D2 78 3E", |
'TA' : "64 F2 EA ED DC 25", |
'IV32' : "20DCFD44", |
'IV16' : "0000", |
'P1K' : "5A5D 73A8 A859 2EC1 DC8B", |
'RC4KEY': "00 20 00 49 8C A4 71 FC FB FA A1 6E 36 10 F0 05"}, |
{'testCase': "IEEE TGi TKIP_Mixer Test vector #5", |
'TK' : "98 3A 16 EF 4F AC B3 51 AA 9E CC 27 1D 73 09 E2", |
'TA' : "50 9C 4B 17 27 D9", |
'IV32' : "F0A410FC", |
'IV16' : "058C", |
'P1K' : "F2DF EBB1 88D3 5923 A07C", |
'RC4KEY': "05 25 8C F4 D8 51 52 F4 D9 AF 1A 64 F1 D0 70 21"}, |
{'testCase': "IEEE TGi TKIP_Mixer Test vector #6", |
'TK' : "98 3A 16 EF 4F AC B3 51 AA 9E CC 27 1D 73 09 E2", |
'TA' : "50 9C 4B 17 27 D9", |
'IV32' : "F0A410FC", |
'IV16' : "058D", |
'P1K' : "F2DF EBB1 88D3 5923 A07C ", |
'RC4KEY': "05 25 8D 09 F8 15 43 B7 6A 59 6F C2 C6 73 8B 30"}, |
{'testCase': "IEEE TGi TKIP_Mixer Test vector #7", |
'TK' : "C8 AD C1 6A 8B 4D DA 3B 4D D5 B6 54 38 35 9B 05", |
'TA' : "94 5E 24 4E 4D 6E", |
'IV32' : "8B1573B7", |
'IV16' : "30F8", |
'P1K' : "EFF1 3F38 A364 60A9 76F3", |
'RC4KEY': "30 30 F8 65 0D A0 73 EA 61 4E A8 F4 74 EE 03 19"}, |
{'testCase': "IEEE TGi TKIP_Mixer Test vector #8", |
'TK' : "C8 AD C1 6A 8B 4D DA 3B 4D D5 B6 54 38 35 9B 05", |
'TA' : "94 5E 24 4E 4D 6E", |
'IV32' : "8B1573B7", |
'IV16' : "30F9", |
'P1K' : "EFF1 3F38 A364 60A9 76F3", |
'RC4KEY': "30 30 F9 31 55 CE 29 34 37 CC 76 71 27 16 AB 8F"} |
] |
TKIP_TestVector = [ |
{'testCase': "-------------TKIP Test Vector 1", |
'TK' : "00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f", |
'TA' : "10 22 33 44 55 66", |
'PN' : 0x000000000000, |
'RC4KEY': "00 20 00 33 EA 8D 2F 60 CA 6D 13 74 23 4A 66 0B"}, |
{'testCase': "-------------IEEE TGi TKIP_Mixer Test vector #6 Mod to PN", |
'TK' : "98 3A 16 EF 4F AC B3 51 AA 9E CC 27 1D 73 09 E2", |
'TA' : "50 9C 4B 17 27 D9", |
'PN' : 0xF0A410FC058D, # [transmitted as: 8D 25 05 DefKeyID FC 10 A4 F0] |
'RC4KEY': "05 25 8D 09 F8 15 43 B7 6A 59 6F C2 C6 73 8B 30"}] |
# Make this test module runnable from the command prompt |
if __name__ == "__main__": |
unittest.main() |
/relevation/ext/cryptopy-1.2.5.patched/crypto/keyedHash/tkip_key_mixing.py |
---|
0,0 → 1,135 |
""" crypto.keyedHash.tkip_key_mixing.py |
TKIP Temporal Key Mixing Function reference implementation |
2002-11-04 |
""" |
from struct import pack, unpack |
from binascii_plus import * |
def S(word): |
""" TKIP S-Box non-linear substitution of a 16 bit word """ |
return (tkipSbox[0][word & 0x00FF] ^ tkipSbox[1][(word>>8) & 0x00FF]) |
""" tkipSbox consists of two 256 word arrays |
The tkip Sbox is formed from the AES/Rijndael Sbox |
""" |
from crypto.cipher.rijndael import Sbox |
tkipSbox = [range(256),range(256)] # arbitrary initialization |
for i in range(256): |
k = Sbox[i] # the rijndael S box (imported) |
if k & 0x80 : # calculate k*2 polynomial math |
k2 = (k<<1)^0x11b # reduce by rijndael modulas |
else: |
k2 = k<<1 |
k3 = k ^ k2 |
tkipSbox[0][i] = (k2<<8)^k3 |
tkipSbox[1][i] = (k3<<8)^k2 # second array is just byte swap of first array |
def rotR1(v16): |
""" circular right rotate on 16 bits """ |
return ((((v16) >> 1) & 0x7FFF) ^ (((v16) & 1) << 15)) |
class TKIP_Mixer: |
""" The TKIP_Mixer class generates dynamic keys for TKIP based on the |
TK (temporal key), TA and PN |
""" |
def __init__(self, tk1=None, transmitterAddress=None, pnBytes=6*chr(0)): |
""" The TKIP Mixer is initialized with tk1 and TA |
tk1 is a temporal key (16 octet string) |
transmitterAddress is a 6 octet MAC address |
pn is the packet number, here as an integer < (1<<8*6) |
""" |
self.tk = None |
self.ta = None |
self.setPnBytes(pnBytes) # sets self.pnBytes and validates input |
self.upper4SequenceOctets = self.pnBytes[-4:] |
if tk1 != None : |
self.setKey(tk1) |
if transmitterAddress != None : |
self.setTA(transmitterAddress) |
def setKey(self, key): |
""" Set the temporal key (tk1) for key mixing """ |
if len(key)!= 16: raise 'Wrong key size' |
# for readability of subroutines, make tk a list of 1 octet ints |
self.tk = [ord(byte) for byte in key] |
if self.ta != None : # reset phase1 value |
self.phase1Key = phase1KeyMixing( self.tk, self.ta, self.pn) |
def setTA(self, taBytes): |
""" Set the transmitter address """ |
if len(taBytes) != 6: raise 'Bad size for transmitterAddress' |
self.ta = [ord(byte) for byte in taBytes] |
if self.tk != None : # reset phase1 value |
self.phase1Key = phase1KeyMixing( self.tk, self.ta, self.pn ) |
def setPnBytes(self, pnBytes): |
""" Set the pnBytes from the packet number (int) """ |
assert( len(pnBytes)==6 ), 'pnBytes must be 6 octets' |
self.pnBytes = pnBytes |
self.pn = [ord(byte) for byte in pnBytes] # int list for readability |
def newKey(self, pnBytes): |
""" return a new 'mixed' key (16 octets) based on |
the pn in 6 octets, also know as TSC |
""" |
assert(self.ta != None), 'No TA' |
assert(self.tk != None), 'No TK' |
self.setPnBytes(pnBytes) |
if self.pnBytes[-4:] != self.upper4SequenceOctets: # check if upper bits change |
# calculate phase1 key only when upper bytes change |
self.upper4SequenceOctets = pnBytes[-4:] |
self.phase1Key = phase1KeyMixing( self.tk, self.ta, self.pn ) |
return phase2KeyMixing( self.tk, self.phase1Key, self.pn ) |
def phase1KeyMixing(tk,ta,pn): |
""" Create a p1k (5 integers) from TK, TA and upper 4 octets of sequence number pn""" |
p1k = [0,0,0,0,0] # array of 5 integers (each 2 octets) |
p1k[0] = pn[3]*256 + pn[2] |
p1k[1] = pn[5]*256 + pn[4] |
p1k[2] = ta[1]*256 + ta[0] # 2 octets of MAC as an integer (little-endian) |
p1k[3] = ta[3]*256 + ta[2] # 2 octets of MAC as an integer (little-endian) |
p1k[4] = ta[5]*256 + ta[4] # 2 octets of MAC as an integer (little-endian) |
for i in range(8): |
j = 2*(i&1) |
p1k[0] = ( p1k[0] + S( p1k[4]^(tk[j+ 1]*256 + tk[j+ 0]))) & 0xFFFF |
p1k[1] = ( p1k[1] + S( p1k[0]^(tk[j+ 5]*256 + tk[j+ 4]))) & 0xFFFF |
p1k[2] = ( p1k[2] + S( p1k[1]^(tk[j+ 9]*256 + tk[j+ 8]))) & 0xFFFF |
p1k[3] = ( p1k[3] + S( p1k[2]^(tk[j+13]*256 + tk[j+12]))) & 0xFFFF |
p1k[4] = ( p1k[4] + S( p1k[3]^(tk[j+ 1]*256 + tk[j])) + i ) & 0xFFFF |
return p1k |
def phase2KeyMixing(tk,p1k,pn): |
""" Create a 16 octet key from the phase1Key (p1k) |
and 2 octets of sequence counter """ |
ppk = [i for i in p1k] |
ppk.append( p1k[4] + pn[1]*256 + pn[0] ) # append value for ppk[5] |
# Bijective non-linear mixing of the 96 bits of ppk |
ppk[0] = (ppk[0] + S(ppk[5] ^ (tk[1]*256 + tk[0]) )) & 0xFFFF |
ppk[1] = (ppk[1] + S(ppk[0] ^ (tk[3]*256 + tk[2]) )) & 0xFFFF |
ppk[2] = (ppk[2] + S(ppk[1] ^ (tk[5]*256 + tk[4]) )) & 0xFFFF |
ppk[3] = (ppk[3] + S(ppk[2] ^ (tk[7]*256 + tk[6]) )) & 0xFFFF |
ppk[4] = (ppk[4] + S(ppk[3] ^ (tk[9]*256 + tk[8]) )) & 0xFFFF |
ppk[5] = (ppk[5] + S(ppk[4] ^ (tk[11]*256+ tk[10]) )) & 0xFFFF |
# Final sweep |
ppk[0] = (ppk[0] + rotR1(ppk[5] ^ (tk[13]*256+tk[12]))) & 0xFFFF |
ppk[1] = (ppk[1] + rotR1(ppk[0] ^ (tk[15]*256+tk[14]))) & 0xFFFF |
ppk[2] = (ppk[2] + rotR1(ppk[1])) & 0xFFFF |
ppk[3] = (ppk[3] + rotR1(ppk[2])) & 0xFFFF |
ppk[4] = (ppk[4] + rotR1(ppk[3])) & 0xFFFF |
ppk[5] = (ppk[5] + rotR1(ppk[4])) & 0xFFFF |
rc4Key = range(16) |
rc4Key[0] = pn[0] |
rc4Key[1] = (pn[0] | 0x20) & 0x7F |
rc4Key[2] = pn[1] |
rc4Key[3] = 0xFF &((ppk[5]^(tk[1]*256+tk[0]))>>1) |
for i in range(6): |
rc4Key[4+2*i] = ppk[i] & 0xff |
rc4Key[5+2*i] = (ppk[i]>>8) & 0xff |
wepSeed = ''.join([chr(i) for i in rc4Key]) # convert to string |
return wepSeed |
/relevation/ext/cryptopy-1.2.5.patched/crypto/keyedHash/hmacHash_test.py |
---|
0,0 → 1,121 |
#!/usr/bin/env python |
""" hmacHash_test.py |
Unit tests for hmacHash.py |
So far only runs test vectors from RFC2104 |
References |
[IETF] RFC 2104 "HMAC: Keyed-Hashing for Message Authentication" |
[IETF] RFC 2202 |
""" |
import unittest |
from crypto.keyedHash.hmacHash import HMAC, HMAC_SHA1 |
from crypto.hash.sha1Hash import SHA1 |
from crypto.hash.md5Hash import MD5 |
from binascii import a2b_hex, b2a_hex |
class HMAC_Simple_TestCases(unittest.TestCase): |
""" HMAC constructed ny hand """ |
def testSHA1_NullKey(self): |
""" HMAC_SHA1 testNullKey """ |
ki = ''.join([chr(0x36) for i in range(64)]) |
ko = ''.join([chr(0x5C) for i in range(64)]) |
h = SHA1() |
keyedHashAlg = HMAC(SHA1,key='') |
assert ( keyedHashAlg('') == h(ko+h(ki)) ), 'Null key, Null data test' |
assert ( keyedHashAlg('a') == h(ko+h(ki+'a')) ), 'Null key, a data test' |
assert ( keyedHashAlg('ab') == h(ko+h(ki+'ab')) ), 'Null key, ab data test' |
assert ( keyedHashAlg(50*'a') == h(ko+h(ki+50*'a')) ), 'Null key, 50*a data test' |
# try hmac in two steps of 25 chrs |
manual_hmac = h(ko+h(ki+50*'a')) |
keyedHashAlg.update(25*'a') |
keyedHashAlg.update(25*'a') |
hm = keyedHashAlg.digest() |
assert (hm == manual_hmac), 'HMAC as update, update and digest' |
def testMD5_NullKey(self): |
""" HMAC_MD5 testNullKey """ |
ki = ''.join([chr(0x36) for i in range(64)]) |
ko = ''.join([chr(0x5C) for i in range(64)]) |
h = MD5() |
keyedHashAlg = HMAC(MD5,key='') |
assert ( keyedHashAlg('') == h(ko+h(ki)) ), 'Null key, Null data test' |
assert ( keyedHashAlg('a') == h(ko+h(ki+'a')) ), 'Null key, a data test' |
assert ( keyedHashAlg('ab') == h(ko+h(ki+'ab')) ), 'Null key, ab data test' |
assert ( keyedHashAlg(50*'a') == h(ko+h(ki+50*'a')) ), 'Null key, 50*a data test' |
def testSHA1_oneByteKey(self): |
""" HMAC_SHA1 oneByteKey of 0xFF""" |
ki = ''.join([chr(0x36) for i in range(64)]) |
ko = ''.join([chr(0x5C) for i in range(64)]) |
ki = chr(ord(ki[0])^0xFF)+ ki[1:] |
ko = chr(ord(ko[0])^0xFF)+ ko[1:] |
h = SHA1() |
keyedHashAlg = HMAC(SHA1,chr(0xff)) |
assert ( keyedHashAlg('') == h(ko+h(ki)) ), 'one byte key, Null data test' |
assert ( keyedHashAlg('a') == h(ko+h(ki+'a')) ), 'one byte key, a data test' |
assert ( keyedHashAlg('ab') == h(ko+h(ki+'ab')) ), 'one byte key, ab data test' |
assert ( keyedHashAlg(50*'a') == h(ko+h(ki+50*'a')) ), 'one byte key, 50*a data test' |
class HMAC_RFC2104_TestCases(unittest.TestCase): |
""" HMAC tests from RFC2104 """ |
def testRFC2104_1(self): |
""" RFC2104 test 1 and various calling methods """ |
key = chr(0x0b)*20 |
keyedHashAlg = HMAC(SHA1,key) |
data = "Hi There" |
digest = a2b_hex('b617318655057264e28bc0b6fb378c8ef146be00') |
cd=keyedHashAlg(data) |
assert( cd == digest ), 'RFC2104 test 1 failed' |
hmac_sha1 = HMAC_SHA1(key) |
cd = hmac_sha1.hash(data) |
assert( cd == digest ), 'RFC2104 test 1 failed, HMAC_SHA1 called' |
cd = hmac_sha1.hash(data[:3],more=1) |
cd = hmac_sha1.hash(data[3:]) |
assert( cd == digest ), 'RFC2104 test 1 failed, HMAC_SHA1 called twice' |
hmac_sha1.update(data[:3]) |
hmac_sha1.update(data[3:]) |
cd = hmac_sha1.digest() |
print b2a_hex(cd) |
assert( cd == digest ), 'RFC2104 test 1 failed, HMAC_SHA1 called with update' |
hmac_sha1.reset(data) |
cd1 = hmac_sha1.hash(data) |
cd2 = hmac_sha1.hash(data) |
print b2a_hex(cd1) |
print b2a_hex(cd2) |
assert( cd1 == cd2 ), 'hash method should default to reseting state' |
def testRFC2104_2(self): |
""" RFC2104 test 2 """ |
keyedHashAlg = HMAC(SHA1) |
key = 'Jefe' |
keyedHashAlg.setKey(key) |
data = 'what do ya want for nothing?' |
digest = a2b_hex('effcdf6ae5eb2fa2d27416d5f184df9c259a7c79') |
cd = keyedHashAlg(data) |
assert( cd == digest ), 'RFC2104 test 2 failed' |
def testRFC2104_3(self): |
""" RFC2104 test 3 """ |
key = a2b_hex('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') |
keyedHashAlg = HMAC_SHA1(key) |
data = 50*chr(0xdd) |
digest = a2b_hex('125d7342b9ac11cd91a39af48aa17b4f63f175d3') |
cd = keyedHashAlg(data) |
assert( cd == digest ), 'RFC2104 test 3 failed' |
if __name__ == '__main__': |
# Run the tests from the command line |
unittest.main() |
/relevation/ext/cryptopy-1.2.5.patched/crypto/keyedHash/hmacHash.py |
---|
0,0 → 1,83 |
""" hmacHash.py |
Implemention of Request for Comments: 2104 |
HMAC: Keyed-Hashing for Message Authentication |
HMAC is a mechanism for message authentication |
using cryptographic hash functions. HMAC can be used with any |
iterative cryptographic hash function, e.g., MD5, SHA-1, in |
combination with a secret shared key. The cryptographic strength of |
HMAC depends on the properties of the underlying hash function. |
This implementation of HMAC uses a generic cryptographic 'hashFunction' |
(self.H). Hash functions must conform to the crypto.hash method |
conventions and are not directly compatible with the Python sha1 or md5 algorithms. |
[IETF] RFC 2104 "HMAC: Keyed-Hashing for Message Authentication" |
>>>key = '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' |
>>>keyedHashAlg = HMAC(SHA1, key) |
>>>result = keyedHashAlg(data) |
""" |
from crypto.hash.hash import Hash |
class HMAC(Hash): |
""" To compute HMAC over the data `text' we perform |
H(K XOR opad, H(K XOR ipad, text)) |
""" |
def __init__(self, hashFunction, key = None): |
""" initialize HMAC with hashfunction and optionally the key """ |
# should check for right type of function |
self.H = hashFunction() # a new instance for inner hash |
self.H_outer = hashFunction() # separate outer context to allow intermediate digests |
self.B = self.H.raw_block_size # in bytes, note - hash block size typically 1 |
# and raw_block_size much larger |
# e.g. raw_block_size is 64 bytes for SHA1 and MD5 |
self.name = 'HMAC_'+self.H.name |
self.blocksize = 1 # single octets can be hashed by padding to raw block size |
self.raw_block_size = self.H.raw_block_size |
self.digest_size = self.H.digest_size |
if key != None: |
self.setKey(key) |
else: |
self.keyed = None |
def setKey(self,key): |
""" setKey(key) ... key is binary string """ |
if len(key) > self.B: # if key is too long then hash it |
key = self.H(key) # humm... this is odd, hash can be smaller than B |
else: # should raise error on short key, but breaks tests :-( |
key =key + (self.B-len(key)) * chr(0) |
self.k_xor_ipad = ''.join([chr(ord(bchar)^0x36) for bchar in key]) |
self.k_xor_opad = ''.join([chr(ord(bchar)^0x5C) for bchar in key]) |
self.keyed = 1 |
self.reset() |
def reset(self): |
self.H.reset() |
if self.keyed == None : |
raise 'no key defined' |
self.H.update(self.k_xor_ipad) # start inner hash with key xored with ipad |
# outer hash always called as one full pass (no updates) |
def update(self,data): |
if self.keyed == None : |
raise 'no key defined' |
self.H.update(data) |
def digest(self): |
if self.keyed == None : |
raise 'no key defined' |
return self.H_outer(self.k_xor_opad+self.H.digest()) |
from crypto.hash.sha1Hash import SHA1 |
class HMAC_SHA1(HMAC): |
""" Predefined HMAC built on SHA1 """ |
def __init__(self, key = None): |
""" optionally initialize with key """ |
HMAC.__init__(self,SHA1,key) |
from crypto.hash.md5Hash import MD5 |
class HMAC_MD5(HMAC): |
""" Predefined HMAC built on SHA1 """ |
def __init__(self, key = None): |
""" optionally initialize with key """ |
HMAC.__init__(self,MD5,key) |
/relevation/ext/cryptopy-1.2.5.patched/crypto/keyedHash |
---|
Property changes: |
Added: bugtraq:number |
+true |
\ No newline at end of property |
/relevation/ext/cryptopy-1.2.5.patched/crypto/passwords/passwordfactory_test.py |
---|
0,0 → 1,32 |
#! /usr/bin/env python |
""" crypto.passwords.passwordfactory_test |
Test classes for password generation |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
""" |
import unittest |
from crypto.passwords.passwordfactory import * |
class Password_Generation_Tests_Basic(unittest.TestCase): |
def testPasswordFactorySimple(self): |
""" Just print a few to see how they look for now """ |
print "==== PasswordFactorySimple ====" |
makePassword = PasswordFactorySimple("factorySpecificSeed",minSize=6, maxSize=10) |
print "minSize=%d maxSize=%d entropy=%d"% (makePassword.minSize,makePassword.maxSize,makePassword.entropy()) |
for i in range(10): |
print makePassword(chr(i)) |
def testPasswordFactoryReadable_01(self): |
""" Examples of PasswordFactoryReadable_01 """ |
print "======== PasswordFactoryReadable_01 ========" |
makePassword = PasswordFactoryReadable_01("factorySpecificSeed",minSize=6, maxSize=10) |
print "minSize=%d maxSize=%d entropy=%d"% (makePassword.minSize,makePassword.maxSize,makePassword.entropy()) |
for i in range(10): |
print makePassword(chr(i)) |
# Make this test module runnable from the command prompt |
if __name__ == "__main__": |
unittest.main() |
/relevation/ext/cryptopy-1.2.5.patched/crypto/passwords/passwordfactory.py |
---|
0,0 → 1,94 |
""" crypto.passwords.passwordfactory |
Python classes to create and recover passwords. Currently contains |
simple password generation. <need to merge the dictionary based pws> |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
August 14, 2002 |
""" |
from random import Random |
from sha import sha # the SHA1 algorithm for cryptographic hashing |
from math import log, ceil |
#from binascii_plus import b2a_p |
class PasswordFactory: |
""" Make passwords using pseudo random seeds. |
Also used to recover passwords by using same pwSeed. |
If the seed is not saved, the password can not be recovered!! |
""" |
def __init__(self, pwFactorySeed, minSize=10, maxSize=10 ): |
""" An abstract class to create passwords """ |
self._factorySeed = pwFactorySeed |
self.minSize = minSize |
self.maxSize = maxSize |
self.rand = Random( self._factorySeed ) |
def getPassword(self, pwSeed): |
raise "MUST be overloaded" |
def __call__(self, pwSeed): |
""" Create a new password as a 'call' """ |
return self.getPassword(pwSeed) |
def entropy(self): |
""" Calculate the security of the password generation as a power of 2 """ |
total = 0 |
for pwSize in range(self.minSize, self.maxSize+1): |
total = total + self.passwordsForSize(pwSize) |
return powof2( total ) |
def powof2(x): |
""" Convert x to a power of 2 """ |
return log(x)/log(2) |
class PasswordFactorySimple(PasswordFactory): |
""" This class implements a very secure but simple selection of numbers and letters. |
Some characters have been removed to prevent confusion between similar shapes |
The removed characters are: (O,0,o), (l,1,I) , (u,v),(U,V) |
""" |
def __init__(self, pwFactorySeed, minSize=10, maxSize=10 ): |
""" Initialize password generation """ |
PasswordFactory.__init__(self, pwFactorySeed, minSize, maxSize ) |
self.lettersReduced = 'abcdefghijkmnpqrstwxyzABCDEFGHJKLMNPQRSTWXYZ' |
self.digitsReduced = '23456789' |
self.specialCharacters = '#%*+$' |
def getPassword(self, pwSeed): |
""" Create a new password from pwSeed. """ |
self.rand.seed( pwSeed + 'getPassword' + self._factorySeed ) # reset prf sequence |
self.passwordSize = self.rand.randrange(self.minSize, self.maxSize+1) |
password = '' |
for i in range(self.passwordSize): |
password = password + self.rand.choice(self.lettersReduced+self.digitsReduced) |
return password |
def passwordsForSize(self,pwSize): |
return (len(self.lettersReduced)+len(self.digitsReduced))**pwSize |
consonants_01 = 'bcdfghjklmnpqrstvwxz' |
vowels_01 = 'aeiouy' |
class PasswordFactoryReadable_01(PasswordFactory): |
""" Readable passwords created by alternating consonate/vowel/consonate ... etc. |
""" |
def getPassword(self, pwSeed): |
""" Create a new password. Also used to recover passwords by using same pwSeed """ |
#self.rand.seed( 'getPassword'+self.__factorySeed+pwSeed ) # reset prf sequence |
self.passwordSize = self.rand.randrange(self.minSize, self.maxSize+1) |
password = '' |
for i in range(self.passwordSize): |
if i == 0 : |
password = password + self.rand.choice(consonants_01) |
else: |
if password[-1] in consonants_01 : |
password = password + self.rand.choice(vowels_01) |
else: |
password = password + self.rand.choice(consonants_01) |
return password |
def passwordsForSize(self,pwSize): |
return (len(vowels_01)**(pwSize/2))*(len(consonants_01)**ceil(pwSize/2)) |
/relevation/ext/cryptopy-1.2.5.patched/crypto/passwords/__init__.py |
---|
0,0 → 1,7 |
""" CryptoPy - a pure python cryptographic libraries |
crypto.passwords package |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
""" |
/relevation/ext/cryptopy-1.2.5.patched/crypto/passwords |
---|
Property changes: |
Added: bugtraq:number |
+true |
\ No newline at end of property |
/relevation/ext/cryptopy-1.2.5.patched/crypto/__init__.py |
---|
0,0 → 1,6 |
""" crypto |
CryptoPy - pure python cryptographic libraries |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
""" |
/relevation/ext/cryptopy-1.2.5.patched/crypto/cipher/__init__.py |
---|
0,0 → 1,8 |
""" crypto.cipher |
cipher package of CryptoPy |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
""" |
/relevation/ext/cryptopy-1.2.5.patched/crypto/cipher/ccm_test.py |
---|
0,0 → 1,589 |
#! /usr/bin/env python |
""" crypto.cipher.ccm_test |
Tests for CCM encryption, uses AES for base algorithm |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
July 24, 2002 |
""" |
import unittest |
from crypto.cipher.ccm import CCM |
from crypto.cipher.aes import AES |
from crypto.cipher.base import noPadding |
from crypto.common import xor |
from binascii_plus import a2b_p, b2a_p |
class CCM_AES128_TestVectors(unittest.TestCase): |
""" Test CCM with AES128 algorithm using know values """ |
def testKnowValues(self): |
""" Test using vectors from...""" |
def CCMtestVector(testCase,macSize,key,nonce,addAuth,pt,kct): |
""" CCM test vectors using AES algorithm """ |
print '%s %s %s'%('='*((54-len(testCase))/2),testCase,'='*((54-len(testCase))/2)) |
key,nonce,pt,addAuth,kct = a2b_p(key),a2b_p(nonce),a2b_p(pt),a2b_p(addAuth),a2b_p(kct) |
alg = CCM(AES(key,keySize=len(key)),macSize=macSize, nonceSize=len(nonce)) |
print 'alg=%s%skeySize=%3d blockSize=%3d M=%2d L=%2d'%(alg.baseCipher.name, |
' '*(10-len(alg.baseCipher.name)), |
alg.keySize, alg.blockSize, alg.M, alg.L) |
print 'key: %s'%b2a_p(key)[9:] |
print 'nonce: %s'%b2a_p(nonce)[9:] |
print 'addAuth:%s'%b2a_p(addAuth)[9:] |
print 'pt: %s'%b2a_p(pt)[9:] |
ct = alg.encrypt(pt,nonce=nonce,addAuthData=addAuth) |
print 'ct: %s'%b2a_p(ct)[9:] |
print 'kct: %s'%b2a_p(kct)[9:] |
print '========================================================' |
self.assertEqual( ct, kct ) |
dct = alg.decrypt(ct,nonce=nonce,addAuthData=addAuth) |
self.assertEqual( dct, pt ) |
CCMtestVector( |
testCase = "CCM Packet Vector #1 (from D.W.)", |
macSize = 8, |
key = "C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF", |
nonce = "00 00 00 03 02 01 00 A0 A1 A2 A3 A4 A5", |
addAuth = "00 01 02 03 04 05 06 07", |
pt = """ 08 09 0A 0B 0C 0D 0E 0F |
10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E """, |
kct = """ 58 8C 97 9A 61 C6 63 D2 |
F0 66 D0 C2 C0 F9 89 80 6D 5F 6B 61 DA C3 84 17 |
E8 D1 2C FD F9 26 E0 """) |
CCMtestVector( |
testCase = "IEEE 802.11 Data Packet, no A4 and no QC", |
macSize = 8, |
key = "c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf", |
nonce = "00 00 02 2d 49 97 b4 06 05 04 03 02 01", |
addAuth = """08 41 00 06 25 a7 c4 36 00 02 2d 49 97 b4 00 06 |
25 a7 c4 36 e0 00""", |
pt = """aa aa 03 00 00 00 88 8e 01 01 00 00 00 00 00 00 |
00""", |
kct = """1e e5 2d 13 b1 be 3f 20 42 5b 3f de dd d4 55 2b |
98 71 d8 7b 65 8c fd 57 f7 """) |
CCMtestVector( |
testCase = "IEEE 802.11 Data Packet, no A4 and no QC, retry", |
macSize = 8, |
key = "c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf", |
nonce = "00 00 02 2d 49 97 b4 06 05 04 03 02 01", |
addAuth = """08 41 00 06 25 a7 c4 36 00 02 2d 49 97 b4 00 06 |
25 a7 c4 36 e0 00 """, |
pt = """aa aa 03 00 00 00 88 8e 01 01 00 00 00 00 00 00 |
00""", |
kct = """1e e5 2d 13 b1 be 3f 20 42 5b 3f de dd d4 55 2b |
98 71 d8 7b 65 8c fd 57 f7 """) |
CCMtestVector( |
testCase = "IEEE 802.11 Data Packet,A4 with no QC ", |
macSize = 8, |
key = "c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf", |
nonce = "00 00 02 2d 49 97 b4 00 00 00 00 00 01", |
addAuth = """08 43 00 06 25 a7 c4 36 00 02 2d 49 97 b4 00 06 |
25 a7 c4 36 e0 00 41 42 43 44 45 46 """, |
pt = """aa aa 03 00 00 00 88 8e 01 01 00 00 00 00 00 00 |
00""", |
kct = """3b e9 b2 46 c6 fc 7a 51 55 1e 14 c6 a8 85 28 bc |
06 56 67 c8 ef 30 b3 12 69 """) |
CCMtestVector( |
testCase = "IEEE 802.11 Data Packet,A4 and QC ", |
macSize = 8, |
key = "c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf", |
nonce = "04 00 02 2d 49 97 b4 00 00 00 00 00 01", |
addAuth = """88 43 00 06 25 a7 c4 36 00 02 2d 49 97 b4 00 06 |
25 a7 c4 36 e0 00 41 42 43 44 45 46 04 00""", |
pt = """aa aa 03 00 00 00 88 8e 01 01 00 00 00 00 00 00 |
00""", |
kct = """46 72 f2 9e 41 54 e9 11 58 47 c2 a9 ae dc 10 0c |
e8 82 53 bd a2 04 ae 1d 33 """) |
CCMtestVector( |
testCase = "IEEE 802.11 Data Packet,QC no A4", |
macSize = 8, |
key = "c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf", |
nonce = "04 00 02 2d 49 97 b4 00 00 00 00 00 01", |
addAuth = """88 41 00 06 25 a7 c4 36 00 02 2d 49 97 b4 00 06 |
25 a7 c4 36 e0 00 04 00 """, |
pt = """aa aa 03 00 00 00 88 8e 01 01 00 00 00 00 00 00 |
00""", |
kct = """46 72 f2 9e 41 54 e9 11 58 47 c2 a9 ae dc 10 0c |
e8 dc 91 98 bf 6a 52 c8 03 """) |
CCMtestVector( |
testCase = "IEEE 802.11 Data Packet,QC no A4", |
macSize = 8, |
key = "c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf", |
nonce = "04 00 02 2d 49 97 b4 00 00 00 00 00 01", |
addAuth = """88 41 00 06 25 a7 c4 36 00 02 2d 49 97 b4 00 06 |
25 a7 c4 36 e0 00 04 00 """, |
pt = """aa aa 03 00 00 00 88 8e 01 01 00 00 00 00 00 00 |
00""", |
kct = """46 72 f2 9e 41 54 e9 11 58 47 c2 a9 ae dc 10 0c |
e8 dc 91 98 bf 6a 52 c8 03 """) |
CCMtestVector( |
testCase = "IEEE 802.11 Data Packet, no A4, No QC, WEP preset", |
macSize = 8, |
key = "00 01 02 03 04 05 06 07 08 c9 0a 0b 0c 0d 0e 0f", |
nonce = "00 00 02 2d 49 97 b4 06 05 04 03 02 01", |
addAuth = """08 41 00 06 25 a7 c4 36 00 02 2d 49 97 b4 00 06 |
25 a7 c4 36 e0 00 """, |
pt = """aa aa 03 00 00 00 88 8e 01 01 00 00 00 00 00 00 |
00""", |
kct = """de bf 2c c9 94 e6 5a 70 2c ee e3 19 84 21 39 c3 |
f2 9a 2e 12 63 11 74 5f 3c """) |
CCMtestVector( |
testCase = "KAT# 1 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "04 e5 1c f0 20 2d 4c 59 0f d2 e1 28 a5 7c 50 30", |
nonce = "f1 84 44 08 ab ae a5 b8 fc ba 33 2e 78", |
addAuth = """ """, |
pt = """ """, |
kct = """6f b0 8f 1f a0 ec e1 f0 """) |
CCMtestVector( |
testCase = "KAT# 2 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "c4 85 98 ee 34 6c 62 1e c9 7c 1f 67 ce 37 11 85", |
nonce = "51 4a 8a 19 f2 bd d5 2f 3a b5 03 97 76", |
addAuth = """0c """, |
pt = """e7 """, |
kct = """13 6d 5e af 39 d5 d3 6f 27 """) |
CCMtestVector( |
testCase = "KAT# 3 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "f8 ba 1a 55 d0 2f 85 ae 96 7b b6 2f b6 cd a8 eb", |
nonce = "7e 78 a0 50 68 dd e8 3a 11 40 85 a2 ea", |
addAuth = """10 """, |
pt = """ """, |
kct = """b8 01 6f 2e fc 56 b2 31 """) |
CCMtestVector( |
testCase = "KAT# 4 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "0c 84 68 50 ee c1 76 2c 88 de af 2e e9 f4 6a 07", |
nonce = "cc ee 9b fb 82 2d 5d 12 fe 9e 30 8f 7a", |
addAuth = """ """, |
pt = """05 """, |
kct = """7d d0 b5 77 e9 0c 1c de b5 """) |
CCMtestVector( |
testCase = "KAT# 5 - AES_CCM 128 M= 4 L= 2", |
macSize = 4, |
key = "77 a5 59 75 29 27 20 97 a6 03 d5 91 31 f3 cb ba", |
nonce = "97 ea 83 a0 63 4b 5e d7 62 7e b9 df 22", |
addAuth = """17 fc 89 c1 fc 0d 63 98 c3 d9 57 7d f7 63 c8 b6 |
a8 8a df 36 91 """, |
pt = """5e 05 74 03 42 de 19 41 """, |
kct = """0c 5f 95 1b 27 29 6a 16 a8 2a 32 d5 """) |
CCMtestVector( |
testCase = "KAT# 6 - AES_CCM 128 M= 6 L= 2", |
macSize = 6, |
key = "8b ca 94 dd 82 f4 ea 74 bf a2 1f 09 1e 67 85 40", |
nonce = "cf b7 a6 2e 88 01 3b d6 d3 af fc c1 91", |
addAuth = """ca 30 a0 e7 50 07 97 22 71 """, |
pt = """04 1e bc 2f dc a0 f3 a5 ae 2c 1b d0 36 83 1c 95 |
49 6c 5f 4d bf 3d 55 9e 72 de 80 2a 18 """, |
kct = """ad 81 34 7b 1f 61 6e b5 34 c0 e9 a0 7b ed 92 57 |
11 cf 4a 4b 2c 3f 9b 01 25 7a 9a e2 76 e6 c1 83 |
f0 2f ad """) |
CCMtestVector( |
testCase = "KAT# 7 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "df 11 db 8e f8 22 73 47 01 59 14 0d d6 46 a2 2f", |
nonce = "c5 d6 81 5d 5a 6d 72 40 ee a5 8c 89 a2", |
addAuth = """70 7f cf 24 b3 2d 38 33 0c f6 70 a5 5a 0f e3 4f |
ad 2b 1c 29 """, |
pt = """eb c9 6c 76 02 """, |
kct = """55 17 b7 c5 78 27 3c dd 6a 15 43 9c a0 """) |
CCMtestVector( |
testCase = "KAT# 8 - AES_CCM 128 M=10 L= 2", |
macSize = 10, |
key = "eb d8 72 fb c3 f3 a0 74 89 8f 8b 2f bb 90 96 66", |
nonce = "d6 c6 38 d6 82 45 de c6 9a 74 80 f3 51", |
addAuth = """c9 6b e2 76 fb e6 c1 27 f2 8a 8c 8e 58 32 f8 b3 |
41 a2 19 a5 74 """, |
pt = """94 6b """, |
kct = """55 cd b0 f0 72 a0 b4 31 37 85 31 55 """) |
CCMtestVector( |
testCase = "KAT# 9 - AES_CCM 128 M=12 L= 2", |
macSize = 12, |
key = "3b b2 5e fd de ff 30 12 2f df d0 66 9d a7 ff e0", |
nonce = "3c 0e 37 28 96 9b 95 4f 26 3a 80 18 a9", |
addAuth = """f9 a6 """, |
pt = """ef 70 a8 b0 51 46 24 81 92 2e 93 fa 94 71 ac 65 |
77 3f 5a f2 84 30 fd ab bf f9 43 b9 """, |
kct = """aa 27 4b a3 37 2e f5 d6 cc ae fe 16 8f de 14 63 |
37 83 e7 d3 0b cc 4a 8f dc f0 18 c9 c6 79 e8 b9 |
10 95 43 3b bf f2 89 f0 """) |
CCMtestVector( |
testCase = "KAT# 10 - AES_CCM 128 M=14 L= 2", |
macSize = 14, |
key = "98 c7 fe 73 71 62 4c 9f fd 3c b3 d9 fb 77 6a f7", |
nonce = "1e ea 4e 1f 58 80 4b 97 17 23 0a d0 61", |
addAuth = """c2 fc a1 """, |
pt = """46 41 5c 6b 81 ec a4 89 89 ab fd a2 2d 3a 0b fc |
9c c1 fc 07 93 63 """, |
kct = """64 e2 0b 0c ef d8 2a 00 27 ed 0f f2 90 1b d3 b7 |
b0 67 6c 1c 4a 4c b7 5c 40 0f db 9c 87 9e 99 c5 |
77 1a 9a 52 """) |
CCMtestVector( |
testCase = "KAT# 11 - AES_CCM 128 M=16 L= 2", |
macSize = 16, |
key = "eb 1d 3c 1d b4 a4 c5 e2 66 8d 9b 50 f4 fd 56 f6", |
nonce = "ef ec 95 20 16 91 83 57 0c 4c cd ee a0", |
addAuth = """48 1b db 34 98 0e 03 81 24 a1 db 1a 89 2b ec 36 |
6a ce 5e ec 40 73 e7 23 98 be ca 86 f4 b3 """, |
pt = """50 a4 20 b9 3c ef f4 e7 62 """, |
kct = """6f 55 64 96 29 95 40 49 34 84 5e 64 dc 68 3c 5f |
40 dc ec 0a 30 17 e5 df ee """) |
CCMtestVector( |
testCase = "KAT# 12 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "0c fd f2 47 24 c5 8e b8 35 66 53 39 e8 1c 37 c0", |
nonce = "95 68 e2 e4 55 2d 5f 72 bb 70 ca 3f 3a", |
addAuth = """5e 55 6e ac 1b f5 4b d5 4e db 23 21 75 43 03 02 |
4c 71 b0 ce fd """, |
pt = """ae 60 c4 8b a9 b5 f8 2c 2f eb 07 e2 9d 82 6b 95 |
a7 64 """, |
kct = """42 eb e1 dc be 9b 60 7b f8 d4 cb 21 6a 7b 5a 57 |
c7 1e 55 97 96 a1 a6 bf 33 2a """) |
CCMtestVector( |
testCase = "KAT# 13 - AES_CCM 128 M= 8 L= 3", |
macSize = 8, |
key = "cc dd 57 cb 5c 0e 5f cd 88 5e 9a 42 39 e9 b9 ca", |
nonce = "d6 0d 64 37 59 79 c2 fc 9a c5 f0 99", |
addAuth = """7d 86 5c 44 c0 6f 28 a6 46 b3 80 49 4b 50 """, |
pt = """f6 85 9a fb 79 8b 8a 4b a4 ad 6d 31 99 85 bc 42 |
9e 8f 0a fa """, |
kct = """fd f2 3f 1f c5 27 9e ec 06 b5 29 e7 69 96 da 50 |
f9 b3 16 5b 6b 27 2c c7 df 89 06 05 """) |
CCMtestVector( |
testCase = "KAT# 14 - AES_CCM 128 M= 8 L= 4", |
macSize = 8, |
key = "46 75 97 1a 48 d0 8c 5b c3 53 cb cd ba 82 e9 34", |
nonce = "37 b3 25 a9 8f 9c 1b d9 c9 3c f3", |
addAuth = """15 2d 76 """, |
pt = """83 ab 9d 98 """, |
kct = """db 12 ef 44 3e f0 a6 aa d4 2f 35 28 """) |
CCMtestVector( |
testCase = "KAT# 15 - AES_CCM 128 M= 8 L= 5", |
macSize = 8, |
key = "32 c6 33 dd 03 9e 4d 75 20 c7 40 ec 29 fa 75 9b", |
nonce = "53 f8 69 fe 27 9a f0 f9 f8 a6", |
addAuth = """2e e1 a3 04 cf 1d 3e 75 fe """, |
pt = """54 16 e3 52 bf d2 70 3d 24 2f 66 c1 ef 48 9e 49 |
bc 3c fe 3f ce 38 95 82 0e 87 """, |
kct = """11 62 22 64 5e 6c a0 d1 c9 95 3a 1b 00 04 59 4e |
3c 90 f0 56 c6 04 f5 37 7e 5a d3 c0 50 0b 33 3a |
4c 19 """) |
CCMtestVector( |
testCase = "KAT# 16 - AES_CCM 128 M= 8 L= 6", |
macSize = 8, |
key = "91 f2 47 2d 7a 12 1c 9c dd 4b 6c 90 80 67 5a 10", |
nonce = "20 aa 00 eb 1f ed cb c9 33", |
addAuth = """9d 52 4a e1 96 d8 ec 48 62 02 be 5c 45 45 67 2a """, |
pt = """e8 a8 29 8c 0b aa 91 90 34 7c eb 9a ab ff d8 3d |
48 86 e5 c2 53 e2 """, |
kct = """86 09 aa 4b 03 c5 67 99 a9 84 4d 4d 62 75 c0 bd |
09 43 f2 69 12 46 88 fa fd ae 6e 06 6a 73 """) |
CCMtestVector( |
testCase = "KAT# 17 - AES_CCM 128 M= 8 L= 7", |
macSize = 8, |
key = "e3 14 d7 0f 1f 9e 85 e7 d2 d6 59 6e 55 d4 f9 a8", |
nonce = "12 e4 a2 8a f7 f3 71 4d", |
addAuth = """f6 62 2e 59 32 f2 18 45 09 23 76 d4 a0 62 a1 5e |
4f aa 28 8b 84 35 bc d8 ac 5a 7e c4 44 e8 """, |
pt = """4b """, |
kct = """5a be a2 22 f4 13 94 50 27 """) |
CCMtestVector( |
testCase = "KAT# 18 - AES_CCM 128 M= 8 L= 8", |
macSize = 8, |
key = "50 53 8b 62 e8 14 02 c2 ee 11 8a 66 62 b4 77 07", |
nonce = "7e d7 94 53 e4 a1 8d", |
addAuth = """48 d5 42 89 16 be 95 29 35 37 b9 aa 08 """, |
pt = """60 43 8c c6 48 4d 6e d0 50 b0 1e 77 fd 8e 43 19 |
81 a2 33 6d 02 f8 cb 84 """, |
kct = """bf fa bd 07 33 ed 9f 6c 90 7c b6 32 0a bf 32 7e |
c3 a5 78 85 5b f2 e2 56 72 c9 3c cc a4 a3 f2 9c """) |
CCMtestVector( |
testCase = "KAT# 19 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "98 8a bd c2 3a 65 bb 5d cd 99 f9 42 67 d3 0b 45", |
nonce = "c7 8e 7d fa 21 24 5a 43 90 8f 80 b3 8b", |
addAuth = """ """, |
pt = """0a 33 d2 12 79 8c f1 32 c5 51 db fd 53 27 7e b4 |
c9 e5 cc 07 e3 c2 e8 1c 58 2e 7d a6 c4 b1 34 5a |
74 """, |
kct = """f3 1f 8e fa 43 b4 cf 36 1d 20 34 62 05 b0 cc fd |
c1 81 79 17 b4 99 c5 84 3e b6 6e c0 b9 6d 27 e5 |
85 9a a9 bd ae a8 00 d1 7a """) |
CCMtestVector( |
testCase = "KAT# 20 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "e0 d7 27 f8 10 5b 00 6d 88 22 96 89 5f 74 dc 0c", |
nonce = "e5 99 95 c7 ed 2a b0 35 7b 0e 7b fd b6", |
addAuth = """c5 """, |
pt = """d0 44 95 d5 24 bb a6 5e 87 f8 5b 00 d0 48 56 4f |
a2 04 df a9 9d 79 94 55 32 67 23 cd 7c 2f 7a 36 |
95 """, |
kct = """ee b1 9c c2 e1 a3 71 3a a0 eb 2f da 57 f3 d3 d8 |
e2 c8 2d e1 2f 39 49 5a ce 8e b0 5d 14 07 9a a2 |
04 e6 29 62 3b a3 a3 0b ea """) |
CCMtestVector( |
testCase = "KAT# 21 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "df 19 a2 25 47 cd 66 d8 75 16 de 8a 18 22 54 26", |
nonce = "c0 8c 9b 85 9a a1 86 50 89 59 2f 7c be", |
addAuth = """9e 27 """, |
pt = """16 5c 95 80 5b d4 ac a2 9d 4e 62 a2 84 31 1b 6f |
5f a9 b8 2d 27 23 88 f2 92 2d 9b 7e """, |
kct = """62 b3 51 dd bc e7 cd f5 80 e8 c8 fd 2b 79 e4 8e |
42 31 11 32 52 b8 6e 7e bd 7a 73 3f 0c 85 7f a6 |
5d 2e 14 4a """) |
CCMtestVector( |
testCase = "KAT# 22 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "b1 20 0c 9a 41 66 58 4d 08 1b 9d ee 30 9b 9e e7", |
nonce = "a7 89 88 53 2f 4c 75 0b 02 63 3f 1b d9", |
addAuth = """86 52 43 02 de 79 1d 5c 3e 3b 3f 93 b5 2c 75 """, |
pt = """92 0a a8 c6 d5 4e a8 d7 e6 c3 fb 9d 6d 9c 9f 8d |
bb 1c ab bb 41 59 d8 93 80 f5 53 40 89 """, |
kct = """2f 8c ac 1a b1 20 0c 0e 41 6c 95 91 b2 6e 89 07 |
75 9b 57 5a eb 90 76 14 f4 fe 64 bb 3c 45 ad 77 |
38 90 37 33 97 """) |
CCMtestVector( |
testCase = "KAT# 23 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "c1 56 c1 1d 02 ff 67 d7 72 bd d2 1f 33 59 12 be", |
nonce = "5b 1f e2 48 8e 6c fe 20 23 77 61 d9 d0", |
addAuth = """d9 da 29 4c d5 20 30 26 2e a0 10 25 e8 e4 20 1e """, |
pt = """ """, |
kct = """f1 22 23 f0 46 71 13 f1 """) |
CCMtestVector( |
testCase = "KAT# 24 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "1b 13 51 12 e0 2e 26 14 5a e5 55 0d 79 b1 5a fc", |
nonce = "70 00 f2 88 ef 21 d3 28 61 7a de da 5b", |
addAuth = """6b 27 87 7e cd 15 af 07 ea f3 06 4d c1 35 cd b9 |
64 """, |
pt = """2e 01 11 9a a1 e1 b6 95 cd 74 22 96 84 8d 0e f2 |
40 ba 3d 29 56 75 7b 43 """, |
kct = """b1 0d 5b a6 c6 9e bf 40 52 cc bf 5e 51 65 8c 95 |
3c 99 f3 9d 18 d8 34 f4 ed 7b b4 c9 7e 3a 6b 39 """) |
CCMtestVector( |
testCase = "KAT# 25 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "99 1c d1 06 71 c6 58 db fd 3e 86 b3 c2 51 ac 0f", |
nonce = "d8 ea cc b4 56 b7 ff 99 98 b4 59 bc b3", |
addAuth = """ed b9 79 05 b3 09 98 54 8f e1 05 d2 26 16 86 2d |
1d 2d dc c7 33 cd 71 fe b5 a7 53 ae ba eb b1 7d """, |
pt = """37 e6 72 ae 6a da 05 dd 88 9d """, |
kct = """db f0 80 9a 74 d3 c6 62 0b f4 c5 1c 91 6c 93 16 |
01 f2 """) |
CCMtestVector( |
testCase = "KAT# 26 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "5f c7 0b 97 11 75 ff bc 69 da e3 e8 bf 08 73 bd", |
nonce = "f8 bb 2c a4 db a6 59 98 d4 2a 28 56 c3", |
addAuth = """71 04 9a 00 2a 1b e2 5c 7b f2 85 8c 31 18 0d ce |
94 f1 8d 20 79 82 """, |
pt = """ """, |
kct = """0d 25 b4 0f 5a be 36 19 """) |
CCMtestVector( |
testCase = "KAT# 27 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "17 40 8b dc 9c 5e 13 94 29 35 dd 2e 7d bd 54 37", |
nonce = "14 7a 47 0d ff ab 27 4c ab a4 38 5d f2", |
addAuth = """ """, |
pt = """df """, |
kct = """dc 49 af 7a 17 61 ce e6 c7 """) |
CCMtestVector( |
testCase = "KAT# 28 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "96 c6 9e f0 99 fc e0 3d 12 fe 0d a0 67 71 6f 0c", |
nonce = "ed 65 37 be f8 08 79 83 78 53 5d 4a 4c", |
addAuth = """3a f1 fa c1 76 5a 19 29 cf 5c 5f 21 94 ac eb 3a |
6d 7e 07 ca 76 fd d7 2b 6f e4 51 f8 c9 b4 b4 c4 """, |
pt = """e0 35 """, |
kct = """d9 b4 34 ee cd 33 3a e8 6c 24 """) |
CCMtestVector( |
testCase = "KAT# 29 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "ca f7 8d 13 4b e2 09 8f 32 62 af 07 32 7c 9f c0", |
nonce = "88 f1 c3 89 76 70 b9 22 72 a1 ae 92 13", |
addAuth = """38 fa 4b bd ca 0b 8f bb 94 1d 23 a1 84 40 """, |
pt = """e2 16 5a """, |
kct = """36 59 64 75 bc a9 1f 8e a1 54 81 """) |
CCMtestVector( |
testCase = "KAT# 30 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "ea 76 e2 95 20 f6 cd 6a 7e 43 b1 5f e4 71 df 47", |
nonce = "68 1f 2c 11 7d 97 10 34 76 3c 3e c5 9b", |
addAuth = """d2 30 20 84 10 67 54 a5 82 32 75 """, |
pt = """4a 27 7e 05 """, |
kct = """88 cc 3d 7d 34 da 0b 2e ff 30 97 e5 """) |
CCMtestVector( |
testCase = "KAT# 31 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "f6 84 fd e0 d5 87 c9 24 66 e0 d3 d6 d6 05 7c ed", |
nonce = "aa 81 33 0b c8 f8 24 82 df 99 d7 57 6b", |
addAuth = """47 99 ee 5f 0c 60 6a 8a d5 1c 04 16 ce 19 63 """, |
pt = """49 7d 2b 08 01 """, |
kct = """c0 2c e4 d5 88 3e e5 36 4a d9 fc c0 ac """) |
CCMtestVector( |
testCase = "KAT# 32 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "75 29 fb 1c db d2 72 2f 14 89 d7 c8 48 29 72 d7", |
nonce = "17 35 b5 aa d2 90 97 28 2f e3 fa 11 37", |
addAuth = """7d 13 21 e4 5c 3c 79 a4 29 78 4c 5c 1f 8c c0 """, |
pt = """d8 94 34 c2 73 b7 """, |
kct = """09 b0 a7 5e 52 66 8c d3 6d 29 97 59 c7 ea """) |
CCMtestVector( |
testCase = "KAT# 33 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "63 9d ac 12 4a 9a 47 03 9c 2b 63 8f 66 48 0b b8", |
nonce = "2f 2d 59 97 8d 0e ef 44 3e 5a ce 50 9b", |
addAuth = """c4 35 4b f6 ca f3 48 4e 6f 2a f3 6f ed ff 1f dc |
0b """, |
pt = """0b 22 97 03 7c 02 9e """, |
kct = """b5 c3 f8 0f 56 b1 9d d8 2c f0 f0 cf dd 7a 22 """) |
CCMtestVector( |
testCase = "KAT# 34 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "25 69 2d 57 e1 de d4 f5 08 34 40 98 c8 fc 70 1e", |
nonce = "a2 db d6 96 04 25 2c 2f d6 3e e7 a9 6b", |
addAuth = """d4 fd 14 f8 18 57 """, |
pt = """69 12 08 9c 94 60 c1 25 """, |
kct = """81 58 32 b4 97 2d 35 e8 0e 9c 10 c0 e0 6b 58 64 """) |
CCMtestVector( |
testCase = "KAT# 35 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "f6 92 a4 95 3e b4 97 c1 cc f1 a1 47 ad 12 59 f1", |
nonce = "e6 cd 88 fd 72 96 90 68 02 24 9d 5c b8", |
addAuth = """db 1b f5 a4 56 93 74 fd cf 34 eb """, |
pt = """fc dc 43 ed 68 17 37 ac 8d """, |
kct = """ba d6 85 af 4c 35 15 03 26 6f 97 69 4f 54 62 7f |
ed """) |
CCMtestVector( |
testCase = "KAT# 36 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "94 c6 17 0a 9b d0 c6 dc e5 66 7b be 9f e9 4e 5d", |
nonce = "b2 bb 6a aa c5 88 ce fb 4e fc c6 2b 61", |
addAuth = """a4 d9 a5 be 4f ee d2 bc eb 0d 9e 59 75 19 72 98 |
f3 be 45 6a 23 ef a9 c7 ed 56 14 """, |
pt = """aa d9 7b 99 47 22 07 9a 25 30 """, |
kct = """11 d7 a8 6e 94 9c 06 d2 48 15 60 2d ca a1 a1 8c |
be 48 """) |
CCMtestVector( |
testCase = "KAT# 37 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "13 28 d8 ea cf 6f 77 da 12 24 72 5b bb 07 43 d2", |
nonce = "21 43 19 d3 f8 67 20 f6 53 3a f5 f1 6c", |
addAuth = """60 1b 7c aa d5 54 1e 9a 7e ea fa """, |
pt = """d5 87 65 96 de 32 a1 e7 85 83 78 """, |
kct = """22 1c f0 92 45 71 38 e7 00 21 af 45 d3 31 28 01 |
69 3a 47 """) |
CCMtestVector( |
testCase = "KAT# 38 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "54 7b 02 1b ef 8c 1c 0f f1 04 ba 1d bf 0e 2c 0b", |
nonce = "f7 a8 59 5b d6 5d 23 e9 cb 17 b1 e1 92", |
addAuth = """ """, |
pt = """64 8c ec 53 c4 79 fe 41 53 17 ba 8e """, |
kct = """6f 52 93 85 89 87 15 21 29 d5 dd 85 0d dc 3d 58 |
60 fb 8a b2 """) |
CCMtestVector( |
testCase = "KAT# 39 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "31 4b 5f 29 01 80 0f 0a 6a 4f ad 8d d1 9b b1 13", |
nonce = "2a a9 31 4e c4 ef 5b 71 b5 3b 2c da 17", |
addAuth = """92 52 e0 44 24 d5 29 f0 00 96 6b a8 87 90 0c 07 |
eb c1 a8 51 02 f0 d0 07 80 20 3d """, |
pt = """40 8d 60 be f0 3c b1 8a 1f 4f 40 5d 9f """, |
kct = """99 a7 5d db a3 72 9f c7 41 22 ba e0 25 4b 7f ba |
05 a1 4b cf 09 """) |
CCMtestVector( |
testCase = "KAT# 40 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "b7 32 3f 57 b7 e5 3d b7 4e bd e0 88 d2 d3 e1 61", |
nonce = "4e 78 a2 6b 45 93 d0 96 9c 8f 9f 63 c1", |
addAuth = """f6 fb 75 4a eb 40 7a 91 6a d8 2c 27 13 01 97 9f |
85 ff 01 80 8e 51 67 29 15 e5 72 """, |
pt = """46 64 14 a0 82 4e 25 9d ef 30 9d 9a 1b 54 """, |
kct = """f9 a1 27 c7 67 4b 39 ea 50 30 c3 eb 45 b1 ff b8 |
b4 5c 86 72 b2 7b """) |
CCMtestVector( |
testCase = "KAT# 41 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "48 28 39 bc 82 e9 4a d1 55 8f b6 79 0b 3e 36 6f", |
nonce = "b8 ed 08 17 e6 f6 df 07 5e f7 87 d2 ef", |
addAuth = """3c 16 89 0f 70 b2 1c ab ba 2b a7 84 35 b0 66 2a |
b6 1c db 78 42 """, |
pt = """52 13 fe 0f 90 8c c5 69 a1 6e 48 c8 c5 d3 92 """, |
kct = """c0 64 0e a7 0a d5 46 f7 3e 7e 44 5f 96 78 f5 57 |
36 22 d9 77 74 93 a4 """) |
CCMtestVector( |
testCase = "KAT# 42 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "73 62 b6 9c e4 dd 9f 02 75 36 9a 60 24 e5 96 69", |
nonce = "c0 a7 67 e3 ba 5c 5d 86 10 6e eb f4 9f", |
addAuth = """2e 37 47 00 22 cc 59 91 a4 a4 13 a0 d8 5a c1 ef |
eb 9a 4a """, |
pt = """16 6a 40 a6 70 60 b2 a6 58 af 1a d5 73 8f 7d 12 """, |
kct = """90 42 65 e5 35 01 bf dd 93 71 87 bd 4c 6c 29 bf |
85 b1 c2 7a 92 70 bb c1 """) |
CCMtestVector( |
testCase = "KAT# 43 - AES_CCM 128 M= 8 L= 2", |
macSize = 8, |
key = "63 de fa 62 5f 45 09 34 78 8f b4 1b 32 69 cc 94", |
nonce = "7f 9d 39 9d 87 26 be f8 10 71 92 90 30", |
addAuth = """ee 42 eb """, |
pt = """0f 3c 27 63 46 fe 7a 72 ad 46 6b 39 a5 62 d5 52 |
5a """, |
kct = """68 72 5d 02 05 49 78 34 6a 7b f5 4e df c6 e6 d8 |
e6 6c 5c 7e e0 3d f8 0a b0 """) |
# Make this test module runnable from the command prompt |
if __name__ == "__main__": |
unittest.main() |
/relevation/ext/cryptopy-1.2.5.patched/crypto/cipher/ccm.py |
---|
0,0 → 1,242 |
""" crypto.cipher.ccm |
CCM block cipher mode |
The CCM class can wrap any BlockCipher to create a 'CCM' mode |
that provides encryption with a strong integrity check. The |
integrity check can optionally include unencrypted 'addAuthData'. |
CCM requires a nonce that MUST NEVER repeat for a given key. |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
""" |
from crypto.cipher.base import BlockCipherWithIntegrity, noPadding |
from crypto.common import xor |
from struct import unpack, pack |
from crypto.errors import InitCryptoError, EncryptError, DecryptError, IntegrityCheckError |
class CCM(BlockCipherWithIntegrity): |
""" The CCM class wraps block ciphers to provide integrity and encryption. |
CCM provides both encryption and a strong integrity check. The |
integrity check can optionally include "additional authentication |
data" that is included in the message integrity check, but is not encrypted. |
CCM is composed of two passes of the same base cipher, first |
the instance calculates a CBC Message Authentication Check, |
and then the same algorithm instance is used for the CTR |
(counter) mode encryption. |
This algorithm mode does NOT support streams of data (moreData flag) |
since a full packet must be available for the two pass CBC_MAC |
and CTR encryption process. |
When decrypting, a 'DecryptIntegrityError' exception is raised |
if the integrity check fails. |
>> aes_ccm = CCM(AES(key)) |
>> cipherText = aes_ccm.encrypt(plainText, nonce) |
>> try: |
>> decryptedText = aes_ccm.decrypt(cipherText, nonce) |
>> except IntegrityCheckError: |
>> print 'failed integrity check' |
or ... |
>> cipherText = aes_ccm.encrypt(plainText, nonce, addAuthData=header) |
>> try: |
>> decryptedText = aes_ccm.decrypt(cipherText, nonce, addAuthData=header) |
>> except IntegrityCheckError: |
>> print 'failed integrity check' |
""" |
def __init__(self, blockCipherInstance, autoNonce=None, macSize=8, nonceSize=13): |
""" CCM algorithms are created by initializing with a BlockCipher instance |
blockCipherInstance -> typically AES_ECB |
autoNonce -> sets the intial value of a nonce for automatic nonce |
creation (not available yet) |
macSize -> size of MAC field can be = 4, 6, 8, 10, 12, 14, or 16 |
nonceSize -> size of nonce in bytes (default 13) |
the counter size is blockSize-nonceSize-1 |
""" |
self.baseCipher = blockCipherInstance |
self.name = self.baseCipher.name + '_CCM' |
self.blockSize = self.baseCipher.blockSize |
self.keySize = self.baseCipher.keySize |
self.baseCipher.padding = noPadding() # baseCipher should NOT pad!! |
self.M = macSize # Number of octets |
if not((3 < self.M < 17) and (macSize%2==0)) : |
raise InitCryptoError, 'CCM, M (size of auth field) is out of bounds' |
self.nonceSize = nonceSize |
self.L = self.baseCipher.blockSize - self.nonceSize - 1 |
if not(1 < self.L < 9) : |
raise InitCryptoError, 'CCM, L (size of length field) is out of bounds' |
self.reset() |
def setKey(self, key): |
self.baseCipher.setKey(key) |
self.reset() |
# Overload to reset both CCM state and the wrapped baseCipher |
def resetEncrypt(self): |
BlockCipherWithIntegrity.resetEncrypt(self) # reset CCM encrypt state (super class) |
self.baseCipher.resetEncrypt() # reset base cipher encrypt state |
def resetDecrypt(self): |
BlockCipherWithIntegrity.resetDecrypt(self) # reset CBC state (super class) |
self.baseCipher.resetEncrypt() # CCM uses encryption of base cipher to decrypt! |
def encrypt(self, plainText, nonce, addAuthData=''): |
""" CCM encryption of plainText |
nonce must be unique for each encryption, if set to none |
it will maintain it's own nonce creation |
addAuthData is optional """ |
# construct authentication block zero |
# flag byte fields |
Adata = ((len(addAuthData))>0) << 6 # bit 6 is 1 if auth |
Mfield = ((self.M-2)/2) << 3 # bits 5,4,3 encode macSize |
Lfield = self.L-1 # bits 2,1,0 encode L size = blockSize-nonceSize-1 |
flagsByte = chr(Adata^Mfield^Lfield) |
if len(nonce) != self.nonceSize : |
raise EncryptError, 'wrong sized nonce' |
lenMessage = len(plainText) |
if lenMessage >= 1L<<(8*self.L): |
raise EncryptError, 'CCM plainText too long for given L field size' |
packedLenMessage = pack('!Q', lenMessage)[-self.L:] # pack and truncate to L bytes |
blockZero = flagsByte+nonce+packedLenMessage |
if len(blockZero) != self.baseCipher.blockSize: |
raise EncryptError, 'CCM bad size of first block' |
authLengthField = self._encodeAuthLength(len(addAuthData)) |
cbcInput = blockZero+authLengthField+addAuthData |
authPadSize = self.baseCipher.blockSize-((len(cbcInput)-1)%self.baseCipher.blockSize)-1 |
cbcInput = cbcInput + authPadSize*chr(0) # pad to block size with zeros |
cbcInput = cbcInput + plainText |
cbcEndPad = chr(0x00)*((self.blockSize-((len(cbcInput))%self.blockSize))%self.blockSize) |
cbcInput = cbcInput + cbcEndPad |
# Calculate CBC_MAC |
numCbcBlocks,extra = divmod(len(cbcInput),self.blockSize) |
assert (extra==0), 'bad block size on cbc_mac calculation' |
cbcMicValue = self.blockSize*chr(0x00) |
for i in range(numCbcBlocks) : |
cbcBlock = cbcInput[i*self.blockSize:(i+1)*self.blockSize] |
cbcMicValue = self.baseCipher.encrypt( xor(cbcMicValue, cbcBlock) ) |
counter = 0L |
# the counter mode preload with counter starting at zero |
ctrModePl = chr(self.L-1)+ nonce + pack('>Q', counter)[-self.L:] |
ccmMIC = xor(self.baseCipher.encrypt(ctrModePl),cbcMicValue)[:self.M] # first M bytes of xor |
ct = '' |
numCtrBlocks,extra = divmod(len(plainText)+self.blockSize,self.blockSize) |
while counter < numCtrBlocks : |
counter = counter + 1L |
ctrModePl = chr(self.L-1) + nonce + pack('>Q', counter)[-self.L:] |
ct = ct + xor(self.baseCipher.encrypt(ctrModePl), plainText[(counter-1)*16:counter*16] ) |
ct = ct + ccmMIC |
return ct |
def decrypt(self, cipherText, nonce, addAuthData=''): |
""" CCM decryption of cipherText |
nonce must be unique for each encryption, if set to none |
it will maintain it's own nonce creation |
the nonce is then included in the cipher text |
addAuthData is option """ |
# construct authentication block zero |
# flag byte fields |
Adata = ((len(addAuthData))>0) << 6 # bit 6 is 1 if auth |
Mfield = ((self.M-2)/2) << 3 # bits 5,4,3 encode macSize |
Lfield = self.L-1 # bits 2,1,0 encode L size = blockSize-nonceSize-1 |
flagsByte = chr(Adata^Mfield^Lfield) |
if len(nonce) != self.nonceSize : |
raise DecryptError, 'wrong sized nonce' |
lenMessage = len(cipherText)-self.M |
if lenMessage >= 1L<<(8*self.L): |
raise DecryptError, 'CCM cipherText too long for given L field size' |
if lenMessage < 0 : |
raise DecryptError, 'Too small of cipherText for MIC size' |
packedLenMessage = pack('!Q', lenMessage)[-self.L:] # pack and truncate to L bytes |
pt = '' |
ct = cipherText[:-self.M] # trim of MIC field |
numCtrBlocks,extra = divmod(len(ct)+self.blockSize,self.blockSize) |
for counter in range(1, numCtrBlocks+1) : |
ctrModePl = chr(self.L-1) + nonce + pack('>Q', counter)[-self.L:] |
ctr = self.baseCipher.encrypt(ctrModePl) |
ctBlock = ct[(counter-1)*self.blockSize:counter*self.blockSize] |
pt = pt + xor( ctr, ctBlock ) |
#------- CBC Mac Calculation |
blockZero = flagsByte+nonce+packedLenMessage |
if len(blockZero) != self.baseCipher.blockSize: |
raise DecryptError, 'CCM bad size of first block' |
authLengthField = self._encodeAuthLength(len(addAuthData)) |
cbcInput = blockZero+authLengthField+addAuthData |
authPadSize = self.baseCipher.blockSize-((len(cbcInput)-1)%self.baseCipher.blockSize)-1 |
cbcInput = cbcInput + authPadSize*chr(0) # pad to block size with zeros |
cbcInput = cbcInput + pt |
cbcEndPad = chr(0x00)*((self.blockSize-((len(cbcInput))%self.blockSize))%self.blockSize) |
cbcInput = cbcInput + cbcEndPad |
# Calculate CBC_MAC |
numCbcBlocks,extra = divmod(len(cbcInput),self.blockSize) |
assert (extra==0), 'bad block size on cbc_mac calculation' |
cbcMicValue = self.blockSize*chr(0x00) |
for i in range(numCbcBlocks) : |
cbcBlock = cbcInput[i*self.blockSize:(i+1)*self.blockSize] |
cbcMicValue = self.baseCipher.encrypt( xor(cbcMicValue, cbcBlock) ) |
ctrModePl0 = chr(self.L-1)+ nonce + pack('>Q', 0)[-self.L:] |
ccmMIC = xor(self.baseCipher.encrypt(ctrModePl0),cbcMicValue)[:self.M] # first 8 bytes of xor |
if ccmMIC != cipherText[-self.M:] : |
raise IntegrityCheckError, 'CCM Integrity check failed on decrypt' |
return pt |
def _encodeAuthLength(self, length): |
""" construct byte string representing length, returns 2 to 10 bytes """ |
if length < 0 : |
raise EncryptError, 'CCM illegal length value' |
elif 0 <= length < 0xFF00: |
byteString = pack('!H', length) # pack into two bytes |
elif 0xFF00 <= length < 0x100000000L: |
byteString = pack('!HI',0xFFFE, length) # pack into 0xFFFE + four bytes |
elif 0x100000000L <= length < 0x10000000000000000L: |
byteString = pack('!HQ',0xFFFF, length) # pack into 0xFFFF + eigth bytes |
else: |
raise EncryptError, 'CCM length error' |
return byteString |
def _decodeAuthLength(self, byteString): |
""" decode byte string representing length, returns length |
Only the first 2 to 10 bytes of the byte string are examined """ |
firstTwoOctets == unpack('!H',bytesString[0:2]) # two bytes used for length |
if firstTwoOctets == 0: |
raise DecryptError, 'CCM auth length zero with auth bit set' |
elif 0 < firstTwoOctets < 0xFEFF: |
messageLength == firstTwoOctets |
elif 0xFEFF < firstTwoOctets < 0xFFFE: |
raise DecryptError, 'CCM auth length illegal values' |
elif firstTwoOctets == 0xFFFE: |
messageLength = unpack('!I',byteString[2:6]) # four bytes used for length |
elif firstTwoOctets == 0xFFFF: |
messageLength = unpack('!Q',byteString[2:10]) # eight bytes used for length |
else: |
raise DecryptError, 'CCM auth length error' |
return messageLength |
/relevation/ext/cryptopy-1.2.5.patched/crypto/cipher/aes_sbox_analysis.py |
---|
0,0 → 1,104 |
#! /usr/bin/env python |
""" crypto.cipher.aes_sbox_analysis |
AES Sbox Analysis - a simple analysis of the AES Sbox that determines |
the number and size of the permutation subgroups in the transformation. |
Could be extended to examine any Sbox ... |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
2002-12-05 Added validation of equation form of AES |
2002-06-01 Original |
""" |
# The AES Sbox |
sbbytes = (0x63,0x7c,0x77,0x7b,0xf2,0x6b,0x6f,0xc5, |
0x30,0x01,0x67,0x2b,0xfe,0xd7,0xab,0x76, |
0xca,0x82,0xc9,0x7d,0xfa,0x59,0x47,0xf0, |
0xad,0xd4,0xa2,0xaf,0x9c,0xa4,0x72,0xc0, |
0xb7,0xfd,0x93,0x26,0x36,0x3f,0xf7,0xcc, |
0x34,0xa5,0xe5,0xf1,0x71,0xd8,0x31,0x15, |
0x04,0xc7,0x23,0xc3,0x18,0x96,0x05,0x9a, |
0x07,0x12,0x80,0xe2,0xeb,0x27,0xb2,0x75, |
0x09,0x83,0x2c,0x1a,0x1b,0x6e,0x5a,0xa0, |
0x52,0x3b,0xd6,0xb3,0x29,0xe3,0x2f,0x84, |
0x53,0xd1,0x00,0xed,0x20,0xfc,0xb1,0x5b, |
0x6a,0xcb,0xbe,0x39,0x4a,0x4c,0x58,0xcf, |
0xd0,0xef,0xaa,0xfb,0x43,0x4d,0x33,0x85, |
0x45,0xf9,0x02,0x7f,0x50,0x3c,0x9f,0xa8, |
0x51,0xa3,0x40,0x8f,0x92,0x9d,0x38,0xf5, |
0xbc,0xb6,0xda,0x21,0x10,0xff,0xf3,0xd2, |
0xcd,0x0c,0x13,0xec,0x5f,0x97,0x44,0x17, |
0xc4,0xa7,0x7e,0x3d,0x64,0x5d,0x19,0x73, |
0x60,0x81,0x4f,0xdc,0x22,0x2a,0x90,0x88, |
0x46,0xee,0xb8,0x14,0xde,0x5e,0x0b,0xdb, |
0xe0,0x32,0x3a,0x0a,0x49,0x06,0x24,0x5c, |
0xc2,0xd3,0xac,0x62,0x91,0x95,0xe4,0x79, |
0xe7,0xc8,0x37,0x6d,0x8d,0xd5,0x4e,0xa9, |
0x6c,0x56,0xf4,0xea,0x65,0x7a,0xae,0x08, |
0xba,0x78,0x25,0x2e,0x1c,0xa6,0xb4,0xc6, |
0xe8,0xdd,0x74,0x1f,0x4b,0xbd,0x8b,0x8a, |
0x70,0x3e,0xb5,0x66,0x48,0x03,0xf6,0x0e, |
0x61,0x35,0x57,0xb9,0x86,0xc1,0x1d,0x9e, |
0xe1,0xf8,0x98,0x11,0x69,0xd9,0x8e,0x94, |
0x9b,0x1e,0x87,0xe9,0xce,0x55,0x28,0xdf, |
0x8c,0xa1,0x89,0x0d,0xbf,0xe6,0x42,0x68, |
0x41,0x99,0x2d,0x0f,0xb0,0x54,0xbb,0x16) |
def groups(subbytes): |
gdict={} # a dictionary of the cycles indexed by the first cycle element |
touched=[0 for i in range(len(subbytes))] |
for i in range(len(sbbytes)): |
touched.append(0) |
for i in range(len(sbbytes)): |
element = i |
cycle = [] |
if not touched[element]: |
for j in range (i,len(sbbytes)): |
touched[element] = 1 |
cycle.append(element) |
element = sbbytes[element] |
if element == i: |
break |
gdict[cycle[1]]=cycle |
else: |
pass |
return gdict |
def grpv(subbytes): |
"""" Returns a list of tuples (cycle start, cycle size) """ |
v=[] |
z=groups(subbytes) |
for i in z.keys(): |
v.append( [i, len(z[i])] ) |
return v |
def sgv(subbytes): |
x = grpv(subbytes) |
sum = 0 |
for i in x: |
sum = sum + i[1] |
return sum |
def main(): |
cycles = grpv(sbbytes) |
print 'The AES sbox contains ', |
print len(cycles), |
print 'permutation subgroups' |
print 'The AES sbox subgroups (start, length) are:' |
print cycles |
# Make this test module runnable from the command prompt |
if __name__ == "__main__": |
main() |
/relevation/ext/cryptopy-1.2.5.patched/crypto/cipher/trolldoll.py |
---|
0,0 → 1,84 |
""" crypto.cipher.trolldoll |
Modification to Icedoll to take advantage of the better error extension |
and provide a IV for randomization of the output and integrity checking. |
IV is simply prepended to plaintext. |
Integrity check is appended to the end of the plain text as |
zeros with count of the blocks in the ciphertext. |
Note !!!! auto IV uses python default random :-( |
should not be 'too bad' (tm) for this applicaiton |
ALso ... currently just IV .... in test .. |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
""" |
from crypto.cipher.icedoll import Icedoll |
from crypto.errors import IntegrityCheckError |
from random import Random # should change to crypto.random!!! |
class Trolldoll(Icedoll): |
""" Trolldoll encryption algorithm |
based on Icedoll, which is based on Rijndael |
Trolldoll adds an 'IV' and integrity checking to Icedoll |
""" |
def __init__(self,key=None,keySize=32,blockSize=32,tapRound=6,extraRounds=6,micSize=16,ivSize=16): |
""" """ |
Icedoll.__init__(self,key=None,keySize=32,blockSize=32,tapRound=6,extraRounds=6) |
self.name = 'TROLLDOLL' |
self.micSize = micSize |
self.ivSize = ivSize |
self.r = Random() # for IV generation |
import time |
newSeed = time.ctime()+str(self.r) # seed with instance location |
self.r.seed(newSeed) # to make unique |
self.reset() |
def reset(self): |
Icedoll.reset(self) |
self.hasIV = None |
def _makeIV(self): |
return self.ivSize*'a' |
def _makeIC(self): |
""" Make the integrity check """ |
return self.micSize*chr(0x00) |
def _verifyIC(self,integrityCheck): |
""" Verify the integrity check """ |
if self.micSize*chr(0x00) == integrityCheck : |
return 1 # matches |
else: |
return 0 # fails |
def encrypt(self, plainText, more=None): |
""" """ |
if not(self.hasIV): # On first call to encrypt put in an IV |
plainText = self._makeIV() + plainText # add the 'IV' |
self.hasIV = 1 |
if more == None: # on last call to encrypt append integrity check |
plainText = plainText + self._makeIC() |
return Icedoll.encrypt(self, plainText, more=more) |
def decrypt(self, cipherText, more=None): |
""" Decrypt cipher text, Icedoll automatically removes |
prepended random bits used as IV. |
Note - typically IV is directly used as the first |
cipher text. Here the IV is prepended to the plaintext |
prior to encryption and removed on decryption. |
""" |
plainText = Icedoll.decrypt(self, cipherText, more=more) |
if not(self.hasIV): # on first call to decrypt remove IV |
plainText = plainText[self.ivSize:] # remove the IV |
self.hasIV = 1 |
if more == None: # on last call to encrypt append integrity check |
if not(self._verifyIC(plainText[-self.micSize:])) : |
raise IntegrityCheckError, 'Trolldoll MIC Failure, bad key or modified data' |
plainText = plainText[:-self.micSize] # trim off the integrity check |
return plainText |
/relevation/ext/cryptopy-1.2.5.patched/crypto/cipher/aes_test.py |
---|
0,0 → 1,1581 |
#! /usr/bin/env python |
""" crypto.cipher.aes_test |
Tests for AES encryption algorithm |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
""" |
import unittest |
from crypto.cipher.aes import AES |
from crypto.cipher.base import noPadding |
from binascii import a2b_hex, b2a_hex |
class AES_TestVectors(unittest.TestCase): |
""" Test AES algorithm using know values.""" |
def testAES_KAT(self): |
""" Run AES know answer tests from hex input """ |
def AEStestVector(i, key, pt, ct): |
""" Test vectors provide test name(i), key, plain text (pt) and know cipher text (ct) """ |
bkey, plainText, knownCipherText = a2b_hex(key), a2b_hex(pt), a2b_hex(ct) |
kSize = len(bkey) |
alg = AES(bkey, keySize=kSize, padding=noPadding()) |
self.assertEqual( alg.encrypt(plainText), knownCipherText ) |
self.assertEqual( alg.decrypt(knownCipherText), plainText ) |
""" AES tests using FIPS example vectors """ |
AEStestVector( i = 'NIST Example', |
key = '2b7e151628aed2a6abf7158809cf4f3c', |
pt = '3243f6a8885a308d313198a2e0370734', |
ct = '3925841d02dc09fbdc118597196a0b32') |
AEStestVector( i = 'NIST 128 bit encrypt decrypt example', |
key = '000102030405060708090a0b0c0d0e0f', |
pt = '00112233445566778899aabbccddeeff', |
ct = '69c4e0d86a7b0430d8cdb78070b4c55a') |
""" AES Known Answer Tests with Variable Text (block size only 128) from ecb_vt.txt""" |
AEStestVector( i = 'aes-ecb-vt-128-1', |
key = '00000000000000000000000000000000', |
pt = '80000000000000000000000000000000', |
ct = '3AD78E726C1EC02B7EBFE92B23D9EC34') |
AEStestVector( i = 'aes-ecb-vt-128-2', |
key = '00000000000000000000000000000000', |
pt = '40000000000000000000000000000000', |
ct = '45BC707D29E8204D88DFBA2F0B0CAD9B') |
AEStestVector( i = 'aes-ecb-vt-128-3', |
key = '00000000000000000000000000000000', |
pt = '20000000000000000000000000000000', |
ct = '161556838018F52805CDBD6202002E3F') |
AEStestVector( i = 'aes-ecb-vt-128-4', |
key = '00000000000000000000000000000000', |
pt = '10000000000000000000000000000000', |
ct = 'F5569B3AB6A6D11EFDE1BF0A64C6854A') |
AEStestVector( i = 'aes-ecb-vt-128-5', |
key = '00000000000000000000000000000000', |
pt = '08000000000000000000000000000000', |
ct = '64E82B50E501FBD7DD4116921159B83E') |
AEStestVector( i = 'aes-ecb-vt-128-6', |
key = '00000000000000000000000000000000', |
pt = '04000000000000000000000000000000', |
ct = 'BAAC12FB613A7DE11450375C74034041') |
AEStestVector( i = 'aes-ecb-vt-128-7', |
key = '00000000000000000000000000000000', |
pt = '02000000000000000000000000000000', |
ct = 'BCF176A7EAAD8085EBACEA362462A281') |
AEStestVector( i = 'aes-ecb-vt-128-8', |
key = '00000000000000000000000000000000', |
pt = '01000000000000000000000000000000', |
ct = '47711816E91D6FF059BBBF2BF58E0FD3') |
AEStestVector( i = 'aes-ecb-vt-128-9', |
key = '00000000000000000000000000000000', |
pt = '00800000000000000000000000000000', |
ct = 'B970DFBE40698AF1638FE38BD3DF3B2F') |
AEStestVector( i = 'aes-ecb-vt-128-10', |
key = '00000000000000000000000000000000', |
pt = '00400000000000000000000000000000', |
ct = 'F95B59A44F391E14CF20B74BDC32FCFF') |
AEStestVector( i = 'aes-ecb-vt-128-11', |
key = '00000000000000000000000000000000', |
pt = '00200000000000000000000000000000', |
ct = '720F74AE04A2A435B9A7256E49378F5B') |
AEStestVector( i = 'aes-ecb-vt-128-12', |
key = '00000000000000000000000000000000', |
pt = '00100000000000000000000000000000', |
ct = '2A0445F61D36BFA7E277070730CF76DA') |
AEStestVector( i = 'aes-ecb-vt-128-13', |
key = '00000000000000000000000000000000', |
pt = '00080000000000000000000000000000', |
ct = '8D0536B997AEFEC1D94011BAB6699A03') |
AEStestVector( i = 'aes-ecb-vt-128-14', |
key = '00000000000000000000000000000000', |
pt = '00040000000000000000000000000000', |
ct = '674F002E19F6ED47EFF319E51FAD4498') |
AEStestVector( i = 'aes-ecb-vt-128-15', |
key = '00000000000000000000000000000000', |
pt = '00020000000000000000000000000000', |
ct = '292C02C5CB9163C80AC0F6CF1DD8E92D') |
AEStestVector( i = 'aes-ecb-vt-128-16', |
key = '00000000000000000000000000000000', |
pt = '00010000000000000000000000000000', |
ct = 'FA321CF18EF5FE727DD82A5C1E945141') |
AEStestVector( i = 'aes-ecb-vt-128-17', |
key = '00000000000000000000000000000000', |
pt = '00008000000000000000000000000000', |
ct = 'A5A7AFE1034C39CCCEBE3C584BC0BE05') |
AEStestVector( i = 'aes-ecb-vt-128-18', |
key = '00000000000000000000000000000000', |
pt = '00004000000000000000000000000000', |
ct = '4FF5A52E697E77D081205DBDB21CEA39') |
AEStestVector( i = 'aes-ecb-vt-128-19', |
key = '00000000000000000000000000000000', |
pt = '00002000000000000000000000000000', |
ct = '209E88DC94C9003000CE0769AF7B7166') |
AEStestVector( i = 'aes-ecb-vt-128-20', |
key = '00000000000000000000000000000000', |
pt = '00001000000000000000000000000000', |
ct = '5DEE41AF864CB4B650E5F51551824D38') |
AEStestVector( i = 'aes-ecb-vt-128-21', |
key = '00000000000000000000000000000000', |
pt = '00000800000000000000000000000000', |
ct = 'A79A63FA7E4503AE6D6E09F5F9053030') |
AEStestVector( i = 'aes-ecb-vt-128-22', |
key = '00000000000000000000000000000000', |
pt = '00000400000000000000000000000000', |
ct = 'A48316749FAE7FAC7002031A6AFD8BA7') |
AEStestVector( i = 'aes-ecb-vt-128-23', |
key = '00000000000000000000000000000000', |
pt = '00000200000000000000000000000000', |
ct = 'D6EEE8A7357A0E1D64262CA9C337AC42') |
AEStestVector( i = 'aes-ecb-vt-128-24', |
key = '00000000000000000000000000000000', |
pt = '00000100000000000000000000000000', |
ct = 'B013CA8A62A858053E9FB667ED39829E') |
AEStestVector( i = 'aes-ecb-vt-128-25', |
key = '00000000000000000000000000000000', |
pt = '00000080000000000000000000000000', |
ct = 'DF6EA9E4538A45A52D5C1A43C88F4B55') |
AEStestVector( i = 'aes-ecb-vt-128-26', |
key = '00000000000000000000000000000000', |
pt = '00000040000000000000000000000000', |
ct = '7D03BA451371591D3FD5547D9165C73B') |
AEStestVector( i = 'aes-ecb-vt-128-27', |
key = '00000000000000000000000000000000', |
pt = '00000020000000000000000000000000', |
ct = '0E0426281A6277E186499D365D5F49FF') |
AEStestVector( i = 'aes-ecb-vt-128-28', |
key = '00000000000000000000000000000000', |
pt = '00000010000000000000000000000000', |
ct = 'DBC02169DD2059E6CC4C57C1FEDF5AB4') |
AEStestVector( i = 'aes-ecb-vt-128-29', |
key = '00000000000000000000000000000000', |
pt = '00000008000000000000000000000000', |
ct = '826590E05D167DA6F00DCC75E22788EB') |
AEStestVector( i = 'aes-ecb-vt-128-30', |
key = '00000000000000000000000000000000', |
pt = '00000004000000000000000000000000', |
ct = '34A73F21A04421D9786335FAAB49423A') |
AEStestVector( i = 'aes-ecb-vt-128-31', |
key = '00000000000000000000000000000000', |
pt = '00000002000000000000000000000000', |
ct = 'ED347D0E0128EE1A7392A1D36AB78AA9') |
AEStestVector( i = 'aes-ecb-vt-128-32', |
key = '00000000000000000000000000000000', |
pt = '00000001000000000000000000000000', |
ct = 'EE944B2FE6E9FC888042608DA9615F75') |
AEStestVector( i = 'aes-ecb-vt-128-33', |
key = '00000000000000000000000000000000', |
pt = '00000000800000000000000000000000', |
ct = '9E7C85A909EF7218BA7947CFB4718F46') |
AEStestVector( i = 'aes-ecb-vt-128-34', |
key = '00000000000000000000000000000000', |
pt = '00000000400000000000000000000000', |
ct = '811AE07A0B2B1F816587FA73699AE77D') |
AEStestVector( i = 'aes-ecb-vt-128-35', |
key = '00000000000000000000000000000000', |
pt = '00000000200000000000000000000000', |
ct = '68466FBF43C2FE13D4B18F7EC5EA745F') |
AEStestVector( i = 'aes-ecb-vt-128-36', |
key = '00000000000000000000000000000000', |
pt = '00000000100000000000000000000000', |
ct = 'D20B015C7191B219780956E6101F9354') |
AEStestVector( i = 'aes-ecb-vt-128-37', |
key = '00000000000000000000000000000000', |
pt = '00000000080000000000000000000000', |
ct = '5939D5C1BBF54EE1B3E326D757BDDE25') |
AEStestVector( i = 'aes-ecb-vt-128-38', |
key = '00000000000000000000000000000000', |
pt = '00000000040000000000000000000000', |
ct = 'B1FDAFE9A0240E8FFEA19CE94B5105D3') |
AEStestVector( i = 'aes-ecb-vt-128-39', |
key = '00000000000000000000000000000000', |
pt = '00000000020000000000000000000000', |
ct = 'D62962ECE02CDD68C06BDFEFB2F9495B') |
AEStestVector( i = 'aes-ecb-vt-128-40', |
key = '00000000000000000000000000000000', |
pt = '00000000010000000000000000000000', |
ct = 'B3BB2DE6F3C26587BA8BAC4F7AD9499A') |
AEStestVector( i = 'aes-ecb-vt-128-41', |
key = '00000000000000000000000000000000', |
pt = '00000000008000000000000000000000', |
ct = 'E0B1072D6D9FF703D6FBEF77852B0A6B') |
AEStestVector( i = 'aes-ecb-vt-128-42', |
key = '00000000000000000000000000000000', |
pt = '00000000004000000000000000000000', |
ct = 'D8DD51C907F478DE0228E83E61FD1758') |
AEStestVector( i = 'aes-ecb-vt-128-43', |
key = '00000000000000000000000000000000', |
pt = '00000000002000000000000000000000', |
ct = 'A42DFFE6E7C1671C06A25236FDD10017') |
AEStestVector( i = 'aes-ecb-vt-128-44', |
key = '00000000000000000000000000000000', |
pt = '00000000001000000000000000000000', |
ct = '25ACF141550BFAB9EF451B6C6A5B2163') |
AEStestVector( i = 'aes-ecb-vt-128-45', |
key = '00000000000000000000000000000000', |
pt = '00000000000800000000000000000000', |
ct = '4DA7FCA3949B16E821DBC84F19581018') |
AEStestVector( i = 'aes-ecb-vt-128-46', |
key = '00000000000000000000000000000000', |
pt = '00000000000400000000000000000000', |
ct = '7D49B6347CBCC8919C7FA96A37A7A215') |
AEStestVector( i = 'aes-ecb-vt-128-47', |
key = '00000000000000000000000000000000', |
pt = '00000000000200000000000000000000', |
ct = '900024B29A08C6721B95BA3B753DDB4D') |
AEStestVector( i = 'aes-ecb-vt-128-48', |
key = '00000000000000000000000000000000', |
pt = '00000000000100000000000000000000', |
ct = '6D2182FB283B6934D90BA7848CAB5E66') |
AEStestVector( i = 'aes-ecb-vt-128-49', |
key = '00000000000000000000000000000000', |
pt = '00000000000080000000000000000000', |
ct = 'F73EF01B448D23A4D90DE8B2F9666E7A') |
AEStestVector( i = 'aes-ecb-vt-128-50', |
key = '00000000000000000000000000000000', |
pt = '00000000000040000000000000000000', |
ct = '4AD9CDA2418643E9A3D926AF5E6B0412') |
AEStestVector( i = 'aes-ecb-vt-128-51', |
key = '00000000000000000000000000000000', |
pt = '00000000000020000000000000000000', |
ct = '7CAEC8E7E5953997D545B033201C8C5B') |
AEStestVector( i = 'aes-ecb-vt-128-52', |
key = '00000000000000000000000000000000', |
pt = '00000000000010000000000000000000', |
ct = '3C43CA1F6B6864503E27B48D88230CF5') |
AEStestVector( i = 'aes-ecb-vt-128-53', |
key = '00000000000000000000000000000000', |
pt = '00000000000008000000000000000000', |
ct = '44F779B93108FE9FEEC880D79BA74488') |
AEStestVector( i = 'aes-ecb-vt-128-54', |
key = '00000000000000000000000000000000', |
pt = '00000000000004000000000000000000', |
ct = '9E50E8D9CFD3A682A78E527C9072A1CF') |
AEStestVector( i = 'aes-ecb-vt-128-55', |
key = '00000000000000000000000000000000', |
pt = '00000000000002000000000000000000', |
ct = '68D000CBC838BBE3C505D6F814C01F28') |
AEStestVector( i = 'aes-ecb-vt-128-56', |
key = '00000000000000000000000000000000', |
pt = '00000000000001000000000000000000', |
ct = '2CB2A9FEC1ACD1D9B0FA05205E304F57') |
AEStestVector( i = 'aes-ecb-vt-128-57', |
key = '00000000000000000000000000000000', |
pt = '00000000000000800000000000000000', |
ct = '01EB2806606E46444520A5CC6180CD4B') |
AEStestVector( i = 'aes-ecb-vt-128-58', |
key = '00000000000000000000000000000000', |
pt = '00000000000000400000000000000000', |
ct = 'DAA9B25168CC702326F217F1A0C0B162') |
AEStestVector( i = 'aes-ecb-vt-128-59', |
key = '00000000000000000000000000000000', |
pt = '00000000000000200000000000000000', |
ct = '3E07E648975D9578D03555B1755807ED') |
AEStestVector( i = 'aes-ecb-vt-128-60', |
key = '00000000000000000000000000000000', |
pt = '00000000000000100000000000000000', |
ct = '0B45F52E802C8B8DE09579425B80B711') |
AEStestVector( i = 'aes-ecb-vt-128-61', |
key = '00000000000000000000000000000000', |
pt = '00000000000000080000000000000000', |
ct = '659595DA0B68F6DF0DD6CA77202986E1') |
AEStestVector( i = 'aes-ecb-vt-128-62', |
key = '00000000000000000000000000000000', |
pt = '00000000000000040000000000000000', |
ct = '05FF42873893536E58C8FA98A45C73C4') |
AEStestVector( i = 'aes-ecb-vt-128-63', |
key = '00000000000000000000000000000000', |
pt = '00000000000000020000000000000000', |
ct = 'B5B03421DE8BBFFC4EADEC767339A9BD') |
AEStestVector( i = 'aes-ecb-vt-128-64', |
key = '00000000000000000000000000000000', |
pt = '00000000000000010000000000000000', |
ct = '788BCD111ECF73D4E78D2E21BEF55460') |
AEStestVector( i = 'aes-ecb-vt-128-65', |
key = '00000000000000000000000000000000', |
pt = '00000000000000008000000000000000', |
ct = '909CD9EC6790359F982DC6F2393D5315') |
AEStestVector( i = 'aes-ecb-vt-128-66', |
key = '00000000000000000000000000000000', |
pt = '00000000000000004000000000000000', |
ct = '332950F361535FF24EFAC8C76293F12C') |
AEStestVector( i = 'aes-ecb-vt-128-67', |
key = '00000000000000000000000000000000', |
pt = '00000000000000002000000000000000', |
ct = 'A68CCD4E330FFDA9D576DA436DB53D75') |
AEStestVector( i = 'aes-ecb-vt-128-68', |
key = '00000000000000000000000000000000', |
pt = '00000000000000001000000000000000', |
ct = '27C8A1CCFDB0B015D1ED5B3E77143791') |
AEStestVector( i = 'aes-ecb-vt-128-69', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000800000000000000', |
ct = 'D76A4B95887A77DF610DD3E1D3B20325') |
AEStestVector( i = 'aes-ecb-vt-128-70', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000400000000000000', |
ct = 'C068AB0DE71C66DAE83C361EF4B2D989') |
AEStestVector( i = 'aes-ecb-vt-128-71', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000200000000000000', |
ct = 'C2120BCD49EDA9A288B3B4BE79AC8158') |
AEStestVector( i = 'aes-ecb-vt-128-72', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000100000000000000', |
ct = '0C546F62BF2773CD0F564FCECA7BA688') |
AEStestVector( i = 'aes-ecb-vt-128-73', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000080000000000000', |
ct = '18F3462BEDE4920213CCB66DAB1640AA') |
AEStestVector( i = 'aes-ecb-vt-128-74', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000040000000000000', |
ct = 'FE42F245EDD0E24B216AEBD8B392D690') |
AEStestVector( i = 'aes-ecb-vt-128-75', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000020000000000000', |
ct = '3D3EEBC8D3D1558A194C2D00C337FF2B') |
AEStestVector( i = 'aes-ecb-vt-128-76', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000010000000000000', |
ct = '29AAEDF043E785DB42836F79BE6CBA28') |
AEStestVector( i = 'aes-ecb-vt-128-77', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000008000000000000', |
ct = '215F90C6744E2944358E78619159A611') |
AEStestVector( i = 'aes-ecb-vt-128-78', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000004000000000000', |
ct = '8606B1AA9E1D548E5442B06551E2C6DC') |
AEStestVector( i = 'aes-ecb-vt-128-79', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000002000000000000', |
ct = '987BB4B8740EC0EDE7FEA97DF033B5B1') |
AEStestVector( i = 'aes-ecb-vt-128-80', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000001000000000000', |
ct = 'C0A3500DA5B0AE07D2F450930BEEDF1B') |
AEStestVector( i = 'aes-ecb-vt-128-81', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000800000000000', |
ct = '525FDF8312FE8F32C781481A8DAAAE37') |
AEStestVector( i = 'aes-ecb-vt-128-82', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000400000000000', |
ct = 'BFD2C56AE5FB9C9DE33A6944572A6487') |
AEStestVector( i = 'aes-ecb-vt-128-83', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000200000000000', |
ct = '7975A57A425CDF5AA1FA929101F650B0') |
AEStestVector( i = 'aes-ecb-vt-128-84', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000100000000000', |
ct = 'BF174BC49609A8709B2CD8366DAA79FE') |
AEStestVector( i = 'aes-ecb-vt-128-85', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000080000000000', |
ct = '06C50C43222F56C874B1704E9F44BF7D') |
AEStestVector( i = 'aes-ecb-vt-128-86', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000040000000000', |
ct = '0CEC48CD34043EA29CA3B8ED5278721E') |
AEStestVector( i = 'aes-ecb-vt-128-87', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000020000000000', |
ct = '9548EA34A1560197B304D0ACB8A1698D') |
AEStestVector( i = 'aes-ecb-vt-128-88', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000010000000000', |
ct = '22F9E9B1BD73B6B5B7D3062C986272F3') |
AEStestVector( i = 'aes-ecb-vt-128-89', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000008000000000', |
ct = 'FEE8E934BD0873295059002230E298D4') |
AEStestVector( i = 'aes-ecb-vt-128-90', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000004000000000', |
ct = '1B08E2E3EB820D139CB4ABBDBE81D00D') |
AEStestVector( i = 'aes-ecb-vt-128-91', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000002000000000', |
ct = '0021177681E4D90CEAF69DCED0145125') |
AEStestVector( i = 'aes-ecb-vt-128-92', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000001000000000', |
ct = '4A8E314452CA8A8A3619FC54BC423643') |
AEStestVector( i = 'aes-ecb-vt-128-93', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000800000000', |
ct = '65047474F7222C94C6965425FF1BFD0A') |
AEStestVector( i = 'aes-ecb-vt-128-94', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000400000000', |
ct = 'E123F551A9C4A8489622B16F961A9AA4') |
AEStestVector( i = 'aes-ecb-vt-128-95', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000200000000', |
ct = 'EF05530948B80915028BB2B6FE429380') |
AEStestVector( i = 'aes-ecb-vt-128-96', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000100000000', |
ct = '72535B7FE0F0F777CEDCD55CD77E2DDF') |
AEStestVector( i = 'aes-ecb-vt-128-97', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000080000000', |
ct = '3423D8EFC31FA2F4C365C77D8F3B5C63') |
AEStestVector( i = 'aes-ecb-vt-128-98', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000040000000', |
ct = 'DE0E51C264663F3C5DBC59580A98D8E4') |
AEStestVector( i = 'aes-ecb-vt-128-99', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000020000000', |
ct = 'B2D9391166680947AB09264156719679') |
AEStestVector( i = 'aes-ecb-vt-128-100', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000010000000', |
ct = '10DB79F23B06D263835C424AF749ADB7') |
AEStestVector( i = 'aes-ecb-vt-128-101', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000008000000', |
ct = 'DDF72D27E6B01EC107EA3E005B59563B') |
AEStestVector( i = 'aes-ecb-vt-128-102', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000004000000', |
ct = '8266B57485A5954A4236751DE07F6694') |
AEStestVector( i = 'aes-ecb-vt-128-103', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000002000000', |
ct = '669A501E1F1ADE6E5523DE01D6DBC987') |
AEStestVector( i = 'aes-ecb-vt-128-104', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000001000000', |
ct = 'C20C48F2989725D461D1DB589DC0896E') |
AEStestVector( i = 'aes-ecb-vt-128-105', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000000800000', |
ct = 'DE35158E7810ED1191825D2AA98FA97D') |
AEStestVector( i = 'aes-ecb-vt-128-106', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000000400000', |
ct = '4FE294F2C0F34D0671B693A237EBDDC8') |
AEStestVector( i = 'aes-ecb-vt-128-107', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000000200000', |
ct = '087AE74B10CCBFDF6739FEB9559C01A4') |
AEStestVector( i = 'aes-ecb-vt-128-108', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000000100000', |
ct = '5DC278970B7DEF77A5536C77AB59C207') |
AEStestVector( i = 'aes-ecb-vt-128-109', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000000080000', |
ct = '7607F078C77085184EAA9B060C1FBFFF') |
AEStestVector( i = 'aes-ecb-vt-128-110', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000000040000', |
ct = '9DB841531BCBE7998DAD19993FB3CC00') |
AEStestVector( i = 'aes-ecb-vt-128-111', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000000020000', |
ct = 'D6A089B654854A94560BAE13298835B8') |
AEStestVector( i = 'aes-ecb-vt-128-112', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000000010000', |
ct = 'E1E223C4CF90CC5D195B370D65114622') |
AEStestVector( i = 'aes-ecb-vt-128-113', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000000008000', |
ct = '1CBED73C50D053BDAD372CEEE54836A1') |
AEStestVector( i = 'aes-ecb-vt-128-114', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000000004000', |
ct = 'D309E69376D257ADF2BFDA152B26555F') |
AEStestVector( i = 'aes-ecb-vt-128-115', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000000002000', |
ct = '740F7649117F0DEE6EAA7789A9994C36') |
AEStestVector( i = 'aes-ecb-vt-128-116', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000000001000', |
ct = '76AE64417C297184D668C5FD908B3CE5') |
AEStestVector( i = 'aes-ecb-vt-128-117', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000000000800', |
ct = '6095FEA4AA8035591F1787A819C48787') |
AEStestVector( i = 'aes-ecb-vt-128-118', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000000000400', |
ct = 'D1FF4E7ACD1C79967FEBAB0F7465D450') |
AEStestVector( i = 'aes-ecb-vt-128-119', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000000000200', |
ct = '5F5AD3C42B9489557BB63BF49ECF5F8A') |
AEStestVector( i = 'aes-ecb-vt-128-120', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000000000100', |
ct = 'FB56CC09B680B1D07C5A52149E29F07C') |
AEStestVector( i = 'aes-ecb-vt-128-121', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000000000080', |
ct = 'FF49B8DF4A97CBE03833E66197620DAD') |
AEStestVector( i = 'aes-ecb-vt-128-122', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000000000040', |
ct = '5E070ADE533D2E090ED0F5BE13BC0983') |
AEStestVector( i = 'aes-ecb-vt-128-123', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000000000020', |
ct = '3AB4FB1D2B7BA376590A2C241D1F508D') |
AEStestVector( i = 'aes-ecb-vt-128-124', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000000000010', |
ct = '58B2431BC0BEDE02550F40238969EC78') |
AEStestVector( i = 'aes-ecb-vt-128-125', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000000000008', |
ct = '0253786E126504F0DAB90C48A30321DE') |
AEStestVector( i = 'aes-ecb-vt-128-126', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000000000004', |
ct = '200211214E7394DA2089B6ACD093ABE0') |
AEStestVector( i = 'aes-ecb-vt-128-127', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000000000002', |
ct = '0388DACE60B6A392F328C2B971B2FE78') |
AEStestVector( i = 'aes-ecb-vt-128-128', |
key = '00000000000000000000000000000000', |
pt = '00000000000000000000000000000001', |
ct = '58E2FCCEFA7E3061367F1D57A4E7455A') |
AEStestVector( i = 'aes-ecb-vt-192-1', |
key = '000000000000000000000000000000000000000000000000', |
pt = '80000000000000000000000000000000', |
ct = '6CD02513E8D4DC986B4AFE087A60BD0C') |
AEStestVector( i = 'aes-ecb-vt-192-2', |
key = '000000000000000000000000000000000000000000000000', |
pt = '40000000000000000000000000000000', |
ct = '423D2772A0CA56DAABB48D2129062987') |
AEStestVector( i = 'aes-ecb-vt-192-3', |
key = '000000000000000000000000000000000000000000000000', |
pt = '20000000000000000000000000000000', |
ct = '1021F2A8DA70EB2219DC16804445FF98') |
AEStestVector( i = 'aes-ecb-vt-192-4', |
key = '000000000000000000000000000000000000000000000000', |
pt = '10000000000000000000000000000000', |
ct = 'C636E35B402577F96974D8804295EBB8') |
AEStestVector( i = 'aes-ecb-vt-192-5', |
key = '000000000000000000000000000000000000000000000000', |
pt = '08000000000000000000000000000000', |
ct = '1566D2E57E8393C19E29F892EA28A9A7') |
AEStestVector( i = 'aes-ecb-vt-192-6', |
key = '000000000000000000000000000000000000000000000000', |
pt = '04000000000000000000000000000000', |
ct = '883C878FED70B36CC09D040F9619DD19') |
AEStestVector( i = 'aes-ecb-vt-192-7', |
key = '000000000000000000000000000000000000000000000000', |
pt = '02000000000000000000000000000000', |
ct = '06734593A974965790E715594FC34AA9') |
AEStestVector( i = 'aes-ecb-vt-192-8', |
key = '000000000000000000000000000000000000000000000000', |
pt = '01000000000000000000000000000000', |
ct = 'F19B389948D9A45534E5BD36C984134A') |
AEStestVector( i = 'aes-ecb-vt-192-9', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00800000000000000000000000000000', |
ct = 'D8410DFC14FA6D175EC968EA8CAC514C') |
AEStestVector( i = 'aes-ecb-vt-192-10', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00400000000000000000000000000000', |
ct = '7E6C6EBB4029A177CF7B2FDD9AC6BB7A') |
AEStestVector( i = 'aes-ecb-vt-192-11', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00200000000000000000000000000000', |
ct = '4B51DD4850DC0A6C3A46D924003D2C27') |
AEStestVector( i = 'aes-ecb-vt-192-12', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00100000000000000000000000000000', |
ct = '2E510A9D917B15BE32A192B12A668F23') |
AEStestVector( i = 'aes-ecb-vt-192-13', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00080000000000000000000000000000', |
ct = '88F6F79962B0FB77FEA8E7C632D3108E') |
AEStestVector( i = 'aes-ecb-vt-192-14', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00040000000000000000000000000000', |
ct = 'A3A35AB1D88DAF07B52794A0F065383A') |
AEStestVector( i = 'aes-ecb-vt-192-15', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00020000000000000000000000000000', |
ct = 'DC6CC878433E2B3BB193049A4ECBFC53') |
AEStestVector( i = 'aes-ecb-vt-192-16', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00010000000000000000000000000000', |
ct = 'EFCD3763EB7B1A415938248A9A5B4FD5') |
AEStestVector( i = 'aes-ecb-vt-192-17', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00008000000000000000000000000000', |
ct = 'AB7E9FB9A66DBE5BB44854F07D9015EE') |
AEStestVector( i = 'aes-ecb-vt-192-18', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00004000000000000000000000000000', |
ct = '8B8E9D3365F8F6743ECF7E33E99255A4') |
AEStestVector( i = 'aes-ecb-vt-192-19', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00002000000000000000000000000000', |
ct = '54D37B4F176FF3D8F6AFC866066D8572') |
AEStestVector( i = 'aes-ecb-vt-192-20', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00001000000000000000000000000000', |
ct = 'E83310889480FBF3C00342E3126D0D02') |
AEStestVector( i = 'aes-ecb-vt-192-21', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000800000000000000000000000000', |
ct = 'D321AB2511F92F098174AA2DE6E85DA2') |
AEStestVector( i = 'aes-ecb-vt-192-22', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000400000000000000000000000000', |
ct = 'D8E3F40B1112D5149D58C481DFA9983F') |
AEStestVector( i = 'aes-ecb-vt-192-23', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000200000000000000000000000000', |
ct = '2454C4E0806639DDF19854D6C68054AD') |
AEStestVector( i = 'aes-ecb-vt-192-24', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000100000000000000000000000000', |
ct = 'A5506D410F7CA32F3955DD79D9D09418') |
AEStestVector( i = 'aes-ecb-vt-192-25', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000080000000000000000000000000', |
ct = '7908EE40677699568A7DC1AA317C7E4E') |
AEStestVector( i = 'aes-ecb-vt-192-26', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000040000000000000000000000000', |
ct = 'B4B7B29DD43B2F5CF765E25192273982') |
AEStestVector( i = 'aes-ecb-vt-192-27', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000020000000000000000000000000', |
ct = '92AFE9668159BEFFE2A86F8503260164') |
AEStestVector( i = 'aes-ecb-vt-192-28', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000010000000000000000000000000', |
ct = '5C36A232FBA6D187A84657AD4028B18F') |
AEStestVector( i = 'aes-ecb-vt-192-29', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000008000000000000000000000000', |
ct = 'A2E994DFAB3A798DF8F54F6DA87E58E2') |
AEStestVector( i = 'aes-ecb-vt-192-30', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000004000000000000000000000000', |
ct = '6CDAB10A72ADF77D71D0765BAAE95631') |
AEStestVector( i = 'aes-ecb-vt-192-31', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000002000000000000000000000000', |
ct = '9FE3C801BCAAF7BB800F2E6BF3278E21') |
AEStestVector( i = 'aes-ecb-vt-192-32', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000001000000000000000000000000', |
ct = 'B459D90D9A6C392E5493BC91CF5A0863') |
AEStestVector( i = 'aes-ecb-vt-192-33', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000800000000000000000000000', |
ct = '0518A9FA5007F6787E0FB4E5AC27D758') |
AEStestVector( i = 'aes-ecb-vt-192-34', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000400000000000000000000000', |
ct = 'BED9795415D28599700ED7952384A963') |
AEStestVector( i = 'aes-ecb-vt-192-35', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000200000000000000000000000', |
ct = 'F0140421173D60251EF6CAB0229B1B50') |
AEStestVector( i = 'aes-ecb-vt-192-36', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000100000000000000000000000', |
ct = '460EB4652B3F6779EA28CB11B37529ED') |
AEStestVector( i = 'aes-ecb-vt-192-37', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000080000000000000000000000', |
ct = 'C4283D351C960A6AC13CD19CCF03AE38') |
AEStestVector( i = 'aes-ecb-vt-192-38', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000040000000000000000000000', |
ct = '6815A10047B2C834A798EBDCC6786C75') |
AEStestVector( i = 'aes-ecb-vt-192-39', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000020000000000000000000000', |
ct = '99BA19F0CDD5990D0386B32CE56C9C4C') |
AEStestVector( i = 'aes-ecb-vt-192-40', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000010000000000000000000000', |
ct = 'DE76F62C61E07915162DA13E79679DEC') |
AEStestVector( i = 'aes-ecb-vt-192-41', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000008000000000000000000000', |
ct = 'DD0325D6854803D06D1D2277D5FB8D67') |
AEStestVector( i = 'aes-ecb-vt-192-42', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000004000000000000000000000', |
ct = '580B71A41DE37D6FAC83CCB0B3BB1C97') |
AEStestVector( i = 'aes-ecb-vt-192-43', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000002000000000000000000000', |
ct = 'E9B1AB470A1B02EF0FF5E6754A092C96') |
AEStestVector( i = 'aes-ecb-vt-192-44', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000001000000000000000000000', |
ct = '8590620F5AF5993B7410282F4126BC1F') |
AEStestVector( i = 'aes-ecb-vt-192-45', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000800000000000000000000', |
ct = '8D4914D2F1B22B2E268E66E532D29D7C') |
AEStestVector( i = 'aes-ecb-vt-192-46', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000400000000000000000000', |
ct = 'FD826CE48E62C5E30867044B86BA4B56') |
AEStestVector( i = 'aes-ecb-vt-192-47', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000200000000000000000000', |
ct = '100E7B831C9F35FA1271F5F1316C6FCF') |
AEStestVector( i = 'aes-ecb-vt-192-48', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000100000000000000000000', |
ct = '0A2DD0C17F68B996AA96C007003D0B31') |
AEStestVector( i = 'aes-ecb-vt-192-49', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000080000000000000000000', |
ct = 'C95F68C57E06B0A2E1F623C83C5D80BF') |
AEStestVector( i = 'aes-ecb-vt-192-50', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000040000000000000000000', |
ct = '571CAFC92C7C8A5EC54C0741E186905C') |
AEStestVector( i = 'aes-ecb-vt-192-51', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000020000000000000000000', |
ct = '22514353E95312C112255E1EED0B2DF6') |
AEStestVector( i = 'aes-ecb-vt-192-52', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000010000000000000000000', |
ct = '791A8BF462BD17580BD9152C6D11C6C5') |
AEStestVector( i = 'aes-ecb-vt-192-53', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000008000000000000000000', |
ct = '5882A0178D548F84A165DB809C60DC28') |
AEStestVector( i = 'aes-ecb-vt-192-54', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000004000000000000000000', |
ct = '3CE4A90EED4458CA6039E42DDADB71C3') |
AEStestVector( i = 'aes-ecb-vt-192-55', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000002000000000000000000', |
ct = 'D3CBAB261207A16BE2751E77044FD7C9') |
AEStestVector( i = 'aes-ecb-vt-192-56', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000001000000000000000000', |
ct = '24E32B698A7B32217093628B01F424AB') |
AEStestVector( i = 'aes-ecb-vt-192-57', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000800000000000000000', |
ct = '9F6AFC0AF27CF565110C77E3C24F4F5B') |
AEStestVector( i = 'aes-ecb-vt-192-58', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000400000000000000000', |
ct = 'E088AA5CDA20EF267BB039B00C72C45B') |
AEStestVector( i = 'aes-ecb-vt-192-59', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000200000000000000000', |
ct = '5CF1018B7E0BA1775601C2E279900360') |
AEStestVector( i = 'aes-ecb-vt-192-60', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000100000000000000000', |
ct = '3B1A7388B89FB9416AD8753CF5AF35D2') |
AEStestVector( i = 'aes-ecb-vt-192-61', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000080000000000000000', |
ct = '137FA4ED00AFCD9F5D8BC0D14BD5837A') |
AEStestVector( i = 'aes-ecb-vt-192-62', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000040000000000000000', |
ct = '806F5C9B663559BB56F234881E4A3E60') |
AEStestVector( i = 'aes-ecb-vt-192-63', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000020000000000000000', |
ct = '8069A449152292DF2DE8642992C632B6') |
AEStestVector( i = 'aes-ecb-vt-192-64', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000010000000000000000', |
ct = '37C6CF2A1ABD1B1F1922B46C7B4A280D') |
AEStestVector( i = 'aes-ecb-vt-192-65', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000008000000000000000', |
ct = '7A2835260E5A0AA2B5DC301800EC8438') |
AEStestVector( i = 'aes-ecb-vt-192-66', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000004000000000000000', |
ct = 'EE81FAF2F9058213FFCACF281CB8509E') |
AEStestVector( i = 'aes-ecb-vt-192-67', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000002000000000000000', |
ct = '57F22D93C37129BA331FDBA38E005A1E') |
AEStestVector( i = 'aes-ecb-vt-192-68', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000001000000000000000', |
ct = 'EC798782E87B7D9F780CC3C3A46519B5') |
AEStestVector( i = 'aes-ecb-vt-192-69', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000800000000000000', |
ct = '43EA28497F5D40E3A4744FA2EDAA42DE') |
AEStestVector( i = 'aes-ecb-vt-192-70', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000400000000000000', |
ct = '91F004E7DEBF41B3414DD8C5C317372C') |
AEStestVector( i = 'aes-ecb-vt-192-71', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000200000000000000', |
ct = 'C249EAE54E7B4DF43B938C1B4CC28314') |
AEStestVector( i = 'aes-ecb-vt-192-72', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000100000000000000', |
ct = '32C289D7EEFB99D2F17AD7B7D45FE1EC') |
AEStestVector( i = 'aes-ecb-vt-192-73', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000080000000000000', |
ct = 'A675FB2E8DDBF810CEF01CF2B728CD2B') |
AEStestVector( i = 'aes-ecb-vt-192-74', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000040000000000000', |
ct = 'A418AAAB6E6921CC731AA8A349386080') |
AEStestVector( i = 'aes-ecb-vt-192-75', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000020000000000000', |
ct = '2E2B0F44863E67D9B0215C4ABD60417F') |
AEStestVector( i = 'aes-ecb-vt-192-76', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000010000000000000', |
ct = 'F0AF7CB19E911D481F6426DAEFDD2240') |
AEStestVector( i = 'aes-ecb-vt-192-77', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000008000000000000', |
ct = 'CB1304DAAA2DF6878F56AC2E0F887E04') |
AEStestVector( i = 'aes-ecb-vt-192-78', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000004000000000000', |
ct = 'B1B70A7E6A0CD1916D9B78BEA19084AE') |
AEStestVector( i = 'aes-ecb-vt-192-79', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000002000000000000', |
ct = '0CDE9F9BE646A5FCE3436B794A9CFC65') |
AEStestVector( i = 'aes-ecb-vt-192-80', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000001000000000000', |
ct = '68C7946D476A0A36674B36AFD7E5DF33') |
AEStestVector( i = 'aes-ecb-vt-192-81', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000800000000000', |
ct = '48770159A07DD8DFFF06C80105F8D57C') |
AEStestVector( i = 'aes-ecb-vt-192-82', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000400000000000', |
ct = '665E62801B3260E3C45BD3BE34DFDEBE') |
AEStestVector( i = 'aes-ecb-vt-192-83', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000200000000000', |
ct = '4159C1F686BFBE5B0E50BDB0DA532B69') |
AEStestVector( i = 'aes-ecb-vt-192-84', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000100000000000', |
ct = '6333100A5A4AD917DC2D4E78A04869A3') |
AEStestVector( i = 'aes-ecb-vt-192-85', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000080000000000', |
ct = '866A4519AB1D199F25886B89D0539ACC') |
AEStestVector( i = 'aes-ecb-vt-192-86', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000040000000000', |
ct = 'EC0CFD37E4CBC7E8BE385283F7AEA75A') |
AEStestVector( i = 'aes-ecb-vt-192-87', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000020000000000', |
ct = 'CA2F383AACCA0810AA13F3E710621422') |
AEStestVector( i = 'aes-ecb-vt-192-88', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000010000000000', |
ct = '1D0EEF6870444F950937831EC0A55D98') |
AEStestVector( i = 'aes-ecb-vt-192-89', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000008000000000', |
ct = '37839B35ED6801E7670496D479A95017') |
AEStestVector( i = 'aes-ecb-vt-192-90', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000004000000000', |
ct = '02317C8C7098C4F94AB867AC7A49DD8D') |
AEStestVector( i = 'aes-ecb-vt-192-91', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000002000000000', |
ct = 'FFB4CB4E3F7F8BF3367EBD43236518B4') |
AEStestVector( i = 'aes-ecb-vt-192-92', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000001000000000', |
ct = '36BEDEF1E4AA3E4A40A305741713FCBF') |
AEStestVector( i = 'aes-ecb-vt-192-93', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000800000000', |
ct = 'B2DFE3C4870269C1E3FEEC39161540D9') |
AEStestVector( i = 'aes-ecb-vt-192-94', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000400000000', |
ct = '147EF2518AD45DA0026056ECBF6A3DFA') |
AEStestVector( i = 'aes-ecb-vt-192-95', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000200000000', |
ct = '027A75E4DE635790E47ACE90D7928804') |
AEStestVector( i = 'aes-ecb-vt-192-96', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000100000000', |
ct = 'C4CF3CCB59BF87D0AFBD629F48CFBB7B') |
AEStestVector( i = 'aes-ecb-vt-192-97', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000080000000', |
ct = '35165C93F564C97E1C32EF97E8151A87') |
AEStestVector( i = 'aes-ecb-vt-192-98', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000040000000', |
ct = '449DE37F7D5A1BBD628ABBE7E061701D') |
AEStestVector( i = 'aes-ecb-vt-192-99', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000020000000', |
ct = 'B1D45EAF218F1799B149BAD677FE129F') |
AEStestVector( i = 'aes-ecb-vt-192-100', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000010000000', |
ct = 'BE08AC6DB6BD0583AA9D2ABC71C73DCD') |
AEStestVector( i = 'aes-ecb-vt-192-101', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000008000000', |
ct = 'BCC835BD3DF1A79E4C7C145B899A5C25') |
AEStestVector( i = 'aes-ecb-vt-192-102', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000004000000', |
ct = '3D311EA611FF5AF371301C58A8E9912D') |
AEStestVector( i = 'aes-ecb-vt-192-103', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000002000000', |
ct = 'A5A1BEA594ACC7CA80F09EA5ADDB5C71') |
AEStestVector( i = 'aes-ecb-vt-192-104', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000001000000', |
ct = '0F09492429FE7222D6CD8190D9F2FFBF') |
AEStestVector( i = 'aes-ecb-vt-192-105', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000800000', |
ct = '816D2220A16B8AAEE71364FD43636C6F') |
AEStestVector( i = 'aes-ecb-vt-192-106', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000400000', |
ct = 'D7E8702408419ED73191B107EAF75A0B') |
AEStestVector( i = 'aes-ecb-vt-192-107', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000200000', |
ct = '9B170EFB1E235B433C78E276BEA082F0') |
AEStestVector( i = 'aes-ecb-vt-192-108', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000100000', |
ct = '03BBECC5598AE974430F29395522F096') |
AEStestVector( i = 'aes-ecb-vt-192-109', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000080000', |
ct = 'DB53517766C0E8CF42059607CBA89380') |
AEStestVector( i = 'aes-ecb-vt-192-110', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000040000', |
ct = '2E2AF4B7931F0AEFFAC5471148A5BB97') |
AEStestVector( i = 'aes-ecb-vt-192-111', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000020000', |
ct = 'C872C0408266403B984F635FF5683DE4') |
AEStestVector( i = 'aes-ecb-vt-192-112', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000010000', |
ct = '15DCF750B0E3A68AD1F4EFD07E8967B4') |
AEStestVector( i = 'aes-ecb-vt-192-113', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000008000', |
ct = 'B41092048E9E6A749F6FD8CE515A23A3') |
AEStestVector( i = 'aes-ecb-vt-192-114', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000004000', |
ct = '4DA9267D62507994312BD5C99ADDE730') |
AEStestVector( i = 'aes-ecb-vt-192-115', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000002000', |
ct = '9E2FCA6D1D626E9C6A924EBF7DBF618A') |
AEStestVector( i = 'aes-ecb-vt-192-116', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000001000', |
ct = 'E092E8D7EF2C2465AEFB2493C3063590') |
AEStestVector( i = 'aes-ecb-vt-192-117', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000000800', |
ct = '1C0E58DA37D1068378A88DBE2EDE4E10') |
AEStestVector( i = 'aes-ecb-vt-192-118', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000000400', |
ct = '19063F854232B8509A6A3A6D46809959') |
AEStestVector( i = 'aes-ecb-vt-192-119', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000000200', |
ct = '447FB09E54EFA285F7530F25C4EA0022') |
AEStestVector( i = 'aes-ecb-vt-192-120', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000000100', |
ct = 'F6ABE86321BE40E1FBFDAFED37CC1D9B') |
AEStestVector( i = 'aes-ecb-vt-192-121', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000000080', |
ct = '4E8506CD006666341D6CF51F98B41F35') |
AEStestVector( i = 'aes-ecb-vt-192-122', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000000040', |
ct = '53995DE0009CA18BECAFB8307C54C14C') |
AEStestVector( i = 'aes-ecb-vt-192-123', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000000020', |
ct = '2006BF99F4C58B6CC2627856593FAEEA') |
AEStestVector( i = 'aes-ecb-vt-192-124', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000000010', |
ct = '2DA697D2737CB30B744A4644FA1CBC6E') |
AEStestVector( i = 'aes-ecb-vt-192-125', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000000008', |
ct = '47A22ACDB60C3A986A8F76ECD0EA3433') |
AEStestVector( i = 'aes-ecb-vt-192-126', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000000004', |
ct = 'FDAA17C2CDE20268FE36E164EA532151') |
AEStestVector( i = 'aes-ecb-vt-192-127', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000000002', |
ct = '98E7247C07F0FE411C267E4384B0F600') |
AEStestVector( i = 'aes-ecb-vt-192-128', |
key = '000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000000001', |
ct = 'CD33B28AC773F74BA00ED1F312572435') |
AEStestVector( i = 'aes-ecb-vt-256-1', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '80000000000000000000000000000000', |
ct = 'DDC6BF790C15760D8D9AEB6F9A75FD4E') |
AEStestVector( i = 'aes-ecb-vt-256-2', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '40000000000000000000000000000000', |
ct = 'C7098C217C334D0C9BDF37EA13B0822C') |
AEStestVector( i = 'aes-ecb-vt-256-3', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '20000000000000000000000000000000', |
ct = '60F0FB0D4C56A8D4EEFEC5264204042D') |
AEStestVector( i = 'aes-ecb-vt-256-4', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '10000000000000000000000000000000', |
ct = '73376FBBF654D0686E0E84001477106B') |
AEStestVector( i = 'aes-ecb-vt-256-5', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '08000000000000000000000000000000', |
ct = '2F443B52BA5F0C6EA0602C7C4FD259B6') |
AEStestVector( i = 'aes-ecb-vt-256-6', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '04000000000000000000000000000000', |
ct = '75D11B0E3A68C4223D88DBF017977DD7') |
AEStestVector( i = 'aes-ecb-vt-256-7', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '02000000000000000000000000000000', |
ct = '779B38D15BFFB63D8D609D551A5CC98E') |
AEStestVector( i = 'aes-ecb-vt-256-8', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '01000000000000000000000000000000', |
ct = '5275F3D86B4FB8684593133EBFA53CD3') |
AEStestVector( i = 'aes-ecb-vt-256-9', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00800000000000000000000000000000', |
ct = '1CEF2074B336CEC62F12DEA2F6AB1481') |
AEStestVector( i = 'aes-ecb-vt-256-10', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00400000000000000000000000000000', |
ct = '1AEF5ABBAD9D7160874578DCD8BAE172') |
AEStestVector( i = 'aes-ecb-vt-256-11', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00200000000000000000000000000000', |
ct = '46C525DB17E72F26BF03216846B6F609') |
AEStestVector( i = 'aes-ecb-vt-256-12', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00100000000000000000000000000000', |
ct = 'E24411F941BBE08788781E3EC52CBAA4') |
AEStestVector( i = 'aes-ecb-vt-256-13', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00080000000000000000000000000000', |
ct = '83A3DEDD1DD27018F6A6477E40527581') |
AEStestVector( i = 'aes-ecb-vt-256-14', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00040000000000000000000000000000', |
ct = 'B68F8A2CDBAB0C923C67FC8F0F1087DE') |
AEStestVector( i = 'aes-ecb-vt-256-15', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00020000000000000000000000000000', |
ct = '649944A70C32BF87A7409E7AE128FDE8') |
AEStestVector( i = 'aes-ecb-vt-256-16', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00010000000000000000000000000000', |
ct = '2846526D67387539C89314DE9E0C2D02') |
AEStestVector( i = 'aes-ecb-vt-256-17', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00008000000000000000000000000000', |
ct = 'A9A0B8402E53C70DD1688054BA58DDFD') |
AEStestVector( i = 'aes-ecb-vt-256-18', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00004000000000000000000000000000', |
ct = '4A72E6E1B79C83AC4BE3EBA5699EED48') |
AEStestVector( i = 'aes-ecb-vt-256-19', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00002000000000000000000000000000', |
ct = 'B0E36B867BA4FF2B77D0614B0E364E4C') |
AEStestVector( i = 'aes-ecb-vt-256-20', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00001000000000000000000000000000', |
ct = '49B57DE141F6418E3090F24DDD4014B6') |
AEStestVector( i = 'aes-ecb-vt-256-21', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000800000000000000000000000000', |
ct = 'A6C0D5B9797258E1987AC5F6CD20146D') |
AEStestVector( i = 'aes-ecb-vt-256-22', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000400000000000000000000000000', |
ct = '426CF4BDCAA369175965D26E7C71EEA2') |
AEStestVector( i = 'aes-ecb-vt-256-23', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000200000000000000000000000000', |
ct = 'E27F484CE54BC99BC1A52BDA3B518A26') |
AEStestVector( i = 'aes-ecb-vt-256-24', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000100000000000000000000000000', |
ct = 'D16D186284C7E6EE64B8104E0EF20BA5') |
AEStestVector( i = 'aes-ecb-vt-256-25', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000080000000000000000000000000', |
ct = '6431F8538AD54E1E044A9F71F8EF556B') |
AEStestVector( i = 'aes-ecb-vt-256-26', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000040000000000000000000000000', |
ct = 'ECD57CEB451D27EB96C55B2042257E8E') |
AEStestVector( i = 'aes-ecb-vt-256-27', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000020000000000000000000000000', |
ct = '4F0F188DC911B1954AFBC734C9F68872') |
AEStestVector( i = 'aes-ecb-vt-256-28', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000010000000000000000000000000', |
ct = 'B54DEF0337626B65614E81EDFDE620F3') |
AEStestVector( i = 'aes-ecb-vt-256-29', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000008000000000000000000000000', |
ct = '6655D8074CAE0B90B0D3A3FE72D4D9DB') |
AEStestVector( i = 'aes-ecb-vt-256-30', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000004000000000000000000000000', |
ct = 'C6B74B6B9EB4FC0C9A237DB1B616D09A') |
AEStestVector( i = 'aes-ecb-vt-256-31', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000002000000000000000000000000', |
ct = 'D7B5D076EA56EC2B20791D7AD51CCF8F') |
AEStestVector( i = 'aes-ecb-vt-256-32', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000001000000000000000000000000', |
ct = 'FE160C224BF003CE3BDDC90CB52ED22C') |
AEStestVector( i = 'aes-ecb-vt-256-33', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000800000000000000000000000', |
ct = '5E00DA9BA94B5EC0D258D8A8002E0F6A') |
AEStestVector( i = 'aes-ecb-vt-256-34', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000400000000000000000000000', |
ct = '09AC6DCFF4DACFF1651E2BA212A292A3') |
AEStestVector( i = 'aes-ecb-vt-256-35', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000200000000000000000000000', |
ct = 'B283617E318D99AF83A05D9810BA89F7') |
AEStestVector( i = 'aes-ecb-vt-256-36', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000100000000000000000000000', |
ct = '0B5F70CCB40B0EF2538AE9B4A9770B35') |
AEStestVector( i = 'aes-ecb-vt-256-37', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000080000000000000000000000', |
ct = '43282BF180248FB517839B37F4DDAAE4') |
AEStestVector( i = 'aes-ecb-vt-256-38', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000040000000000000000000000', |
ct = 'DDBD534C8B2E6D30A268F88C55AD765B') |
AEStestVector( i = 'aes-ecb-vt-256-39', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000020000000000000000000000', |
ct = 'A41A164E50EC2D9F175E752B755E0B5C') |
AEStestVector( i = 'aes-ecb-vt-256-40', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000010000000000000000000000', |
ct = '37BFF99FF2F7AA97779E4ADF6F13FB10') |
AEStestVector( i = 'aes-ecb-vt-256-41', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000008000000000000000000000', |
ct = '9BA4F7BD298152903A683C4CEC669216') |
AEStestVector( i = 'aes-ecb-vt-256-42', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000004000000000000000000000', |
ct = '5FB750C7CE10DE7B4504248914D0DA06') |
AEStestVector( i = 'aes-ecb-vt-256-43', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000002000000000000000000000', |
ct = '3E748BFA108E086F51D56EC74A9E0FB9') |
AEStestVector( i = 'aes-ecb-vt-256-44', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000001000000000000000000000', |
ct = '31D4E56B99F5B73C1B8437DF332AFB98') |
AEStestVector( i = 'aes-ecb-vt-256-45', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000800000000000000000000', |
ct = '9DC6717B84FC55D266E7B1D9B5C52A5F') |
AEStestVector( i = 'aes-ecb-vt-256-46', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000400000000000000000000', |
ct = '8EF8BA007F23C0A50FC120E07041BCCD') |
AEStestVector( i = 'aes-ecb-vt-256-47', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000200000000000000000000', |
ct = 'C58F38E1839FC1918A12B8C9E88C66B6') |
AEStestVector( i = 'aes-ecb-vt-256-48', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000100000000000000000000', |
ct = 'B695D72A3FCF508C4050E12E40061C2D') |
AEStestVector( i = 'aes-ecb-vt-256-49', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000080000000000000000000', |
ct = '5D2736AD478A50583BC8C11BEFF16D7A') |
AEStestVector( i = 'aes-ecb-vt-256-50', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000040000000000000000000', |
ct = 'DF0EACA8F17847AD41F9578F14C7B56B') |
AEStestVector( i = 'aes-ecb-vt-256-51', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000020000000000000000000', |
ct = 'E5AA14AD48AD0A3C47CC35D5F8020E51') |
AEStestVector( i = 'aes-ecb-vt-256-52', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000010000000000000000000', |
ct = '11BE6C8F58EBD8CEF1A53F591A68E8CE') |
AEStestVector( i = 'aes-ecb-vt-256-53', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000008000000000000000000', |
ct = 'ECFE7BAFCBF42C1FEE015488770B3053') |
AEStestVector( i = 'aes-ecb-vt-256-54', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000004000000000000000000', |
ct = 'E552649F8D8EC4A1E1CD6DF50B6E6777') |
AEStestVector( i = 'aes-ecb-vt-256-55', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000002000000000000000000', |
ct = '521C0629DE93B9119CDB1DDC5809DDEA') |
AEStestVector( i = 'aes-ecb-vt-256-56', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000001000000000000000000', |
ct = 'CB38A62A0BAB1784156BA038CBA99BF6') |
AEStestVector( i = 'aes-ecb-vt-256-57', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000800000000000000000', |
ct = '76CCEE8AAACD394DE1EEF3DDA10CB54B') |
AEStestVector( i = 'aes-ecb-vt-256-58', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000400000000000000000', |
ct = '6AFF910FA1D5673140E2DB59B8416049') |
AEStestVector( i = 'aes-ecb-vt-256-59', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000200000000000000000', |
ct = '064A12C0EF73FB386801BF4F35F3120D') |
AEStestVector( i = 'aes-ecb-vt-256-60', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000100000000000000000', |
ct = '2240E374929D5B1BB8FF0FFDDDF640EC') |
AEStestVector( i = 'aes-ecb-vt-256-61', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000080000000000000000', |
ct = 'D4BA15C904C7692185DE85C02052E180') |
AEStestVector( i = 'aes-ecb-vt-256-62', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000040000000000000000', |
ct = '1714A315AB0166728A44CD91D4AE9018') |
AEStestVector( i = 'aes-ecb-vt-256-63', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000020000000000000000', |
ct = '6C970BDD9F0E222722EA31A1D12DD0AD') |
AEStestVector( i = 'aes-ecb-vt-256-64', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000010000000000000000', |
ct = 'F5956EDF02BD36A401BBB6CE77C3D3FB') |
AEStestVector( i = 'aes-ecb-vt-256-65', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000008000000000000000', |
ct = '0CA11F122CCD7C259DC597EED3DF9BC4') |
AEStestVector( i = 'aes-ecb-vt-256-66', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000004000000000000000', |
ct = '50109AB4912AD2560B206F331B62EB6C') |
AEStestVector( i = 'aes-ecb-vt-256-67', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000002000000000000000', |
ct = 'DBE7C91A4175614889A2D4BEFD64845E') |
AEStestVector( i = 'aes-ecb-vt-256-68', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000001000000000000000', |
ct = '0D3322853A571A6B46B79C0228E0DD25') |
AEStestVector( i = 'aes-ecb-vt-256-69', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000800000000000000', |
ct = '96E4EE0BB9A11C6FB8522F285BADDEB6') |
AEStestVector( i = 'aes-ecb-vt-256-70', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000400000000000000', |
ct = '96705C52D2CFCE82E630C93477C79C49') |
AEStestVector( i = 'aes-ecb-vt-256-71', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000200000000000000', |
ct = 'C50130AED6A126149D71F3888C83C232') |
AEStestVector( i = 'aes-ecb-vt-256-72', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000100000000000000', |
ct = '4816EFE3DEB380566EBA0C17BF582090') |
AEStestVector( i = 'aes-ecb-vt-256-73', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000080000000000000', |
ct = '0390857B4C8C98E4CF7A2B6F3394C507') |
AEStestVector( i = 'aes-ecb-vt-256-74', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000040000000000000', |
ct = '422E73A02025EBE8B8B5D6E0FA24FCB2') |
AEStestVector( i = 'aes-ecb-vt-256-75', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000020000000000000', |
ct = '3271AA7F4BF1D7C38050A43076D4FF76') |
AEStestVector( i = 'aes-ecb-vt-256-76', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000010000000000000', |
ct = 'D2074946F0D37B8975607BFC2E70234C') |
AEStestVector( i = 'aes-ecb-vt-256-77', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000008000000000000', |
ct = '1A509194C1270AB92E5A42D3A9F8D98B') |
AEStestVector( i = 'aes-ecb-vt-256-78', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000004000000000000', |
ct = '512438946360CCC4A5C6D73F6EED7130') |
AEStestVector( i = 'aes-ecb-vt-256-79', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000002000000000000', |
ct = '98CFCDEC46EBEA1A286B3004F2746A0D') |
AEStestVector( i = 'aes-ecb-vt-256-80', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000001000000000000', |
ct = 'A1CF369949677A3AF3D58E3EABF2741B') |
AEStestVector( i = 'aes-ecb-vt-256-81', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000800000000000', |
ct = 'D84C2E1A0E4A52166FA8FF6889D1E5E2') |
AEStestVector( i = 'aes-ecb-vt-256-82', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000400000000000', |
ct = '4AD91CCEEF60119B5078FD162D2735DE') |
AEStestVector( i = 'aes-ecb-vt-256-83', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000200000000000', |
ct = '2860793D818E97AAFF1D339D7702438D') |
AEStestVector( i = 'aes-ecb-vt-256-84', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000100000000000', |
ct = '6F9068BE73364AE250D89D78A6C9CE6F') |
AEStestVector( i = 'aes-ecb-vt-256-85', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000080000000000', |
ct = '024FC3FEF4883FEB1A8DD005305FECCE') |
AEStestVector( i = 'aes-ecb-vt-256-86', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000040000000000', |
ct = '08A61FE0816D75EA15EB3C9FB9CCDED6') |
AEStestVector( i = 'aes-ecb-vt-256-87', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000020000000000', |
ct = '449C86DFA13F260175CE39797686FFA4') |
AEStestVector( i = 'aes-ecb-vt-256-88', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000010000000000', |
ct = '4FFFFC29A59858E1133F2BFB1A8A4817') |
AEStestVector( i = 'aes-ecb-vt-256-89', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000008000000000', |
ct = '19425D1F6480B25096561295697DC2B7') |
AEStestVector( i = 'aes-ecb-vt-256-90', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000004000000000', |
ct = '31974727ECDD2C77C3A428FC3A8CB3FC') |
AEStestVector( i = 'aes-ecb-vt-256-91', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000002000000000', |
ct = 'A57CD704B3C95E744D08DF443458F2F5') |
AEStestVector( i = 'aes-ecb-vt-256-92', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000001000000000', |
ct = '486D8C193DB1ED73ACB17990442FC40B') |
AEStestVector( i = 'aes-ecb-vt-256-93', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000800000000', |
ct = '5E4DBF4E83AB3BC055B9FCC7A6B3A763') |
AEStestVector( i = 'aes-ecb-vt-256-94', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000400000000', |
ct = 'ACF2E0A693FBBCBA4D41B861E0D89E37') |
AEStestVector( i = 'aes-ecb-vt-256-95', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000200000000', |
ct = '32A7CB2AE066A51D2B78FC4B4CFCB608') |
AEStestVector( i = 'aes-ecb-vt-256-96', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000100000000', |
ct = '677D494DBB73CAF55C1990158DA12F14') |
AEStestVector( i = 'aes-ecb-vt-256-97', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000080000000', |
ct = '082A0D2367512ADF0D75A151BFBE0A17') |
AEStestVector( i = 'aes-ecb-vt-256-98', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000040000000', |
ct = '5E5BB7337923C482CE8CBA249E6A8C7D') |
AEStestVector( i = 'aes-ecb-vt-256-99', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000020000000', |
ct = 'D3001BA7C7026EE3E5003179530AFCFC') |
AEStestVector( i = 'aes-ecb-vt-256-100', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000010000000', |
ct = '46EC44F8931E629FE8FD8961312EDDE1') |
AEStestVector( i = 'aes-ecb-vt-256-101', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000008000000', |
ct = 'C5F8ECD79C7B30E81D17E32079969310') |
AEStestVector( i = 'aes-ecb-vt-256-102', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000004000000', |
ct = '5B8AD6919E24CAEBCC55401AEE0C9802') |
AEStestVector( i = 'aes-ecb-vt-256-103', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000002000000', |
ct = 'C2302B7E701B5CC7F8B29E3516DBBFA6') |
AEStestVector( i = 'aes-ecb-vt-256-104', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000001000000', |
ct = 'A1D04D6A76F9F7A94D49FAA64A87F244') |
AEStestVector( i = 'aes-ecb-vt-256-105', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000800000', |
ct = '7FB6F92D35B5CB6C631600EDB9E860BA') |
AEStestVector( i = 'aes-ecb-vt-256-106', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000400000', |
ct = 'B2EF7078BCFACE07AEEC3F9B48830EB3') |
AEStestVector( i = 'aes-ecb-vt-256-107', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000200000', |
ct = 'F475A7493D24C7036E53390374C378B3') |
AEStestVector( i = 'aes-ecb-vt-256-108', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000100000', |
ct = 'B36802AC987377A37BD8EADC97C57D60') |
AEStestVector( i = 'aes-ecb-vt-256-109', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000080000', |
ct = 'ADDCD3D19689C4DDC738CE5F69DC9505') |
AEStestVector( i = 'aes-ecb-vt-256-110', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000040000', |
ct = '0DAF8CA22884915403C0F0BB1F4BD74F') |
AEStestVector( i = 'aes-ecb-vt-256-111', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000020000', |
ct = '4AF36BAE2660503B3248E4685059FD05') |
AEStestVector( i = 'aes-ecb-vt-256-112', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000010000', |
ct = '7D5631814DD8E917D97A0D514C743971') |
AEStestVector( i = 'aes-ecb-vt-256-113', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000008000', |
ct = 'BC3352500FC0CBB9DB5B5F6B491C1BE8') |
AEStestVector( i = 'aes-ecb-vt-256-114', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000004000', |
ct = '6A4A30BA87E87AF65C90AEB7AFEDC76B') |
AEStestVector( i = 'aes-ecb-vt-256-115', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000002000', |
ct = '77E6125897668AC8E73E8C79A6FF8336') |
AEStestVector( i = 'aes-ecb-vt-256-116', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000001000', |
ct = '3FA9D39104EBB323C7AAAA248960DD1E') |
AEStestVector( i = 'aes-ecb-vt-256-117', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000000800', |
ct = 'FAD75AD76AB10ADC49036B250E229D39') |
AEStestVector( i = 'aes-ecb-vt-256-118', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000000400', |
ct = '2FACAA5FE35B228A16AC74088D702EC4') |
AEStestVector( i = 'aes-ecb-vt-256-119', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000000200', |
ct = '88B6CBCFDFEF8AD91720A1BB69A1F33E') |
AEStestVector( i = 'aes-ecb-vt-256-120', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000000100', |
ct = 'C7E9D250998632D444356242EF04058D') |
AEStestVector( i = 'aes-ecb-vt-256-121', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000000080', |
ct = 'B14DAD8D3D9153F46C0D3A1AD63C7A05') |
AEStestVector( i = 'aes-ecb-vt-256-122', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000000040', |
ct = '60ABA678A506608D0845966D29B5F790') |
AEStestVector( i = 'aes-ecb-vt-256-123', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000000020', |
ct = '482DC43F2388EF25D24144E144BD834E') |
AEStestVector( i = 'aes-ecb-vt-256-124', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000000010', |
ct = '1490A05A7CEE43BDE98B56E309DC0126') |
AEStestVector( i = 'aes-ecb-vt-256-125', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000000008', |
ct = 'ABFA77CD6E85DA245FB0BDC5E52CFC29') |
AEStestVector( i = 'aes-ecb-vt-256-126', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000000004', |
ct = 'DD4AB1284D4AE17B41E85924470C36F7') |
AEStestVector( i = 'aes-ecb-vt-256-127', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000000002', |
ct = 'CEA7403D4D606B6E074EC5D3BAF39D18') |
AEStestVector( i = 'aes-ecb-vt-256-128', |
key = '0000000000000000000000000000000000000000000000000000000000000000', |
pt = '00000000000000000000000000000001', |
ct = '530F8AFBC74536B9A963B4F1C4CB738B') |
# Make this test module runnable from the command prompt |
if __name__ == "__main__": |
unittest.main() |
/relevation/ext/cryptopy-1.2.5.patched/crypto/cipher/aes.py |
---|
0,0 → 1,33 |
""" crypto.aes |
AES Encryption Algorithm |
The AES algorithm is just Rijndael algorithm restricted to the default |
blockSize of 128 bits. |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
2002-06-01 |
""" |
from crypto.cipher.rijndael import Rijndael |
from crypto.cipher.base import BlockCipher, padWithPadLen, noPadding |
from crypto.errors import BadKeySizeError |
class AES(Rijndael): |
""" The AES algorithm is the Rijndael block cipher restricted to block |
sizes of 128 bits and key sizes of 128, 192 or 256 bits |
""" |
def __init__(self, key = None, padding = padWithPadLen(), keySize=16): |
""" Initialize AES, keySize is in bytes """ |
if not (keySize == 16 or keySize == 24 or keySize == 32) : |
raise BadKeySizeError, 'Illegal AES key size, must be 16, 24, or 32 bytes' |
Rijndael.__init__( self, key, padding=padding, keySize=keySize, blockSize=16 ) |
self.name = 'AES' |
/relevation/ext/cryptopy-1.2.5.patched/crypto/cipher/icedoll_test.py |
---|
0,0 → 1,91 |
#! /usr/bin/env python |
""" crypto.cipher.icedoll_test |
Tests for icedoll encryption algorithm |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
""" |
from crypto.cipher.icedoll import Icedoll |
from crypto.cipher.base import noPadding |
from binascii import a2b_hex |
from binascii_plus import b2a_p, a2b_p |
import unittest |
class Icedoll_Basic_Tests(unittest.TestCase): |
""" Test Icedoll algorithm """ |
def testDctEqPt(self): |
""" test of plaintext = decrypt(encrypt(plaintext)) """ |
alg = Icedoll( 16*chr(0), padding=noPadding()) |
pt = 16*4*'a' # block aligned |
ct = alg.encrypt(pt) |
print 'ct = ',b2a_p(ct) |
dct = alg.decrypt(ct) |
print 'dct = ',b2a_p(dct) |
assert(pt == dct), 'pt != dct' |
alg = Icedoll( 16*chr(0)) # autoPad |
pt = 17*4*'a' # non-block aligned |
ct = alg.encrypt(pt) |
print 'ct = ',b2a_p(ct) |
dct = alg.decrypt(ct) |
print 'dct = ',b2a_p(dct) |
assert(pt == dct), 'pt != dct' |
def xxxtestGladman_dev_vec(self): |
""" All 25 combinations of block and key size. |
These test vectors were generated by Dr Brian Gladman |
using the program aes_vec.cpp <brg@gladman.uk.net> 24th May 2001. |
vectors in file: dev_vec.txt |
http://fp.gladman.plus.com/cryptography_technology/rijndael/index.htm |
note -> ket, pt the same .. ct different |
""" |
def IcedollTestVec(i, key, pt, ct): |
""" Run single AES test vector with any legal blockSize |
and any legal key size. """ |
bkey, plainText, cipherText = a2b_hex(key), a2b_hex(pt), a2b_hex(ct) |
kSize = len(bkey) |
bSize = len(cipherText) # set block size to length of block |
alg = Icedoll(bkey, keySize=kSize, blockSize=bSize, padding=noPadding()) |
cct = alg.encrypt(plainText) |
print 'pt =',b2a_p(plainText) |
print 'ct =',b2a_p(cct) |
dcct = alg.decrypt(cct) |
#print '_dcct',b2a_p(dcct) |
self.assertEqual( dcct, plainText ) |
self.assertEqual( alg.encrypt(plainText), cipherText ) |
self.assertEqual( alg.decrypt(cipherText), plainText ) |
IcedollTestVec( i = 'dev_vec.txt 16 byte block, 16 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c', |
pt = '3243f6a8885a308d313198a2e0370734', |
ct = '3925841d02dc09fbdc118597196a0b32') |
IcedollTestVec( i = 'dev_vec.txt 16 byte block, 20 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c762e7160', |
pt = '3243f6a8885a308d313198a2e0370734', |
ct = '231d844639b31b412211cfe93712b880') |
IcedollTestVec( i = 'dev_vec.txt 16 byte block, 24 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da5', |
pt = '3243f6a8885a308d313198a2e0370734', |
ct = 'f9fb29aefc384a250340d833b87ebc00') |
IcedollTestVec( i = 'dev_vec.txt 16 byte block, 28 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a784d90', |
pt = '3243f6a8885a308d313198a2e0370734', |
ct = '8faa8fe4dee9eb17caa4797502fc9d3f') |
IcedollTestVec( i = 'dev_vec.txt 16 byte block, 32 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a784d9045190cfe', |
pt = '3243f6a8885a308d313198a2e0370734', |
ct = '1a6e6c2c662e7da6501ffb62bc9e93f3') |
# Make this test module runnable from the command prompt |
if __name__ == "__main__": |
unittest.main() |
/relevation/ext/cryptopy-1.2.5.patched/crypto/cipher/base.py |
---|
0,0 → 1,140 |
""" crypto.cipher.base |
Base 'BlockCipher' and Pad classes for cipher instances. |
BlockCipher supports automatic padding and type conversion. The BlockCipher |
class was written to make the actual algorithm code more readable and |
not for performance. |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
2002-04-25 changed block input |
""" |
from crypto.errors import DecryptNotBlockAlignedError |
from crypto.keyedHash.pbkdf2 import pbkdf2 |
class BlockCipher: |
""" Block ciphers """ |
def __init__(self): |
self.reset() |
def reset(self): |
self.resetEncrypt() |
self.resetDecrypt() |
def resetEncrypt(self): |
self.encryptBlockCount = 0 |
self.bytesToEncrypt = '' |
def resetDecrypt(self): |
self.decryptBlockCount = 0 |
self.bytesToDecrypt = '' |
def setPassphrase(self,passphrase): |
""" Use pbkdf2 to hash passphrase into a key """ |
self.setKey( pbkdf2( passphrase, self.name, 4096, self.keySize) ) |
def encrypt(self, plainText, more = None): |
""" Encrypt a string and return a binary string """ |
self.bytesToEncrypt += plainText # append plainText to any bytes from prior encrypt |
numBlocks, numExtraBytes = divmod(len(self.bytesToEncrypt), self.blockSize) |
cipherText = '' |
for i in range(numBlocks): |
bStart = i*self.blockSize |
ctBlock = self.encryptBlock(self.bytesToEncrypt[bStart:bStart+self.blockSize]) |
self.encryptBlockCount += 1 |
cipherText += ctBlock |
if numExtraBytes > 0: # save any bytes that are not block aligned |
self.bytesToEncrypt = self.bytesToEncrypt[-numExtraBytes:] |
else: |
self.bytesToEncrypt = '' |
if more == None: # no more data expected from caller |
finalBytes = self.padding.addPad(self.bytesToEncrypt,self.blockSize) |
if len(finalBytes) > 0: |
ctBlock = self.encryptBlock(finalBytes) |
self.encryptBlockCount += 1 |
cipherText += ctBlock |
self.resetEncrypt() |
return cipherText |
def decrypt(self, cipherText, more = None): |
""" Decrypt a string and return a string """ |
self.bytesToDecrypt += cipherText # append to any bytes from prior decrypt |
numBlocks, numExtraBytes = divmod(len(self.bytesToDecrypt), self.blockSize) |
if more == None: # no more calls to decrypt, should have all the data |
if numExtraBytes != 0: |
raise DecryptNotBlockAlignedError, 'Data not block aligned on decrypt' |
# hold back some bytes in case last decrypt has zero len |
if (more != None) and (numExtraBytes == 0) and (numBlocks >0) : |
numBlocks -= 1 |
numExtraBytes = self.blockSize |
plainText = '' |
for i in range(numBlocks): |
bStart = i*self.blockSize |
ptBlock = self.decryptBlock(self.bytesToDecrypt[bStart : bStart+self.blockSize]) |
self.decryptBlockCount += 1 |
plainText += ptBlock |
if numExtraBytes > 0: # save any bytes that are not block aligned |
self.bytesToEncrypt = self.bytesToEncrypt[-numExtraBytes:] |
else: |
self.bytesToEncrypt = '' |
if more == None: # last decrypt remove padding |
plainText = self.padding.removePad(plainText, self.blockSize) |
self.resetDecrypt() |
return plainText |
class BlockCipherWithIntegrity(BlockCipher): |
""" Base class for encryption with integrity checking |
just a holding place for now ... """ |
def __init__(self, authData, plainText): |
self.reset() |
class Pad: |
def __init__(self): |
pass # eventually could put in calculation of min and max size extension |
class padWithPadLen(Pad): |
""" Pad a binary string with the length of the padding """ |
def addPad(self, extraBytes, blockSize): |
""" Add padding to a binary string to make it an even multiple |
of the block size """ |
blocks, numExtraBytes = divmod(len(extraBytes), blockSize) |
padLength = blockSize - numExtraBytes |
return extraBytes + padLength*chr(padLength) |
def removePad(self, paddedBinaryString, blockSize): |
""" Remove padding from a binary string """ |
if not(0<len(paddedBinaryString)): |
raise DecryptNotBlockAlignedError, 'Expected More Data' |
return paddedBinaryString[:-ord(paddedBinaryString[-1])] |
class noPadding(Pad): |
""" No padding. Use this to get ECB behavior from encrypt/decrypt """ |
def addPad(self, extraBytes, blockSize): |
""" Add no padding """ |
return extraBytes |
def removePad(self, paddedBinaryString, blockSize): |
""" Remove no padding """ |
return paddedBinaryString |
class padWithZeros(Pad): |
""" Zero padding. Used in CBC_MAC processing """ |
def addPad(self, extraBytes, blockSize): |
""" Add padding to a binary string to make it an even multiple |
of the block size """ |
blocks, numExtraBytes = divmod(len(extraBytes), blockSize) |
padLength = blockSize - numExtraBytes |
return extraBytes + padLength*chr(0x00) |
def removePad(self, paddedBinaryString, blockSize): |
""" Remove no padding, you really should, but no way to tell padding size """ |
return paddedBinaryString |
/relevation/ext/cryptopy-1.2.5.patched/crypto/cipher/icedoll.py |
---|
0,0 → 1,102 |
""" crypto.cipher.icedoll |
Modification of Rijndael to provide infinite error extension. |
The ith round of Rijndael is tapped and used to process the |
subsequent block. |
Changes to base Rijndael are marked with: '# --------------------------' |
For Rijndael with N rounds, normally ECB mode is C[i] = Ek(N,P[i]) |
Modification is: |
Fi = Ek(t,P[i-1]) ; Fi, with i=0 is nonce or a fixed value |
C[i] = Fi^Ek(N,P[i]^Fi) |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
June 2002 |
February 2003 -> discovered Ron Rivest's "Tweakable Block Ciphers" |
http://theory.lcs.mit.edu/~rivest/publications.html |
These are about the same concept .... |
""" |
from crypto.cipher.base import BlockCipherWithIntegrity, padWithPadLen, noPadding |
from crypto.cipher.rijndael import * |
from binascii_plus import b2a_hex |
from copy import deepcopy |
class Icedoll(Rijndael): |
""" IceDoll encryption algorithm |
based on Rijndael, with added feedback for better integrity processing. |
Note - no integrity check is built into Icedoll directly |
""" |
def __init__(self,key=None,padding=padWithPadLen(),keySize=16,blockSize=16,tapRound=6,extraRounds=6): |
""" key, keysize, blockSize same as Rijndael, tapROund is feedback tap, """ |
self.tapRound = tapRound # <------- !!! change from Rijndael !!! |
self.extraRounds = extraRounds # <------- !!! change from Rijndael !!! |
self.name = 'ICEDOLL' |
self.keySize = keySize |
self.strength = keySize |
self.blockSize = blockSize # blockSize is in bytes |
self.padding = padding # change default to noPadding() to get normal ECB behavior |
assert( keySize%4==0 and NrTable[4].has_key(keySize/4)),'key size must be 16,20,24,29 or 32 bytes' |
assert( blockSize%4==0 and NrTable.has_key(blockSize/4)), 'block size must be 16,20,24,29 or 32 bytes' |
self.Nb = self.blockSize/4 # Nb is number of columns of 32 bit words |
self.Nk = keySize/4 # Nk is the key length in 32-bit words |
self.Nr = NrTable[self.Nb][self.Nk]+extraRounds # <------- !!! change from Rijndael !!! |
if key != None: |
self.setKey(key) |
def setKey(self, key): |
""" Set a key and generate the expanded key """ |
assert( len(key) == (self.Nk*4) ), 'Key length must be same as keySize parameter' |
self.__expandedKey = keyExpansion(self, key) |
self.reset() # BlockCipher.reset() |
def encryptBlock(self, plainTextBlock): |
""" Encrypt a block, plainTextBlock must be a array of bytes [Nb by 4] """ |
self.state = self._toBlock(plainTextBlock) |
if self.encryptBlockCount == 0: # first call, set frdd back |
self.priorFeedBack = self._toBlock(chr(0)*(4*self.Nb)) # <------- !!! change from Rijndael !!! |
AddRoundKey(self, self.priorFeedBack) # <------- !!! change from Rijndael !!! |
AddRoundKey(self, self.__expandedKey[0:self.Nb]) |
for round in range(1,self.Nr): #for round = 1 step 1 to Nr1 |
SubBytes(self) |
ShiftRows(self) |
MixColumns(self) |
if round == self.tapRound: |
nextFeedBack = deepcopy(self.state) # <------- !!! change from Rijndael !!! |
AddRoundKey(self, self.__expandedKey[round*self.Nb:(round+1)*self.Nb]) |
SubBytes(self) |
ShiftRows(self) |
AddRoundKey(self, self.__expandedKey[self.Nr*self.Nb:(self.Nr+1)*self.Nb]) |
AddRoundKey(self, self.priorFeedBack) # <------- !!! change from Rijndael !!! |
self.priorFeedBack = nextFeedBack # <------- !!! change from Rijndael !!! |
return self._toBString(self.state) |
def decryptBlock(self, encryptedBlock): |
""" decrypt a block (array of bytes) """ |
self.state = self._toBlock(encryptedBlock) |
if self.decryptBlockCount == 0: # first call, set frdd back |
self.priorFeedBack = self._toBlock( chr(0)*(4*self.Nb) ) # <------- !!! change from Rijndael !!! |
AddRoundKey(self, self.priorFeedBack) # <------- !!! change from Rijndael !!! |
AddRoundKey(self, self.__expandedKey[self.Nr*self.Nb:(self.Nr+1)*self.Nb]) |
for round in range(self.Nr-1,0,-1): |
InvShiftRows(self) |
InvSubBytes(self) |
AddRoundKey(self, self.__expandedKey[round*self.Nb:(round+1)*self.Nb]) |
if round == self.tapRound: |
nextFeedBack = deepcopy(self.state) # <------- !!! change from Rijndael !!! |
InvMixColumns(self) |
InvShiftRows(self) |
InvSubBytes(self) |
AddRoundKey(self, self.__expandedKey[0:self.Nb]) |
AddRoundKey(self, self.priorFeedBack) # <------- !!! change from Rijndael !!! |
self.priorFeedBack = nextFeedBack # <------- !!! change from Rijndael !!! |
return self._toBString(self.state) |
/relevation/ext/cryptopy-1.2.5.patched/crypto/cipher/tkip_encr_test.py |
---|
0,0 → 1,97 |
#! /usr/bin/env python |
""" crypto.cipher.tkip_encr_test |
Tests for tkip encryption (mpdu only, no Michael) |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
January 2003 May have broken key mixing ...need to validate |
November 21, 2002 |
""" |
import unittest |
from crypto.cipher.tkip_encr import TKIP_encr |
from crypto.keyedHash.tkip_key_mixing import TKIP_Mixer |
from binascii_plus import a2b_p, b2a_p |
from struct import pack |
class TKIP_encr_TestVectors(unittest.TestCase): |
""" Test TKIP_encr algorithm using know values """ |
def checkTKIPtestVector(self, description, key, ta, iv, plainText, cipherText): |
""" Process TKIP encryption test vectors (no MIC) """ |
print '%s %s %s'%('='*((54-len(description))/2),description,'='*((54-len(description))/2)) |
# Convert from octet lists to string |
key = a2b_p(key) |
ta = a2b_p(ta) |
iv = a2b_p(iv) |
pt = a2b_p(plainText) |
kct = a2b_p(cipherText) |
mixer = TKIP_Mixer(key,ta) |
rc4key = mixer.newKey(iv) |
alg = TKIP_encr(key) |
alg.setTA(ta) |
print 'key: %s'%b2a_p(key)[9:] |
print 'rc4Key %s'%b2a_p(rc4key)[9:] # calculated |
print 'ta: %s'%b2a_p(ta)[9:] |
print 'iv: %s'%b2a_p(iv)[9:] |
print 'pt: %s'%b2a_p(pt)[9:] |
print 'kct: %s'%b2a_p(kct)[9:] |
ct = alg.encrypt(pt, iv) |
print 'ct: %s'%b2a_p(ct)[9:] |
cpt = alg.decrypt(kct) |
print 'cpt: %s'%b2a_p(cpt)[9:] |
print '========================================================' |
self.assertEqual( ct, kct ) |
alg.setKey(key) |
dct = alg.decrypt( ct ) |
self.assertEqual( dct, pt ) |
def testTKIP_KnownAnswer_01(self): |
""" TKIP Known Answer #1 |
Hand created from GC example 1 to include MIC in plaintext |
note - iv==0 """ |
description = "TKIP encr test 1 - all zero pn " |
key = "00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f" |
ta = "10 22 33 44 55 66" |
iv = "00 00 00 00 00 00" |
plainText = """08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 |
18 19 1a 1b |
9c 12 11 62 08 e9 a0 83""" |
cipherText = """00 20 00 20 00 00 00 00 |
06 60 91 dc 37 82 31 ca 75 84 82 b6 54 b7 c5 3a |
81 4a cb bd 31 1e cc 3b 5c f7 df 69 53 0f c5 1b""" |
self.checkTKIPtestVector(description, key, ta, iv, plainText, cipherText) |
def XtestTKIP_KnownAnswer_02(self): |
""" TKIP Known Answer #2 """ |
description = "TKIP encr test 2" |
key = "36 23 0f 41 40 20 c9 e3 02 cb 5d 5d 28 d5 ff bf" |
ta = "01 02 03 04 05 06" |
iv = b2a_p(pack('<Q',0x123456785BA0)[:6]) |
rc4key = "5b 7b a0 31 a1 b0 60 55 f3" |
plainText = """aa aa 03 00 00 00 08 00 45 00 00 4e 66 1a 00 00 |
80 11 be 64 0a 00 01 22 0a ff ff ff 00 89 00 89 |
00 3a 00 00 80 a6 01 10 00 01 00 00 00 00 00""" |
cipherText = """58 11 A0 20 78 56 34 12 |
12 86 13 90 94 44 88 49 a3 9f e1 48 e0 f4 f3 8f |
78 ee de 66 c4 a2 8c a1 bd 39 00 7f 88 9b 95 c6 |
e6 9d cd 19 31 dc 25 61 c3 e1 9a d4 a6 4d 22 |
13 9b fa 26""" |
protectedMPDU = """08 41 23 01 01 02 03 04 05 06 01 02 03 04 05 06 |
01 22 33 44 55 66 00 00 a0 7b 5b 20 78 56 34 12 |
b8 2c 10 90 94 44 80 49 e6 9f e1 06 86 ee f3 8f |
f8 ff 60 02 ce a2 8d 83 b7 c6 ff 80 88 12 95 4f |
e6 a7 cd 19 b1 7a 24 71 c3 e0 9a d4 a6 4d 22 13 |
9b fa 26""" |
self.checkTKIPtestVector(description, key, ta, iv, plainText, cipherText) |
if __name__ == '__main__': |
# Run the tests from the command line |
unittest.main() |
/relevation/ext/cryptopy-1.2.5.patched/crypto/cipher/aes_cbc_test.py |
---|
0,0 → 1,75 |
#! /usr/bin/env python |
""" crypto.cipher.cbc_test |
Tests for cbc encryption, uses AES for base algorithm |
Copyright (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
""" |
from crypto.cipher.aes_cbc import AES_CBC |
from crypto.cipher.base import noPadding, padWithPadLen |
import unittest |
from binascii_plus import a2b_hex, b2a_hex, a2b_p |
class AES_CBC_autoIV(unittest.TestCase): |
def testAutoIV(self): |
k = a2b_hex('2b7e151628aed2a6abf7158809cf4f3c') |
alg = AES_CBC(key=k, padding=noPadding()) |
pt = a2b_hex('6bc1bee22e409f96e93d7e117393172a') |
ct = alg.encrypt(pt) |
dct = alg.decrypt(ct) |
self.assertEqual( dct, pt ) # 'AES_CBC auto IV error' |
def testAutoIVandPadding(self): |
k = a2b_hex('2b7e151628aed2a6abf7158809cf4f3c') |
alg = AES_CBC(key=k) # should default to padWithPadLen |
pt = a2b_hex('6bc1bee22e409f96e93d7e117393172a') |
ct = alg.encrypt(pt) |
dct = alg.decrypt(ct) |
self.assertEqual( dct, pt ) # 'AES_CBC auto IV and pad error' |
def testNonDupIV(self): |
""" Test to ensure that two instances of CBC don't get duplicate IV """ |
k = a2b_hex('2b7e151628aed2a6abf7158809cf4f3c') |
alg1 = AES_CBC(k) |
alg2 = AES_CBC(k) |
pt = a2b_hex('6bc1bee22e409f96e93d7e117393172a') |
ct1 = alg1.encrypt(pt) |
ct2 = alg2.encrypt(pt) |
assert( ct1!= ct2 ), 'AES_CBC dup IV error' |
class AES_CBC128_TestVectors(unittest.TestCase): |
""" Test AES_CBC128 algorithm using know values """ |
def testKnowValues(self): |
""" Test using vectors from NIST """ |
def CBCtestVector(key,iv,pt,kct): |
""" CBC test vectors using AES algorithm """ |
key,iv,pt,kct = a2b_hex(key),a2b_hex(iv),a2b_p(pt),a2b_p(kct) |
alg = AES_CBC(key, padding=noPadding()) |
self.assertEqual( alg.encrypt(pt,iv=iv), kct ) |
self.assertEqual( alg.decrypt(iv+kct), pt ) |
# http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf page 34 |
CBCtestVector( key = '2b7e151628aed2a6abf7158809cf4f3c', |
iv = '000102030405060708090a0b0c0d0e0f', |
pt = '6bc1bee22e409f96e93d7e117393172a', |
kct = '7649abac8119b246cee98e9b12e9197d') |
# four blocks of data |
CBCtestVector( key = '2b7e151628aed2a6abf7158809cf4f3c', |
iv = '000102030405060708090a0b0c0d0e0f', |
pt = """6bc1bee22e409f96e93d7e117393172a |
ae2d8a571e03ac9c9eb76fac45af8e51 |
30c81c46a35ce411e5fbc1191a0a52ef |
f69f2445df4f9b17ad2b417be66c3710""", |
kct = """7649abac8119b246cee98e9b12e9197d |
5086cb9b507219ee95db113a917678b2 |
73bed6b8e3c1743b7116e69e22229516 |
3ff1caa1681fac09120eca307586e1a7""") |
# Make this test module runnable from the command prompt |
if __name__ == "__main__": |
unittest.main() |
/relevation/ext/cryptopy-1.2.5.patched/crypto/cipher/tkip_encr.py |
---|
0,0 → 1,94 |
""" crypto.cipher.tkip_encr |
TKIP encryption from IEEE 802.11 TGi |
TKIP uses WEP (ARC4 with crc32) and key mixing |
This is only the encryption and not the Michael integrity check! |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
November 2002 |
""" |
from crypto.cipher.arc4 import ARC4 |
from zlib import crc32 |
from struct import pack |
from crypto.keyedHash.tkip_key_mixing import TKIP_Mixer |
from crypto.errors import BadKeySizeError, IntegrityCheckError |
from binascii_plus import * |
class TKIP_encr: |
""" TKIP Stream Cipher Algorithm without the Michael integrity check |
TKIP encryption on an MPDU using WEP with a longer 'iv' |
and the TKIP key mixing algorithm . This does NOT include |
the Michael integrity algorithm that operates on the MSDU data. |
""" |
def __init__(self, key=None, transmitterAddress=None, keyID=None): |
""" Initialize TKIP_encr, key -> octet string for key """ |
assert(keyID==0 or keyID==None), 'keyID should be zero in TKIP' |
self.keyId = 0 |
self.name = 'TKIP_encr' |
self.strength = 128 |
self.encryptHeaderSize = 8 # used to skip octets on decrypt |
self.arc4 = ARC4() # base algorithm |
self.keyMixer = TKIP_Mixer(key,transmitterAddress) |
if key != None: # normally in base init, uses adjusted keySize |
self.setKey(key) |
if transmitterAddress!=None: |
self.setTA(transmitterAddress) |
def setKey(self, key, ta=None): |
""" Set key, key string is 16 octets long """ |
self.keyMixer.setKey(key) |
if ta!=None: |
self.setTA(ta) |
def setTA(self, transmitterAddress): |
""" Set the transmitter address """ |
self.keyMixer.setTA(transmitterAddress) |
def _getIVandKeyID(self, cipherText): |
""" Parse the TKIP header to get iv and set KeyID |
iv is returned as octet string and is little-endian!!! |
""" |
assert(ord(cipherText[3])& 0x20),'extIV SHOULD be set in TKIP header' |
self.setCurrentKeyID = (ord(cipherText[3])&0xC0)>>6 |
return cipherText[:3] + cipherText[5:9] # note iv octets are little-endian!!! |
def _makeARC4key(self, tscOctets, keyID=0): |
""" Make an ARC4 key from TKIP Sequence Counter Octets (little-endian) """ |
if keyID!=0 : |
raise 'TKIP expects keyID of zero' |
print "tscOctets in tkmixer=",b2a_p(tscOctets) |
newKey = self.keyMixer.newKey(tscOctets) |
print "newKey=", b2a_p(newKey) |
return newKey |
def encrypt(self, plainText, iv): |
""" Encrypt a string and return a binary string |
iv is 6 octets of little-endian encoded pn |
""" |
assert(len(iv)==6),'TKIP bad IV size on encryption' |
self.pnField = iv |
self.arc4.setKey( self._makeARC4key(iv) ) |
eh1 = chr((ord(iv[0])|0x20)&0x7f) |
encryptionHeader = iv[0] + eh1 + iv[1] + chr((self.keyId<<6)|0x20) + iv[2:] |
crc = pack('<I', crc32(plainText) ) |
cipherText = encryptionHeader + self.arc4.encrypt(plainText+crc) |
return cipherText |
def decrypt(self, cipherText): |
""" Decrypt a WEP packet, assumes WEP 4 byte header on packet """ |
assert(ord(cipherText[3])& 0x20),'extIV SHOULD be set in TKIP header' |
self.setCurrentKeyID = (ord(cipherText[3])&0xC0)>>6 |
iv = cipherText[0]+cipherText[2]+cipherText[4:8] |
self.pnField = iv |
self.arc4.setKey( self._makeARC4key(iv) ) |
plainText = self.arc4.decrypt(cipherText[self.encryptHeaderSize:]) |
if plainText[-4:] != pack('<I',crc32(plainText[:-4])): # check data integrity |
raise IntegrityCheckError, 'WEP CRC Integrity Check Error' |
return plainText[:-4] |
/relevation/ext/cryptopy-1.2.5.patched/crypto/cipher/aes_cbc.py |
---|
0,0 → 1,20 |
""" crypto.cipher.aes_cbc |
AES_CBC Encryption Algorithm |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
2002-06-14 |
""" |
from crypto.cipher.aes import AES |
from crypto.cipher.cbc import CBC |
from crypto.cipher.base import BlockCipher, padWithPadLen, noPadding |
class AES_CBC(CBC): |
""" AES encryption in CBC feedback mode """ |
def __init__(self, key=None, padding=padWithPadLen(), keySize=16): |
CBC.__init__( self, AES(key, noPadding(), keySize), padding) |
self.name = 'AES_CBC' |
/relevation/ext/cryptopy-1.2.5.patched/crypto/cipher/tkip_fake_crc_test.py |
---|
0,0 → 1,89 |
#! /usr/bin/env python |
""" crypto.cipher.tkip_fake_crc_test |
This module tests the creation of TKIP data that passes |
the WEP crc, but would fail the Michael MIC check. |
The IEEE TGi specification mandates a 60 second |
dissassociation of all sessions when two of these |
malicious packets are recieved in a 60 second period. |
Copyright © (c) 2003 by Paul A. Lambert. |
See LICENSE.txt for license terms of this software. |
""" |
import unittest |
from crypto.cipher.tkip_encr import TKIP_encr |
from crypto.common import xor |
from binascii_plus import * |
from zlib import crc32 |
from struct import pack, unpack |
class TKIP_tkip_fake_crc_test(unittest.TestCase): |
""" Create TKIP encrypted data, modifiy it and patch the crc32 """ |
def testTKIP_crc_modify(self): |
""" TKIP crc modification test """ |
key = a2b_p( "00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f" ) # the PMK |
ta = a2b_p( "10 22 33 44 55 66" ) # the TK (key) is created from the iv and ta |
keyID = 0 |
alg = TKIP_encr(key, ta, keyID) # this is just the encryption algorithm with no Michael MIC |
plainText = ''.join([chr(i) for i in range(20)]) # 20 octets (0 t 19) |
iv = a2b_p( "01 00 00 00 00 00" ) # the little-endian encoded PacketNumber |
cipherText = alg.encrypt(plainText, iv) |
ctHeader = cipherText[0:8] # encoded iv and keyId |
ctData = cipherText[8:-4] |
ctCrcEncrypted = cipherText[-4:] # just the encrypted crc fields |
# lets change the first octet of the data from 0x00 to 0x01 |
base = (len(ctData))*chr(0) |
baseCrc = crc32(base) |
bitMask = chr(1)+(len(ctData)-1)*chr(0) |
maskCrc = crc32(bitMask) |
maskedCt = xor(bitMask,ctData) |
maskedCtCrc = crc32(maskedCt) |
print "--------------- make a modified packet and MIC ------------" |
print "plainText = %s " % b2a_hex(plainText) |
print "cipherText= %s " % b2a_hex(cipherText) |
print "ctData = %s " % b2a_hex(ctData) |
print "ctxtCrc = %s " % b2a_hex(ctCrcEncrypted) |
print "base = %s " % b2a_hex(base) |
print "baseCrc = %0X" % baseCrc |
print "mask = %s " % b2a_hex(bitMask) |
print "maskCrc = %0X" % maskCrc |
print "maskedCt = %s " % b2a_hex(maskedCt) |
print "maskCtCrc= %0X" % maskedCtCrc |
maskDiff = maskCrc ^ baseCrc |
newCtCrc = pack('<I', (maskDiff ^ unpack('<I',ctCrcEncrypted)[0]) ) |
newCt = ctHeader + maskedCt + newCtCrc |
newPt = alg.decrypt(newCt) # this will raise an exception if the crc is 'bad'! |
print "newPt = %s " % b2a_hex(newPt) |
def test_TKIP_MIC_Analysis(self): |
""" Simple analysis of TKIP CRC attacks based on |
given Michael strength of 2^20 |
""" |
michaelStrength = 2.**20 # probability of MIC attack from N.F. |
secondsPerHour = 60.*60. |
secondsPerDay = 24.*secondsPerHour |
secondsPerYear = 365.*secondsPerDay |
attacksPerSecond = 1. |
attacksPerYear = attacksPerSecond * secondsPerYear |
print "\n\n---- Michael Attack Analysis w/wo Countermeasures ----" |
print "%s"%"Attacks Number Counter Mean" |
print "%s"%" per of Measure Success" |
print "%s"%"Second STAs Type Time" |
print "------------------------------------" |
print " 1 1 none %3d days" % (michaelStrength/secondsPerDay/attacksPerSecond) |
attacksPerSecond = 100 |
print " 100 1 none %3d hours" % (michaelStrength/secondsPerHour/attacksPerSecond) |
print " .016 1 60sec/session %3d year" % (michaelStrength/secondsPerYear/(1/60.)) |
print " 100/60 100 60sec/session %3d days" % (michaelStrength/secondsPerDay/(100./60.) ) |
print " 100 1 none %3d hours" % (michaelStrength/secondsPerHour/attacksPerSecond) |
if __name__ == '__main__': |
# Run the tests from the command line |
unittest.main() |
/relevation/ext/cryptopy-1.2.5.patched/crypto/cipher/test_all_ciphers.py |
---|
0,0 → 1,26 |
#! /usr/bin/env python |
""" crypto.cipher.test_all_ciphers |
All unit tests in the cipher package |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
""" |
import unittest |
import crypto.cipher.aes_cbc_test |
import crypto.cipher.aes_test |
import crypto.cipher.arc4_test |
import crypto.cipher.cbc_test |
import crypto.cipher.ccm_test |
import crypto.cipher.icedoll_test |
import crypto.cipher.rijndael_test |
import crypto.cipher.tkip_encr_test |
import crypto.cipher.tkip_fake_crc_test |
import crypto.cipher.wep_test |
# Make this test module runnable from the command prompt |
if __name__ == "__main__": |
unittest.main() |
/relevation/ext/cryptopy-1.2.5.patched/crypto/cipher/cbc_test.py |
---|
0,0 → 1,127 |
#! /usr/bin/env python |
""" crypto.cipher.cbc_test |
Tests for cbc encryption, uses AES for base algorithm |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
""" |
from crypto.cipher.cbc import CBC |
from crypto.cipher.aes import AES |
from crypto.cipher.rijndael import Rijndael |
from crypto.cipher.base import noPadding |
import unittest |
from binascii_plus import b2a_hex, a2b_p, b2a_p |
class CBC_AES128_TestVectors(unittest.TestCase): |
""" Test CBC with AES128 algorithm using know values """ |
def testKnowValues(self): |
""" Test using vectors from NIST cbc_e_m.txt""" |
def CBCtestVector(key,iv,pt,kct): |
""" CBC test vectors using AES algorithm """ |
key,iv,pt,kct = a2b_p(key),a2b_p(iv),a2b_p(pt),a2b_p(kct) |
alg = CBC(AES(key), padding=noPadding()) |
self.assertEqual( alg.encrypt(pt,iv=iv), kct ) |
self.assertEqual( alg.decrypt(iv+kct), pt ) |
# http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf page 34 |
CBCtestVector( key = '2b7e151628aed2a6abf7158809cf4f3c', |
iv = '000102030405060708090a0b0c0d0e0f', |
pt = '6bc1bee22e409f96e93d7e117393172a', |
kct = '7649abac8119b246cee98e9b12e9197d') |
# four blocks of data |
CBCtestVector( key = '2b7e151628aed2a6abf7158809cf4f3c', |
iv = '000102030405060708090a0b0c0d0e0f', |
pt = """6bc1bee22e409f96e93d7e117393172a |
ae2d8a571e03ac9c9eb76fac45af8e51 |
30c81c46a35ce411e5fbc1191a0a52ef |
f69f2445df4f9b17ad2b417be66c3710""", |
kct = """7649abac8119b246cee98e9b12e9197d |
5086cb9b507219ee95db113a917678b2 |
73bed6b8e3c1743b7116e69e22229516 |
3ff1caa1681fac09120eca307586e1a7""") |
class CBC_Rijndael_Test(unittest.TestCase): |
""" CBC test with Rijndael """ |
def testCBC_Rijndael_256(self): |
""" Rijndael CBC 256 """ |
key = '2b7e151628aed2a6abf7158809cf4f3c' |
iv = '000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f' |
pt = """6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e51 |
30c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710""" |
key,iv,pt = a2b_p(key),a2b_p(iv),a2b_p(pt) |
alg = CBC(Rijndael(key, blockSize=32)) |
ct = alg.encrypt(pt,iv=iv) |
self.assertEqual( alg.decrypt(iv+ct), pt ) |
def testCBC_Rijndael_variable_data(self): |
""" Rijndael CBC 256 """ |
key = '2b7e151628aed2a6abf7158809cf4f3c' |
iv = '000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f' |
key,iv = a2b_p(key),a2b_p(iv) |
alg = CBC(Rijndael(key, blockSize=32)) |
for i in range(100): |
pt = i*'a' |
ct = alg.encrypt(pt,iv=iv) |
self.assertEqual( alg.decrypt(iv+ct), pt ) |
class CBC_Auto_IV_Test(unittest.TestCase): |
""" CBC IV tests""" |
def testIVuniqueness(self): |
""" Test that two different instances have different IVs """ |
key = a2b_p('2b7e151628aed2a6abf7158809cf4f3c') |
pt = "This is a test case" |
alg1 = CBC(Rijndael(key, blockSize=32)) |
alg2 = CBC(Rijndael(key, blockSize=32)) |
ct1 = alg1.encrypt(pt) |
ct2 = alg2.encrypt(pt) |
self.assertNotEqual( ct1,ct2 ) |
def testIVmultencryptUnique(self): |
""" Test that two different encrypts have different IVs """ |
key = a2b_p('2b7e151628aed2a6abf7158809cf4f3c') |
pt = "This is yet another test case" |
alg1 = CBC(Rijndael(key, blockSize=32)) |
ct1 = alg1.encrypt(pt) |
ct2 = alg1.encrypt(pt) |
self.assertNotEqual( ct1, ct2 ) |
self.assertEqual( alg1.decrypt(ct1), pt ) |
self.assertEqual( alg1.decrypt(ct1), alg1.decrypt(ct2) ) |
class CBC_multipart_tests(unittest.TestCase): |
""" Test mulitple calls to encrypt/decrypt with moreData set """ |
def testMultipassEncrypt(self): |
""" Test moreData usage """ |
alg = CBC(Rijndael(16*chr(0), blockSize=32)) |
ct1 = '' |
for i in range(129): |
ct1 += alg.encrypt('a',more=1) |
ct1 += alg.encrypt('') # flush any remaining |
ct2 = alg.encrypt(129*'a') |
self.assertNotEqual( ct1, ct2 ) |
pt1 = alg.decrypt(ct1) |
pt2 = alg.decrypt(ct2) |
self.assertEqual(pt1,pt2) |
pt3 = alg.decrypt('',more=1) |
for i in range(len(ct2)): |
pt3 += alg.decrypt(ct2[i], more=1) |
pt3 += alg.decrypt('') |
class CBC_another_Simple_Test(unittest.TestCase): |
""" Test simple encrypt decrypt """ |
def test(self): |
aes_cbc = CBC(AES()) |
aes_cbc.setKey('aaaaaaaaaaaaaaaa') |
ct1 = aes_cbc.encrypt('test') |
ct2 = aes_cbc.encrypt('test') # note - auto iv, reslt is different ths time |
# text below from cli usage that failed :-( ... bad sized message |
#aes_cbc.decrypt('U+f)f\xfb\x96\xc8vu\xbb\xff7BJ}') |
# Make this test module runnable from the command prompt |
if __name__ == "__main__": |
unittest.main() |
/relevation/ext/cryptopy-1.2.5.patched/crypto/cipher/rijndael_test.py |
---|
0,0 → 1,164 |
#! /usr/bin/env python |
""" crypto.cipher.rijndael_test |
Tests for the rijndael encryption algorithm |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
""" |
from crypto.cipher.rijndael import Rijndael |
from crypto.cipher.base import noPadding |
from binascii import a2b_hex |
import unittest |
class Rijndael_TestVectors(unittest.TestCase): |
""" Test Rijndael algorithm using know values.""" |
def testGladman_dev_vec(self): |
""" All 25 combinations of block and key size. |
These test vectors were generated by Dr Brian Gladman |
using the program aes_vec.cpp <brg@gladman.uk.net> 24th May 2001. |
vectors in file: dev_vec.txt |
http://fp.gladman.plus.com/cryptography_technology/rijndael/index.htm |
""" |
def RijndaelTestVec(i, key, pt, ct): |
""" Run single AES test vector with any legal blockSize |
and any legal key size. """ |
bkey, plainText, cipherText = a2b_hex(key), a2b_hex(pt), a2b_hex(ct) |
kSize = len(bkey) |
bSize = len(cipherText) # set block size to length of block |
alg = Rijndael(bkey, keySize=kSize, blockSize=bSize, padding=noPadding()) |
self.assertEqual( alg.encrypt(plainText), cipherText ) |
self.assertEqual( alg.decrypt(cipherText), plainText ) |
RijndaelTestVec( i = 'dev_vec.txt 16 byte block, 16 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c', |
pt = '3243f6a8885a308d313198a2e0370734', |
ct = '3925841d02dc09fbdc118597196a0b32') |
RijndaelTestVec( i = 'dev_vec.txt 16 byte block, 20 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c762e7160', |
pt = '3243f6a8885a308d313198a2e0370734', |
ct = '231d844639b31b412211cfe93712b880') |
RijndaelTestVec( i = 'dev_vec.txt 16 byte block, 24 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da5', |
pt = '3243f6a8885a308d313198a2e0370734', |
ct = 'f9fb29aefc384a250340d833b87ebc00') |
RijndaelTestVec( i = 'dev_vec.txt 16 byte block, 28 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a784d90', |
pt = '3243f6a8885a308d313198a2e0370734', |
ct = '8faa8fe4dee9eb17caa4797502fc9d3f') |
RijndaelTestVec( i = 'dev_vec.txt 16 byte block, 32 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a784d9045190cfe', |
pt = '3243f6a8885a308d313198a2e0370734', |
ct = '1a6e6c2c662e7da6501ffb62bc9e93f3') |
RijndaelTestVec( i = 'dev_vec.txt 20 byte block, 16 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c', |
pt = '3243f6a8885a308d313198a2e03707344a409382', |
ct = '16e73aec921314c29df905432bc8968ab64b1f51') |
RijndaelTestVec( i = 'dev_vec.txt 20 byte block, 20 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c762e7160', |
pt = '3243f6a8885a308d313198a2e03707344a409382', |
ct = '0553eb691670dd8a5a5b5addf1aa7450f7a0e587') |
RijndaelTestVec( i = 'dev_vec.txt 20 byte block, 24 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da5', |
pt = '3243f6a8885a308d313198a2e03707344a409382', |
ct = '73cd6f3423036790463aa9e19cfcde894ea16623') |
RijndaelTestVec( i = 'dev_vec.txt 20 byte block, 28 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a784d90', |
pt = '3243f6a8885a308d313198a2e03707344a409382', |
ct = '601b5dcd1cf4ece954c740445340bf0afdc048df') |
RijndaelTestVec( i = 'dev_vec.txt 20 byte block, 32 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a784d9045190cfe', |
pt = '3243f6a8885a308d313198a2e03707344a409382', |
ct = '579e930b36c1529aa3e86628bacfe146942882cf') |
RijndaelTestVec( i = 'dev_vec.txt 24 byte block, 16 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c', |
pt = '3243f6a8885a308d313198a2e03707344a4093822299f31d', |
ct = 'b24d275489e82bb8f7375e0d5fcdb1f481757c538b65148a') |
RijndaelTestVec( i = 'dev_vec.txt 24 byte block, 20 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c762e7160', |
pt = '3243f6a8885a308d313198a2e03707344a4093822299f31d', |
ct = '738dae25620d3d3beff4a037a04290d73eb33521a63ea568') |
RijndaelTestVec( i = 'dev_vec.txt 24 byte block, 24 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da5', |
pt = '3243f6a8885a308d313198a2e03707344a4093822299f31d', |
ct = '725ae43b5f3161de806a7c93e0bca93c967ec1ae1b71e1cf') |
RijndaelTestVec( i = 'dev_vec.txt 24 byte block, 28 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a784d90', |
pt = '3243f6a8885a308d313198a2e03707344a4093822299f31d', |
ct = 'bbfc14180afbf6a36382a061843f0b63e769acdc98769130') |
RijndaelTestVec( i = 'dev_vec.txt 24 byte block, 32 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a784d9045190cfe', |
pt = '3243f6a8885a308d313198a2e03707344a4093822299f31d', |
ct = '0ebacf199e3315c2e34b24fcc7c46ef4388aa475d66c194c') |
RijndaelTestVec( i = 'dev_vec.txt 28 byte block, 16 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c', |
pt = '3243f6a8885a308d313198a2e03707344a4093822299f31d0082efa9', |
ct = 'b0a8f78f6b3c66213f792ffd2a61631f79331407a5e5c8d3793aceb1') |
RijndaelTestVec( i = 'dev_vec.txt 28 byte block, 20 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c762e7160', |
pt = '3243f6a8885a308d313198a2e03707344a4093822299f31d0082efa9', |
ct = '08b99944edfce33a2acb131183ab0168446b2d15e958480010f545e3') |
RijndaelTestVec( i = 'dev_vec.txt 28 byte block, 24 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da5', |
pt = '3243f6a8885a308d313198a2e03707344a4093822299f31d0082efa9', |
ct = 'be4c597d8f7efe22a2f7e5b1938e2564d452a5bfe72399c7af1101e2') |
RijndaelTestVec( i = 'dev_vec.txt 28 byte block, 28 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a784d90', |
pt = '3243f6a8885a308d313198a2e03707344a4093822299f31d0082efa9', |
ct = 'ef529598ecbce297811b49bbed2c33bbe1241d6e1a833dbe119569e8') |
RijndaelTestVec( i = 'dev_vec.txt 28 byte block, 32 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a784d9045190cfe', |
pt = '3243f6a8885a308d313198a2e03707344a4093822299f31d0082efa9', |
ct = '02fafc200176ed05deb8edb82a3555b0b10d47a388dfd59cab2f6c11') |
RijndaelTestVec( i = 'dev_vec.txt 32 byte block, 16 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c', |
pt = '3243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c8', |
ct = '7d15479076b69a46ffb3b3beae97ad8313f622f67fedb487de9f06b9ed9c8f19') |
RijndaelTestVec( i = 'dev_vec.txt 32 byte block, 20 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c762e7160', |
pt = '3243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c8', |
ct = '514f93fb296b5ad16aa7df8b577abcbd484decacccc7fb1f18dc567309ceeffd') |
RijndaelTestVec( i = 'dev_vec.txt 32 byte block, 24 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da5', |
pt = '3243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c8', |
ct = '5d7101727bb25781bf6715b0e6955282b9610e23a43c2eb062699f0ebf5887b2') |
RijndaelTestVec( i = 'dev_vec.txt 32 byte block, 28 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a784d90', |
pt = '3243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c8', |
ct = 'd56c5a63627432579e1dd308b2c8f157b40a4bfb56fea1377b25d3ed3d6dbf80') |
RijndaelTestVec( i = 'dev_vec.txt 32 byte block, 32 byte key', |
key = '2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a784d9045190cfe', |
pt = '3243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c8', |
ct = 'a49406115dfb30a40418aafa4869b7c6a886ff31602a7dd19c889dc64f7e4e7a') |
# Make this test module runnable from the command prompt |
if __name__ == "__main__": |
unittest.main() |
/relevation/ext/cryptopy-1.2.5.patched/crypto/cipher/cbc.py |
---|
0,0 → 1,109 |
""" crypto.cipher.cbc |
CBC mode of encryption for block ciphers. |
This algorithm mode wraps any BlockCipher to make a |
Cipher Block Chaining mode. |
Note !!!! auto IV uses python default random :-( |
should not be 'too bad' (tm) for this cbc applicaiton |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
""" |
from crypto.cipher.base import BlockCipher, padWithPadLen, noPadding |
from crypto.errors import EncryptError |
from crypto.common import xor |
from random import Random # should change to crypto.random!!! |
class CBC(BlockCipher): |
""" The CBC class wraps block ciphers to make cipher block chaining (CBC) mode |
algorithms. The initialization (IV) is automatic if set to None. Padding |
is also automatic based on the Pad class used to initialize the algorithm |
""" |
def __init__(self, blockCipherInstance, padding = padWithPadLen()): |
""" CBC algorithms are created by initializing with a BlockCipher instance """ |
self.baseCipher = blockCipherInstance |
self.name = self.baseCipher.name + '_CBC' |
self.blockSize = self.baseCipher.blockSize |
self.keySize = self.baseCipher.keySize |
self.padding = padding |
self.baseCipher.padding = noPadding() # baseCipher should NOT pad!! |
self.r = Random() # for IV generation, currently uses |
# mediocre standard distro version <---------------- |
import time |
newSeed = time.ctime()+str(self.r) # seed with instance location |
self.r.seed(newSeed) # to make unique |
self.reset() |
def setKey(self, key): |
self.baseCipher.setKey(key) |
# Overload to reset both CBC state and the wrapped baseCipher |
def resetEncrypt(self): |
BlockCipher.resetEncrypt(self) # reset CBC encrypt state (super class) |
self.baseCipher.resetEncrypt() # reset base cipher encrypt state |
def resetDecrypt(self): |
BlockCipher.resetDecrypt(self) # reset CBC state (super class) |
self.baseCipher.resetDecrypt() # reset base cipher decrypt state |
def encrypt(self, plainText, iv=None, more=None): |
""" CBC encryption - overloads baseCipher to allow optional explicit IV |
when iv=None, iv is auto generated! |
""" |
if self.encryptBlockCount == 0: |
self.iv = iv |
else: |
assert(iv==None), 'IV used only on first call to encrypt' |
return BlockCipher.encrypt(self,plainText, more=more) |
def decrypt(self, cipherText, iv=None, more=None): |
""" CBC decryption - overloads baseCipher to allow optional explicit IV |
when iv=None, iv is auto generated! |
""" |
if self.decryptBlockCount == 0: |
self.iv = iv |
else: |
assert(iv==None), 'IV used only on first call to decrypt' |
return BlockCipher.decrypt(self, cipherText, more=more) |
def encryptBlock(self, plainTextBlock): |
""" CBC block encryption, IV is set with 'encrypt' """ |
auto_IV = '' |
if self.encryptBlockCount == 0: |
if self.iv == None: |
# generate IV and use |
self.iv = ''.join([chr(self.r.randrange(256)) for i in range(self.blockSize)]) |
self.prior_encr_CT_block = self.iv |
auto_IV = self.prior_encr_CT_block # prepend IV if it's automatic |
else: # application provided IV |
assert(len(self.iv) == self.blockSize ),'IV must be same length as block' |
self.prior_encr_CT_block = self.iv |
""" encrypt the prior CT XORed with the PT """ |
ct = self.baseCipher.encryptBlock( xor(self.prior_encr_CT_block, plainTextBlock) ) |
self.prior_encr_CT_block = ct |
return auto_IV+ct |
def decryptBlock(self, encryptedBlock): |
""" Decrypt a single block """ |
if self.decryptBlockCount == 0: # first call, process IV |
if self.iv == None: # auto decrypt IV? |
self.prior_CT_block = encryptedBlock |
return '' |
else: |
assert(len(self.iv)==self.blockSize),"Bad IV size on CBC decryption" |
self.prior_CT_block = self.iv |
dct = self.baseCipher.decryptBlock(encryptedBlock) |
""" XOR the prior decrypted CT with the prior CT """ |
dct_XOR_priorCT = xor( self.prior_CT_block, dct ) |
self.prior_CT_block = encryptedBlock |
return dct_XOR_priorCT |
/relevation/ext/cryptopy-1.2.5.patched/crypto/cipher/arc4_test.py |
---|
0,0 → 1,140 |
#! /usr/bin/env python |
""" crypto.cipher.arc4_test |
Tests for arc4 encryption, uses AES for base algorithm |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
July 24, 2002 |
""" |
import unittest |
from crypto.cipher.arc4 import ARC4 |
from binascii_plus import b2a_p |
class ARC4_TestVectors(unittest.TestCase): |
""" Test ARC4 algorithm using know values """ |
def testKnowValues(self): |
""" Test using vectors from...""" |
def ARC4testVector(testCase,plainText,key,cipherText): |
""" Process ARC4 test vectors from RFCxxxx""" |
print '%s %s %s'%('='*((54-len(testCase))/2),testCase,'='*((54-len(testCase))/2)) |
# Convert from octet lists to string |
pt = ''.join([chr(i) for i in plainText]) |
key = ''.join([chr(i) for i in key]) |
kct = ''.join([chr(i) for i in cipherText]) |
alg = ARC4(key) |
print 'key: %s'%b2a_p(key)[9:] |
print 'pt: %s'%b2a_p(pt)[9:] |
ct = alg.encrypt(pt) |
print 'ct: %s'%b2a_p(ct)[9:] |
print 'kct: %s'%b2a_p(kct)[9:] |
print '========================================================' |
self.assertEqual( ct, kct ) |
alg.setKey(key) |
dct = alg.decrypt( ct ) |
self.assertEqual( dct, pt ) |
ARC4testVector( |
testCase = "Test Vectors from [CRYPTLIB]", |
plainText = (0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), |
key = (0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF), |
cipherText = (0x74, 0x94, 0xC2, 0xE7, 0x10, 0x4B, 0x08, 0x79)) |
ARC4testVector( |
testCase = "Test Vectors from [COMMERCE]", |
plainText = (0xdc, 0xee, 0x4c, 0xf9, 0x2c), |
key = (0x61, 0x8a, 0x63, 0xd2, 0xfb), |
cipherText = (0xf1, 0x38, 0x29, 0xc9, 0xde)) |
ARC4testVector( |
testCase = "Test Vectors from [SSH ARCFOUR]", |
plainText = (0x52, 0x75, 0x69, 0x73, 0x6c, 0x69, 0x6e, 0x6e, |
0x75, 0x6e, 0x20, 0x6c, 0x61, 0x75, 0x6c, 0x75, |
0x20, 0x6b, 0x6f, 0x72, 0x76, 0x69, 0x73, 0x73, |
0x73, 0x61, 0x6e, 0x69, 0x2c, 0x20, 0x74, 0xe4, |
0x68, 0x6b, 0xe4, 0x70, 0xe4, 0x69, 0x64, 0x65, |
0x6e, 0x20, 0x70, 0xe4, 0xe4, 0x6c, 0x6c, 0xe4, |
0x20, 0x74, 0xe4, 0x79, 0x73, 0x69, 0x6b, 0x75, |
0x75, 0x2e, 0x20, 0x4b, 0x65, 0x73, 0xe4, 0x79, |
0xf6, 0x6e, 0x20, 0x6f, 0x6e, 0x20, 0x6f, 0x6e, |
0x6e, 0x69, 0x20, 0x6f, 0x6d, 0x61, 0x6e, 0x61, |
0x6e, 0x69, 0x2c, 0x20, 0x6b, 0x61, 0x73, 0x6b, |
0x69, 0x73, 0x61, 0x76, 0x75, 0x75, 0x6e, 0x20, |
0x6c, 0x61, 0x61, 0x6b, 0x73, 0x6f, 0x74, 0x20, |
0x76, 0x65, 0x72, 0x68, 0x6f, 0x75, 0x75, 0x2e, |
0x20, 0x45, 0x6e, 0x20, 0x6d, 0x61, 0x20, 0x69, |
0x6c, 0x6f, 0x69, 0x74, 0x73, 0x65, 0x2c, 0x20, |
0x73, 0x75, 0x72, 0x65, 0x20, 0x68, 0x75, 0x6f, |
0x6b, 0x61, 0x61, 0x2c, 0x20, 0x6d, 0x75, 0x74, |
0x74, 0x61, 0x20, 0x6d, 0x65, 0x74, 0x73, 0xe4, |
0x6e, 0x20, 0x74, 0x75, 0x6d, 0x6d, 0x75, 0x75, |
0x73, 0x20, 0x6d, 0x75, 0x6c, 0x6c, 0x65, 0x20, |
0x74, 0x75, 0x6f, 0x6b, 0x61, 0x61, 0x2e, 0x20, |
0x50, 0x75, 0x75, 0x6e, 0x74, 0x6f, 0x20, 0x70, |
0x69, 0x6c, 0x76, 0x65, 0x6e, 0x2c, 0x20, 0x6d, |
0x69, 0x20, 0x68, 0x75, 0x6b, 0x6b, 0x75, 0x75, |
0x2c, 0x20, 0x73, 0x69, 0x69, 0x6e, 0x74, 0x6f, |
0x20, 0x76, 0x61, 0x72, 0x61, 0x6e, 0x20, 0x74, |
0x75, 0x75, 0x6c, 0x69, 0x73, 0x65, 0x6e, 0x2c, |
0x20, 0x6d, 0x69, 0x20, 0x6e, 0x75, 0x6b, 0x6b, |
0x75, 0x75, 0x2e, 0x20, 0x54, 0x75, 0x6f, 0x6b, |
0x73, 0x75, 0x74, 0x20, 0x76, 0x61, 0x6e, 0x61, |
0x6d, 0x6f, 0x6e, 0x20, 0x6a, 0x61, 0x20, 0x76, |
0x61, 0x72, 0x6a, 0x6f, 0x74, 0x20, 0x76, 0x65, |
0x65, 0x6e, 0x2c, 0x20, 0x6e, 0x69, 0x69, 0x73, |
0x74, 0xe4, 0x20, 0x73, 0x79, 0x64, 0xe4, 0x6d, |
0x65, 0x6e, 0x69, 0x20, 0x6c, 0x61, 0x75, 0x6c, |
0x75, 0x6e, 0x20, 0x74, 0x65, 0x65, 0x6e, 0x2e, |
0x20, 0x2d, 0x20, 0x45, 0x69, 0x6e, 0x6f, 0x20, |
0x4c, 0x65, 0x69, 0x6e, 0x6f), |
key = (0x29, 0x04, 0x19, 0x72, 0xfb, 0x42, 0xba, 0x5f, |
0xc7, 0x12, 0x77, 0x12, 0xf1, 0x38, 0x29, 0xc9), |
cipherText = (0x35, 0x81, 0x86, 0x99, 0x90, 0x01, 0xe6, 0xb5, |
0xda, 0xf0, 0x5e, 0xce, 0xeb, 0x7e, 0xee, 0x21, |
0xe0, 0x68, 0x9c, 0x1f, 0x00, 0xee, 0xa8, 0x1f, |
0x7d, 0xd2, 0xca, 0xae, 0xe1, 0xd2, 0x76, 0x3e, |
0x68, 0xaf, 0x0e, 0xad, 0x33, 0xd6, 0x6c, 0x26, |
0x8b, 0xc9, 0x46, 0xc4, 0x84, 0xfb, 0xe9, 0x4c, |
0x5f, 0x5e, 0x0b, 0x86, 0xa5, 0x92, 0x79, 0xe4, |
0xf8, 0x24, 0xe7, 0xa6, 0x40, 0xbd, 0x22, 0x32, |
0x10, 0xb0, 0xa6, 0x11, 0x60, 0xb7, 0xbc, 0xe9, |
0x86, 0xea, 0x65, 0x68, 0x80, 0x03, 0x59, 0x6b, |
0x63, 0x0a, 0x6b, 0x90, 0xf8, 0xe0, 0xca, 0xf6, |
0x91, 0x2a, 0x98, 0xeb, 0x87, 0x21, 0x76, 0xe8, |
0x3c, 0x20, 0x2c, 0xaa, 0x64, 0x16, 0x6d, 0x2c, |
0xce, 0x57, 0xff, 0x1b, 0xca, 0x57, 0xb2, 0x13, |
0xf0, 0xed, 0x1a, 0xa7, 0x2f, 0xb8, 0xea, 0x52, |
0xb0, 0xbe, 0x01, 0xcd, 0x1e, 0x41, 0x28, 0x67, |
0x72, 0x0b, 0x32, 0x6e, 0xb3, 0x89, 0xd0, 0x11, |
0xbd, 0x70, 0xd8, 0xaf, 0x03, 0x5f, 0xb0, 0xd8, |
0x58, 0x9d, 0xbc, 0xe3, 0xc6, 0x66, 0xf5, 0xea, |
0x8d, 0x4c, 0x79, 0x54, 0xc5, 0x0c, 0x3f, 0x34, |
0x0b, 0x04, 0x67, 0xf8, 0x1b, 0x42, 0x59, 0x61, |
0xc1, 0x18, 0x43, 0x07, 0x4d, 0xf6, 0x20, 0xf2, |
0x08, 0x40, 0x4b, 0x39, 0x4c, 0xf9, 0xd3, 0x7f, |
0xf5, 0x4b, 0x5f, 0x1a, 0xd8, 0xf6, 0xea, 0x7d, |
0xa3, 0xc5, 0x61, 0xdf, 0xa7, 0x28, 0x1f, 0x96, |
0x44, 0x63, 0xd2, 0xcc, 0x35, 0xa4, 0xd1, 0xb0, |
0x34, 0x90, 0xde, 0xc5, 0x1b, 0x07, 0x11, 0xfb, |
0xd6, 0xf5, 0x5f, 0x79, 0x23, 0x4d, 0x5b, 0x7c, |
0x76, 0x66, 0x22, 0xa6, 0x6d, 0xe9, 0x2b, 0xe9, |
0x96, 0x46, 0x1d, 0x5e, 0x4d, 0xc8, 0x78, 0xef, |
0x9b, 0xca, 0x03, 0x05, 0x21, 0xe8, 0x35, 0x1e, |
0x4b, 0xae, 0xd2, 0xfd, 0x04, 0xf9, 0x46, 0x73, |
0x68, 0xc4, 0xad, 0x6a, 0xc1, 0x86, 0xd0, 0x82, |
0x45, 0xb2, 0x63, 0xa2, 0x66, 0x6d, 0x1f, 0x6c, |
0x54, 0x20, 0xf1, 0x59, 0x9d, 0xfd, 0x9f, 0x43, |
0x89, 0x21, 0xc2, 0xf5, 0xa4, 0x63, 0x93, 0x8c, |
0xe0, 0x98, 0x22, 0x65, 0xee, 0xf7, 0x01, 0x79, |
0xbc, 0x55, 0x3f, 0x33, 0x9e, 0xb1, 0xa4, 0xc1, |
0xaf, 0x5f, 0x6a, 0x54, 0x7f)) |
# Make this test module runnable from the command prompt |
if __name__ == "__main__": |
unittest.main() |
/relevation/ext/cryptopy-1.2.5.patched/crypto/cipher/rijndael.py |
---|
0,0 → 1,288 |
""" crypto.cipher.rijndael |
Rijndael encryption algorithm |
This byte oriented implementation is intended to closely |
match FIPS specification for readability. It is not implemented |
for performance. |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
2002-06-01 |
""" |
from crypto.cipher.base import BlockCipher, padWithPadLen, noPadding |
class Rijndael(BlockCipher): |
""" Rijndael encryption algorithm """ |
def __init__(self, key = None, padding = padWithPadLen(), keySize=16, blockSize=16 ): |
self.name = 'RIJNDAEL' |
self.keySize = keySize |
self.strength = keySize*8 |
self.blockSize = blockSize # blockSize is in bytes |
self.padding = padding # change default to noPadding() to get normal ECB behavior |
assert( keySize%4==0 and NrTable[4].has_key(keySize/4)),'key size must be 16,20,24,29 or 32 bytes' |
assert( blockSize%4==0 and NrTable.has_key(blockSize/4)), 'block size must be 16,20,24,29 or 32 bytes' |
self.Nb = self.blockSize/4 # Nb is number of columns of 32 bit words |
self.Nk = keySize/4 # Nk is the key length in 32-bit words |
self.Nr = NrTable[self.Nb][self.Nk] # The number of rounds (Nr) is a function of |
# the block (Nb) and key (Nk) sizes. |
if key != None: |
self.setKey(key) |
def setKey(self, key): |
""" Set a key and generate the expanded key """ |
assert( len(key) == (self.Nk*4) ), 'Key length must be same as keySize parameter' |
self.__expandedKey = keyExpansion(self, key) |
self.reset() # BlockCipher.reset() |
def encryptBlock(self, plainTextBlock): |
""" Encrypt a block, plainTextBlock must be a array of bytes [Nb by 4] """ |
self.state = self._toBlock(plainTextBlock) |
AddRoundKey(self, self.__expandedKey[0:self.Nb]) |
for round in range(1,self.Nr): #for round = 1 step 1 to Nr1 |
SubBytes(self) |
ShiftRows(self) |
MixColumns(self) |
AddRoundKey(self, self.__expandedKey[round*self.Nb:(round+1)*self.Nb]) |
SubBytes(self) |
ShiftRows(self) |
AddRoundKey(self, self.__expandedKey[self.Nr*self.Nb:(self.Nr+1)*self.Nb]) |
return self._toBString(self.state) |
def decryptBlock(self, encryptedBlock): |
""" decrypt a block (array of bytes) """ |
self.state = self._toBlock(encryptedBlock) |
AddRoundKey(self, self.__expandedKey[self.Nr*self.Nb:(self.Nr+1)*self.Nb]) |
for round in range(self.Nr-1,0,-1): |
InvShiftRows(self) |
InvSubBytes(self) |
AddRoundKey(self, self.__expandedKey[round*self.Nb:(round+1)*self.Nb]) |
InvMixColumns(self) |
InvShiftRows(self) |
InvSubBytes(self) |
AddRoundKey(self, self.__expandedKey[0:self.Nb]) |
return self._toBString(self.state) |
def _toBlock(self, bs): |
""" Convert binary string to array of bytes, state[col][row]""" |
assert ( len(bs) == 4*self.Nb ), 'Rijndarl blocks must be of size blockSize' |
return [[ord(bs[4*i]),ord(bs[4*i+1]),ord(bs[4*i+2]),ord(bs[4*i+3])] for i in range(self.Nb)] |
def _toBString(self, block): |
""" Convert block (array of bytes) to binary string """ |
l = [] |
for col in block: |
for rowElement in col: |
l.append(chr(rowElement)) |
return ''.join(l) |
#------------------------------------- |
""" Number of rounds Nr = NrTable[Nb][Nk] |
Nb Nk=4 Nk=5 Nk=6 Nk=7 Nk=8 |
------------------------------------- """ |
NrTable = {4: {4:10, 5:11, 6:12, 7:13, 8:14}, |
5: {4:11, 5:11, 6:12, 7:13, 8:14}, |
6: {4:12, 5:12, 6:12, 7:13, 8:14}, |
7: {4:13, 5:13, 6:13, 7:13, 8:14}, |
8: {4:14, 5:14, 6:14, 7:14, 8:14}} |
#------------------------------------- |
def keyExpansion(algInstance, keyString): |
""" Expand a string of size keySize into a larger array """ |
Nk, Nb, Nr = algInstance.Nk, algInstance.Nb, algInstance.Nr # for readability |
key = [ord(byte) for byte in keyString] # convert string to list |
w = [[key[4*i],key[4*i+1],key[4*i+2],key[4*i+3]] for i in range(Nk)] |
for i in range(Nk,Nb*(Nr+1)): |
temp = w[i-1] # a four byte column |
if (i%Nk) == 0 : |
temp = temp[1:]+[temp[0]] # RotWord(temp) |
temp = [ Sbox[byte] for byte in temp ] |
temp[0] ^= Rcon[i/Nk] |
elif Nk > 6 and i%Nk == 4 : |
temp = [ Sbox[byte] for byte in temp ] # SubWord(temp) |
w.append( [ w[i-Nk][byte]^temp[byte] for byte in range(4) ] ) |
return w |
Rcon = (0,0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x1b,0x36, # note extra '0' !!! |
0x6c,0xd8,0xab,0x4d,0x9a,0x2f,0x5e,0xbc,0x63,0xc6, |
0x97,0x35,0x6a,0xd4,0xb3,0x7d,0xfa,0xef,0xc5,0x91) |
#------------------------------------- |
def AddRoundKey(algInstance, keyBlock): |
""" XOR the algorithm state with a block of key material """ |
for column in range(algInstance.Nb): |
for row in range(4): |
algInstance.state[column][row] ^= keyBlock[column][row] |
#------------------------------------- |
def SubBytes(algInstance): |
for column in range(algInstance.Nb): |
for row in range(4): |
algInstance.state[column][row] = Sbox[algInstance.state[column][row]] |
def InvSubBytes(algInstance): |
for column in range(algInstance.Nb): |
for row in range(4): |
algInstance.state[column][row] = InvSbox[algInstance.state[column][row]] |
Sbox = (0x63,0x7c,0x77,0x7b,0xf2,0x6b,0x6f,0xc5, |
0x30,0x01,0x67,0x2b,0xfe,0xd7,0xab,0x76, |
0xca,0x82,0xc9,0x7d,0xfa,0x59,0x47,0xf0, |
0xad,0xd4,0xa2,0xaf,0x9c,0xa4,0x72,0xc0, |
0xb7,0xfd,0x93,0x26,0x36,0x3f,0xf7,0xcc, |
0x34,0xa5,0xe5,0xf1,0x71,0xd8,0x31,0x15, |
0x04,0xc7,0x23,0xc3,0x18,0x96,0x05,0x9a, |
0x07,0x12,0x80,0xe2,0xeb,0x27,0xb2,0x75, |
0x09,0x83,0x2c,0x1a,0x1b,0x6e,0x5a,0xa0, |
0x52,0x3b,0xd6,0xb3,0x29,0xe3,0x2f,0x84, |
0x53,0xd1,0x00,0xed,0x20,0xfc,0xb1,0x5b, |
0x6a,0xcb,0xbe,0x39,0x4a,0x4c,0x58,0xcf, |
0xd0,0xef,0xaa,0xfb,0x43,0x4d,0x33,0x85, |
0x45,0xf9,0x02,0x7f,0x50,0x3c,0x9f,0xa8, |
0x51,0xa3,0x40,0x8f,0x92,0x9d,0x38,0xf5, |
0xbc,0xb6,0xda,0x21,0x10,0xff,0xf3,0xd2, |
0xcd,0x0c,0x13,0xec,0x5f,0x97,0x44,0x17, |
0xc4,0xa7,0x7e,0x3d,0x64,0x5d,0x19,0x73, |
0x60,0x81,0x4f,0xdc,0x22,0x2a,0x90,0x88, |
0x46,0xee,0xb8,0x14,0xde,0x5e,0x0b,0xdb, |
0xe0,0x32,0x3a,0x0a,0x49,0x06,0x24,0x5c, |
0xc2,0xd3,0xac,0x62,0x91,0x95,0xe4,0x79, |
0xe7,0xc8,0x37,0x6d,0x8d,0xd5,0x4e,0xa9, |
0x6c,0x56,0xf4,0xea,0x65,0x7a,0xae,0x08, |
0xba,0x78,0x25,0x2e,0x1c,0xa6,0xb4,0xc6, |
0xe8,0xdd,0x74,0x1f,0x4b,0xbd,0x8b,0x8a, |
0x70,0x3e,0xb5,0x66,0x48,0x03,0xf6,0x0e, |
0x61,0x35,0x57,0xb9,0x86,0xc1,0x1d,0x9e, |
0xe1,0xf8,0x98,0x11,0x69,0xd9,0x8e,0x94, |
0x9b,0x1e,0x87,0xe9,0xce,0x55,0x28,0xdf, |
0x8c,0xa1,0x89,0x0d,0xbf,0xe6,0x42,0x68, |
0x41,0x99,0x2d,0x0f,0xb0,0x54,0xbb,0x16) |
InvSbox = (0x52,0x09,0x6a,0xd5,0x30,0x36,0xa5,0x38, |
0xbf,0x40,0xa3,0x9e,0x81,0xf3,0xd7,0xfb, |
0x7c,0xe3,0x39,0x82,0x9b,0x2f,0xff,0x87, |
0x34,0x8e,0x43,0x44,0xc4,0xde,0xe9,0xcb, |
0x54,0x7b,0x94,0x32,0xa6,0xc2,0x23,0x3d, |
0xee,0x4c,0x95,0x0b,0x42,0xfa,0xc3,0x4e, |
0x08,0x2e,0xa1,0x66,0x28,0xd9,0x24,0xb2, |
0x76,0x5b,0xa2,0x49,0x6d,0x8b,0xd1,0x25, |
0x72,0xf8,0xf6,0x64,0x86,0x68,0x98,0x16, |
0xd4,0xa4,0x5c,0xcc,0x5d,0x65,0xb6,0x92, |
0x6c,0x70,0x48,0x50,0xfd,0xed,0xb9,0xda, |
0x5e,0x15,0x46,0x57,0xa7,0x8d,0x9d,0x84, |
0x90,0xd8,0xab,0x00,0x8c,0xbc,0xd3,0x0a, |
0xf7,0xe4,0x58,0x05,0xb8,0xb3,0x45,0x06, |
0xd0,0x2c,0x1e,0x8f,0xca,0x3f,0x0f,0x02, |
0xc1,0xaf,0xbd,0x03,0x01,0x13,0x8a,0x6b, |
0x3a,0x91,0x11,0x41,0x4f,0x67,0xdc,0xea, |
0x97,0xf2,0xcf,0xce,0xf0,0xb4,0xe6,0x73, |
0x96,0xac,0x74,0x22,0xe7,0xad,0x35,0x85, |
0xe2,0xf9,0x37,0xe8,0x1c,0x75,0xdf,0x6e, |
0x47,0xf1,0x1a,0x71,0x1d,0x29,0xc5,0x89, |
0x6f,0xb7,0x62,0x0e,0xaa,0x18,0xbe,0x1b, |
0xfc,0x56,0x3e,0x4b,0xc6,0xd2,0x79,0x20, |
0x9a,0xdb,0xc0,0xfe,0x78,0xcd,0x5a,0xf4, |
0x1f,0xdd,0xa8,0x33,0x88,0x07,0xc7,0x31, |
0xb1,0x12,0x10,0x59,0x27,0x80,0xec,0x5f, |
0x60,0x51,0x7f,0xa9,0x19,0xb5,0x4a,0x0d, |
0x2d,0xe5,0x7a,0x9f,0x93,0xc9,0x9c,0xef, |
0xa0,0xe0,0x3b,0x4d,0xae,0x2a,0xf5,0xb0, |
0xc8,0xeb,0xbb,0x3c,0x83,0x53,0x99,0x61, |
0x17,0x2b,0x04,0x7e,0xba,0x77,0xd6,0x26, |
0xe1,0x69,0x14,0x63,0x55,0x21,0x0c,0x7d) |
#------------------------------------- |
""" For each block size (Nb), the ShiftRow operation shifts row i |
by the amount Ci. Note that row 0 is not shifted. |
Nb C1 C2 C3 |
------------------- """ |
shiftOffset = { 4 : ( 0, 1, 2, 3), |
5 : ( 0, 1, 2, 3), |
6 : ( 0, 1, 2, 3), |
7 : ( 0, 1, 2, 4), |
8 : ( 0, 1, 3, 4) } |
def ShiftRows(algInstance): |
tmp = [0]*algInstance.Nb # list of size Nb |
for r in range(1,4): # row 0 reamains unchanged and can be skipped |
for c in range(algInstance.Nb): |
tmp[c] = algInstance.state[(c+shiftOffset[algInstance.Nb][r]) % algInstance.Nb][r] |
for c in range(algInstance.Nb): |
algInstance.state[c][r] = tmp[c] |
def InvShiftRows(algInstance): |
tmp = [0]*algInstance.Nb # list of size Nb |
for r in range(1,4): # row 0 reamains unchanged and can be skipped |
for c in range(algInstance.Nb): |
tmp[c] = algInstance.state[(c+algInstance.Nb-shiftOffset[algInstance.Nb][r]) % algInstance.Nb][r] |
for c in range(algInstance.Nb): |
algInstance.state[c][r] = tmp[c] |
#------------------------------------- |
def MixColumns(a): |
Sprime = [0,0,0,0] |
for j in range(a.Nb): # for each column |
Sprime[0] = mul(2,a.state[j][0])^mul(3,a.state[j][1])^mul(1,a.state[j][2])^mul(1,a.state[j][3]) |
Sprime[1] = mul(1,a.state[j][0])^mul(2,a.state[j][1])^mul(3,a.state[j][2])^mul(1,a.state[j][3]) |
Sprime[2] = mul(1,a.state[j][0])^mul(1,a.state[j][1])^mul(2,a.state[j][2])^mul(3,a.state[j][3]) |
Sprime[3] = mul(3,a.state[j][0])^mul(1,a.state[j][1])^mul(1,a.state[j][2])^mul(2,a.state[j][3]) |
for i in range(4): |
a.state[j][i] = Sprime[i] |
def InvMixColumns(a): |
""" Mix the four bytes of every column in a linear way |
This is the opposite operation of Mixcolumn """ |
Sprime = [0,0,0,0] |
for j in range(a.Nb): # for each column |
Sprime[0] = mul(0x0E,a.state[j][0])^mul(0x0B,a.state[j][1])^mul(0x0D,a.state[j][2])^mul(0x09,a.state[j][3]) |
Sprime[1] = mul(0x09,a.state[j][0])^mul(0x0E,a.state[j][1])^mul(0x0B,a.state[j][2])^mul(0x0D,a.state[j][3]) |
Sprime[2] = mul(0x0D,a.state[j][0])^mul(0x09,a.state[j][1])^mul(0x0E,a.state[j][2])^mul(0x0B,a.state[j][3]) |
Sprime[3] = mul(0x0B,a.state[j][0])^mul(0x0D,a.state[j][1])^mul(0x09,a.state[j][2])^mul(0x0E,a.state[j][3]) |
for i in range(4): |
a.state[j][i] = Sprime[i] |
#------------------------------------- |
def mul(a, b): |
""" Multiply two elements of GF(2^m) |
needed for MixColumn and InvMixColumn """ |
if (a !=0 and b!=0): |
return Alogtable[(Logtable[a] + Logtable[b])%255] |
else: |
return 0 |
Logtable = ( 0, 0, 25, 1, 50, 2, 26, 198, 75, 199, 27, 104, 51, 238, 223, 3, |
100, 4, 224, 14, 52, 141, 129, 239, 76, 113, 8, 200, 248, 105, 28, 193, |
125, 194, 29, 181, 249, 185, 39, 106, 77, 228, 166, 114, 154, 201, 9, 120, |
101, 47, 138, 5, 33, 15, 225, 36, 18, 240, 130, 69, 53, 147, 218, 142, |
150, 143, 219, 189, 54, 208, 206, 148, 19, 92, 210, 241, 64, 70, 131, 56, |
102, 221, 253, 48, 191, 6, 139, 98, 179, 37, 226, 152, 34, 136, 145, 16, |
126, 110, 72, 195, 163, 182, 30, 66, 58, 107, 40, 84, 250, 133, 61, 186, |
43, 121, 10, 21, 155, 159, 94, 202, 78, 212, 172, 229, 243, 115, 167, 87, |
175, 88, 168, 80, 244, 234, 214, 116, 79, 174, 233, 213, 231, 230, 173, 232, |
44, 215, 117, 122, 235, 22, 11, 245, 89, 203, 95, 176, 156, 169, 81, 160, |
127, 12, 246, 111, 23, 196, 73, 236, 216, 67, 31, 45, 164, 118, 123, 183, |
204, 187, 62, 90, 251, 96, 177, 134, 59, 82, 161, 108, 170, 85, 41, 157, |
151, 178, 135, 144, 97, 190, 220, 252, 188, 149, 207, 205, 55, 63, 91, 209, |
83, 57, 132, 60, 65, 162, 109, 71, 20, 42, 158, 93, 86, 242, 211, 171, |
68, 17, 146, 217, 35, 32, 46, 137, 180, 124, 184, 38, 119, 153, 227, 165, |
103, 74, 237, 222, 197, 49, 254, 24, 13, 99, 140, 128, 192, 247, 112, 7) |
Alogtable= ( 1, 3, 5, 15, 17, 51, 85, 255, 26, 46, 114, 150, 161, 248, 19, 53, |
95, 225, 56, 72, 216, 115, 149, 164, 247, 2, 6, 10, 30, 34, 102, 170, |
229, 52, 92, 228, 55, 89, 235, 38, 106, 190, 217, 112, 144, 171, 230, 49, |
83, 245, 4, 12, 20, 60, 68, 204, 79, 209, 104, 184, 211, 110, 178, 205, |
76, 212, 103, 169, 224, 59, 77, 215, 98, 166, 241, 8, 24, 40, 120, 136, |
131, 158, 185, 208, 107, 189, 220, 127, 129, 152, 179, 206, 73, 219, 118, 154, |
181, 196, 87, 249, 16, 48, 80, 240, 11, 29, 39, 105, 187, 214, 97, 163, |
254, 25, 43, 125, 135, 146, 173, 236, 47, 113, 147, 174, 233, 32, 96, 160, |
251, 22, 58, 78, 210, 109, 183, 194, 93, 231, 50, 86, 250, 21, 63, 65, |
195, 94, 226, 61, 71, 201, 64, 192, 91, 237, 44, 116, 156, 191, 218, 117, |
159, 186, 213, 100, 172, 239, 42, 126, 130, 157, 188, 223, 122, 142, 137, 128, |
155, 182, 193, 88, 232, 35, 101, 175, 234, 37, 111, 177, 200, 67, 197, 84, |
252, 31, 33, 99, 165, 244, 7, 9, 27, 45, 119, 153, 176, 203, 70, 202, |
69, 207, 74, 222, 121, 139, 134, 145, 168, 227, 62, 66, 198, 81, 243, 14, |
18, 54, 90, 238, 41, 123, 141, 140, 143, 138, 133, 148, 167, 242, 13, 23, |
57, 75, 221, 124, 132, 151, 162, 253, 28, 36, 108, 180, 199, 82, 246, 1) |
/relevation/ext/cryptopy-1.2.5.patched/crypto/cipher/arc4.py |
---|
0,0 → 1,75 |
""" crypto.cipher.arc4 |
A Stream Cipher Encryption Algorithm 'Arcfour' |
A few lines of code/ideas borrowed from [PING] |
[PING] CipherSaber implementation by Ka-Ping Yee <ping@lfw.org>, 5 May 2000. |
Some documentation text and test vectors taken from [IDARC4] |
[IDARCH4] K.Kaukonen, R.Thayer, "A Stream Cipher Encryption Algorithm 'Arcfour'", |
ftp://ietf.org/draft-kaukonen-cipher-arcfour-03.txt |
Generally munged to map to crypto.cipher calling conventions |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
November 5, 2002 |
""" |
class ARC4: |
""" ARC4 Stream Cipher Algorithm |
""" |
def __init__(self,key=None): |
""" key -> octet string for key """ |
self.name = 'ARC4' |
self.strength = None # depends on keySize |
self.blockSize = 1 # blockSize is in bytes |
if key != None: |
self.setKey(key) |
def setKey(self, key): |
""" Set initial state from key. Never use the same key more than once! |
""" |
self.keySize = len(key) |
self.strength = self.keySize # this does not include subtracting IV size :-( |
i, j, self.state = 0, 0, range(256) |
for i in range(256): |
j = (j + self.state[i] + ord(key[i % len(key)])) % 256 |
self.state[i], self.state[j] = self.state[j], self.state[i] |
self.keyReady = 1 # Ready |
def encrypt(self, plainText, more = None): |
""" Encrypt a string and return a binary string |
multiple sequential calls can be made using more =1, |
this continues the encryption |
New sessions of encrypt can NOT be called twice with the same key!!!! |
""" |
if self.keyReady != 1 : raise 'Error, ARC4 key already used once!' |
if more != 1: |
self.keyReady = None |
cipherText = arcfourBlock(self.state, plainText) |
return cipherText |
def decrypt(self, cipherText, more = None): |
""" Decrypt a string and return a string """ |
if self.keyReady != 1 : |
raise 'set for decryption required' |
if more != 1: |
self.keyReady = None |
plainText = arcfourBlock(self.state, cipherText) |
return plainText |
def arcfourBlock(state, input): |
""" Use state to encrypt input string, returns string """ |
i, j, output = 0, 0, [] |
for byte in input: |
i = (i + 1) % 256 |
j = (j + state[i]) % 256 |
state[i], state[j] = state[j], state[i] |
n = (state[i] + state[j]) % 256 |
output.append(chr(ord(byte) ^ state[n])) |
output = ''.join(output) # convert to string |
return output |
/relevation/ext/cryptopy-1.2.5.patched/crypto/cipher/wep_test.py |
---|
0,0 → 1,71 |
#! /usr/bin/env python |
""" crypto.cipher.wep_test |
Tests for wep encryption |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
2002-11-05 |
""" |
import unittest |
from crypto.cipher.wep import WEP |
from binascii_plus import a2b_p, b2a_p |
from zlib import crc32 |
from struct import pack |
class WEP_TestVectors(unittest.TestCase): |
""" Test WEP algorithm using know values """ |
def testKnowValues(self): |
""" Test using vectors from...""" |
def WEPtestVector(testCase,plainText,iv,key,keyId,cipherText): |
""" Process WEP test vectors from RFCxxxx""" |
print '%s %s %s'%('='*((54-len(testCase))/2),testCase,'='*((54-len(testCase))/2)) |
# Convert from octet lists to string |
pt = a2b_p(plainText) |
iv = a2b_p(iv) |
key = a2b_p(key) |
kct = a2b_p(cipherText) |
alg = WEP(key,keyId=keyId) |
print 'key: %s'%b2a_p(key)[9:] |
print 'keyId: %x'%keyId |
print 'iv: %s'%b2a_p(iv)[9:] |
print 'pt: %s'%b2a_p(pt)[9:] |
print 'kct: %s'%b2a_p(kct)[9:] |
ct = alg.encrypt(pt, iv, keyId) |
print 'ct: %s'%b2a_p(ct)[9:] |
print 'crc: %s'%b2a_p(pack('<I',crc32(plainText)))[9:] |
print '========================================================' |
self.assertEqual( ct, kct ) |
alg.setKey(key,keyId=keyId) |
dct = alg.decrypt( ct ) |
self.assertEqual( dct, pt ) |
WEPtestVector( |
testCase = "Test Vectors from IEEE 802.11 TGi D2.x", |
plainText = """aa aa 03 00 00 00 08 00 45 00 00 4e 66 1a 00 00 |
80 11 be 64 0a 00 01 22 0a ff ff ff 00 89 00 89 |
00 3a 00 00 80 a6 01 10 00 01 00 00 00 00 00 00 |
20 45 43 45 4a 45 48 45 43 46 43 45 50 46 45 45 |
49 45 46 46 43 43 41 43 41 43 41 43 41 43 41 41 |
41 00 00 20 00 01 """, |
iv = "fb 02 9e", |
key = "30 31 32 33 34", |
keyId = 2, |
cipherText = """fb 02 9e 80 |
f6 9c 58 06 bd 6c e8 46 26 bc be fb 94 74 65 0a |
ad 1f 79 09 b0 f6 4d 5f 58 a5 03 a2 58 b7 ed 22 |
eb 0e a6 49 30 d3 a0 56 a5 57 42 fc ce 14 1d 48 |
5f 8a a8 36 de a1 8d f4 2c 53 80 80 5a d0 c6 1a |
5d 6f 58 f4 10 40 b2 4b 7d 1a 69 38 56 ed 0d 43 |
98 e7 ae e3 bf 0e 2a 2c a8 f7 """) |
# Make this test module runnable from the command prompt |
if __name__ == "__main__": |
unittest.main() |
/relevation/ext/cryptopy-1.2.5.patched/crypto/cipher/wep.py |
---|
0,0 → 1,75 |
""" crypto.cipher.wep |
The WEP encryption algorithm used in IEEE 802.11 |
Copyright © (c) 2002 by Paul A. Lambert |
Read LICENSE.txt for license information. |
September 2002 |
""" |
from crypto.cipher.arc4 import ARC4 |
from crypto.errors import IntegrityCheckError, BadKeySizeError |
from zlib import crc32 |
from struct import pack |
class WEP: |
""" WEP Stream Cipher Algorithm |
Automatically adds and removes IV and KeyId |
""" |
def __init__(self, key=None, keyId=None): |
""" key -> octet string for key """ |
self.name = 'WEP' |
self.strength = None # depends on keySize |
self.arc4 = ARC4() # base algorithm |
self.__key = [None,None,None,None] # four possible keys, initialize to invalid keys |
self.encryptHeaderSize = 4 |
self.setCurrentKeyId(keyId) |
if key != None: |
self.setKey(key) |
def setKey(self, key, keyId=None): |
""" Set key, key string is typically 5 or 13 octets long |
""" |
if not(len(key) in (5,13)): |
raise BadKeySizeError,'Key not valid size of 5 or 13 octets' |
if keyId != None : |
self.setCurrentKeyId(keyId) |
self.__key[self.currentKeyId] = key |
self.keySize = len(key) |
self.strength = self.keySize * 8 |
def setCurrentKeyId(self, keyId): |
if keyId == None : |
self.currentKeyId = 0 |
elif (0<=keyId<4): |
self.currentKeyId = keyId |
else: |
raise 'WEP keyId must be value 0, 1, 2 or 3' |
def encrypt(self, plainText, iv, keyId=None): |
""" Encrypt a string and return a binary string |
Adds WEP encryption header and crc |
""" |
assert(len(iv)==3),'Wrong size WEP IV' |
if keyId != None : |
self.setCurrentKeyId(keyId) |
assert(self.__key[self.currentKeyId]!=None), 'Must set key for specific keyId before encryption' |
self.arc4.setKey( iv + self.__key[self.currentKeyId] ) |
crc = pack('<I',crc32(plainText)) |
cipherText = self.arc4.encrypt(plainText+crc) |
# add header that contains IV |
cipherText = iv + chr((self.currentKeyId<<6)) + cipherText |
return cipherText |
def decrypt(self, cipherText): |
""" Decrypt a WEP packet, assumes WEP 4 byte header on packet """ |
iv = cipherText[:3] |
self.currentKeyId = (ord(cipherText[3])&0xC0)>>6 |
assert(self.__key[self.currentKeyId]!=None), 'Must set key for specific keyId before encryption' |
self.arc4.setKey( iv + self.__key[self.currentKeyId] ) |
plainText = self.arc4.decrypt(cipherText[self.encryptHeaderSize:]) |
if plainText[-self.encryptHeaderSize:] == pack('<I',crc32(plainText)): # check data integrity |
raise IntegrityCheckError, 'WEP Integrity Check Error' |
return plainText[:-4] |
/relevation/ext/cryptopy-1.2.5.patched/crypto/cipher |
---|
Property changes: |
Added: bugtraq:number |
+true |
\ No newline at end of property |
/relevation/ext/cryptopy-1.2.5.patched/crypto/. |
---|
Property changes: |
Added: bugtraq:number |
+true |
\ No newline at end of property |