Updated DB_Helper by adding firebase methods.
This commit is contained in:
parent
485cc3bbba
commit
c82121d036
1810 changed files with 537281 additions and 1 deletions
59
venv/Lib/site-packages/Crypto/SelfTest/Cipher/__init__.py
Normal file
59
venv/Lib/site-packages/Crypto/SelfTest/Cipher/__init__.py
Normal file
|
@ -0,0 +1,59 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# SelfTest/Cipher/__init__.py: Self-test for cipher modules
|
||||
#
|
||||
# Written in 2008 by Dwayne C. Litzenberger <dlitz@dlitz.net>
|
||||
#
|
||||
# ===================================================================
|
||||
# The contents of this file are dedicated to the public domain. To
|
||||
# the extent that dedication to the public domain is not available,
|
||||
# everyone is granted a worldwide, perpetual, royalty-free,
|
||||
# non-exclusive license to exercise all rights associated with the
|
||||
# contents of this file for any purpose whatsoever.
|
||||
# No rights are reserved.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
# ===================================================================
|
||||
|
||||
"""Self-test for cipher modules"""
|
||||
|
||||
__revision__ = "$Id$"
|
||||
|
||||
def get_tests(config={}):
|
||||
tests = []
|
||||
from Crypto.SelfTest.Cipher import test_AES; tests += test_AES.get_tests(config=config)
|
||||
from Crypto.SelfTest.Cipher import test_ARC2; tests += test_ARC2.get_tests(config=config)
|
||||
from Crypto.SelfTest.Cipher import test_ARC4; tests += test_ARC4.get_tests(config=config)
|
||||
from Crypto.SelfTest.Cipher import test_Blowfish; tests += test_Blowfish.get_tests(config=config)
|
||||
from Crypto.SelfTest.Cipher import test_CAST; tests += test_CAST.get_tests(config=config)
|
||||
from Crypto.SelfTest.Cipher import test_DES3; tests += test_DES3.get_tests(config=config)
|
||||
from Crypto.SelfTest.Cipher import test_DES; tests += test_DES.get_tests(config=config)
|
||||
from Crypto.SelfTest.Cipher import test_Salsa20; tests += test_Salsa20.get_tests(config=config)
|
||||
from Crypto.SelfTest.Cipher import test_ChaCha20; tests += test_ChaCha20.get_tests(config=config)
|
||||
from Crypto.SelfTest.Cipher import test_pkcs1_15; tests += test_pkcs1_15.get_tests(config=config)
|
||||
from Crypto.SelfTest.Cipher import test_pkcs1_oaep; tests += test_pkcs1_oaep.get_tests(config=config)
|
||||
from Crypto.SelfTest.Cipher import test_OCB; tests += test_OCB.get_tests(config=config)
|
||||
from Crypto.SelfTest.Cipher import test_CBC; tests += test_CBC.get_tests(config=config)
|
||||
from Crypto.SelfTest.Cipher import test_CFB; tests += test_CFB.get_tests(config=config)
|
||||
from Crypto.SelfTest.Cipher import test_OpenPGP; tests += test_OpenPGP.get_tests(config=config)
|
||||
from Crypto.SelfTest.Cipher import test_OFB; tests += test_OFB.get_tests(config=config)
|
||||
from Crypto.SelfTest.Cipher import test_CTR; tests += test_CTR.get_tests(config=config)
|
||||
from Crypto.SelfTest.Cipher import test_CCM; tests += test_CCM.get_tests(config=config)
|
||||
from Crypto.SelfTest.Cipher import test_EAX; tests += test_EAX.get_tests(config=config)
|
||||
from Crypto.SelfTest.Cipher import test_GCM; tests += test_GCM.get_tests(config=config)
|
||||
from Crypto.SelfTest.Cipher import test_SIV; tests += test_SIV.get_tests(config=config)
|
||||
return tests
|
||||
|
||||
if __name__ == '__main__':
|
||||
import unittest
|
||||
suite = lambda: unittest.TestSuite(get_tests())
|
||||
unittest.main(defaultTest='suite')
|
||||
|
||||
# vim:set ts=4 sw=4 sts=4 expandtab:
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
328
venv/Lib/site-packages/Crypto/SelfTest/Cipher/common.py
Normal file
328
venv/Lib/site-packages/Crypto/SelfTest/Cipher/common.py
Normal file
|
@ -0,0 +1,328 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# SelfTest/Hash/common.py: Common code for Crypto.SelfTest.Hash
|
||||
#
|
||||
# Written in 2008 by Dwayne C. Litzenberger <dlitz@dlitz.net>
|
||||
#
|
||||
# ===================================================================
|
||||
# The contents of this file are dedicated to the public domain. To
|
||||
# the extent that dedication to the public domain is not available,
|
||||
# everyone is granted a worldwide, perpetual, royalty-free,
|
||||
# non-exclusive license to exercise all rights associated with the
|
||||
# contents of this file for any purpose whatsoever.
|
||||
# No rights are reserved.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
# ===================================================================
|
||||
|
||||
"""Self-testing for PyCrypto hash modules"""
|
||||
|
||||
import unittest
|
||||
from binascii import a2b_hex, b2a_hex, hexlify
|
||||
|
||||
from Crypto.Util.py3compat import *
|
||||
from Crypto.Util.strxor import strxor_c
|
||||
|
||||
class _NoDefault: pass # sentinel object
|
||||
def _extract(d, k, default=_NoDefault):
|
||||
"""Get an item from a dictionary, and remove it from the dictionary."""
|
||||
try:
|
||||
retval = d[k]
|
||||
except KeyError:
|
||||
if default is _NoDefault:
|
||||
raise
|
||||
return default
|
||||
del d[k]
|
||||
return retval
|
||||
|
||||
# Generic cipher test case
|
||||
class CipherSelfTest(unittest.TestCase):
|
||||
|
||||
def __init__(self, module, params):
|
||||
unittest.TestCase.__init__(self)
|
||||
self.module = module
|
||||
|
||||
# Extract the parameters
|
||||
params = params.copy()
|
||||
self.description = _extract(params, 'description')
|
||||
self.key = b(_extract(params, 'key'))
|
||||
self.plaintext = b(_extract(params, 'plaintext'))
|
||||
self.ciphertext = b(_extract(params, 'ciphertext'))
|
||||
self.module_name = _extract(params, 'module_name', None)
|
||||
self.assoc_data = _extract(params, 'assoc_data', None)
|
||||
self.mac = _extract(params, 'mac', None)
|
||||
if self.assoc_data:
|
||||
self.mac = b(self.mac)
|
||||
|
||||
mode = _extract(params, 'mode', None)
|
||||
self.mode_name = str(mode)
|
||||
|
||||
if mode is not None:
|
||||
# Block cipher
|
||||
self.mode = getattr(self.module, "MODE_" + mode)
|
||||
|
||||
self.iv = _extract(params, 'iv', None)
|
||||
if self.iv is None:
|
||||
self.iv = _extract(params, 'nonce', None)
|
||||
if self.iv is not None:
|
||||
self.iv = b(self.iv)
|
||||
|
||||
else:
|
||||
# Stream cipher
|
||||
self.mode = None
|
||||
self.iv = _extract(params, 'iv', None)
|
||||
if self.iv is not None:
|
||||
self.iv = b(self.iv)
|
||||
|
||||
self.extra_params = params
|
||||
|
||||
def shortDescription(self):
|
||||
return self.description
|
||||
|
||||
def _new(self, do_decryption=0):
|
||||
params = self.extra_params.copy()
|
||||
|
||||
if self.mode is None:
|
||||
if self.iv is None:
|
||||
return self.module.new(a2b_hex(self.key), **params)
|
||||
else:
|
||||
return self.module.new(a2b_hex(self.key), a2b_hex(self.iv), **params)
|
||||
elif self.iv is None:
|
||||
# Block cipher without iv
|
||||
return self.module.new(a2b_hex(self.key), self.mode, **params)
|
||||
else:
|
||||
return self.module.new(a2b_hex(self.key), self.mode, a2b_hex(self.iv), **params)
|
||||
|
||||
def isMode(self, name):
|
||||
if not hasattr(self.module, "MODE_"+name):
|
||||
return False
|
||||
return self.mode == getattr(self.module, "MODE_"+name)
|
||||
|
||||
def runTest(self):
|
||||
plaintext = a2b_hex(self.plaintext)
|
||||
ciphertext = a2b_hex(self.ciphertext)
|
||||
assoc_data = []
|
||||
if self.assoc_data:
|
||||
assoc_data = [ a2b_hex(b(x)) for x in self.assoc_data]
|
||||
|
||||
ct = None
|
||||
pt = None
|
||||
|
||||
#
|
||||
# Repeat the same encryption or decryption twice and verify
|
||||
# that the result is always the same
|
||||
#
|
||||
for i in range(2):
|
||||
cipher = self._new()
|
||||
decipher = self._new(1)
|
||||
|
||||
# Only AEAD modes
|
||||
for comp in assoc_data:
|
||||
cipher.update(comp)
|
||||
decipher.update(comp)
|
||||
|
||||
ctX = b2a_hex(cipher.encrypt(plaintext))
|
||||
ptX = b2a_hex(decipher.decrypt(ciphertext))
|
||||
|
||||
if ct:
|
||||
self.assertEqual(ct, ctX)
|
||||
self.assertEqual(pt, ptX)
|
||||
ct, pt = ctX, ptX
|
||||
|
||||
self.assertEqual(self.ciphertext, ct) # encrypt
|
||||
self.assertEqual(self.plaintext, pt) # decrypt
|
||||
|
||||
if self.mac:
|
||||
mac = b2a_hex(cipher.digest())
|
||||
self.assertEqual(self.mac, mac)
|
||||
decipher.verify(a2b_hex(self.mac))
|
||||
|
||||
class CipherStreamingSelfTest(CipherSelfTest):
|
||||
|
||||
def shortDescription(self):
|
||||
desc = self.module_name
|
||||
if self.mode is not None:
|
||||
desc += " in %s mode" % (self.mode_name,)
|
||||
return "%s should behave like a stream cipher" % (desc,)
|
||||
|
||||
def runTest(self):
|
||||
plaintext = a2b_hex(self.plaintext)
|
||||
ciphertext = a2b_hex(self.ciphertext)
|
||||
|
||||
# The cipher should work like a stream cipher
|
||||
|
||||
# Test counter mode encryption, 3 bytes at a time
|
||||
ct3 = []
|
||||
cipher = self._new()
|
||||
for i in range(0, len(plaintext), 3):
|
||||
ct3.append(cipher.encrypt(plaintext[i:i+3]))
|
||||
ct3 = b2a_hex(b("").join(ct3))
|
||||
self.assertEqual(self.ciphertext, ct3) # encryption (3 bytes at a time)
|
||||
|
||||
# Test counter mode decryption, 3 bytes at a time
|
||||
pt3 = []
|
||||
cipher = self._new()
|
||||
for i in range(0, len(ciphertext), 3):
|
||||
pt3.append(cipher.encrypt(ciphertext[i:i+3]))
|
||||
# PY3K: This is meant to be text, do not change to bytes (data)
|
||||
pt3 = b2a_hex(b("").join(pt3))
|
||||
self.assertEqual(self.plaintext, pt3) # decryption (3 bytes at a time)
|
||||
|
||||
|
||||
class RoundtripTest(unittest.TestCase):
|
||||
def __init__(self, module, params):
|
||||
from Crypto import Random
|
||||
unittest.TestCase.__init__(self)
|
||||
self.module = module
|
||||
self.iv = Random.get_random_bytes(module.block_size)
|
||||
self.key = b(params['key'])
|
||||
self.plaintext = 100 * b(params['plaintext'])
|
||||
self.module_name = params.get('module_name', None)
|
||||
|
||||
def shortDescription(self):
|
||||
return """%s .decrypt() output of .encrypt() should not be garbled""" % (self.module_name,)
|
||||
|
||||
def runTest(self):
|
||||
|
||||
## ECB mode
|
||||
mode = self.module.MODE_ECB
|
||||
encryption_cipher = self.module.new(a2b_hex(self.key), mode)
|
||||
ciphertext = encryption_cipher.encrypt(self.plaintext)
|
||||
decryption_cipher = self.module.new(a2b_hex(self.key), mode)
|
||||
decrypted_plaintext = decryption_cipher.decrypt(ciphertext)
|
||||
self.assertEqual(self.plaintext, decrypted_plaintext)
|
||||
|
||||
|
||||
class IVLengthTest(unittest.TestCase):
|
||||
def __init__(self, module, params):
|
||||
unittest.TestCase.__init__(self)
|
||||
self.module = module
|
||||
self.key = b(params['key'])
|
||||
|
||||
def shortDescription(self):
|
||||
return "Check that all modes except MODE_ECB and MODE_CTR require an IV of the proper length"
|
||||
|
||||
def runTest(self):
|
||||
self.assertRaises(TypeError, self.module.new, a2b_hex(self.key),
|
||||
self.module.MODE_ECB, b(""))
|
||||
|
||||
def _dummy_counter(self):
|
||||
return "\0" * self.module.block_size
|
||||
|
||||
class NoDefaultECBTest(unittest.TestCase):
|
||||
def __init__(self, module, params):
|
||||
unittest.TestCase.__init__(self)
|
||||
self.module = module
|
||||
self.key = b(params['key'])
|
||||
|
||||
def runTest(self):
|
||||
self.assertRaises(TypeError, self.module.new, a2b_hex(self.key))
|
||||
|
||||
|
||||
def make_block_tests(module, module_name, test_data, additional_params=dict()):
|
||||
tests = []
|
||||
extra_tests_added = 0
|
||||
for i in range(len(test_data)):
|
||||
row = test_data[i]
|
||||
|
||||
# Build the "params" dictionary with
|
||||
# - plaintext
|
||||
# - ciphertext
|
||||
# - key
|
||||
# - mode (default is ECB)
|
||||
# - (optionally) description
|
||||
# - (optionally) any other parameter that this cipher mode requires
|
||||
params = {}
|
||||
if len(row) == 3:
|
||||
(params['plaintext'], params['ciphertext'], params['key']) = row
|
||||
elif len(row) == 4:
|
||||
(params['plaintext'], params['ciphertext'], params['key'], params['description']) = row
|
||||
elif len(row) == 5:
|
||||
(params['plaintext'], params['ciphertext'], params['key'], params['description'], extra_params) = row
|
||||
params.update(extra_params)
|
||||
else:
|
||||
raise AssertionError("Unsupported tuple size %d" % (len(row),))
|
||||
|
||||
if "mode" not in params:
|
||||
params["mode"] = "ECB"
|
||||
|
||||
# Build the display-name for the test
|
||||
p2 = params.copy()
|
||||
p_key = _extract(p2, 'key')
|
||||
p_plaintext = _extract(p2, 'plaintext')
|
||||
p_ciphertext = _extract(p2, 'ciphertext')
|
||||
p_mode = _extract(p2, 'mode')
|
||||
p_description = _extract(p2, 'description', None)
|
||||
|
||||
if p_description is not None:
|
||||
description = p_description
|
||||
elif p_mode == 'ECB' and not p2:
|
||||
description = "p=%s, k=%s" % (p_plaintext, p_key)
|
||||
else:
|
||||
description = "p=%s, k=%s, %r" % (p_plaintext, p_key, p2)
|
||||
name = "%s #%d: %s" % (module_name, i+1, description)
|
||||
params['description'] = name
|
||||
params['module_name'] = module_name
|
||||
params.update(additional_params)
|
||||
|
||||
# Add extra test(s) to the test suite before the current test
|
||||
if not extra_tests_added:
|
||||
tests += [
|
||||
RoundtripTest(module, params),
|
||||
IVLengthTest(module, params),
|
||||
NoDefaultECBTest(module, params),
|
||||
]
|
||||
extra_tests_added = 1
|
||||
|
||||
# Add the current test to the test suite
|
||||
tests.append(CipherSelfTest(module, params))
|
||||
|
||||
return tests
|
||||
|
||||
def make_stream_tests(module, module_name, test_data):
|
||||
tests = []
|
||||
for i in range(len(test_data)):
|
||||
row = test_data[i]
|
||||
|
||||
# Build the "params" dictionary
|
||||
params = {}
|
||||
if len(row) == 3:
|
||||
(params['plaintext'], params['ciphertext'], params['key']) = row
|
||||
elif len(row) == 4:
|
||||
(params['plaintext'], params['ciphertext'], params['key'], params['description']) = row
|
||||
elif len(row) == 5:
|
||||
(params['plaintext'], params['ciphertext'], params['key'], params['description'], extra_params) = row
|
||||
params.update(extra_params)
|
||||
else:
|
||||
raise AssertionError("Unsupported tuple size %d" % (len(row),))
|
||||
|
||||
# Build the display-name for the test
|
||||
p2 = params.copy()
|
||||
p_key = _extract(p2, 'key')
|
||||
p_plaintext = _extract(p2, 'plaintext')
|
||||
p_ciphertext = _extract(p2, 'ciphertext')
|
||||
p_description = _extract(p2, 'description', None)
|
||||
|
||||
if p_description is not None:
|
||||
description = p_description
|
||||
elif not p2:
|
||||
description = "p=%s, k=%s" % (p_plaintext, p_key)
|
||||
else:
|
||||
description = "p=%s, k=%s, %r" % (p_plaintext, p_key, p2)
|
||||
name = "%s #%d: %s" % (module_name, i+1, description)
|
||||
params['description'] = name
|
||||
params['module_name'] = module_name
|
||||
|
||||
# Add the test to the test suite
|
||||
tests.append(CipherSelfTest(module, params))
|
||||
tests.append(CipherStreamingSelfTest(module, params))
|
||||
return tests
|
||||
|
||||
# vim:set ts=4 sw=4 sts=4 expandtab:
|
1251
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_AES.py
Normal file
1251
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_AES.py
Normal file
File diff suppressed because it is too large
Load diff
130
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_ARC2.py
Normal file
130
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_ARC2.py
Normal file
|
@ -0,0 +1,130 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# SelfTest/Cipher/ARC2.py: Self-test for the Alleged-RC2 cipher
|
||||
#
|
||||
# Written in 2008 by Dwayne C. Litzenberger <dlitz@dlitz.net>
|
||||
#
|
||||
# ===================================================================
|
||||
# The contents of this file are dedicated to the public domain. To
|
||||
# the extent that dedication to the public domain is not available,
|
||||
# everyone is granted a worldwide, perpetual, royalty-free,
|
||||
# non-exclusive license to exercise all rights associated with the
|
||||
# contents of this file for any purpose whatsoever.
|
||||
# No rights are reserved.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
# ===================================================================
|
||||
|
||||
"""Self-test suite for Crypto.Cipher.ARC2"""
|
||||
|
||||
import unittest
|
||||
|
||||
from Crypto.Util.py3compat import b, bchr
|
||||
|
||||
from Crypto.Cipher import ARC2
|
||||
|
||||
# This is a list of (plaintext, ciphertext, key[, description[, extra_params]]) tuples.
|
||||
test_data = [
|
||||
# Test vectors from RFC 2268
|
||||
|
||||
# 63-bit effective key length
|
||||
('0000000000000000', 'ebb773f993278eff', '0000000000000000',
|
||||
'RFC2268-1', dict(effective_keylen=63)),
|
||||
|
||||
# 64-bit effective key length
|
||||
('ffffffffffffffff', '278b27e42e2f0d49', 'ffffffffffffffff',
|
||||
'RFC2268-2', dict(effective_keylen=64)),
|
||||
('1000000000000001', '30649edf9be7d2c2', '3000000000000000',
|
||||
'RFC2268-3', dict(effective_keylen=64)),
|
||||
#('0000000000000000', '61a8a244adacccf0', '88',
|
||||
# 'RFC2268-4', dict(effective_keylen=64)),
|
||||
('0000000000000000', '6ccf4308974c267f', '88bca90e90875a',
|
||||
'RFC2268-5', dict(effective_keylen=64)),
|
||||
('0000000000000000', '1a807d272bbe5db1', '88bca90e90875a7f0f79c384627bafb2',
|
||||
'RFC2268-6', dict(effective_keylen=64)),
|
||||
|
||||
# 128-bit effective key length
|
||||
('0000000000000000', '2269552ab0f85ca6', '88bca90e90875a7f0f79c384627bafb2',
|
||||
"RFC2268-7", dict(effective_keylen=128)),
|
||||
('0000000000000000', '5b78d3a43dfff1f1',
|
||||
'88bca90e90875a7f0f79c384627bafb216f80a6f85920584c42fceb0be255daf1e',
|
||||
"RFC2268-8", dict(effective_keylen=129)),
|
||||
|
||||
# Test vectors from PyCrypto 2.0.1's testdata.py
|
||||
# 1024-bit effective key length
|
||||
('0000000000000000', '624fb3e887419e48', '5068696c6970476c617373',
|
||||
'PCTv201-0'),
|
||||
('ffffffffffffffff', '79cadef44c4a5a85', '5068696c6970476c617373',
|
||||
'PCTv201-1'),
|
||||
('0001020304050607', '90411525b34e4c2c', '5068696c6970476c617373',
|
||||
'PCTv201-2'),
|
||||
('0011223344556677', '078656aaba61cbfb', '5068696c6970476c617373',
|
||||
'PCTv201-3'),
|
||||
('0000000000000000', 'd7bcc5dbb4d6e56a', 'ffffffffffffffff',
|
||||
'PCTv201-4'),
|
||||
('ffffffffffffffff', '7259018ec557b357', 'ffffffffffffffff',
|
||||
'PCTv201-5'),
|
||||
('0001020304050607', '93d20a497f2ccb62', 'ffffffffffffffff',
|
||||
'PCTv201-6'),
|
||||
('0011223344556677', 'cb15a7f819c0014d', 'ffffffffffffffff',
|
||||
'PCTv201-7'),
|
||||
('0000000000000000', '63ac98cdf3843a7a', 'ffffffffffffffff5065746572477265656e6177617953e5ffe553',
|
||||
'PCTv201-8'),
|
||||
('ffffffffffffffff', '3fb49e2fa12371dd', 'ffffffffffffffff5065746572477265656e6177617953e5ffe553',
|
||||
'PCTv201-9'),
|
||||
('0001020304050607', '46414781ab387d5f', 'ffffffffffffffff5065746572477265656e6177617953e5ffe553',
|
||||
'PCTv201-10'),
|
||||
('0011223344556677', 'be09dc81feaca271', 'ffffffffffffffff5065746572477265656e6177617953e5ffe553',
|
||||
'PCTv201-11'),
|
||||
('0000000000000000', 'e64221e608be30ab', '53e5ffe553',
|
||||
'PCTv201-12'),
|
||||
('ffffffffffffffff', '862bc60fdcd4d9a9', '53e5ffe553',
|
||||
'PCTv201-13'),
|
||||
('0001020304050607', '6a34da50fa5e47de', '53e5ffe553',
|
||||
'PCTv201-14'),
|
||||
('0011223344556677', '584644c34503122c', '53e5ffe553',
|
||||
'PCTv201-15'),
|
||||
]
|
||||
|
||||
class BufferOverflowTest(unittest.TestCase):
|
||||
# Test a buffer overflow found in older versions of PyCrypto
|
||||
|
||||
def runTest(self):
|
||||
"""ARC2 with keylength > 128"""
|
||||
key = b("x") * 16384
|
||||
self.assertRaises(ValueError, ARC2.new, key, ARC2.MODE_ECB)
|
||||
|
||||
class KeyLength(unittest.TestCase):
|
||||
|
||||
def runTest(self):
|
||||
self.assertRaises(ValueError, ARC2.new, bchr(0) * 4, ARC2.MODE_ECB)
|
||||
self.assertRaises(ValueError, ARC2.new, bchr(0) * 129, ARC2.MODE_ECB)
|
||||
|
||||
self.assertRaises(ValueError, ARC2.new, bchr(0) * 16, ARC2.MODE_ECB,
|
||||
effective_keylen=39)
|
||||
self.assertRaises(ValueError, ARC2.new, bchr(0) * 16, ARC2.MODE_ECB,
|
||||
effective_keylen=1025)
|
||||
|
||||
def get_tests(config={}):
|
||||
from Crypto.Cipher import ARC2
|
||||
from .common import make_block_tests
|
||||
|
||||
tests = make_block_tests(ARC2, "ARC2", test_data)
|
||||
tests.append(BufferOverflowTest())
|
||||
tests.append(KeyLength())
|
||||
|
||||
return tests
|
||||
|
||||
if __name__ == '__main__':
|
||||
import unittest
|
||||
suite = lambda: unittest.TestSuite(get_tests())
|
||||
unittest.main(defaultTest='suite')
|
||||
|
||||
# vim:set ts=4 sw=4 sts=4 expandtab:
|
464
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_ARC4.py
Normal file
464
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_ARC4.py
Normal file
|
@ -0,0 +1,464 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# SelfTest/Cipher/ARC4.py: Self-test for the Alleged-RC4 cipher
|
||||
#
|
||||
# Written in 2008 by Dwayne C. Litzenberger <dlitz@dlitz.net>
|
||||
#
|
||||
# ===================================================================
|
||||
# The contents of this file are dedicated to the public domain. To
|
||||
# the extent that dedication to the public domain is not available,
|
||||
# everyone is granted a worldwide, perpetual, royalty-free,
|
||||
# non-exclusive license to exercise all rights associated with the
|
||||
# contents of this file for any purpose whatsoever.
|
||||
# No rights are reserved.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
# ===================================================================
|
||||
|
||||
"""Self-test suite for Crypto.Cipher.ARC4"""
|
||||
|
||||
__revision__ = "$Id$"
|
||||
|
||||
from Crypto.Util.py3compat import *
|
||||
from Crypto.SelfTest.st_common import *
|
||||
from binascii import unhexlify
|
||||
|
||||
from Crypto.Cipher import ARC4
|
||||
|
||||
# This is a list of (plaintext, ciphertext, key[, description]) tuples.
|
||||
test_data = [
|
||||
# Test vectors from Eric Rescorla's message with the subject
|
||||
# "RC4 compatibility testing", sent to the cipherpunks mailing list on
|
||||
# September 13, 1994.
|
||||
# http://cypherpunks.venona.com/date/1994/09/msg00420.html
|
||||
|
||||
('0123456789abcdef', '75b7878099e0c596', '0123456789abcdef',
|
||||
'Test vector 0'),
|
||||
|
||||
('0000000000000000', '7494c2e7104b0879', '0123456789abcdef',
|
||||
'Test vector 1'),
|
||||
|
||||
('0000000000000000', 'de188941a3375d3a', '0000000000000000',
|
||||
'Test vector 2'),
|
||||
|
||||
#('00000000000000000000', 'd6a141a7ec3c38dfbd61', 'ef012345',
|
||||
# 'Test vector 3'),
|
||||
|
||||
('01' * 512,
|
||||
'7595c3e6114a09780c4ad452338e1ffd9a1be9498f813d76533449b6778dcad8'
|
||||
+ 'c78a8d2ba9ac66085d0e53d59c26c2d1c490c1ebbe0ce66d1b6b1b13b6b919b8'
|
||||
+ '47c25a91447a95e75e4ef16779cde8bf0a95850e32af9689444fd377108f98fd'
|
||||
+ 'cbd4e726567500990bcc7e0ca3c4aaa304a387d20f3b8fbbcd42a1bd311d7a43'
|
||||
+ '03dda5ab078896ae80c18b0af66dff319616eb784e495ad2ce90d7f772a81747'
|
||||
+ 'b65f62093b1e0db9e5ba532fafec47508323e671327df9444432cb7367cec82f'
|
||||
+ '5d44c0d00b67d650a075cd4b70dedd77eb9b10231b6b5b741347396d62897421'
|
||||
+ 'd43df9b42e446e358e9c11a9b2184ecbef0cd8e7a877ef968f1390ec9b3d35a5'
|
||||
+ '585cb009290e2fcde7b5ec66d9084be44055a619d9dd7fc3166f9487f7cb2729'
|
||||
+ '12426445998514c15d53a18c864ce3a2b7555793988126520eacf2e3066e230c'
|
||||
+ '91bee4dd5304f5fd0405b35bd99c73135d3d9bc335ee049ef69b3867bf2d7bd1'
|
||||
+ 'eaa595d8bfc0066ff8d31509eb0c6caa006c807a623ef84c3d33c195d23ee320'
|
||||
+ 'c40de0558157c822d4b8c569d849aed59d4e0fd7f379586b4b7ff684ed6a189f'
|
||||
+ '7486d49b9c4bad9ba24b96abf924372c8a8fffb10d55354900a77a3db5f205e1'
|
||||
+ 'b99fcd8660863a159ad4abe40fa48934163ddde542a6585540fd683cbfd8c00f'
|
||||
+ '12129a284deacc4cdefe58be7137541c047126c8d49e2755ab181ab7e940b0c0',
|
||||
'0123456789abcdef',
|
||||
"Test vector 4"),
|
||||
]
|
||||
|
||||
class RFC6229_Tests(unittest.TestCase):
|
||||
# Test vectors from RFC 6229. Each test vector is a tuple with two items:
|
||||
# the ARC4 key and a dictionary. The dictionary has keystream offsets as keys
|
||||
# and the 16-byte keystream starting at the relevant offset as value.
|
||||
rfc6229_data = [
|
||||
# Page 3
|
||||
(
|
||||
'0102030405',
|
||||
{
|
||||
0: 'b2 39 63 05 f0 3d c0 27 cc c3 52 4a 0a 11 18 a8',
|
||||
16: '69 82 94 4f 18 fc 82 d5 89 c4 03 a4 7a 0d 09 19',
|
||||
240: '28 cb 11 32 c9 6c e2 86 42 1d ca ad b8 b6 9e ae',
|
||||
256: '1c fc f6 2b 03 ed db 64 1d 77 df cf 7f 8d 8c 93',
|
||||
496: '42 b7 d0 cd d9 18 a8 a3 3d d5 17 81 c8 1f 40 41',
|
||||
512: '64 59 84 44 32 a7 da 92 3c fb 3e b4 98 06 61 f6',
|
||||
752: 'ec 10 32 7b de 2b ee fd 18 f9 27 76 80 45 7e 22',
|
||||
768: 'eb 62 63 8d 4f 0b a1 fe 9f ca 20 e0 5b f8 ff 2b',
|
||||
1008:'45 12 90 48 e6 a0 ed 0b 56 b4 90 33 8f 07 8d a5',
|
||||
1024:'30 ab bc c7 c2 0b 01 60 9f 23 ee 2d 5f 6b b7 df',
|
||||
1520:'32 94 f7 44 d8 f9 79 05 07 e7 0f 62 e5 bb ce ea',
|
||||
1536:'d8 72 9d b4 18 82 25 9b ee 4f 82 53 25 f5 a1 30',
|
||||
2032:'1e b1 4a 0c 13 b3 bf 47 fa 2a 0b a9 3a d4 5b 8b',
|
||||
2048:'cc 58 2f 8b a9 f2 65 e2 b1 be 91 12 e9 75 d2 d7',
|
||||
3056:'f2 e3 0f 9b d1 02 ec bf 75 aa ad e9 bc 35 c4 3c',
|
||||
3072:'ec 0e 11 c4 79 dc 32 9d c8 da 79 68 fe 96 56 81',
|
||||
4080:'06 83 26 a2 11 84 16 d2 1f 9d 04 b2 cd 1c a0 50',
|
||||
4096:'ff 25 b5 89 95 99 67 07 e5 1f bd f0 8b 34 d8 75'
|
||||
}
|
||||
),
|
||||
# Page 4
|
||||
(
|
||||
'01020304050607',
|
||||
{
|
||||
0: '29 3f 02 d4 7f 37 c9 b6 33 f2 af 52 85 fe b4 6b',
|
||||
16: 'e6 20 f1 39 0d 19 bd 84 e2 e0 fd 75 20 31 af c1',
|
||||
240: '91 4f 02 53 1c 92 18 81 0d f6 0f 67 e3 38 15 4c',
|
||||
256: 'd0 fd b5 83 07 3c e8 5a b8 39 17 74 0e c0 11 d5',
|
||||
496: '75 f8 14 11 e8 71 cf fa 70 b9 0c 74 c5 92 e4 54',
|
||||
512: '0b b8 72 02 93 8d ad 60 9e 87 a5 a1 b0 79 e5 e4',
|
||||
752: 'c2 91 12 46 b6 12 e7 e7 b9 03 df ed a1 da d8 66',
|
||||
768: '32 82 8f 91 50 2b 62 91 36 8d e8 08 1d e3 6f c2',
|
||||
1008:'f3 b9 a7 e3 b2 97 bf 9a d8 04 51 2f 90 63 ef f1',
|
||||
1024:'8e cb 67 a9 ba 1f 55 a5 a0 67 e2 b0 26 a3 67 6f',
|
||||
1520:'d2 aa 90 2b d4 2d 0d 7c fd 34 0c d4 58 10 52 9f',
|
||||
1536:'78 b2 72 c9 6e 42 ea b4 c6 0b d9 14 e3 9d 06 e3',
|
||||
2032:'f4 33 2f d3 1a 07 93 96 ee 3c ee 3f 2a 4f f0 49',
|
||||
2048:'05 45 97 81 d4 1f da 7f 30 c1 be 7e 12 46 c6 23',
|
||||
3056:'ad fd 38 68 b8 e5 14 85 d5 e6 10 01 7e 3d d6 09',
|
||||
3072:'ad 26 58 1c 0c 5b e4 5f 4c ea 01 db 2f 38 05 d5',
|
||||
4080:'f3 17 2c ef fc 3b 3d 99 7c 85 cc d5 af 1a 95 0c',
|
||||
4096:'e7 4b 0b 97 31 22 7f d3 7c 0e c0 8a 47 dd d8 b8'
|
||||
}
|
||||
),
|
||||
(
|
||||
'0102030405060708',
|
||||
{
|
||||
0: '97 ab 8a 1b f0 af b9 61 32 f2 f6 72 58 da 15 a8',
|
||||
16: '82 63 ef db 45 c4 a1 86 84 ef 87 e6 b1 9e 5b 09',
|
||||
240: '96 36 eb c9 84 19 26 f4 f7 d1 f3 62 bd df 6e 18',
|
||||
256: 'd0 a9 90 ff 2c 05 fe f5 b9 03 73 c9 ff 4b 87 0a',
|
||||
496: '73 23 9f 1d b7 f4 1d 80 b6 43 c0 c5 25 18 ec 63',
|
||||
512: '16 3b 31 99 23 a6 bd b4 52 7c 62 61 26 70 3c 0f',
|
||||
752: '49 d6 c8 af 0f 97 14 4a 87 df 21 d9 14 72 f9 66',
|
||||
768: '44 17 3a 10 3b 66 16 c5 d5 ad 1c ee 40 c8 63 d0',
|
||||
1008:'27 3c 9c 4b 27 f3 22 e4 e7 16 ef 53 a4 7d e7 a4',
|
||||
1024:'c6 d0 e7 b2 26 25 9f a9 02 34 90 b2 61 67 ad 1d',
|
||||
1520:'1f e8 98 67 13 f0 7c 3d 9a e1 c1 63 ff 8c f9 d3',
|
||||
1536:'83 69 e1 a9 65 61 0b e8 87 fb d0 c7 91 62 aa fb',
|
||||
2032:'0a 01 27 ab b4 44 84 b9 fb ef 5a bc ae 1b 57 9f',
|
||||
2048:'c2 cd ad c6 40 2e 8e e8 66 e1 f3 7b db 47 e4 2c',
|
||||
3056:'26 b5 1e a3 7d f8 e1 d6 f7 6f c3 b6 6a 74 29 b3',
|
||||
3072:'bc 76 83 20 5d 4f 44 3d c1 f2 9d da 33 15 c8 7b',
|
||||
4080:'d5 fa 5a 34 69 d2 9a aa f8 3d 23 58 9d b8 c8 5b',
|
||||
4096:'3f b4 6e 2c 8f 0f 06 8e dc e8 cd cd 7d fc 58 62'
|
||||
}
|
||||
),
|
||||
# Page 5
|
||||
(
|
||||
'0102030405060708090a',
|
||||
{
|
||||
0: 'ed e3 b0 46 43 e5 86 cc 90 7d c2 18 51 70 99 02',
|
||||
16: '03 51 6b a7 8f 41 3b eb 22 3a a5 d4 d2 df 67 11',
|
||||
240: '3c fd 6c b5 8e e0 fd de 64 01 76 ad 00 00 04 4d',
|
||||
256: '48 53 2b 21 fb 60 79 c9 11 4c 0f fd 9c 04 a1 ad',
|
||||
496: '3e 8c ea 98 01 71 09 97 90 84 b1 ef 92 f9 9d 86',
|
||||
512: 'e2 0f b4 9b db 33 7e e4 8b 8d 8d c0 f4 af ef fe',
|
||||
752: '5c 25 21 ea cd 79 66 f1 5e 05 65 44 be a0 d3 15',
|
||||
768: 'e0 67 a7 03 19 31 a2 46 a6 c3 87 5d 2f 67 8a cb',
|
||||
1008:'a6 4f 70 af 88 ae 56 b6 f8 75 81 c0 e2 3e 6b 08',
|
||||
1024:'f4 49 03 1d e3 12 81 4e c6 f3 19 29 1f 4a 05 16',
|
||||
1520:'bd ae 85 92 4b 3c b1 d0 a2 e3 3a 30 c6 d7 95 99',
|
||||
1536:'8a 0f ed db ac 86 5a 09 bc d1 27 fb 56 2e d6 0a',
|
||||
2032:'b5 5a 0a 5b 51 a1 2a 8b e3 48 99 c3 e0 47 51 1a',
|
||||
2048:'d9 a0 9c ea 3c e7 5f e3 96 98 07 03 17 a7 13 39',
|
||||
3056:'55 22 25 ed 11 77 f4 45 84 ac 8c fa 6c 4e b5 fc',
|
||||
3072:'7e 82 cb ab fc 95 38 1b 08 09 98 44 21 29 c2 f8',
|
||||
4080:'1f 13 5e d1 4c e6 0a 91 36 9d 23 22 be f2 5e 3c',
|
||||
4096:'08 b6 be 45 12 4a 43 e2 eb 77 95 3f 84 dc 85 53'
|
||||
}
|
||||
),
|
||||
(
|
||||
'0102030405060708090a0b0c0d0e0f10',
|
||||
{
|
||||
0: '9a c7 cc 9a 60 9d 1e f7 b2 93 28 99 cd e4 1b 97',
|
||||
16: '52 48 c4 95 90 14 12 6a 6e 8a 84 f1 1d 1a 9e 1c',
|
||||
240: '06 59 02 e4 b6 20 f6 cc 36 c8 58 9f 66 43 2f 2b',
|
||||
256: 'd3 9d 56 6b c6 bc e3 01 07 68 15 15 49 f3 87 3f',
|
||||
496: 'b6 d1 e6 c4 a5 e4 77 1c ad 79 53 8d f2 95 fb 11',
|
||||
512: 'c6 8c 1d 5c 55 9a 97 41 23 df 1d bc 52 a4 3b 89',
|
||||
752: 'c5 ec f8 8d e8 97 fd 57 fe d3 01 70 1b 82 a2 59',
|
||||
768: 'ec cb e1 3d e1 fc c9 1c 11 a0 b2 6c 0b c8 fa 4d',
|
||||
1008:'e7 a7 25 74 f8 78 2a e2 6a ab cf 9e bc d6 60 65',
|
||||
1024:'bd f0 32 4e 60 83 dc c6 d3 ce dd 3c a8 c5 3c 16',
|
||||
1520:'b4 01 10 c4 19 0b 56 22 a9 61 16 b0 01 7e d2 97',
|
||||
1536:'ff a0 b5 14 64 7e c0 4f 63 06 b8 92 ae 66 11 81',
|
||||
2032:'d0 3d 1b c0 3c d3 3d 70 df f9 fa 5d 71 96 3e bd',
|
||||
2048:'8a 44 12 64 11 ea a7 8b d5 1e 8d 87 a8 87 9b f5',
|
||||
3056:'fa be b7 60 28 ad e2 d0 e4 87 22 e4 6c 46 15 a3',
|
||||
3072:'c0 5d 88 ab d5 03 57 f9 35 a6 3c 59 ee 53 76 23',
|
||||
4080:'ff 38 26 5c 16 42 c1 ab e8 d3 c2 fe 5e 57 2b f8',
|
||||
4096:'a3 6a 4c 30 1a e8 ac 13 61 0c cb c1 22 56 ca cc'
|
||||
}
|
||||
),
|
||||
# Page 6
|
||||
(
|
||||
'0102030405060708090a0b0c0d0e0f101112131415161718',
|
||||
{
|
||||
0: '05 95 e5 7f e5 f0 bb 3c 70 6e da c8 a4 b2 db 11',
|
||||
16: 'df de 31 34 4a 1a f7 69 c7 4f 07 0a ee 9e 23 26',
|
||||
240: 'b0 6b 9b 1e 19 5d 13 d8 f4 a7 99 5c 45 53 ac 05',
|
||||
256: '6b d2 37 8e c3 41 c9 a4 2f 37 ba 79 f8 8a 32 ff',
|
||||
496: 'e7 0b ce 1d f7 64 5a db 5d 2c 41 30 21 5c 35 22',
|
||||
512: '9a 57 30 c7 fc b4 c9 af 51 ff da 89 c7 f1 ad 22',
|
||||
752: '04 85 05 5f d4 f6 f0 d9 63 ef 5a b9 a5 47 69 82',
|
||||
768: '59 1f c6 6b cd a1 0e 45 2b 03 d4 55 1f 6b 62 ac',
|
||||
1008:'27 53 cc 83 98 8a fa 3e 16 88 a1 d3 b4 2c 9a 02',
|
||||
1024:'93 61 0d 52 3d 1d 3f 00 62 b3 c2 a3 bb c7 c7 f0',
|
||||
1520:'96 c2 48 61 0a ad ed fe af 89 78 c0 3d e8 20 5a',
|
||||
1536:'0e 31 7b 3d 1c 73 b9 e9 a4 68 8f 29 6d 13 3a 19',
|
||||
2032:'bd f0 e6 c3 cc a5 b5 b9 d5 33 b6 9c 56 ad a1 20',
|
||||
2048:'88 a2 18 b6 e2 ec e1 e6 24 6d 44 c7 59 d1 9b 10',
|
||||
3056:'68 66 39 7e 95 c1 40 53 4f 94 26 34 21 00 6e 40',
|
||||
3072:'32 cb 0a 1e 95 42 c6 b3 b8 b3 98 ab c3 b0 f1 d5',
|
||||
4080:'29 a0 b8 ae d5 4a 13 23 24 c6 2e 42 3f 54 b4 c8',
|
||||
4096:'3c b0 f3 b5 02 0a 98 b8 2a f9 fe 15 44 84 a1 68'
|
||||
}
|
||||
),
|
||||
(
|
||||
'0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20',
|
||||
{
|
||||
0: 'ea a6 bd 25 88 0b f9 3d 3f 5d 1e 4c a2 61 1d 91',
|
||||
16: 'cf a4 5c 9f 7e 71 4b 54 bd fa 80 02 7c b1 43 80',
|
||||
240: '11 4a e3 44 de d7 1b 35 f2 e6 0f eb ad 72 7f d8',
|
||||
256: '02 e1 e7 05 6b 0f 62 39 00 49 64 22 94 3e 97 b6',
|
||||
496: '91 cb 93 c7 87 96 4e 10 d9 52 7d 99 9c 6f 93 6b',
|
||||
512: '49 b1 8b 42 f8 e8 36 7c be b5 ef 10 4b a1 c7 cd',
|
||||
752: '87 08 4b 3b a7 00 ba de 95 56 10 67 27 45 b3 74',
|
||||
768: 'e7 a7 b9 e9 ec 54 0d 5f f4 3b db 12 79 2d 1b 35',
|
||||
1008:'c7 99 b5 96 73 8f 6b 01 8c 76 c7 4b 17 59 bd 90',
|
||||
1024:'7f ec 5b fd 9f 9b 89 ce 65 48 30 90 92 d7 e9 58',
|
||||
1520:'40 f2 50 b2 6d 1f 09 6a 4a fd 4c 34 0a 58 88 15',
|
||||
1536:'3e 34 13 5c 79 db 01 02 00 76 76 51 cf 26 30 73',
|
||||
2032:'f6 56 ab cc f8 8d d8 27 02 7b 2c e9 17 d4 64 ec',
|
||||
2048:'18 b6 25 03 bf bc 07 7f ba bb 98 f2 0d 98 ab 34',
|
||||
3056:'8a ed 95 ee 5b 0d cb fb ef 4e b2 1d 3a 3f 52 f9',
|
||||
3072:'62 5a 1a b0 0e e3 9a 53 27 34 6b dd b0 1a 9c 18',
|
||||
4080:'a1 3a 7c 79 c7 e1 19 b5 ab 02 96 ab 28 c3 00 b9',
|
||||
4096:'f3 e4 c0 a2 e0 2d 1d 01 f7 f0 a7 46 18 af 2b 48'
|
||||
}
|
||||
),
|
||||
# Page 7
|
||||
(
|
||||
'833222772a',
|
||||
{
|
||||
0: '80 ad 97 bd c9 73 df 8a 2e 87 9e 92 a4 97 ef da',
|
||||
16: '20 f0 60 c2 f2 e5 12 65 01 d3 d4 fe a1 0d 5f c0',
|
||||
240: 'fa a1 48 e9 90 46 18 1f ec 6b 20 85 f3 b2 0e d9',
|
||||
256: 'f0 da f5 ba b3 d5 96 83 98 57 84 6f 73 fb fe 5a',
|
||||
496: '1c 7e 2f c4 63 92 32 fe 29 75 84 b2 96 99 6b c8',
|
||||
512: '3d b9 b2 49 40 6c c8 ed ff ac 55 cc d3 22 ba 12',
|
||||
752: 'e4 f9 f7 e0 06 61 54 bb d1 25 b7 45 56 9b c8 97',
|
||||
768: '75 d5 ef 26 2b 44 c4 1a 9c f6 3a e1 45 68 e1 b9',
|
||||
1008:'6d a4 53 db f8 1e 82 33 4a 3d 88 66 cb 50 a1 e3',
|
||||
1024:'78 28 d0 74 11 9c ab 5c 22 b2 94 d7 a9 bf a0 bb',
|
||||
1520:'ad b8 9c ea 9a 15 fb e6 17 29 5b d0 4b 8c a0 5c',
|
||||
1536:'62 51 d8 7f d4 aa ae 9a 7e 4a d5 c2 17 d3 f3 00',
|
||||
2032:'e7 11 9b d6 dd 9b 22 af e8 f8 95 85 43 28 81 e2',
|
||||
2048:'78 5b 60 fd 7e c4 e9 fc b6 54 5f 35 0d 66 0f ab',
|
||||
3056:'af ec c0 37 fd b7 b0 83 8e b3 d7 0b cd 26 83 82',
|
||||
3072:'db c1 a7 b4 9d 57 35 8c c9 fa 6d 61 d7 3b 7c f0',
|
||||
4080:'63 49 d1 26 a3 7a fc ba 89 79 4f 98 04 91 4f dc',
|
||||
4096:'bf 42 c3 01 8c 2f 7c 66 bf de 52 49 75 76 81 15'
|
||||
}
|
||||
),
|
||||
(
|
||||
'1910833222772a',
|
||||
{
|
||||
0: 'bc 92 22 db d3 27 4d 8f c6 6d 14 cc bd a6 69 0b',
|
||||
16: '7a e6 27 41 0c 9a 2b e6 93 df 5b b7 48 5a 63 e3',
|
||||
240: '3f 09 31 aa 03 de fb 30 0f 06 01 03 82 6f 2a 64',
|
||||
256: 'be aa 9e c8 d5 9b b6 81 29 f3 02 7c 96 36 11 81',
|
||||
496: '74 e0 4d b4 6d 28 64 8d 7d ee 8a 00 64 b0 6c fe',
|
||||
512: '9b 5e 81 c6 2f e0 23 c5 5b e4 2f 87 bb f9 32 b8',
|
||||
752: 'ce 17 8f c1 82 6e fe cb c1 82 f5 79 99 a4 61 40',
|
||||
768: '8b df 55 cd 55 06 1c 06 db a6 be 11 de 4a 57 8a',
|
||||
1008:'62 6f 5f 4d ce 65 25 01 f3 08 7d 39 c9 2c c3 49',
|
||||
1024:'42 da ac 6a 8f 9a b9 a7 fd 13 7c 60 37 82 56 82',
|
||||
1520:'cc 03 fd b7 91 92 a2 07 31 2f 53 f5 d4 dc 33 d9',
|
||||
1536:'f7 0f 14 12 2a 1c 98 a3 15 5d 28 b8 a0 a8 a4 1d',
|
||||
2032:'2a 3a 30 7a b2 70 8a 9c 00 fe 0b 42 f9 c2 d6 a1',
|
||||
2048:'86 26 17 62 7d 22 61 ea b0 b1 24 65 97 ca 0a e9',
|
||||
3056:'55 f8 77 ce 4f 2e 1d db bf 8e 13 e2 cd e0 fd c8',
|
||||
3072:'1b 15 56 cb 93 5f 17 33 37 70 5f bb 5d 50 1f c1',
|
||||
4080:'ec d0 e9 66 02 be 7f 8d 50 92 81 6c cc f2 c2 e9',
|
||||
4096:'02 78 81 fa b4 99 3a 1c 26 20 24 a9 4f ff 3f 61'
|
||||
}
|
||||
),
|
||||
# Page 8
|
||||
(
|
||||
'641910833222772a',
|
||||
{
|
||||
0: 'bb f6 09 de 94 13 17 2d 07 66 0c b6 80 71 69 26',
|
||||
16: '46 10 1a 6d ab 43 11 5d 6c 52 2b 4f e9 36 04 a9',
|
||||
240: 'cb e1 ff f2 1c 96 f3 ee f6 1e 8f e0 54 2c bd f0',
|
||||
256: '34 79 38 bf fa 40 09 c5 12 cf b4 03 4b 0d d1 a7',
|
||||
496: '78 67 a7 86 d0 0a 71 47 90 4d 76 dd f1 e5 20 e3',
|
||||
512: '8d 3e 9e 1c ae fc cc b3 fb f8 d1 8f 64 12 0b 32',
|
||||
752: '94 23 37 f8 fd 76 f0 fa e8 c5 2d 79 54 81 06 72',
|
||||
768: 'b8 54 8c 10 f5 16 67 f6 e6 0e 18 2f a1 9b 30 f7',
|
||||
1008:'02 11 c7 c6 19 0c 9e fd 12 37 c3 4c 8f 2e 06 c4',
|
||||
1024:'bd a6 4f 65 27 6d 2a ac b8 f9 02 12 20 3a 80 8e',
|
||||
1520:'bd 38 20 f7 32 ff b5 3e c1 93 e7 9d 33 e2 7c 73',
|
||||
1536:'d0 16 86 16 86 19 07 d4 82 e3 6c da c8 cf 57 49',
|
||||
2032:'97 b0 f0 f2 24 b2 d2 31 71 14 80 8f b0 3a f7 a0',
|
||||
2048:'e5 96 16 e4 69 78 79 39 a0 63 ce ea 9a f9 56 d1',
|
||||
3056:'c4 7e 0d c1 66 09 19 c1 11 01 20 8f 9e 69 aa 1f',
|
||||
3072:'5a e4 f1 28 96 b8 37 9a 2a ad 89 b5 b5 53 d6 b0',
|
||||
4080:'6b 6b 09 8d 0c 29 3b c2 99 3d 80 bf 05 18 b6 d9',
|
||||
4096:'81 70 cc 3c cd 92 a6 98 62 1b 93 9d d3 8f e7 b9'
|
||||
}
|
||||
),
|
||||
(
|
||||
'8b37641910833222772a',
|
||||
{
|
||||
0: 'ab 65 c2 6e dd b2 87 60 0d b2 fd a1 0d 1e 60 5c',
|
||||
16: 'bb 75 90 10 c2 96 58 f2 c7 2d 93 a2 d1 6d 29 30',
|
||||
240: 'b9 01 e8 03 6e d1 c3 83 cd 3c 4c 4d d0 a6 ab 05',
|
||||
256: '3d 25 ce 49 22 92 4c 55 f0 64 94 33 53 d7 8a 6c',
|
||||
496: '12 c1 aa 44 bb f8 7e 75 e6 11 f6 9b 2c 38 f4 9b',
|
||||
512: '28 f2 b3 43 4b 65 c0 98 77 47 00 44 c6 ea 17 0d',
|
||||
752: 'bd 9e f8 22 de 52 88 19 61 34 cf 8a f7 83 93 04',
|
||||
768: '67 55 9c 23 f0 52 15 84 70 a2 96 f7 25 73 5a 32',
|
||||
1008:'8b ab 26 fb c2 c1 2b 0f 13 e2 ab 18 5e ab f2 41',
|
||||
1024:'31 18 5a 6d 69 6f 0c fa 9b 42 80 8b 38 e1 32 a2',
|
||||
1520:'56 4d 3d ae 18 3c 52 34 c8 af 1e 51 06 1c 44 b5',
|
||||
1536:'3c 07 78 a7 b5 f7 2d 3c 23 a3 13 5c 7d 67 b9 f4',
|
||||
2032:'f3 43 69 89 0f cf 16 fb 51 7d ca ae 44 63 b2 dd',
|
||||
2048:'02 f3 1c 81 e8 20 07 31 b8 99 b0 28 e7 91 bf a7',
|
||||
3056:'72 da 64 62 83 22 8c 14 30 08 53 70 17 95 61 6f',
|
||||
3072:'4e 0a 8c 6f 79 34 a7 88 e2 26 5e 81 d6 d0 c8 f4',
|
||||
4080:'43 8d d5 ea fe a0 11 1b 6f 36 b4 b9 38 da 2a 68',
|
||||
4096:'5f 6b fc 73 81 58 74 d9 71 00 f0 86 97 93 57 d8'
|
||||
}
|
||||
),
|
||||
# Page 9
|
||||
(
|
||||
'ebb46227c6cc8b37641910833222772a',
|
||||
{
|
||||
0: '72 0c 94 b6 3e df 44 e1 31 d9 50 ca 21 1a 5a 30',
|
||||
16: 'c3 66 fd ea cf 9c a8 04 36 be 7c 35 84 24 d2 0b',
|
||||
240: 'b3 39 4a 40 aa bf 75 cb a4 22 82 ef 25 a0 05 9f',
|
||||
256: '48 47 d8 1d a4 94 2d bc 24 9d ef c4 8c 92 2b 9f',
|
||||
496: '08 12 8c 46 9f 27 53 42 ad da 20 2b 2b 58 da 95',
|
||||
512: '97 0d ac ef 40 ad 98 72 3b ac 5d 69 55 b8 17 61',
|
||||
752: '3c b8 99 93 b0 7b 0c ed 93 de 13 d2 a1 10 13 ac',
|
||||
768: 'ef 2d 67 6f 15 45 c2 c1 3d c6 80 a0 2f 4a db fe',
|
||||
1008:'b6 05 95 51 4f 24 bc 9f e5 22 a6 ca d7 39 36 44',
|
||||
1024:'b5 15 a8 c5 01 17 54 f5 90 03 05 8b db 81 51 4e',
|
||||
1520:'3c 70 04 7e 8c bc 03 8e 3b 98 20 db 60 1d a4 95',
|
||||
1536:'11 75 da 6e e7 56 de 46 a5 3e 2b 07 56 60 b7 70',
|
||||
2032:'00 a5 42 bb a0 21 11 cc 2c 65 b3 8e bd ba 58 7e',
|
||||
2048:'58 65 fd bb 5b 48 06 41 04 e8 30 b3 80 f2 ae de',
|
||||
3056:'34 b2 1a d2 ad 44 e9 99 db 2d 7f 08 63 f0 d9 b6',
|
||||
3072:'84 a9 21 8f c3 6e 8a 5f 2c cf be ae 53 a2 7d 25',
|
||||
4080:'a2 22 1a 11 b8 33 cc b4 98 a5 95 40 f0 54 5f 4a',
|
||||
4096:'5b be b4 78 7d 59 e5 37 3f db ea 6c 6f 75 c2 9b'
|
||||
}
|
||||
),
|
||||
(
|
||||
'c109163908ebe51debb46227c6cc8b37641910833222772a',
|
||||
{
|
||||
0: '54 b6 4e 6b 5a 20 b5 e2 ec 84 59 3d c7 98 9d a7',
|
||||
16: 'c1 35 ee e2 37 a8 54 65 ff 97 dc 03 92 4f 45 ce',
|
||||
240: 'cf cc 92 2f b4 a1 4a b4 5d 61 75 aa bb f2 d2 01',
|
||||
256: '83 7b 87 e2 a4 46 ad 0e f7 98 ac d0 2b 94 12 4f',
|
||||
496: '17 a6 db d6 64 92 6a 06 36 b3 f4 c3 7a 4f 46 94',
|
||||
512: '4a 5f 9f 26 ae ee d4 d4 a2 5f 63 2d 30 52 33 d9',
|
||||
752: '80 a3 d0 1e f0 0c 8e 9a 42 09 c1 7f 4e eb 35 8c',
|
||||
768: 'd1 5e 7d 5f fa aa bc 02 07 bf 20 0a 11 77 93 a2',
|
||||
1008:'34 96 82 bf 58 8e aa 52 d0 aa 15 60 34 6a ea fa',
|
||||
1024:'f5 85 4c db 76 c8 89 e3 ad 63 35 4e 5f 72 75 e3',
|
||||
1520:'53 2c 7c ec cb 39 df 32 36 31 84 05 a4 b1 27 9c',
|
||||
1536:'ba ef e6 d9 ce b6 51 84 22 60 e0 d1 e0 5e 3b 90',
|
||||
2032:'e8 2d 8c 6d b5 4e 3c 63 3f 58 1c 95 2b a0 42 07',
|
||||
2048:'4b 16 e5 0a bd 38 1b d7 09 00 a9 cd 9a 62 cb 23',
|
||||
3056:'36 82 ee 33 bd 14 8b d9 f5 86 56 cd 8f 30 d9 fb',
|
||||
3072:'1e 5a 0b 84 75 04 5d 9b 20 b2 62 86 24 ed fd 9e',
|
||||
4080:'63 ed d6 84 fb 82 62 82 fe 52 8f 9c 0e 92 37 bc',
|
||||
4096:'e4 dd 2e 98 d6 96 0f ae 0b 43 54 54 56 74 33 91'
|
||||
}
|
||||
),
|
||||
# Page 10
|
||||
(
|
||||
'1ada31d5cf688221c109163908ebe51debb46227c6cc8b37641910833222772a',
|
||||
{
|
||||
0: 'dd 5b cb 00 18 e9 22 d4 94 75 9d 7c 39 5d 02 d3',
|
||||
16: 'c8 44 6f 8f 77 ab f7 37 68 53 53 eb 89 a1 c9 eb',
|
||||
240: 'af 3e 30 f9 c0 95 04 59 38 15 15 75 c3 fb 90 98',
|
||||
256: 'f8 cb 62 74 db 99 b8 0b 1d 20 12 a9 8e d4 8f 0e',
|
||||
496: '25 c3 00 5a 1c b8 5d e0 76 25 98 39 ab 71 98 ab',
|
||||
512: '9d cb c1 83 e8 cb 99 4b 72 7b 75 be 31 80 76 9c',
|
||||
752: 'a1 d3 07 8d fa 91 69 50 3e d9 d4 49 1d ee 4e b2',
|
||||
768: '85 14 a5 49 58 58 09 6f 59 6e 4b cd 66 b1 06 65',
|
||||
1008:'5f 40 d5 9e c1 b0 3b 33 73 8e fa 60 b2 25 5d 31',
|
||||
1024:'34 77 c7 f7 64 a4 1b ac ef f9 0b f1 4f 92 b7 cc',
|
||||
1520:'ac 4e 95 36 8d 99 b9 eb 78 b8 da 8f 81 ff a7 95',
|
||||
1536:'8c 3c 13 f8 c2 38 8b b7 3f 38 57 6e 65 b7 c4 46',
|
||||
2032:'13 c4 b9 c1 df b6 65 79 ed dd 8a 28 0b 9f 73 16',
|
||||
2048:'dd d2 78 20 55 01 26 69 8e fa ad c6 4b 64 f6 6e',
|
||||
3056:'f0 8f 2e 66 d2 8e d1 43 f3 a2 37 cf 9d e7 35 59',
|
||||
3072:'9e a3 6c 52 55 31 b8 80 ba 12 43 34 f5 7b 0b 70',
|
||||
4080:'d5 a3 9e 3d fc c5 02 80 ba c4 a6 b5 aa 0d ca 7d',
|
||||
4096:'37 0b 1c 1f e6 55 91 6d 97 fd 0d 47 ca 1d 72 b8'
|
||||
}
|
||||
)
|
||||
]
|
||||
|
||||
def test_keystream(self):
|
||||
for tv in self.rfc6229_data:
|
||||
key = unhexlify(b((tv[0])))
|
||||
cipher = ARC4.new(key)
|
||||
count = 0
|
||||
for offset in range(0,4096+1,16):
|
||||
ct = cipher.encrypt(b('\x00')*16)
|
||||
expected = tv[1].get(offset)
|
||||
if expected:
|
||||
expected = unhexlify(b(expected.replace(" ",'')))
|
||||
self.assertEqual(ct, expected)
|
||||
count += 1
|
||||
self.assertEqual(count, len(tv[1]))
|
||||
|
||||
class Drop_Tests(unittest.TestCase):
|
||||
key = b('\xAA')*16
|
||||
data = b('\x00')*5000
|
||||
|
||||
def setUp(self):
|
||||
self.cipher = ARC4.new(self.key)
|
||||
|
||||
def test_drop256_encrypt(self):
|
||||
cipher_drop = ARC4.new(self.key, 256)
|
||||
ct_drop = cipher_drop.encrypt(self.data[:16])
|
||||
ct = self.cipher.encrypt(self.data)[256:256+16]
|
||||
self.assertEqual(ct_drop, ct)
|
||||
|
||||
def test_drop256_decrypt(self):
|
||||
cipher_drop = ARC4.new(self.key, 256)
|
||||
pt_drop = cipher_drop.decrypt(self.data[:16])
|
||||
pt = self.cipher.decrypt(self.data)[256:256+16]
|
||||
self.assertEqual(pt_drop, pt)
|
||||
|
||||
class KeyLength(unittest.TestCase):
|
||||
|
||||
def runTest(self):
|
||||
self.assertRaises(ValueError, ARC4.new, bchr(0) * 4)
|
||||
self.assertRaises(ValueError, ARC4.new, bchr(0) * 257)
|
||||
|
||||
def get_tests(config={}):
|
||||
from .common import make_stream_tests
|
||||
tests = make_stream_tests(ARC4, "ARC4", test_data)
|
||||
tests += list_test_cases(RFC6229_Tests)
|
||||
tests += list_test_cases(Drop_Tests)
|
||||
tests.append(KeyLength())
|
||||
return tests
|
||||
|
||||
if __name__ == '__main__':
|
||||
import unittest
|
||||
suite = lambda: unittest.TestSuite(get_tests())
|
||||
unittest.main(defaultTest='suite')
|
||||
|
||||
# vim:set ts=4 sw=4 sts=4 expandtab:
|
124
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_Blowfish.py
Normal file
124
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_Blowfish.py
Normal file
|
@ -0,0 +1,124 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# SelfTest/Cipher/test_Blowfish.py: Self-test for the Blowfish cipher
|
||||
#
|
||||
# Written in 2008 by Dwayne C. Litzenberger <dlitz@dlitz.net>
|
||||
#
|
||||
# ===================================================================
|
||||
# The contents of this file are dedicated to the public domain. To
|
||||
# the extent that dedication to the public domain is not available,
|
||||
# everyone is granted a worldwide, perpetual, royalty-free,
|
||||
# non-exclusive license to exercise all rights associated with the
|
||||
# contents of this file for any purpose whatsoever.
|
||||
# No rights are reserved.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
# ===================================================================
|
||||
|
||||
"""Self-test suite for Crypto.Cipher.Blowfish"""
|
||||
|
||||
import unittest
|
||||
|
||||
from Crypto.Util.py3compat import bchr
|
||||
|
||||
from Crypto.Cipher import Blowfish
|
||||
|
||||
# This is a list of (plaintext, ciphertext, key) tuples.
|
||||
test_data = [
|
||||
# Test vectors from http://www.schneier.com/code/vectors.txt
|
||||
('0000000000000000', '4ef997456198dd78', '0000000000000000'),
|
||||
('ffffffffffffffff', '51866fd5b85ecb8a', 'ffffffffffffffff'),
|
||||
('1000000000000001', '7d856f9a613063f2', '3000000000000000'),
|
||||
('1111111111111111', '2466dd878b963c9d', '1111111111111111'),
|
||||
('1111111111111111', '61f9c3802281b096', '0123456789abcdef'),
|
||||
('0123456789abcdef', '7d0cc630afda1ec7', '1111111111111111'),
|
||||
('0000000000000000', '4ef997456198dd78', '0000000000000000'),
|
||||
('0123456789abcdef', '0aceab0fc6a0a28d', 'fedcba9876543210'),
|
||||
('01a1d6d039776742', '59c68245eb05282b', '7ca110454a1a6e57'),
|
||||
('5cd54ca83def57da', 'b1b8cc0b250f09a0', '0131d9619dc1376e'),
|
||||
('0248d43806f67172', '1730e5778bea1da4', '07a1133e4a0b2686'),
|
||||
('51454b582ddf440a', 'a25e7856cf2651eb', '3849674c2602319e'),
|
||||
('42fd443059577fa2', '353882b109ce8f1a', '04b915ba43feb5b6'),
|
||||
('059b5e0851cf143a', '48f4d0884c379918', '0113b970fd34f2ce'),
|
||||
('0756d8e0774761d2', '432193b78951fc98', '0170f175468fb5e6'),
|
||||
('762514b829bf486a', '13f04154d69d1ae5', '43297fad38e373fe'),
|
||||
('3bdd119049372802', '2eedda93ffd39c79', '07a7137045da2a16'),
|
||||
('26955f6835af609a', 'd887e0393c2da6e3', '04689104c2fd3b2f'),
|
||||
('164d5e404f275232', '5f99d04f5b163969', '37d06bb516cb7546'),
|
||||
('6b056e18759f5cca', '4a057a3b24d3977b', '1f08260d1ac2465e'),
|
||||
('004bd6ef09176062', '452031c1e4fada8e', '584023641aba6176'),
|
||||
('480d39006ee762f2', '7555ae39f59b87bd', '025816164629b007'),
|
||||
('437540c8698f3cfa', '53c55f9cb49fc019', '49793ebc79b3258f'),
|
||||
('072d43a077075292', '7a8e7bfa937e89a3', '4fb05e1515ab73a7'),
|
||||
('02fe55778117f12a', 'cf9c5d7a4986adb5', '49e95d6d4ca229bf'),
|
||||
('1d9d5c5018f728c2', 'd1abb290658bc778', '018310dc409b26d6'),
|
||||
('305532286d6f295a', '55cb3774d13ef201', '1c587f1c13924fef'),
|
||||
('0123456789abcdef', 'fa34ec4847b268b2', '0101010101010101'),
|
||||
('0123456789abcdef', 'a790795108ea3cae', '1f1f1f1f0e0e0e0e'),
|
||||
('0123456789abcdef', 'c39e072d9fac631d', 'e0fee0fef1fef1fe'),
|
||||
('ffffffffffffffff', '014933e0cdaff6e4', '0000000000000000'),
|
||||
('0000000000000000', 'f21e9a77b71c49bc', 'ffffffffffffffff'),
|
||||
('0000000000000000', '245946885754369a', '0123456789abcdef'),
|
||||
('ffffffffffffffff', '6b5c5a9c5d9e0a5a', 'fedcba9876543210'),
|
||||
#('fedcba9876543210', 'f9ad597c49db005e', 'f0'),
|
||||
#('fedcba9876543210', 'e91d21c1d961a6d6', 'f0e1'),
|
||||
#('fedcba9876543210', 'e9c2b70a1bc65cf3', 'f0e1d2'),
|
||||
#('fedcba9876543210', 'be1e639408640f05', 'f0e1d2c3'),
|
||||
('fedcba9876543210', 'b39e44481bdb1e6e', 'f0e1d2c3b4'),
|
||||
('fedcba9876543210', '9457aa83b1928c0d', 'f0e1d2c3b4a5'),
|
||||
('fedcba9876543210', '8bb77032f960629d', 'f0e1d2c3b4a596'),
|
||||
('fedcba9876543210', 'e87a244e2cc85e82', 'f0e1d2c3b4a59687'),
|
||||
('fedcba9876543210', '15750e7a4f4ec577', 'f0e1d2c3b4a5968778'),
|
||||
('fedcba9876543210', '122ba70b3ab64ae0', 'f0e1d2c3b4a596877869'),
|
||||
('fedcba9876543210', '3a833c9affc537f6', 'f0e1d2c3b4a5968778695a'),
|
||||
('fedcba9876543210', '9409da87a90f6bf2', 'f0e1d2c3b4a5968778695a4b'),
|
||||
('fedcba9876543210', '884f80625060b8b4', 'f0e1d2c3b4a5968778695a4b3c'),
|
||||
('fedcba9876543210', '1f85031c19e11968', 'f0e1d2c3b4a5968778695a4b3c2d'),
|
||||
('fedcba9876543210', '79d9373a714ca34f', 'f0e1d2c3b4a5968778695a4b3c2d1e'),
|
||||
('fedcba9876543210', '93142887ee3be15c',
|
||||
'f0e1d2c3b4a5968778695a4b3c2d1e0f'),
|
||||
('fedcba9876543210', '03429e838ce2d14b',
|
||||
'f0e1d2c3b4a5968778695a4b3c2d1e0f00'),
|
||||
('fedcba9876543210', 'a4299e27469ff67b',
|
||||
'f0e1d2c3b4a5968778695a4b3c2d1e0f0011'),
|
||||
('fedcba9876543210', 'afd5aed1c1bc96a8',
|
||||
'f0e1d2c3b4a5968778695a4b3c2d1e0f001122'),
|
||||
('fedcba9876543210', '10851c0e3858da9f',
|
||||
'f0e1d2c3b4a5968778695a4b3c2d1e0f00112233'),
|
||||
('fedcba9876543210', 'e6f51ed79b9db21f',
|
||||
'f0e1d2c3b4a5968778695a4b3c2d1e0f0011223344'),
|
||||
('fedcba9876543210', '64a6e14afd36b46f',
|
||||
'f0e1d2c3b4a5968778695a4b3c2d1e0f001122334455'),
|
||||
('fedcba9876543210', '80c7d7d45a5479ad',
|
||||
'f0e1d2c3b4a5968778695a4b3c2d1e0f00112233445566'),
|
||||
('fedcba9876543210', '05044b62fa52d080',
|
||||
'f0e1d2c3b4a5968778695a4b3c2d1e0f0011223344556677'),
|
||||
]
|
||||
|
||||
|
||||
class KeyLength(unittest.TestCase):
|
||||
|
||||
def runTest(self):
|
||||
self.assertRaises(ValueError, Blowfish.new, bchr(0) * 4,
|
||||
Blowfish.MODE_ECB)
|
||||
self.assertRaises(ValueError, Blowfish.new, bchr(0) * 57,
|
||||
Blowfish.MODE_ECB)
|
||||
|
||||
def get_tests(config={}):
|
||||
from .common import make_block_tests
|
||||
tests = make_block_tests(Blowfish, "Blowfish", test_data)
|
||||
tests.append(KeyLength())
|
||||
return tests
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import unittest
|
||||
suite = lambda: unittest.TestSuite(get_tests())
|
||||
unittest.main(defaultTest='suite')
|
66
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_CAST.py
Normal file
66
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_CAST.py
Normal file
|
@ -0,0 +1,66 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# SelfTest/Cipher/CAST.py: Self-test for the CAST-128 (CAST5) cipher
|
||||
#
|
||||
# Written in 2008 by Dwayne C. Litzenberger <dlitz@dlitz.net>
|
||||
#
|
||||
# ===================================================================
|
||||
# The contents of this file are dedicated to the public domain. To
|
||||
# the extent that dedication to the public domain is not available,
|
||||
# everyone is granted a worldwide, perpetual, royalty-free,
|
||||
# non-exclusive license to exercise all rights associated with the
|
||||
# contents of this file for any purpose whatsoever.
|
||||
# No rights are reserved.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
# ===================================================================
|
||||
|
||||
"""Self-test suite for Crypto.Cipher.CAST"""
|
||||
|
||||
import unittest
|
||||
|
||||
from Crypto.Util.py3compat import bchr
|
||||
|
||||
from Crypto.Cipher import CAST
|
||||
|
||||
# This is a list of (plaintext, ciphertext, key) tuples.
|
||||
test_data = [
|
||||
# Test vectors from RFC 2144, B.1
|
||||
('0123456789abcdef', '238b4fe5847e44b2',
|
||||
'0123456712345678234567893456789a',
|
||||
'128-bit key'),
|
||||
|
||||
('0123456789abcdef', 'eb6a711a2c02271b',
|
||||
'01234567123456782345',
|
||||
'80-bit key'),
|
||||
|
||||
('0123456789abcdef', '7ac816d16e9b302e',
|
||||
'0123456712',
|
||||
'40-bit key'),
|
||||
]
|
||||
|
||||
|
||||
class KeyLength(unittest.TestCase):
|
||||
|
||||
def runTest(self):
|
||||
self.assertRaises(ValueError, CAST.new, bchr(0) * 4, CAST.MODE_ECB)
|
||||
self.assertRaises(ValueError, CAST.new, bchr(0) * 17, CAST.MODE_ECB)
|
||||
|
||||
|
||||
def get_tests(config={}):
|
||||
from .common import make_block_tests
|
||||
|
||||
tests = make_block_tests(CAST, "CAST", test_data)
|
||||
tests.append(KeyLength())
|
||||
return tests
|
||||
|
||||
if __name__ == '__main__':
|
||||
suite = lambda: unittest.TestSuite(get_tests())
|
||||
unittest.main(defaultTest='suite')
|
410
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_CBC.py
Normal file
410
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_CBC.py
Normal file
|
@ -0,0 +1,410 @@
|
|||
# ===================================================================
|
||||
#
|
||||
# Copyright (c) 2014, Legrandin <helderijs@gmail.com>
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
# ===================================================================
|
||||
|
||||
import unittest
|
||||
|
||||
from Crypto.SelfTest.loader import load_tests
|
||||
from Crypto.SelfTest.st_common import list_test_cases
|
||||
from Crypto.Util.py3compat import tobytes, b, unhexlify
|
||||
from Crypto.Cipher import AES, DES3, DES
|
||||
from Crypto.Hash import SHAKE128
|
||||
|
||||
def get_tag_random(tag, length):
|
||||
return SHAKE128.new(data=tobytes(tag)).read(length)
|
||||
|
||||
class BlockChainingTests(unittest.TestCase):
|
||||
|
||||
key_128 = get_tag_random("key_128", 16)
|
||||
key_192 = get_tag_random("key_192", 24)
|
||||
iv_128 = get_tag_random("iv_128", 16)
|
||||
iv_64 = get_tag_random("iv_64", 8)
|
||||
data_128 = get_tag_random("data_128", 16)
|
||||
|
||||
def test_loopback_128(self):
|
||||
cipher = AES.new(self.key_128, self.aes_mode, self.iv_128)
|
||||
pt = get_tag_random("plaintext", 16 * 100)
|
||||
ct = cipher.encrypt(pt)
|
||||
|
||||
cipher = AES.new(self.key_128, self.aes_mode, self.iv_128)
|
||||
pt2 = cipher.decrypt(ct)
|
||||
self.assertEqual(pt, pt2)
|
||||
|
||||
def test_loopback_64(self):
|
||||
cipher = DES3.new(self.key_192, self.des3_mode, self.iv_64)
|
||||
pt = get_tag_random("plaintext", 8 * 100)
|
||||
ct = cipher.encrypt(pt)
|
||||
|
||||
cipher = DES3.new(self.key_192, self.des3_mode, self.iv_64)
|
||||
pt2 = cipher.decrypt(ct)
|
||||
self.assertEqual(pt, pt2)
|
||||
|
||||
def test_iv(self):
|
||||
# If not passed, the iv is created randomly
|
||||
cipher = AES.new(self.key_128, self.aes_mode)
|
||||
iv1 = cipher.iv
|
||||
cipher = AES.new(self.key_128, self.aes_mode)
|
||||
iv2 = cipher.iv
|
||||
self.assertNotEqual(iv1, iv2)
|
||||
self.assertEqual(len(iv1), 16)
|
||||
|
||||
# IV can be passed in uppercase or lowercase
|
||||
cipher = AES.new(self.key_128, self.aes_mode, self.iv_128)
|
||||
ct = cipher.encrypt(self.data_128)
|
||||
|
||||
cipher = AES.new(self.key_128, self.aes_mode, iv=self.iv_128)
|
||||
self.assertEqual(ct, cipher.encrypt(self.data_128))
|
||||
|
||||
cipher = AES.new(self.key_128, self.aes_mode, IV=self.iv_128)
|
||||
self.assertEqual(ct, cipher.encrypt(self.data_128))
|
||||
|
||||
def test_iv_must_be_bytes(self):
|
||||
self.assertRaises(TypeError, AES.new, self.key_128, self.aes_mode,
|
||||
iv = 'test1234567890-*')
|
||||
|
||||
def test_only_one_iv(self):
|
||||
# Only one IV/iv keyword allowed
|
||||
self.assertRaises(TypeError, AES.new, self.key_128, self.aes_mode,
|
||||
iv=self.iv_128, IV=self.iv_128)
|
||||
|
||||
def test_iv_with_matching_length(self):
|
||||
self.assertRaises(ValueError, AES.new, self.key_128, self.aes_mode,
|
||||
b(""))
|
||||
self.assertRaises(ValueError, AES.new, self.key_128, self.aes_mode,
|
||||
self.iv_128[:15])
|
||||
self.assertRaises(ValueError, AES.new, self.key_128, self.aes_mode,
|
||||
self.iv_128 + b("0"))
|
||||
|
||||
def test_block_size_128(self):
|
||||
cipher = AES.new(self.key_128, self.aes_mode, self.iv_128)
|
||||
self.assertEqual(cipher.block_size, AES.block_size)
|
||||
|
||||
def test_block_size_64(self):
|
||||
cipher = DES3.new(self.key_192, self.des3_mode, self.iv_64)
|
||||
self.assertEqual(cipher.block_size, DES3.block_size)
|
||||
|
||||
def test_unaligned_data_128(self):
|
||||
cipher = AES.new(self.key_128, self.aes_mode, self.iv_128)
|
||||
for wrong_length in range(1,16):
|
||||
self.assertRaises(ValueError, cipher.encrypt, b("5") * wrong_length)
|
||||
|
||||
cipher = AES.new(self.key_128, self.aes_mode, self.iv_128)
|
||||
for wrong_length in range(1,16):
|
||||
self.assertRaises(ValueError, cipher.decrypt, b("5") * wrong_length)
|
||||
|
||||
def test_unaligned_data_64(self):
|
||||
cipher = DES3.new(self.key_192, self.des3_mode, self.iv_64)
|
||||
for wrong_length in range(1,8):
|
||||
self.assertRaises(ValueError, cipher.encrypt, b("5") * wrong_length)
|
||||
|
||||
cipher = DES3.new(self.key_192, self.des3_mode, self.iv_64)
|
||||
for wrong_length in range(1,8):
|
||||
self.assertRaises(ValueError, cipher.decrypt, b("5") * wrong_length)
|
||||
|
||||
def test_IV_iv_attributes(self):
|
||||
data = get_tag_random("data", 16 * 100)
|
||||
for func in "encrypt", "decrypt":
|
||||
cipher = AES.new(self.key_128, self.aes_mode, self.iv_128)
|
||||
getattr(cipher, func)(data)
|
||||
self.assertEqual(cipher.iv, self.iv_128)
|
||||
self.assertEqual(cipher.IV, self.iv_128)
|
||||
|
||||
def test_unknown_parameters(self):
|
||||
self.assertRaises(TypeError, AES.new, self.key_128, self.aes_mode,
|
||||
self.iv_128, 7)
|
||||
self.assertRaises(TypeError, AES.new, self.key_128, self.aes_mode,
|
||||
iv=self.iv_128, unknown=7)
|
||||
# But some are only known by the base cipher (e.g. use_aesni consumed by the AES module)
|
||||
AES.new(self.key_128, self.aes_mode, iv=self.iv_128, use_aesni=False)
|
||||
|
||||
def test_null_encryption_decryption(self):
|
||||
for func in "encrypt", "decrypt":
|
||||
cipher = AES.new(self.key_128, self.aes_mode, self.iv_128)
|
||||
result = getattr(cipher, func)(b(""))
|
||||
self.assertEqual(result, b(""))
|
||||
|
||||
def test_either_encrypt_or_decrypt(self):
|
||||
cipher = AES.new(self.key_128, self.aes_mode, self.iv_128)
|
||||
cipher.encrypt(b(""))
|
||||
self.assertRaises(TypeError, cipher.decrypt, b(""))
|
||||
|
||||
cipher = AES.new(self.key_128, self.aes_mode, self.iv_128)
|
||||
cipher.decrypt(b(""))
|
||||
self.assertRaises(TypeError, cipher.encrypt, b(""))
|
||||
|
||||
def test_data_must_be_bytes(self):
|
||||
cipher = AES.new(self.key_128, self.aes_mode, self.iv_128)
|
||||
self.assertRaises(TypeError, cipher.encrypt, 'test1234567890-*')
|
||||
|
||||
cipher = AES.new(self.key_128, self.aes_mode, self.iv_128)
|
||||
self.assertRaises(TypeError, cipher.decrypt, 'test1234567890-*')
|
||||
|
||||
|
||||
class CbcTests(BlockChainingTests):
|
||||
aes_mode = AES.MODE_CBC
|
||||
des3_mode = DES3.MODE_CBC
|
||||
|
||||
|
||||
class NistBlockChainingVectors(unittest.TestCase):
|
||||
|
||||
def _do_kat_aes_test(self, file_name):
|
||||
test_vectors = load_tests(("Crypto", "SelfTest", "Cipher", "test_vectors", "AES"),
|
||||
file_name,
|
||||
"AES KAT",
|
||||
{ "count" : lambda x: int(x) } )
|
||||
assert(test_vectors)
|
||||
|
||||
direction = None
|
||||
for tv in test_vectors:
|
||||
|
||||
# The test vector file contains some directive lines
|
||||
if isinstance(tv, str):
|
||||
direction = tv
|
||||
continue
|
||||
|
||||
self.description = tv.desc
|
||||
|
||||
cipher = AES.new(tv.key, self.aes_mode, tv.iv)
|
||||
if direction == "[ENCRYPT]":
|
||||
self.assertEqual(cipher.encrypt(tv.plaintext), tv.ciphertext)
|
||||
elif direction == "[DECRYPT]":
|
||||
self.assertEqual(cipher.decrypt(tv.ciphertext), tv.plaintext)
|
||||
else:
|
||||
assert False
|
||||
|
||||
# See Section 6.4.2 in AESAVS
|
||||
def _do_mct_aes_test(self, file_name):
|
||||
test_vectors = load_tests(("Crypto", "SelfTest", "Cipher", "test_vectors", "AES"),
|
||||
file_name,
|
||||
"AES Montecarlo",
|
||||
{ "count" : lambda x: int(x) } )
|
||||
assert(test_vectors)
|
||||
|
||||
direction = None
|
||||
for tv in test_vectors:
|
||||
|
||||
# The test vector file contains some directive lines
|
||||
if isinstance(tv, str):
|
||||
direction = tv
|
||||
continue
|
||||
|
||||
self.description = tv.desc
|
||||
cipher = AES.new(tv.key, self.aes_mode, tv.iv)
|
||||
|
||||
if direction == '[ENCRYPT]':
|
||||
cts = [ tv.iv ]
|
||||
for count in range(1000):
|
||||
cts.append(cipher.encrypt(tv.plaintext))
|
||||
tv.plaintext = cts[-2]
|
||||
self.assertEqual(cts[-1], tv.ciphertext)
|
||||
elif direction == '[DECRYPT]':
|
||||
pts = [ tv.iv]
|
||||
for count in range(1000):
|
||||
pts.append(cipher.decrypt(tv.ciphertext))
|
||||
tv.ciphertext = pts[-2]
|
||||
self.assertEqual(pts[-1], tv.plaintext)
|
||||
else:
|
||||
assert False
|
||||
|
||||
def _do_tdes_test(self, file_name):
|
||||
test_vectors = load_tests(("Crypto", "SelfTest", "Cipher", "test_vectors", "TDES"),
|
||||
file_name,
|
||||
"TDES CBC KAT",
|
||||
{ "count" : lambda x: int(x) } )
|
||||
assert(test_vectors)
|
||||
|
||||
direction = None
|
||||
for tv in test_vectors:
|
||||
|
||||
# The test vector file contains some directive lines
|
||||
if isinstance(tv, str):
|
||||
direction = tv
|
||||
continue
|
||||
|
||||
self.description = tv.desc
|
||||
if hasattr(tv, "keys"):
|
||||
cipher = DES.new(tv.keys, self.des_mode, tv.iv)
|
||||
else:
|
||||
if tv.key1 != tv.key3:
|
||||
key = tv.key1 + tv.key2 + tv.key3 # Option 3
|
||||
else:
|
||||
key = tv.key1 + tv.key2 # Option 2
|
||||
cipher = DES3.new(key, self.des3_mode, tv.iv)
|
||||
|
||||
if direction == "[ENCRYPT]":
|
||||
self.assertEqual(cipher.encrypt(tv.plaintext), tv.ciphertext)
|
||||
elif direction == "[DECRYPT]":
|
||||
self.assertEqual(cipher.decrypt(tv.ciphertext), tv.plaintext)
|
||||
else:
|
||||
assert False
|
||||
|
||||
|
||||
class NistCbcVectors(NistBlockChainingVectors):
|
||||
aes_mode = AES.MODE_CBC
|
||||
des_mode = DES.MODE_CBC
|
||||
des3_mode = DES3.MODE_CBC
|
||||
|
||||
|
||||
# Create one test method per file
|
||||
nist_aes_kat_mmt_files = (
|
||||
# KAT
|
||||
"CBCGFSbox128.rsp",
|
||||
"CBCGFSbox192.rsp",
|
||||
"CBCGFSbox256.rsp",
|
||||
"CBCKeySbox128.rsp",
|
||||
"CBCKeySbox192.rsp",
|
||||
"CBCKeySbox256.rsp",
|
||||
"CBCVarKey128.rsp",
|
||||
"CBCVarKey192.rsp",
|
||||
"CBCVarKey256.rsp",
|
||||
"CBCVarTxt128.rsp",
|
||||
"CBCVarTxt192.rsp",
|
||||
"CBCVarTxt256.rsp",
|
||||
# MMT
|
||||
"CBCMMT128.rsp",
|
||||
"CBCMMT192.rsp",
|
||||
"CBCMMT256.rsp",
|
||||
)
|
||||
nist_aes_mct_files = (
|
||||
"CBCMCT128.rsp",
|
||||
"CBCMCT192.rsp",
|
||||
"CBCMCT256.rsp",
|
||||
)
|
||||
|
||||
for file_name in nist_aes_kat_mmt_files:
|
||||
def new_func(self, file_name=file_name):
|
||||
self._do_kat_aes_test(file_name)
|
||||
setattr(NistCbcVectors, "test_AES_" + file_name, new_func)
|
||||
|
||||
for file_name in nist_aes_mct_files:
|
||||
def new_func(self, file_name=file_name):
|
||||
self._do_mct_aes_test(file_name)
|
||||
setattr(NistCbcVectors, "test_AES_" + file_name, new_func)
|
||||
del file_name, new_func
|
||||
|
||||
nist_tdes_files = (
|
||||
"TCBCMMT2.rsp", # 2TDES
|
||||
"TCBCMMT3.rsp", # 3TDES
|
||||
"TCBCinvperm.rsp", # Single DES
|
||||
"TCBCpermop.rsp",
|
||||
"TCBCsubtab.rsp",
|
||||
"TCBCvarkey.rsp",
|
||||
"TCBCvartext.rsp",
|
||||
)
|
||||
|
||||
for file_name in nist_tdes_files:
|
||||
def new_func(self, file_name=file_name):
|
||||
self._do_tdes_test(file_name)
|
||||
setattr(NistCbcVectors, "test_TDES_" + file_name, new_func)
|
||||
|
||||
# END OF NIST CBC TEST VECTORS
|
||||
|
||||
|
||||
class SP800TestVectors(unittest.TestCase):
|
||||
"""Class exercising the CBC test vectors found in Section F.2
|
||||
of NIST SP 800-3A"""
|
||||
|
||||
def test_aes_128(self):
|
||||
key = '2b7e151628aed2a6abf7158809cf4f3c'
|
||||
iv = '000102030405060708090a0b0c0d0e0f'
|
||||
plaintext = '6bc1bee22e409f96e93d7e117393172a' +\
|
||||
'ae2d8a571e03ac9c9eb76fac45af8e51' +\
|
||||
'30c81c46a35ce411e5fbc1191a0a52ef' +\
|
||||
'f69f2445df4f9b17ad2b417be66c3710'
|
||||
ciphertext = '7649abac8119b246cee98e9b12e9197d' +\
|
||||
'5086cb9b507219ee95db113a917678b2' +\
|
||||
'73bed6b8e3c1743b7116e69e22229516' +\
|
||||
'3ff1caa1681fac09120eca307586e1a7'
|
||||
|
||||
key = unhexlify(key)
|
||||
iv = unhexlify(iv)
|
||||
plaintext = unhexlify(plaintext)
|
||||
ciphertext = unhexlify(ciphertext)
|
||||
|
||||
cipher = AES.new(key, AES.MODE_CBC, iv)
|
||||
self.assertEqual(cipher.encrypt(plaintext), ciphertext)
|
||||
cipher = AES.new(key, AES.MODE_CBC, iv)
|
||||
self.assertEqual(cipher.decrypt(ciphertext), plaintext)
|
||||
|
||||
def test_aes_192(self):
|
||||
key = '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b'
|
||||
iv = '000102030405060708090a0b0c0d0e0f'
|
||||
plaintext = '6bc1bee22e409f96e93d7e117393172a' +\
|
||||
'ae2d8a571e03ac9c9eb76fac45af8e51' +\
|
||||
'30c81c46a35ce411e5fbc1191a0a52ef' +\
|
||||
'f69f2445df4f9b17ad2b417be66c3710'
|
||||
ciphertext = '4f021db243bc633d7178183a9fa071e8' +\
|
||||
'b4d9ada9ad7dedf4e5e738763f69145a' +\
|
||||
'571b242012fb7ae07fa9baac3df102e0' +\
|
||||
'08b0e27988598881d920a9e64f5615cd'
|
||||
|
||||
key = unhexlify(key)
|
||||
iv = unhexlify(iv)
|
||||
plaintext = unhexlify(plaintext)
|
||||
ciphertext = unhexlify(ciphertext)
|
||||
|
||||
cipher = AES.new(key, AES.MODE_CBC, iv)
|
||||
self.assertEqual(cipher.encrypt(plaintext), ciphertext)
|
||||
cipher = AES.new(key, AES.MODE_CBC, iv)
|
||||
self.assertEqual(cipher.decrypt(ciphertext), plaintext)
|
||||
|
||||
def test_aes_256(self):
|
||||
key = '603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4'
|
||||
iv = '000102030405060708090a0b0c0d0e0f'
|
||||
plaintext = '6bc1bee22e409f96e93d7e117393172a' +\
|
||||
'ae2d8a571e03ac9c9eb76fac45af8e51' +\
|
||||
'30c81c46a35ce411e5fbc1191a0a52ef' +\
|
||||
'f69f2445df4f9b17ad2b417be66c3710'
|
||||
ciphertext = 'f58c4c04d6e5f1ba779eabfb5f7bfbd6' +\
|
||||
'9cfc4e967edb808d679f777bc6702c7d' +\
|
||||
'39f23369a9d9bacfa530e26304231461' +\
|
||||
'b2eb05e2c39be9fcda6c19078c6a9d1b'
|
||||
|
||||
key = unhexlify(key)
|
||||
iv = unhexlify(iv)
|
||||
plaintext = unhexlify(plaintext)
|
||||
ciphertext = unhexlify(ciphertext)
|
||||
|
||||
cipher = AES.new(key, AES.MODE_CBC, iv)
|
||||
self.assertEqual(cipher.encrypt(plaintext), ciphertext)
|
||||
cipher = AES.new(key, AES.MODE_CBC, iv)
|
||||
self.assertEqual(cipher.decrypt(ciphertext), plaintext)
|
||||
|
||||
|
||||
def get_tests(config={}):
|
||||
tests = []
|
||||
tests += list_test_cases(CbcTests)
|
||||
tests += list_test_cases(NistCbcVectors)
|
||||
tests += list_test_cases(SP800TestVectors)
|
||||
return tests
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
suite = lambda: unittest.TestSuite(get_tests())
|
||||
unittest.main(defaultTest='suite')
|
675
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_CCM.py
Normal file
675
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_CCM.py
Normal file
|
@ -0,0 +1,675 @@
|
|||
# ===================================================================
|
||||
#
|
||||
# Copyright (c) 2015, Legrandin <helderijs@gmail.com>
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
# ===================================================================
|
||||
|
||||
import unittest
|
||||
|
||||
from Crypto.SelfTest.st_common import list_test_cases
|
||||
from Crypto.Util.py3compat import unhexlify, tobytes, bchr, b
|
||||
from Crypto.Cipher import AES
|
||||
from Crypto.Hash import SHAKE128
|
||||
|
||||
|
||||
def get_tag_random(tag, length):
|
||||
return SHAKE128.new(data=tobytes(tag)).read(length)
|
||||
|
||||
|
||||
class CcmTests(unittest.TestCase):
|
||||
|
||||
key_128 = get_tag_random("key_128", 16)
|
||||
nonce_96 = get_tag_random("nonce_128", 12)
|
||||
data_128 = get_tag_random("data_128", 16)
|
||||
|
||||
def test_loopback_128(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
pt = get_tag_random("plaintext", 16 * 100)
|
||||
ct = cipher.encrypt(pt)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
pt2 = cipher.decrypt(ct)
|
||||
self.assertEqual(pt, pt2)
|
||||
|
||||
def test_nonce(self):
|
||||
# If not passed, the nonce is created randomly
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM)
|
||||
nonce1 = cipher.nonce
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM)
|
||||
nonce2 = cipher.nonce
|
||||
self.assertEqual(len(nonce1), 11)
|
||||
self.assertNotEqual(nonce1, nonce2)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, self.nonce_96)
|
||||
ct = cipher.encrypt(self.data_128)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
self.assertEqual(ct, cipher.encrypt(self.data_128))
|
||||
|
||||
def test_nonce_must_be_bytes(self):
|
||||
self.assertRaises(TypeError, AES.new, self.key_128, AES.MODE_CCM,
|
||||
nonce='test12345678')
|
||||
|
||||
def test_nonce_length(self):
|
||||
self.assertRaises(ValueError, AES.new, self.key_128, AES.MODE_CCM,
|
||||
nonce=b(""))
|
||||
self.assertRaises(ValueError, AES.new, self.key_128, AES.MODE_CCM,
|
||||
nonce=bchr(1) * 6)
|
||||
self.assertRaises(ValueError, AES.new, self.key_128, AES.MODE_CCM,
|
||||
nonce=bchr(1) * 14)
|
||||
for x in range(7, 13 + 1):
|
||||
AES.new(self.key_128, AES.MODE_CCM, nonce=bchr(1) * x)
|
||||
|
||||
def test_block_size(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
self.assertEqual(cipher.block_size, AES.block_size)
|
||||
|
||||
def test_nonce_attribute(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
self.assertEqual(cipher.nonce, self.nonce_96)
|
||||
|
||||
# By default, a 11 bytes long nonce is randomly generated
|
||||
nonce1 = AES.new(self.key_128, AES.MODE_CCM).nonce
|
||||
nonce2 = AES.new(self.key_128, AES.MODE_CCM).nonce
|
||||
self.assertEqual(len(nonce1), 11)
|
||||
self.assertNotEqual(nonce1, nonce2)
|
||||
|
||||
def test_unknown_parameters(self):
|
||||
self.assertRaises(TypeError, AES.new, self.key_128, AES.MODE_CCM,
|
||||
self.nonce_96, 7)
|
||||
self.assertRaises(TypeError, AES.new, self.key_128, AES.MODE_CCM,
|
||||
nonce=self.nonce_96, unknown=7)
|
||||
|
||||
# But some are only known by the base cipher
|
||||
# (e.g. use_aesni consumed by the AES module)
|
||||
AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96,
|
||||
use_aesni=False)
|
||||
|
||||
def test_null_encryption_decryption(self):
|
||||
for func in "encrypt", "decrypt":
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
result = getattr(cipher, func)(b(""))
|
||||
self.assertEqual(result, b(""))
|
||||
|
||||
def test_either_encrypt_or_decrypt(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
cipher.encrypt(b(""))
|
||||
self.assertRaises(TypeError, cipher.decrypt, b(""))
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
cipher.decrypt(b(""))
|
||||
self.assertRaises(TypeError, cipher.encrypt, b(""))
|
||||
|
||||
def test_data_must_be_bytes(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
self.assertRaises(TypeError, cipher.encrypt, 'test1234567890-*')
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
self.assertRaises(TypeError, cipher.decrypt, 'test1234567890-*')
|
||||
|
||||
def test_mac_len(self):
|
||||
# Invalid MAC length
|
||||
for mac_len in range(3, 17 + 1, 2):
|
||||
self.assertRaises(ValueError, AES.new, self.key_128, AES.MODE_CCM,
|
||||
nonce=self.nonce_96, mac_len=mac_len)
|
||||
|
||||
# Valid MAC length
|
||||
for mac_len in range(4, 16 + 1, 2):
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96,
|
||||
mac_len=mac_len)
|
||||
_, mac = cipher.encrypt_and_digest(self.data_128)
|
||||
self.assertEqual(len(mac), mac_len)
|
||||
|
||||
# Default MAC length
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
_, mac = cipher.encrypt_and_digest(self.data_128)
|
||||
self.assertEqual(len(mac), 16)
|
||||
|
||||
def test_invalid_mac(self):
|
||||
from Crypto.Util.strxor import strxor_c
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
ct, mac = cipher.encrypt_and_digest(self.data_128)
|
||||
|
||||
invalid_mac = strxor_c(mac, 0x01)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
self.assertRaises(ValueError, cipher.decrypt_and_verify, ct,
|
||||
invalid_mac)
|
||||
|
||||
def test_hex_mac(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
mac_hex = cipher.hexdigest()
|
||||
self.assertEqual(cipher.digest(), unhexlify(mac_hex))
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
cipher.hexverify(mac_hex)
|
||||
|
||||
def test_longer_assoc_data_than_declared(self):
|
||||
# More than zero
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96,
|
||||
assoc_len=0)
|
||||
self.assertRaises(ValueError, cipher.update, b("1"))
|
||||
|
||||
# Too large
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96,
|
||||
assoc_len=15)
|
||||
self.assertRaises(ValueError, cipher.update, self.data_128)
|
||||
|
||||
def test_shorter_assoc_data_than_expected(self):
|
||||
# With plaintext
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96,
|
||||
assoc_len=17)
|
||||
cipher.update(self.data_128)
|
||||
self.assertRaises(ValueError, cipher.encrypt, self.data_128)
|
||||
|
||||
# With empty plaintext
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96,
|
||||
assoc_len=17)
|
||||
cipher.update(self.data_128)
|
||||
self.assertRaises(ValueError, cipher.digest)
|
||||
|
||||
# With ciphertext
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96,
|
||||
assoc_len=17)
|
||||
cipher.update(self.data_128)
|
||||
self.assertRaises(ValueError, cipher.decrypt, self.data_128)
|
||||
|
||||
# With empty ciphertext
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
mac = cipher.digest()
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96,
|
||||
assoc_len=17)
|
||||
cipher.update(self.data_128)
|
||||
self.assertRaises(ValueError, cipher.verify, mac)
|
||||
|
||||
def test_shorter_and_longer_plaintext_than_declared(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96,
|
||||
msg_len=17)
|
||||
cipher.encrypt(self.data_128)
|
||||
self.assertRaises(ValueError, cipher.digest)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96,
|
||||
msg_len=15)
|
||||
self.assertRaises(ValueError, cipher.encrypt, self.data_128)
|
||||
|
||||
def test_shorter_ciphertext_than_declared(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
ct, mac = cipher.encrypt_and_digest(self.data_128)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96,
|
||||
msg_len=17)
|
||||
cipher.decrypt(ct)
|
||||
self.assertRaises(ValueError, cipher.verify, mac)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96,
|
||||
msg_len=15)
|
||||
self.assertRaises(ValueError, cipher.decrypt, ct)
|
||||
|
||||
def test_message_chunks(self):
|
||||
# Validate that both associated data and plaintext/ciphertext
|
||||
# can be broken up in chunks of arbitrary length
|
||||
|
||||
auth_data = get_tag_random("authenticated data", 127)
|
||||
plaintext = get_tag_random("plaintext", 127)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
cipher.update(auth_data)
|
||||
ciphertext, ref_mac = cipher.encrypt_and_digest(plaintext)
|
||||
|
||||
def break_up(data, chunk_length):
|
||||
return [data[i:i+chunk_length] for i in range(0, len(data),
|
||||
chunk_length)]
|
||||
|
||||
# Encryption
|
||||
for chunk_length in 1, 2, 3, 7, 10, 13, 16, 40, 80, 128:
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96,
|
||||
msg_len=127, assoc_len=127)
|
||||
|
||||
for chunk in break_up(auth_data, chunk_length):
|
||||
cipher.update(chunk)
|
||||
pt2 = b("")
|
||||
for chunk in break_up(ciphertext, chunk_length):
|
||||
pt2 += cipher.decrypt(chunk)
|
||||
self.assertEqual(plaintext, pt2)
|
||||
cipher.verify(ref_mac)
|
||||
|
||||
# Decryption
|
||||
for chunk_length in 1, 2, 3, 7, 10, 13, 16, 40, 80, 128:
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96,
|
||||
msg_len=127, assoc_len=127)
|
||||
|
||||
for chunk in break_up(auth_data, chunk_length):
|
||||
cipher.update(chunk)
|
||||
ct2 = b("")
|
||||
for chunk in break_up(plaintext, chunk_length):
|
||||
ct2 += cipher.encrypt(chunk)
|
||||
self.assertEqual(ciphertext, ct2)
|
||||
self.assertEqual(cipher.digest(), ref_mac)
|
||||
|
||||
|
||||
class CcmFSMTests(unittest.TestCase):
|
||||
|
||||
key_128 = get_tag_random("key_128", 16)
|
||||
nonce_96 = get_tag_random("nonce_128", 12)
|
||||
data_128 = get_tag_random("data_128", 16)
|
||||
|
||||
def test_valid_init_encrypt_decrypt_digest_verify(self):
|
||||
# No authenticated data, fixed plaintext
|
||||
for assoc_len in (None, 0):
|
||||
for msg_len in (None, len(self.data_128)):
|
||||
# Verify path INIT->ENCRYPT->DIGEST
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM,
|
||||
nonce=self.nonce_96,
|
||||
assoc_len=assoc_len,
|
||||
msg_len=msg_len)
|
||||
ct = cipher.encrypt(self.data_128)
|
||||
mac = cipher.digest()
|
||||
|
||||
# Verify path INIT->DECRYPT->VERIFY
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM,
|
||||
nonce=self.nonce_96,
|
||||
assoc_len=assoc_len,
|
||||
msg_len=msg_len)
|
||||
cipher.decrypt(ct)
|
||||
cipher.verify(mac)
|
||||
|
||||
def test_valid_init_update_digest_verify(self):
|
||||
# No plaintext, fixed authenticated data
|
||||
for assoc_len in (None, len(self.data_128)):
|
||||
for msg_len in (None, 0):
|
||||
# Verify path INIT->UPDATE->DIGEST
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM,
|
||||
nonce=self.nonce_96,
|
||||
assoc_len=assoc_len,
|
||||
msg_len=msg_len)
|
||||
cipher.update(self.data_128)
|
||||
mac = cipher.digest()
|
||||
|
||||
# Verify path INIT->UPDATE->VERIFY
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM,
|
||||
nonce=self.nonce_96,
|
||||
assoc_len=assoc_len,
|
||||
msg_len=msg_len)
|
||||
cipher.update(self.data_128)
|
||||
cipher.verify(mac)
|
||||
|
||||
def test_valid_full_path(self):
|
||||
# Fixed authenticated data, fixed plaintext
|
||||
for assoc_len in (None, len(self.data_128)):
|
||||
for msg_len in (None, len(self.data_128)):
|
||||
# Verify path INIT->UPDATE->ENCRYPT->DIGEST
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM,
|
||||
nonce=self.nonce_96,
|
||||
assoc_len=assoc_len,
|
||||
msg_len=msg_len)
|
||||
cipher.update(self.data_128)
|
||||
ct = cipher.encrypt(self.data_128)
|
||||
mac = cipher.digest()
|
||||
|
||||
# Verify path INIT->UPDATE->DECRYPT->VERIFY
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM,
|
||||
nonce=self.nonce_96,
|
||||
assoc_len=assoc_len,
|
||||
msg_len=msg_len)
|
||||
cipher.update(self.data_128)
|
||||
cipher.decrypt(ct)
|
||||
cipher.verify(mac)
|
||||
|
||||
def test_valid_init_digest(self):
|
||||
# Verify path INIT->DIGEST
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
cipher.digest()
|
||||
|
||||
def test_valid_init_verify(self):
|
||||
# Verify path INIT->VERIFY
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
mac = cipher.digest()
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
cipher.verify(mac)
|
||||
|
||||
def test_valid_multiple_encrypt_or_decrypt(self):
|
||||
# Only possible if msg_len is declared in advance
|
||||
for method_name in "encrypt", "decrypt":
|
||||
for auth_data in (None, b("333"), self.data_128,
|
||||
self.data_128 + b("3")):
|
||||
if auth_data is None:
|
||||
assoc_len = None
|
||||
else:
|
||||
assoc_len = len(auth_data)
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM,
|
||||
nonce=self.nonce_96,
|
||||
msg_len=64,
|
||||
assoc_len=assoc_len)
|
||||
if auth_data is not None:
|
||||
cipher.update(auth_data)
|
||||
method = getattr(cipher, method_name)
|
||||
method(self.data_128)
|
||||
method(self.data_128)
|
||||
method(self.data_128)
|
||||
method(self.data_128)
|
||||
|
||||
def test_valid_multiple_digest_or_verify(self):
|
||||
# Multiple calls to digest
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
first_mac = cipher.digest()
|
||||
for x in range(4):
|
||||
self.assertEqual(first_mac, cipher.digest())
|
||||
|
||||
# Multiple calls to verify
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
for x in range(5):
|
||||
cipher.verify(first_mac)
|
||||
|
||||
def test_valid_encrypt_and_digest_decrypt_and_verify(self):
|
||||
# encrypt_and_digest
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
ct, mac = cipher.encrypt_and_digest(self.data_128)
|
||||
|
||||
# decrypt_and_verify
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
pt = cipher.decrypt_and_verify(ct, mac)
|
||||
self.assertEqual(self.data_128, pt)
|
||||
|
||||
def test_invalid_multiple_encrypt_decrypt_without_msg_len(self):
|
||||
# Once per method, with or without assoc. data
|
||||
for method_name in "encrypt", "decrypt":
|
||||
for assoc_data_present in (True, False):
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM,
|
||||
nonce=self.nonce_96)
|
||||
if assoc_data_present:
|
||||
cipher.update(self.data_128)
|
||||
method = getattr(cipher, method_name)
|
||||
method(self.data_128)
|
||||
self.assertRaises(TypeError, method, self.data_128)
|
||||
|
||||
def test_invalid_mixing_encrypt_decrypt(self):
|
||||
# Once per method, with or without assoc. data
|
||||
for method1_name, method2_name in (("encrypt", "decrypt"),
|
||||
("decrypt", "encrypt")):
|
||||
for assoc_data_present in (True, False):
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM,
|
||||
nonce=self.nonce_96,
|
||||
msg_len=32)
|
||||
if assoc_data_present:
|
||||
cipher.update(self.data_128)
|
||||
getattr(cipher, method1_name)(self.data_128)
|
||||
self.assertRaises(TypeError, getattr(cipher, method2_name),
|
||||
self.data_128)
|
||||
|
||||
def test_invalid_encrypt_or_update_after_digest(self):
|
||||
for method_name in "encrypt", "update":
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
cipher.encrypt(self.data_128)
|
||||
cipher.digest()
|
||||
self.assertRaises(TypeError, getattr(cipher, method_name),
|
||||
self.data_128)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
cipher.encrypt_and_digest(self.data_128)
|
||||
|
||||
def test_invalid_decrypt_or_update_after_verify(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
ct = cipher.encrypt(self.data_128)
|
||||
mac = cipher.digest()
|
||||
|
||||
for method_name in "decrypt", "update":
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
cipher.decrypt(ct)
|
||||
cipher.verify(mac)
|
||||
self.assertRaises(TypeError, getattr(cipher, method_name),
|
||||
self.data_128)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_CCM, nonce=self.nonce_96)
|
||||
cipher.decrypt_and_verify(ct, mac)
|
||||
self.assertRaises(TypeError, getattr(cipher, method_name),
|
||||
self.data_128)
|
||||
|
||||
|
||||
class TestVectors(unittest.TestCase):
|
||||
"""Class exercising the CCM test vectors found in Appendix C
|
||||
of NIST SP 800-38C and in RFC 3610"""
|
||||
|
||||
# List of test vectors, each made up of:
|
||||
# - authenticated data
|
||||
# - plaintext
|
||||
# - ciphertext
|
||||
# - MAC
|
||||
# - AES key
|
||||
# - nonce
|
||||
test_vectors = [
|
||||
# NIST SP 800 38C
|
||||
( '0001020304050607',
|
||||
'20212223',
|
||||
'7162015b',
|
||||
'4dac255d',
|
||||
'404142434445464748494a4b4c4d4e4f',
|
||||
'10111213141516'),
|
||||
( '000102030405060708090a0b0c0d0e0f',
|
||||
'202122232425262728292a2b2c2d2e2f',
|
||||
'd2a1f0e051ea5f62081a7792073d593d',
|
||||
'1fc64fbfaccd',
|
||||
'404142434445464748494a4b4c4d4e4f',
|
||||
'1011121314151617'),
|
||||
( '000102030405060708090a0b0c0d0e0f10111213',
|
||||
'202122232425262728292a2b2c2d2e2f3031323334353637',
|
||||
'e3b201a9f5b71a7a9b1ceaeccd97e70b6176aad9a4428aa5',
|
||||
'484392fbc1b09951',
|
||||
'404142434445464748494a4b4c4d4e4f',
|
||||
'101112131415161718191a1b'),
|
||||
( (''.join(["%02X" % (x*16+y) for x in range(0,16) for y in range(0,16)]))*256,
|
||||
'202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f',
|
||||
'69915dad1e84c6376a68c2967e4dab615ae0fd1faec44cc484828529463ccf72',
|
||||
'b4ac6bec93e8598e7f0dadbcea5b',
|
||||
'404142434445464748494a4b4c4d4e4f',
|
||||
'101112131415161718191a1b1c'),
|
||||
# RFC3610
|
||||
( '0001020304050607',
|
||||
'08090a0b0c0d0e0f101112131415161718191a1b1c1d1e',
|
||||
'588c979a61c663d2f066d0c2c0f989806d5f6b61dac384',
|
||||
'17e8d12cfdf926e0',
|
||||
'c0c1c2c3c4c5c6c7c8c9cacbcccdcecf',
|
||||
'00000003020100a0a1a2a3a4a5'),
|
||||
(
|
||||
'0001020304050607',
|
||||
'08090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f',
|
||||
'72c91a36e135f8cf291ca894085c87e3cc15c439c9e43a3b',
|
||||
'a091d56e10400916',
|
||||
'c0c1c2c3c4c5c6c7c8c9cacbcccdcecf',
|
||||
'00000004030201a0a1a2a3a4a5'),
|
||||
( '0001020304050607',
|
||||
'08090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20',
|
||||
'51b1e5f44a197d1da46b0f8e2d282ae871e838bb64da859657',
|
||||
'4adaa76fbd9fb0c5',
|
||||
'c0c1c2c3c4c5c6c7c8c9cacbcccdcecf',
|
||||
'00000005040302A0A1A2A3A4A5'),
|
||||
( '000102030405060708090a0b',
|
||||
'0c0d0e0f101112131415161718191a1b1c1d1e',
|
||||
'a28c6865939a9a79faaa5c4c2a9d4a91cdac8c',
|
||||
'96c861b9c9e61ef1',
|
||||
'c0c1c2c3c4c5c6c7c8c9cacbcccdcecf',
|
||||
'00000006050403a0a1a2a3a4a5'),
|
||||
( '000102030405060708090a0b',
|
||||
'0c0d0e0f101112131415161718191a1b1c1d1e1f',
|
||||
'dcf1fb7b5d9e23fb9d4e131253658ad86ebdca3e',
|
||||
'51e83f077d9c2d93',
|
||||
'c0c1c2c3c4c5c6c7c8c9cacbcccdcecf',
|
||||
'00000007060504a0a1a2a3a4a5'),
|
||||
( '000102030405060708090a0b',
|
||||
'0c0d0e0f101112131415161718191a1b1c1d1e1f20',
|
||||
'6fc1b011f006568b5171a42d953d469b2570a4bd87',
|
||||
'405a0443ac91cb94',
|
||||
'c0c1c2c3c4c5c6c7c8c9cacbcccdcecf',
|
||||
'00000008070605a0a1a2a3a4a5'),
|
||||
( '0001020304050607',
|
||||
'08090a0b0c0d0e0f101112131415161718191a1b1c1d1e',
|
||||
'0135d1b2c95f41d5d1d4fec185d166b8094e999dfed96c',
|
||||
'048c56602c97acbb7490',
|
||||
'c0c1c2c3c4c5c6c7c8c9cacbcccdcecf',
|
||||
'00000009080706a0a1a2a3a4a5'),
|
||||
( '0001020304050607',
|
||||
'08090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f',
|
||||
'7b75399ac0831dd2f0bbd75879a2fd8f6cae6b6cd9b7db24',
|
||||
'c17b4433f434963f34b4',
|
||||
'c0c1c2c3c4c5c6c7c8c9cacbcccdcecf',
|
||||
'0000000a090807a0a1a2a3a4a5'),
|
||||
( '0001020304050607',
|
||||
'08090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20',
|
||||
'82531a60cc24945a4b8279181ab5c84df21ce7f9b73f42e197',
|
||||
'ea9c07e56b5eb17e5f4e',
|
||||
'c0c1c2c3c4c5c6c7c8c9cacbcccdcecf',
|
||||
'0000000b0a0908a0a1a2a3a4a5'),
|
||||
( '000102030405060708090a0b',
|
||||
'0c0d0e0f101112131415161718191a1b1c1d1e',
|
||||
'07342594157785152b074098330abb141b947b',
|
||||
'566aa9406b4d999988dd',
|
||||
'c0c1c2c3c4c5c6c7c8c9cacbcccdcecf',
|
||||
'0000000c0b0a09a0a1a2a3a4a5'),
|
||||
( '000102030405060708090a0b',
|
||||
'0c0d0e0f101112131415161718191a1b1c1d1e1f',
|
||||
'676bb20380b0e301e8ab79590a396da78b834934',
|
||||
'f53aa2e9107a8b6c022c',
|
||||
'c0c1c2c3c4c5c6c7c8c9cacbcccdcecf',
|
||||
'0000000d0c0b0aa0a1a2a3a4a5'),
|
||||
( '000102030405060708090a0b',
|
||||
'0c0d0e0f101112131415161718191a1b1c1d1e1f20',
|
||||
'c0ffa0d6f05bdb67f24d43a4338d2aa4bed7b20e43',
|
||||
'cd1aa31662e7ad65d6db',
|
||||
'c0c1c2c3c4c5c6c7c8c9cacbcccdcecf',
|
||||
'0000000e0d0c0ba0a1a2a3a4a5'),
|
||||
( '0be1a88bace018b1',
|
||||
'08e8cf97d820ea258460e96ad9cf5289054d895ceac47c',
|
||||
'4cb97f86a2a4689a877947ab8091ef5386a6ffbdd080f8',
|
||||
'e78cf7cb0cddd7b3',
|
||||
'd7828d13b2b0bdc325a76236df93cc6b',
|
||||
'00412b4ea9cdbe3c9696766cfa'),
|
||||
( '63018f76dc8a1bcb',
|
||||
'9020ea6f91bdd85afa0039ba4baff9bfb79c7028949cd0ec',
|
||||
'4ccb1e7ca981befaa0726c55d378061298c85c92814abc33',
|
||||
'c52ee81d7d77c08a',
|
||||
'd7828d13b2b0bdc325a76236df93cc6b',
|
||||
'0033568ef7b2633c9696766cfa'),
|
||||
( 'aa6cfa36cae86b40',
|
||||
'b916e0eacc1c00d7dcec68ec0b3bbb1a02de8a2d1aa346132e',
|
||||
'b1d23a2220ddc0ac900d9aa03c61fcf4a559a4417767089708',
|
||||
'a776796edb723506',
|
||||
'd7828d13b2b0bdc325a76236df93cc6b',
|
||||
'00103fe41336713c9696766cfa'),
|
||||
( 'd0d0735c531e1becf049c244',
|
||||
'12daac5630efa5396f770ce1a66b21f7b2101c',
|
||||
'14d253c3967b70609b7cbb7c49916028324526',
|
||||
'9a6f49975bcadeaf',
|
||||
'd7828d13b2b0bdc325a76236df93cc6b',
|
||||
'00764c63b8058e3c9696766cfa'),
|
||||
( '77b60f011c03e1525899bcae',
|
||||
'e88b6a46c78d63e52eb8c546efb5de6f75e9cc0d',
|
||||
'5545ff1a085ee2efbf52b2e04bee1e2336c73e3f',
|
||||
'762c0c7744fe7e3c',
|
||||
'd7828d13b2b0bdc325a76236df93cc6b',
|
||||
'00f8b678094e3b3c9696766cfa'),
|
||||
( 'cd9044d2b71fdb8120ea60c0',
|
||||
'6435acbafb11a82e2f071d7ca4a5ebd93a803ba87f',
|
||||
'009769ecabdf48625594c59251e6035722675e04c8',
|
||||
'47099e5ae0704551',
|
||||
'd7828d13b2b0bdc325a76236df93cc6b',
|
||||
'00d560912d3f703c9696766cfa'),
|
||||
( 'd85bc7e69f944fb8',
|
||||
'8a19b950bcf71a018e5e6701c91787659809d67dbedd18',
|
||||
'bc218daa947427b6db386a99ac1aef23ade0b52939cb6a',
|
||||
'637cf9bec2408897c6ba',
|
||||
'd7828d13b2b0bdc325a76236df93cc6b',
|
||||
'0042fff8f1951c3c9696766cfa'),
|
||||
( '74a0ebc9069f5b37',
|
||||
'1761433c37c5a35fc1f39f406302eb907c6163be38c98437',
|
||||
'5810e6fd25874022e80361a478e3e9cf484ab04f447efff6',
|
||||
'f0a477cc2fc9bf548944',
|
||||
'd7828d13b2b0bdc325a76236df93cc6b',
|
||||
'00920f40e56cdc3c9696766cfa'),
|
||||
( '44a3aa3aae6475ca',
|
||||
'a434a8e58500c6e41530538862d686ea9e81301b5ae4226bfa',
|
||||
'f2beed7bc5098e83feb5b31608f8e29c38819a89c8e776f154',
|
||||
'4d4151a4ed3a8b87b9ce',
|
||||
'd7828d13b2b0bdc325a76236df93cc6b',
|
||||
'0027ca0c7120bc3c9696766cfa'),
|
||||
( 'ec46bb63b02520c33c49fd70',
|
||||
'b96b49e21d621741632875db7f6c9243d2d7c2',
|
||||
'31d750a09da3ed7fddd49a2032aabf17ec8ebf',
|
||||
'7d22c8088c666be5c197',
|
||||
'd7828d13b2b0bdc325a76236df93cc6b',
|
||||
'005b8ccbcd9af83c9696766cfa'),
|
||||
( '47a65ac78b3d594227e85e71',
|
||||
'e2fcfbb880442c731bf95167c8ffd7895e337076',
|
||||
'e882f1dbd38ce3eda7c23f04dd65071eb41342ac',
|
||||
'df7e00dccec7ae52987d',
|
||||
'd7828d13b2b0bdc325a76236df93cc6b',
|
||||
'003ebe94044b9a3c9696766cfa'),
|
||||
( '6e37a6ef546d955d34ab6059',
|
||||
'abf21c0b02feb88f856df4a37381bce3cc128517d4',
|
||||
'f32905b88a641b04b9c9ffb58cc390900f3da12ab1',
|
||||
'6dce9e82efa16da62059',
|
||||
'd7828d13b2b0bdc325a76236df93cc6b',
|
||||
'008d493b30ae8b3c9696766cfa'),
|
||||
]
|
||||
|
||||
for index, tv in enumerate(test_vectors):
|
||||
test_vectors[index] = (unhexlify(x) for x in tv)
|
||||
|
||||
def runTest(self):
|
||||
for assoc_data, pt, ct, mac, key, nonce in self.test_vectors:
|
||||
# Encrypt
|
||||
cipher = AES.new(key, AES.MODE_CCM, nonce, mac_len=len(mac))
|
||||
cipher.update(assoc_data)
|
||||
ct2, mac2 = cipher.encrypt_and_digest(pt)
|
||||
self.assertEqual(ct, ct2)
|
||||
self.assertEqual(mac, mac2)
|
||||
|
||||
# Decrypt
|
||||
cipher = AES.new(key, AES.MODE_CCM, nonce, mac_len=len(mac))
|
||||
cipher.update(assoc_data)
|
||||
pt2 = cipher.decrypt_and_verify(ct, mac)
|
||||
self.assertEqual(pt, pt2)
|
||||
|
||||
|
||||
def get_tests(config={}):
|
||||
tests = []
|
||||
tests += list_test_cases(CcmTests)
|
||||
tests += list_test_cases(CcmFSMTests)
|
||||
tests += [TestVectors()]
|
||||
return tests
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
suite = lambda: unittest.TestSuite(get_tests())
|
||||
unittest.main(defaultTest='suite')
|
401
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_CFB.py
Normal file
401
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_CFB.py
Normal file
|
@ -0,0 +1,401 @@
|
|||
# ===================================================================
|
||||
#
|
||||
# Copyright (c) 2014, Legrandin <helderijs@gmail.com>
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
# ===================================================================
|
||||
|
||||
import unittest
|
||||
|
||||
from Crypto.SelfTest.loader import load_tests
|
||||
from Crypto.SelfTest.st_common import list_test_cases
|
||||
from Crypto.Util.py3compat import tobytes, b, unhexlify
|
||||
from Crypto.Cipher import AES, DES3, DES
|
||||
from Crypto.Hash import SHAKE128
|
||||
|
||||
def get_tag_random(tag, length):
|
||||
return SHAKE128.new(data=tobytes(tag)).read(length)
|
||||
|
||||
|
||||
from Crypto.SelfTest.Cipher.test_CBC import BlockChainingTests
|
||||
|
||||
class CfbTests(BlockChainingTests):
|
||||
|
||||
aes_mode = AES.MODE_CFB
|
||||
des3_mode = DES3.MODE_CFB
|
||||
|
||||
# Redefine test_unaligned_data_128/64
|
||||
|
||||
def test_unaligned_data_128(self):
|
||||
plaintexts = [ b("7777777") ] * 100
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_CFB, self.iv_128, segment_size=8)
|
||||
ciphertexts = [ cipher.encrypt(x) for x in plaintexts ]
|
||||
cipher = AES.new(self.key_128, AES.MODE_CFB, self.iv_128, segment_size=8)
|
||||
self.assertEqual(b("").join(ciphertexts), cipher.encrypt(b("").join(plaintexts)))
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_CFB, self.iv_128, segment_size=128)
|
||||
ciphertexts = [ cipher.encrypt(x) for x in plaintexts ]
|
||||
cipher = AES.new(self.key_128, AES.MODE_CFB, self.iv_128, segment_size=128)
|
||||
self.assertEqual(b("").join(ciphertexts), cipher.encrypt(b("").join(plaintexts)))
|
||||
|
||||
def test_unaligned_data_64(self):
|
||||
plaintexts = [ b("7777777") ] * 100
|
||||
cipher = DES3.new(self.key_192, DES3.MODE_CFB, self.iv_64, segment_size=8)
|
||||
ciphertexts = [ cipher.encrypt(x) for x in plaintexts ]
|
||||
cipher = DES3.new(self.key_192, DES3.MODE_CFB, self.iv_64, segment_size=8)
|
||||
self.assertEqual(b("").join(ciphertexts), cipher.encrypt(b("").join(plaintexts)))
|
||||
|
||||
cipher = DES3.new(self.key_192, DES3.MODE_CFB, self.iv_64, segment_size=64)
|
||||
ciphertexts = [ cipher.encrypt(x) for x in plaintexts ]
|
||||
cipher = DES3.new(self.key_192, DES3.MODE_CFB, self.iv_64, segment_size=64)
|
||||
self.assertEqual(b("").join(ciphertexts), cipher.encrypt(b("").join(plaintexts)))
|
||||
|
||||
# Extra
|
||||
|
||||
def test_segment_size_128(self):
|
||||
for bits in range(8, 129, 8):
|
||||
cipher = AES.new(self.key_128, AES.MODE_CFB, self.iv_128,
|
||||
segment_size=bits)
|
||||
|
||||
for bits in 0, 7, 9, 127, 129:
|
||||
self.assertRaises(ValueError, AES.new, self.key_128, AES.MODE_CFB,
|
||||
self.iv_128,
|
||||
segment_size=bits)
|
||||
|
||||
def test_segment_size_64(self):
|
||||
for bits in range(8, 65, 8):
|
||||
cipher = DES3.new(self.key_192, DES3.MODE_CFB, self.iv_64,
|
||||
segment_size=bits)
|
||||
|
||||
for bits in 0, 7, 9, 63, 65:
|
||||
self.assertRaises(ValueError, DES3.new, self.key_192, AES.MODE_CFB,
|
||||
self.iv_64,
|
||||
segment_size=bits)
|
||||
|
||||
|
||||
class NistCfbVectors(unittest.TestCase):
|
||||
|
||||
def _do_kat_aes_test(self, file_name, segment_size):
|
||||
test_vectors = load_tests(("Crypto", "SelfTest", "Cipher", "test_vectors", "AES"),
|
||||
file_name,
|
||||
"AES CFB%d KAT" % segment_size,
|
||||
{ "count" : lambda x: int(x) } )
|
||||
assert(test_vectors)
|
||||
|
||||
direction = None
|
||||
for tv in test_vectors:
|
||||
|
||||
# The test vector file contains some directive lines
|
||||
if isinstance(tv, str):
|
||||
direction = tv
|
||||
continue
|
||||
|
||||
self.description = tv.desc
|
||||
cipher = AES.new(tv.key, AES.MODE_CFB, tv.iv,
|
||||
segment_size=segment_size)
|
||||
if direction == "[ENCRYPT]":
|
||||
self.assertEqual(cipher.encrypt(tv.plaintext), tv.ciphertext)
|
||||
elif direction == "[DECRYPT]":
|
||||
self.assertEqual(cipher.decrypt(tv.ciphertext), tv.plaintext)
|
||||
else:
|
||||
assert False
|
||||
|
||||
# See Section 6.4.5 in AESAVS
|
||||
def _do_mct_aes_test(self, file_name, segment_size):
|
||||
test_vectors = load_tests(("Crypto", "SelfTest", "Cipher", "test_vectors", "AES"),
|
||||
file_name,
|
||||
"AES CFB%d Montecarlo" % segment_size,
|
||||
{ "count" : lambda x: int(x) } )
|
||||
assert(test_vectors)
|
||||
assert(segment_size in (8, 128))
|
||||
|
||||
direction = None
|
||||
for tv in test_vectors:
|
||||
|
||||
# The test vector file contains some directive lines
|
||||
if isinstance(tv, str):
|
||||
direction = tv
|
||||
continue
|
||||
|
||||
self.description = tv.desc
|
||||
cipher = AES.new(tv.key, AES.MODE_CFB, tv.iv,
|
||||
segment_size=segment_size)
|
||||
|
||||
def get_input(input_text, output_seq, j):
|
||||
# CFB128
|
||||
if segment_size == 128:
|
||||
if j >= 2:
|
||||
return output_seq[-2]
|
||||
return [input_text, tv.iv][j]
|
||||
# CFB8
|
||||
if j == 0:
|
||||
return input_text
|
||||
elif j <= 16:
|
||||
return tv.iv[j - 1:j]
|
||||
return output_seq[j - 17]
|
||||
|
||||
if direction == '[ENCRYPT]':
|
||||
cts = []
|
||||
for j in range(1000):
|
||||
plaintext = get_input(tv.plaintext, cts, j)
|
||||
cts.append(cipher.encrypt(plaintext))
|
||||
self.assertEqual(cts[-1], tv.ciphertext)
|
||||
elif direction == '[DECRYPT]':
|
||||
pts = []
|
||||
for j in range(1000):
|
||||
ciphertext = get_input(tv.ciphertext, pts, j)
|
||||
pts.append(cipher.decrypt(ciphertext))
|
||||
self.assertEqual(pts[-1], tv.plaintext)
|
||||
else:
|
||||
assert False
|
||||
|
||||
def _do_tdes_test(self, file_name, segment_size):
|
||||
test_vectors = load_tests(("Crypto", "SelfTest", "Cipher", "test_vectors", "TDES"),
|
||||
file_name,
|
||||
"AES CFB%d KAT" % segment_size,
|
||||
{ "count" : lambda x: int(x) } )
|
||||
assert(test_vectors)
|
||||
|
||||
direction = None
|
||||
for tv in test_vectors:
|
||||
|
||||
# The test vector file contains some directive lines
|
||||
if isinstance(tv, str):
|
||||
direction = tv
|
||||
continue
|
||||
|
||||
self.description = tv.desc
|
||||
if hasattr(tv, "keys"):
|
||||
cipher = DES.new(tv.keys, DES.MODE_CFB, tv.iv,
|
||||
segment_size=segment_size)
|
||||
else:
|
||||
if tv.key1 != tv.key3:
|
||||
key = tv.key1 + tv.key2 + tv.key3 # Option 3
|
||||
else:
|
||||
key = tv.key1 + tv.key2 # Option 2
|
||||
cipher = DES3.new(key, DES3.MODE_CFB, tv.iv,
|
||||
segment_size=segment_size)
|
||||
if direction == "[ENCRYPT]":
|
||||
self.assertEqual(cipher.encrypt(tv.plaintext), tv.ciphertext)
|
||||
elif direction == "[DECRYPT]":
|
||||
self.assertEqual(cipher.decrypt(tv.ciphertext), tv.plaintext)
|
||||
else:
|
||||
assert False
|
||||
|
||||
|
||||
# Create one test method per file
|
||||
nist_aes_kat_mmt_files = (
|
||||
# KAT
|
||||
"CFB?GFSbox128.rsp",
|
||||
"CFB?GFSbox192.rsp",
|
||||
"CFB?GFSbox256.rsp",
|
||||
"CFB?KeySbox128.rsp",
|
||||
"CFB?KeySbox192.rsp",
|
||||
"CFB?KeySbox256.rsp",
|
||||
"CFB?VarKey128.rsp",
|
||||
"CFB?VarKey192.rsp",
|
||||
"CFB?VarKey256.rsp",
|
||||
"CFB?VarTxt128.rsp",
|
||||
"CFB?VarTxt192.rsp",
|
||||
"CFB?VarTxt256.rsp",
|
||||
# MMT
|
||||
"CFB?MMT128.rsp",
|
||||
"CFB?MMT192.rsp",
|
||||
"CFB?MMT256.rsp",
|
||||
)
|
||||
nist_aes_mct_files = (
|
||||
"CFB?MCT128.rsp",
|
||||
"CFB?MCT192.rsp",
|
||||
"CFB?MCT256.rsp",
|
||||
)
|
||||
|
||||
for file_gen_name in nist_aes_kat_mmt_files:
|
||||
for bits in "8", "128":
|
||||
file_name = file_gen_name.replace("?", bits)
|
||||
def new_func(self, file_name=file_name, bits=bits):
|
||||
self._do_kat_aes_test(file_name, int(bits))
|
||||
setattr(NistCfbVectors, "test_AES_" + file_name, new_func)
|
||||
|
||||
for file_gen_name in nist_aes_mct_files:
|
||||
for bits in "8", "128":
|
||||
file_name = file_gen_name.replace("?", bits)
|
||||
def new_func(self, file_name=file_name, bits=bits):
|
||||
self._do_mct_aes_test(file_name, int(bits))
|
||||
setattr(NistCfbVectors, "test_AES_" + file_name, new_func)
|
||||
del file_name, new_func
|
||||
|
||||
nist_tdes_files = (
|
||||
"TCFB?MMT2.rsp", # 2TDES
|
||||
"TCFB?MMT3.rsp", # 3TDES
|
||||
"TCFB?invperm.rsp", # Single DES
|
||||
"TCFB?permop.rsp",
|
||||
"TCFB?subtab.rsp",
|
||||
"TCFB?varkey.rsp",
|
||||
"TCFB?vartext.rsp",
|
||||
)
|
||||
|
||||
for file_gen_name in nist_tdes_files:
|
||||
for bits in "8", "64":
|
||||
file_name = file_gen_name.replace("?", bits)
|
||||
def new_func(self, file_name=file_name, bits=bits):
|
||||
self._do_tdes_test(file_name, int(bits))
|
||||
setattr(NistCfbVectors, "test_TDES_" + file_name, new_func)
|
||||
|
||||
# END OF NIST CBC TEST VECTORS
|
||||
|
||||
|
||||
class SP800TestVectors(unittest.TestCase):
|
||||
"""Class exercising the CFB test vectors found in Section F.3
|
||||
of NIST SP 800-3A"""
|
||||
|
||||
def test_aes_128_cfb8(self):
|
||||
plaintext = '6bc1bee22e409f96e93d7e117393172aae2d'
|
||||
ciphertext = '3b79424c9c0dd436bace9e0ed4586a4f32b9'
|
||||
key = '2b7e151628aed2a6abf7158809cf4f3c'
|
||||
iv = '000102030405060708090a0b0c0d0e0f'
|
||||
|
||||
key = unhexlify(key)
|
||||
iv = unhexlify(iv)
|
||||
plaintext = unhexlify(plaintext)
|
||||
ciphertext = unhexlify(ciphertext)
|
||||
|
||||
cipher = AES.new(key, AES.MODE_CFB, iv, segment_size=8)
|
||||
self.assertEqual(cipher.encrypt(plaintext), ciphertext)
|
||||
cipher = AES.new(key, AES.MODE_CFB, iv, segment_size=8)
|
||||
self.assertEqual(cipher.decrypt(ciphertext), plaintext)
|
||||
|
||||
def test_aes_192_cfb8(self):
|
||||
plaintext = '6bc1bee22e409f96e93d7e117393172aae2d'
|
||||
ciphertext = 'cda2521ef0a905ca44cd057cbf0d47a0678a'
|
||||
key = '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b'
|
||||
iv = '000102030405060708090a0b0c0d0e0f'
|
||||
|
||||
key = unhexlify(key)
|
||||
iv = unhexlify(iv)
|
||||
plaintext = unhexlify(plaintext)
|
||||
ciphertext = unhexlify(ciphertext)
|
||||
|
||||
cipher = AES.new(key, AES.MODE_CFB, iv, segment_size=8)
|
||||
self.assertEqual(cipher.encrypt(plaintext), ciphertext)
|
||||
cipher = AES.new(key, AES.MODE_CFB, iv, segment_size=8)
|
||||
self.assertEqual(cipher.decrypt(ciphertext), plaintext)
|
||||
|
||||
def test_aes_256_cfb8(self):
|
||||
plaintext = '6bc1bee22e409f96e93d7e117393172aae2d'
|
||||
ciphertext = 'dc1f1a8520a64db55fcc8ac554844e889700'
|
||||
key = '603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4'
|
||||
iv = '000102030405060708090a0b0c0d0e0f'
|
||||
|
||||
key = unhexlify(key)
|
||||
iv = unhexlify(iv)
|
||||
plaintext = unhexlify(plaintext)
|
||||
ciphertext = unhexlify(ciphertext)
|
||||
|
||||
cipher = AES.new(key, AES.MODE_CFB, iv, segment_size=8)
|
||||
self.assertEqual(cipher.encrypt(plaintext), ciphertext)
|
||||
cipher = AES.new(key, AES.MODE_CFB, iv, segment_size=8)
|
||||
self.assertEqual(cipher.decrypt(ciphertext), plaintext)
|
||||
|
||||
def test_aes_128_cfb128(self):
|
||||
plaintext = '6bc1bee22e409f96e93d7e117393172a' +\
|
||||
'ae2d8a571e03ac9c9eb76fac45af8e51' +\
|
||||
'30c81c46a35ce411e5fbc1191a0a52ef' +\
|
||||
'f69f2445df4f9b17ad2b417be66c3710'
|
||||
ciphertext = '3b3fd92eb72dad20333449f8e83cfb4a' +\
|
||||
'c8a64537a0b3a93fcde3cdad9f1ce58b' +\
|
||||
'26751f67a3cbb140b1808cf187a4f4df' +\
|
||||
'c04b05357c5d1c0eeac4c66f9ff7f2e6'
|
||||
key = '2b7e151628aed2a6abf7158809cf4f3c'
|
||||
iv = '000102030405060708090a0b0c0d0e0f'
|
||||
|
||||
key = unhexlify(key)
|
||||
iv = unhexlify(iv)
|
||||
plaintext = unhexlify(plaintext)
|
||||
ciphertext = unhexlify(ciphertext)
|
||||
|
||||
cipher = AES.new(key, AES.MODE_CFB, iv, segment_size=128)
|
||||
self.assertEqual(cipher.encrypt(plaintext), ciphertext)
|
||||
cipher = AES.new(key, AES.MODE_CFB, iv, segment_size=128)
|
||||
self.assertEqual(cipher.decrypt(ciphertext), plaintext)
|
||||
|
||||
def test_aes_192_cfb128(self):
|
||||
plaintext = '6bc1bee22e409f96e93d7e117393172a' +\
|
||||
'ae2d8a571e03ac9c9eb76fac45af8e51' +\
|
||||
'30c81c46a35ce411e5fbc1191a0a52ef' +\
|
||||
'f69f2445df4f9b17ad2b417be66c3710'
|
||||
ciphertext = 'cdc80d6fddf18cab34c25909c99a4174' +\
|
||||
'67ce7f7f81173621961a2b70171d3d7a' +\
|
||||
'2e1e8a1dd59b88b1c8e60fed1efac4c9' +\
|
||||
'c05f9f9ca9834fa042ae8fba584b09ff'
|
||||
key = '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b'
|
||||
iv = '000102030405060708090a0b0c0d0e0f'
|
||||
|
||||
key = unhexlify(key)
|
||||
iv = unhexlify(iv)
|
||||
plaintext = unhexlify(plaintext)
|
||||
ciphertext = unhexlify(ciphertext)
|
||||
|
||||
cipher = AES.new(key, AES.MODE_CFB, iv, segment_size=128)
|
||||
self.assertEqual(cipher.encrypt(plaintext), ciphertext)
|
||||
cipher = AES.new(key, AES.MODE_CFB, iv, segment_size=128)
|
||||
self.assertEqual(cipher.decrypt(ciphertext), plaintext)
|
||||
|
||||
def test_aes_256_cfb128(self):
|
||||
plaintext = '6bc1bee22e409f96e93d7e117393172a' +\
|
||||
'ae2d8a571e03ac9c9eb76fac45af8e51' +\
|
||||
'30c81c46a35ce411e5fbc1191a0a52ef' +\
|
||||
'f69f2445df4f9b17ad2b417be66c3710'
|
||||
|
||||
ciphertext = 'dc7e84bfda79164b7ecd8486985d3860' +\
|
||||
'39ffed143b28b1c832113c6331e5407b' +\
|
||||
'df10132415e54b92a13ed0a8267ae2f9' +\
|
||||
'75a385741ab9cef82031623d55b1e471'
|
||||
key = '603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4'
|
||||
iv = '000102030405060708090a0b0c0d0e0f'
|
||||
|
||||
key = unhexlify(key)
|
||||
iv = unhexlify(iv)
|
||||
plaintext = unhexlify(plaintext)
|
||||
ciphertext = unhexlify(ciphertext)
|
||||
|
||||
cipher = AES.new(key, AES.MODE_CFB, iv, segment_size=128)
|
||||
self.assertEqual(cipher.encrypt(plaintext), ciphertext)
|
||||
cipher = AES.new(key, AES.MODE_CFB, iv, segment_size=128)
|
||||
self.assertEqual(cipher.decrypt(ciphertext), plaintext)
|
||||
|
||||
|
||||
def get_tests(config={}):
|
||||
tests = []
|
||||
tests += list_test_cases(CfbTests)
|
||||
tests += list_test_cases(NistCfbVectors)
|
||||
tests += list_test_cases(SP800TestVectors)
|
||||
return tests
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
suite = lambda: unittest.TestSuite(get_tests())
|
||||
unittest.main(defaultTest='suite')
|
351
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_CTR.py
Normal file
351
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_CTR.py
Normal file
|
@ -0,0 +1,351 @@
|
|||
# ===================================================================
|
||||
#
|
||||
# Copyright (c) 2015, Legrandin <helderijs@gmail.com>
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
# ===================================================================
|
||||
|
||||
import unittest
|
||||
|
||||
from Crypto.SelfTest.st_common import list_test_cases
|
||||
from Crypto.Util.py3compat import tobytes, b, unhexlify, bchr
|
||||
from Crypto.Cipher import AES, DES3
|
||||
from Crypto.Hash import SHAKE128
|
||||
from Crypto.Util import Counter
|
||||
|
||||
def get_tag_random(tag, length):
|
||||
return SHAKE128.new(data=tobytes(tag)).read(length)
|
||||
|
||||
class CtrTests(unittest.TestCase):
|
||||
|
||||
key_128 = get_tag_random("key_128", 16)
|
||||
key_192 = get_tag_random("key_192", 24)
|
||||
nonce_32 = get_tag_random("nonce_32", 4)
|
||||
nonce_64 = get_tag_random("nonce_64", 8)
|
||||
ctr_64 = Counter.new(32, prefix=nonce_32)
|
||||
ctr_128 = Counter.new(64, prefix=nonce_64)
|
||||
|
||||
def test_loopback_128(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_CTR, counter=self.ctr_128)
|
||||
pt = get_tag_random("plaintext", 16 * 100)
|
||||
ct = cipher.encrypt(pt)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_CTR, counter=self.ctr_128)
|
||||
pt2 = cipher.decrypt(ct)
|
||||
self.assertEqual(pt, pt2)
|
||||
|
||||
def test_loopback_64(self):
|
||||
cipher = DES3.new(self.key_192, DES3.MODE_CTR, counter=self.ctr_64)
|
||||
pt = get_tag_random("plaintext", 8 * 100)
|
||||
ct = cipher.encrypt(pt)
|
||||
|
||||
cipher = DES3.new(self.key_192, DES3.MODE_CTR, counter=self.ctr_64)
|
||||
pt2 = cipher.decrypt(ct)
|
||||
self.assertEqual(pt, pt2)
|
||||
|
||||
def test_invalid_counter_parameter(self):
|
||||
# Counter object is required for ciphers with short block size
|
||||
self.assertRaises(TypeError, DES3.new, self.key_192, AES.MODE_CTR)
|
||||
# Positional arguments are not allowed (Counter must be passed as
|
||||
# keyword)
|
||||
self.assertRaises(TypeError, AES.new, self.key_128, AES.MODE_CTR, self.ctr_128)
|
||||
|
||||
def test_nonce_attribute(self):
|
||||
# Nonce attribute is the prefix passed to Counter (DES3)
|
||||
cipher = DES3.new(self.key_192, DES3.MODE_CTR, counter=self.ctr_64)
|
||||
self.assertEqual(cipher.nonce, self.nonce_32)
|
||||
|
||||
# Nonce attribute is the prefix passed to Counter (AES)
|
||||
cipher = AES.new(self.key_128, AES.MODE_CTR, counter=self.ctr_128)
|
||||
self.assertEqual(cipher.nonce, self.nonce_64)
|
||||
|
||||
# Nonce attribute is not defined if suffix is used in Counter
|
||||
counter = Counter.new(64, prefix=self.nonce_32, suffix=self.nonce_32)
|
||||
cipher = AES.new(self.key_128, AES.MODE_CTR, counter=counter)
|
||||
self.assertFalse(hasattr(cipher, "nonce"))
|
||||
|
||||
def test_nonce_parameter(self):
|
||||
# Nonce parameter becomes nonce attribute
|
||||
cipher1 = AES.new(self.key_128, AES.MODE_CTR, nonce=self.nonce_64)
|
||||
self.assertEqual(cipher1.nonce, self.nonce_64)
|
||||
|
||||
counter = Counter.new(64, prefix=self.nonce_64, initial_value=0)
|
||||
cipher2 = AES.new(self.key_128, AES.MODE_CTR, counter=counter)
|
||||
self.assertEqual(cipher1.nonce, cipher2.nonce)
|
||||
|
||||
pt = get_tag_random("plaintext", 65536)
|
||||
self.assertEqual(cipher1.encrypt(pt), cipher2.encrypt(pt))
|
||||
|
||||
# Nonce is implicitly created (for AES) when no parameters are passed
|
||||
nonce1 = AES.new(self.key_128, AES.MODE_CTR).nonce
|
||||
nonce2 = AES.new(self.key_128, AES.MODE_CTR).nonce
|
||||
self.assertNotEqual(nonce1, nonce2)
|
||||
self.assertEqual(len(nonce1), 8)
|
||||
|
||||
# Nonce can be zero-length
|
||||
cipher = AES.new(self.key_128, AES.MODE_CTR, nonce=b(""))
|
||||
self.assertEqual(b(""), cipher.nonce)
|
||||
|
||||
# Nonce and Counter are mutually exclusive
|
||||
self.assertRaises(TypeError, AES.new, self.key_128, AES.MODE_CTR,
|
||||
counter=self.ctr_128, nonce=self.nonce_64)
|
||||
|
||||
def test_initial_value_parameter(self):
|
||||
# Test with nonce parameter
|
||||
cipher1 = AES.new(self.key_128, AES.MODE_CTR,
|
||||
nonce=self.nonce_64, initial_value=0xFFFF)
|
||||
counter = Counter.new(64, prefix=self.nonce_64, initial_value=0xFFFF)
|
||||
cipher2 = AES.new(self.key_128, AES.MODE_CTR, counter=counter)
|
||||
pt = get_tag_random("plaintext", 65536)
|
||||
self.assertEqual(cipher1.encrypt(pt), cipher2.encrypt(pt))
|
||||
|
||||
# Test without nonce parameter
|
||||
cipher1 = AES.new(self.key_128, AES.MODE_CTR,
|
||||
initial_value=0xFFFF)
|
||||
counter = Counter.new(64, prefix=cipher1.nonce, initial_value=0xFFFF)
|
||||
cipher2 = AES.new(self.key_128, AES.MODE_CTR, counter=counter)
|
||||
pt = get_tag_random("plaintext", 65536)
|
||||
self.assertEqual(cipher1.encrypt(pt), cipher2.encrypt(pt))
|
||||
|
||||
# Initial_value and Counter are mutually exclusive
|
||||
self.assertRaises(TypeError, AES.new, self.key_128, AES.MODE_CTR,
|
||||
counter=self.ctr_128, initial_value=0)
|
||||
|
||||
def test_iv_with_matching_length(self):
|
||||
self.assertRaises(ValueError, AES.new, self.key_128, AES.MODE_CTR,
|
||||
counter=Counter.new(120))
|
||||
self.assertRaises(ValueError, AES.new, self.key_128, AES.MODE_CTR,
|
||||
counter=Counter.new(136))
|
||||
|
||||
def test_block_size_128(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_CTR, counter=self.ctr_128)
|
||||
self.assertEqual(cipher.block_size, AES.block_size)
|
||||
|
||||
def test_block_size_64(self):
|
||||
cipher = DES3.new(self.key_192, DES3.MODE_CTR, counter=self.ctr_64)
|
||||
self.assertEqual(cipher.block_size, DES3.block_size)
|
||||
|
||||
def test_unaligned_data_128(self):
|
||||
plaintexts = [ b("7777777") ] * 100
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_CTR, counter=self.ctr_128)
|
||||
ciphertexts = [ cipher.encrypt(x) for x in plaintexts ]
|
||||
cipher = AES.new(self.key_128, AES.MODE_CTR, counter=self.ctr_128)
|
||||
self.assertEqual(b("").join(ciphertexts), cipher.encrypt(b("").join(plaintexts)))
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_CTR, counter=self.ctr_128)
|
||||
ciphertexts = [ cipher.encrypt(x) for x in plaintexts ]
|
||||
cipher = AES.new(self.key_128, AES.MODE_CTR, counter=self.ctr_128)
|
||||
self.assertEqual(b("").join(ciphertexts), cipher.encrypt(b("").join(plaintexts)))
|
||||
|
||||
def test_unaligned_data_64(self):
|
||||
plaintexts = [ b("7777777") ] * 100
|
||||
cipher = DES3.new(self.key_192, AES.MODE_CTR, counter=self.ctr_64)
|
||||
ciphertexts = [ cipher.encrypt(x) for x in plaintexts ]
|
||||
cipher = DES3.new(self.key_192, AES.MODE_CTR, counter=self.ctr_64)
|
||||
self.assertEqual(b("").join(ciphertexts), cipher.encrypt(b("").join(plaintexts)))
|
||||
|
||||
cipher = DES3.new(self.key_192, AES.MODE_CTR, counter=self.ctr_64)
|
||||
ciphertexts = [ cipher.encrypt(x) for x in plaintexts ]
|
||||
cipher = DES3.new(self.key_192, AES.MODE_CTR, counter=self.ctr_64)
|
||||
self.assertEqual(b("").join(ciphertexts), cipher.encrypt(b("").join(plaintexts)))
|
||||
|
||||
def test_unknown_parameters(self):
|
||||
self.assertRaises(TypeError, AES.new, self.key_128, AES.MODE_CTR,
|
||||
7, counter=self.ctr_128)
|
||||
self.assertRaises(TypeError, AES.new, self.key_128, AES.MODE_CTR,
|
||||
counter=self.ctr_128, unknown=7)
|
||||
# But some are only known by the base cipher (e.g. use_aesni consumed by the AES module)
|
||||
AES.new(self.key_128, AES.MODE_CTR, counter=self.ctr_128, use_aesni=False)
|
||||
|
||||
def test_null_encryption_decryption(self):
|
||||
for func in "encrypt", "decrypt":
|
||||
cipher = AES.new(self.key_128, AES.MODE_CTR, counter=self.ctr_128)
|
||||
result = getattr(cipher, func)(b(""))
|
||||
self.assertEqual(result, b(""))
|
||||
|
||||
def test_either_encrypt_or_decrypt(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_CTR, counter=self.ctr_128)
|
||||
cipher.encrypt(b(""))
|
||||
self.assertRaises(TypeError, cipher.decrypt, b(""))
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_CTR, counter=self.ctr_128)
|
||||
cipher.decrypt(b(""))
|
||||
self.assertRaises(TypeError, cipher.encrypt, b(""))
|
||||
|
||||
def test_wrap_around(self):
|
||||
counter = Counter.new(8, prefix=bchr(9) * 15)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_CTR, counter=counter)
|
||||
cipher.encrypt(bchr(9) * 16 * 255)
|
||||
self.assertRaises(OverflowError, cipher.encrypt, bchr(9) * 16)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_CTR, counter=counter)
|
||||
cipher.decrypt(bchr(9) * 16 * 255)
|
||||
self.assertRaises(OverflowError, cipher.decrypt, bchr(9) * 16)
|
||||
|
||||
class SP800TestVectors(unittest.TestCase):
|
||||
"""Class exercising the CTR test vectors found in Section F.3
|
||||
of NIST SP 800-3A"""
|
||||
|
||||
def test_aes_128(self):
|
||||
plaintext = '6bc1bee22e409f96e93d7e117393172a' +\
|
||||
'ae2d8a571e03ac9c9eb76fac45af8e51' +\
|
||||
'30c81c46a35ce411e5fbc1191a0a52ef' +\
|
||||
'f69f2445df4f9b17ad2b417be66c3710'
|
||||
ciphertext = '874d6191b620e3261bef6864990db6ce' +\
|
||||
'9806f66b7970fdff8617187bb9fffdff' +\
|
||||
'5ae4df3edbd5d35e5b4f09020db03eab' +\
|
||||
'1e031dda2fbe03d1792170a0f3009cee'
|
||||
key = '2b7e151628aed2a6abf7158809cf4f3c'
|
||||
counter = Counter.new(nbits=16,
|
||||
prefix=unhexlify('f0f1f2f3f4f5f6f7f8f9fafbfcfd'),
|
||||
initial_value=0xfeff)
|
||||
|
||||
key = unhexlify(key)
|
||||
plaintext = unhexlify(plaintext)
|
||||
ciphertext = unhexlify(ciphertext)
|
||||
|
||||
cipher = AES.new(key, AES.MODE_CTR, counter=counter)
|
||||
self.assertEqual(cipher.encrypt(plaintext), ciphertext)
|
||||
cipher = AES.new(key, AES.MODE_CTR, counter=counter)
|
||||
self.assertEqual(cipher.decrypt(ciphertext), plaintext)
|
||||
|
||||
def test_aes_192(self):
|
||||
plaintext = '6bc1bee22e409f96e93d7e117393172a' +\
|
||||
'ae2d8a571e03ac9c9eb76fac45af8e51' +\
|
||||
'30c81c46a35ce411e5fbc1191a0a52ef' +\
|
||||
'f69f2445df4f9b17ad2b417be66c3710'
|
||||
ciphertext = '1abc932417521ca24f2b0459fe7e6e0b' +\
|
||||
'090339ec0aa6faefd5ccc2c6f4ce8e94' +\
|
||||
'1e36b26bd1ebc670d1bd1d665620abf7' +\
|
||||
'4f78a7f6d29809585a97daec58c6b050'
|
||||
key = '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b'
|
||||
counter = Counter.new(nbits=16,
|
||||
prefix=unhexlify('f0f1f2f3f4f5f6f7f8f9fafbfcfd'),
|
||||
initial_value=0xfeff)
|
||||
|
||||
key = unhexlify(key)
|
||||
plaintext = unhexlify(plaintext)
|
||||
ciphertext = unhexlify(ciphertext)
|
||||
|
||||
cipher = AES.new(key, AES.MODE_CTR, counter=counter)
|
||||
self.assertEqual(cipher.encrypt(plaintext), ciphertext)
|
||||
cipher = AES.new(key, AES.MODE_CTR, counter=counter)
|
||||
self.assertEqual(cipher.decrypt(ciphertext), plaintext)
|
||||
|
||||
def test_aes_256(self):
|
||||
plaintext = '6bc1bee22e409f96e93d7e117393172a' +\
|
||||
'ae2d8a571e03ac9c9eb76fac45af8e51' +\
|
||||
'30c81c46a35ce411e5fbc1191a0a52ef' +\
|
||||
'f69f2445df4f9b17ad2b417be66c3710'
|
||||
ciphertext = '601ec313775789a5b7a7f504bbf3d228' +\
|
||||
'f443e3ca4d62b59aca84e990cacaf5c5' +\
|
||||
'2b0930daa23de94ce87017ba2d84988d' +\
|
||||
'dfc9c58db67aada613c2dd08457941a6'
|
||||
key = '603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4'
|
||||
counter = Counter.new(nbits=16,
|
||||
prefix=unhexlify('f0f1f2f3f4f5f6f7f8f9fafbfcfd'),
|
||||
initial_value=0xfeff)
|
||||
key = unhexlify(key)
|
||||
plaintext = unhexlify(plaintext)
|
||||
ciphertext = unhexlify(ciphertext)
|
||||
|
||||
cipher = AES.new(key, AES.MODE_CTR, counter=counter)
|
||||
self.assertEqual(cipher.encrypt(plaintext), ciphertext)
|
||||
cipher = AES.new(key, AES.MODE_CTR, counter=counter)
|
||||
self.assertEqual(cipher.decrypt(ciphertext), plaintext)
|
||||
|
||||
|
||||
class RFC3686TestVectors(unittest.TestCase):
|
||||
|
||||
# Each item is a test vector with:
|
||||
# - plaintext
|
||||
# - ciphertext
|
||||
# - key (AES 128, 192 or 256 bits)
|
||||
# - counter prefix
|
||||
data = (
|
||||
('53696e676c6520626c6f636b206d7367',
|
||||
'e4095d4fb7a7b3792d6175a3261311b8',
|
||||
'ae6852f8121067cc4bf7a5765577f39e',
|
||||
'00000030'+'0000000000000000'),
|
||||
('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f',
|
||||
'5104a106168a72d9790d41ee8edad388eb2e1efc46da57c8fce630df9141be28',
|
||||
'7e24067817fae0d743d6ce1f32539163',
|
||||
'006cb6dbc0543b59da48d90b'),
|
||||
('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20212223',
|
||||
'c1cf48a89f2ffdd9cf4652e9efdb72d74540a42bde6d7836d59a5ceaaef3105325b2072f',
|
||||
'7691be035e5020a8ac6e618529f9a0dc',
|
||||
'00e0017b27777f3f4a1786f0'),
|
||||
('53696e676c6520626c6f636b206d7367',
|
||||
'4b55384fe259c9c84e7935a003cbe928',
|
||||
'16af5b145fc9f579c175f93e3bfb0eed863d06ccfdb78515',
|
||||
'0000004836733c147d6d93cb'),
|
||||
('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f',
|
||||
'453243fc609b23327edfaafa7131cd9f8490701c5ad4a79cfc1fe0ff42f4fb00',
|
||||
'7c5cb2401b3dc33c19e7340819e0f69c678c3db8e6f6a91a',
|
||||
'0096b03b020c6eadc2cb500d'),
|
||||
('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20212223',
|
||||
'96893fc55e5c722f540b7dd1ddf7e758d288bc95c69165884536c811662f2188abee0935',
|
||||
'02bf391ee8ecb159b959617b0965279bf59b60a786d3e0fe',
|
||||
'0007bdfd5cbd60278dcc0912'),
|
||||
('53696e676c6520626c6f636b206d7367',
|
||||
'145ad01dbf824ec7560863dc71e3e0c0',
|
||||
'776beff2851db06f4c8a0542c8696f6c6a81af1eec96b4d37fc1d689e6c1c104',
|
||||
'00000060db5672c97aa8f0b2'),
|
||||
('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f',
|
||||
'f05e231b3894612c49ee000b804eb2a9b8306b508f839d6a5530831d9344af1c',
|
||||
'f6d66d6bd52d59bb0796365879eff886c66dd51a5b6a99744b50590c87a23884',
|
||||
'00faac24c1585ef15a43d875'),
|
||||
('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20212223',
|
||||
'eb6c52821d0bbbf7ce7594462aca4faab407df866569fd07f48cc0b583d6071f1ec0e6b8',
|
||||
'ff7a617ce69148e4f1726e2f43581de2aa62d9f805532edff1eed687fb54153d',
|
||||
'001cc5b751a51d70a1c11148')
|
||||
)
|
||||
|
||||
bindata = []
|
||||
for tv in data:
|
||||
bindata.append([unhexlify(x) for x in tv])
|
||||
|
||||
def runTest(self):
|
||||
for pt, ct, key, prefix in self.bindata:
|
||||
counter = Counter.new(32, prefix=prefix)
|
||||
cipher = AES.new(key, AES.MODE_CTR, counter=counter)
|
||||
result = cipher.encrypt(pt)
|
||||
self.assertEqual(ct, result)
|
||||
|
||||
|
||||
def get_tests(config={}):
|
||||
tests = []
|
||||
tests += list_test_cases(CtrTests)
|
||||
tests += list_test_cases(SP800TestVectors)
|
||||
tests += [ RFC3686TestVectors() ]
|
||||
return tests
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
suite = lambda: unittest.TestSuite(get_tests())
|
||||
unittest.main(defaultTest='suite')
|
214
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_ChaCha20.py
Normal file
214
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_ChaCha20.py
Normal file
|
@ -0,0 +1,214 @@
|
|||
# ===================================================================
|
||||
#
|
||||
# Copyright (c) 2014, Legrandin <helderijs@gmail.com>
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
# ===================================================================
|
||||
|
||||
import os
|
||||
import re
|
||||
import unittest
|
||||
from binascii import unhexlify, hexlify
|
||||
|
||||
from Crypto.Util.py3compat import b, tobytes, bchr
|
||||
from Crypto.Util.strxor import strxor_c
|
||||
from Crypto.SelfTest.st_common import list_test_cases
|
||||
|
||||
from Crypto.Cipher import ChaCha20
|
||||
|
||||
|
||||
class ChaCha20Test(unittest.TestCase):
|
||||
|
||||
def test_new_positive(self):
|
||||
cipher = ChaCha20.new(key=b("0")*32, nonce=b("0")*8)
|
||||
self.assertEqual(cipher.nonce, b("0") * 8)
|
||||
|
||||
def test_new_negative(self):
|
||||
new = ChaCha20.new
|
||||
self.assertRaises(TypeError, new)
|
||||
self.assertRaises(TypeError, new, nonce=b("0"))
|
||||
self.assertRaises(ValueError, new, nonce=b("0")*8, key=b("0"))
|
||||
self.assertRaises(ValueError, new, nonce=b("0"), key=b("0")*32)
|
||||
|
||||
def test_default_nonce(self):
|
||||
cipher1 = ChaCha20.new(key=bchr(1) * 32)
|
||||
cipher2 = ChaCha20.new(key=bchr(1) * 32)
|
||||
self.assertEqual(len(cipher1.nonce), 8)
|
||||
self.assertNotEqual(cipher1.nonce, cipher2.nonce)
|
||||
|
||||
def test_eiter_encrypt_or_decrypt(self):
|
||||
"""Verify that a cipher cannot be used for both decrypting and encrypting"""
|
||||
|
||||
c1 = ChaCha20.new(key=b("5") * 32, nonce=b("6") * 8)
|
||||
c1.encrypt(b("8"))
|
||||
self.assertRaises(TypeError, c1.decrypt, b("9"))
|
||||
|
||||
c2 = ChaCha20.new(key=b("5") * 32, nonce=b("6") * 8)
|
||||
c2.decrypt(b("8"))
|
||||
self.assertRaises(TypeError, c2.encrypt, b("9"))
|
||||
|
||||
def test_round_trip(self):
|
||||
pt = b("A") * 1024
|
||||
c1 = ChaCha20.new(key=b("5") * 32, nonce=b("6") * 8)
|
||||
c2 = ChaCha20.new(key=b("5") * 32, nonce=b("6") * 8)
|
||||
ct = c1.encrypt(pt)
|
||||
self.assertEqual(c2.decrypt(ct), pt)
|
||||
|
||||
self.assertEqual(c1.encrypt(b("")), b(""))
|
||||
self.assertEqual(c2.decrypt(b("")), b(""))
|
||||
|
||||
def test_streaming(self):
|
||||
"""Verify that an arbitrary number of bytes can be encrypted/decrypted"""
|
||||
from Crypto.Hash import SHA1
|
||||
|
||||
segments = (1, 3, 5, 7, 11, 17, 23)
|
||||
total = sum(segments)
|
||||
|
||||
pt = b("")
|
||||
while len(pt) < total:
|
||||
pt += SHA1.new(pt).digest()
|
||||
|
||||
cipher1 = ChaCha20.new(key=b("7") * 32, nonce=b("t") * 8)
|
||||
ct = cipher1.encrypt(pt)
|
||||
|
||||
cipher2 = ChaCha20.new(key=b("7") * 32, nonce=b("t") * 8)
|
||||
cipher3 = ChaCha20.new(key=b("7") * 32, nonce=b("t") * 8)
|
||||
idx = 0
|
||||
for segment in segments:
|
||||
self.assertEqual(cipher2.decrypt(ct[idx:idx+segment]), pt[idx:idx+segment])
|
||||
self.assertEqual(cipher3.encrypt(pt[idx:idx+segment]), ct[idx:idx+segment])
|
||||
idx += segment
|
||||
|
||||
def test_seek(self):
|
||||
cipher1 = ChaCha20.new(key=b("9") * 32, nonce=b("e") * 8)
|
||||
|
||||
offset = 64 * 900 + 7
|
||||
pt = b("1") * 64
|
||||
|
||||
cipher1.encrypt(b("0") * offset)
|
||||
ct1 = cipher1.encrypt(pt)
|
||||
|
||||
cipher2 = ChaCha20.new(key=b("9") * 32, nonce=b("e") * 8)
|
||||
cipher2.seek(offset)
|
||||
ct2 = cipher2.encrypt(pt)
|
||||
|
||||
self.assertEqual(ct1, ct2)
|
||||
|
||||
def test_seek_tv(self):
|
||||
# Test Vector #4, A.1 from
|
||||
# http://tools.ietf.org/html/draft-nir-cfrg-chacha20-poly1305-04
|
||||
key = bchr(0) + bchr(255) + bchr(0) * 30
|
||||
nonce = bchr(0) * 8
|
||||
cipher = ChaCha20.new(key=key, nonce=nonce)
|
||||
cipher.seek(64 * 2)
|
||||
expected_key_stream = unhexlify(b(
|
||||
"72d54dfbf12ec44b362692df94137f32"
|
||||
"8fea8da73990265ec1bbbea1ae9af0ca"
|
||||
"13b25aa26cb4a648cb9b9d1be65b2c09"
|
||||
"24a66c54d545ec1b7374f4872e99f096"
|
||||
))
|
||||
ct = cipher.encrypt(bchr(0) * len(expected_key_stream))
|
||||
self.assertEqual(expected_key_stream, ct)
|
||||
|
||||
|
||||
class ChaCha20_AGL_NIR(unittest.TestCase):
|
||||
|
||||
# From http://tools.ietf.org/html/draft-agl-tls-chacha20poly1305-04
|
||||
# and http://tools.ietf.org/html/draft-nir-cfrg-chacha20-poly1305-04
|
||||
tv = [
|
||||
( "00" * 32,
|
||||
"00" * 8,
|
||||
"76b8e0ada0f13d90405d6ae55386bd28bdd219b8a08ded1aa836efcc"
|
||||
"8b770dc7da41597c5157488d7724e03fb8d84a376a43b8f41518a11c"
|
||||
"c387b669b2ee6586"
|
||||
"9f07e7be5551387a98ba977c732d080d"
|
||||
"cb0f29a048e3656912c6533e32ee7aed"
|
||||
"29b721769ce64e43d57133b074d839d5"
|
||||
"31ed1f28510afb45ace10a1f4b794d6f"
|
||||
),
|
||||
( "00" * 31 + "01",
|
||||
"00" * 8,
|
||||
"4540f05a9f1fb296d7736e7b208e3c96eb4fe1834688d2604f450952"
|
||||
"ed432d41bbe2a0b6ea7566d2a5d1e7e20d42af2c53d792b1c43fea81"
|
||||
"7e9ad275ae546963"
|
||||
"3aeb5224ecf849929b9d828db1ced4dd"
|
||||
"832025e8018b8160b82284f3c949aa5a"
|
||||
"8eca00bbb4a73bdad192b5c42f73f2fd"
|
||||
"4e273644c8b36125a64addeb006c13a0"
|
||||
),
|
||||
( "00" * 32,
|
||||
"00" * 7 + "01",
|
||||
"de9cba7bf3d69ef5e786dc63973f653a0b49e015adbff7134fcb7df1"
|
||||
"37821031e85a050278a7084527214f73efc7fa5b5277062eb7a0433e"
|
||||
"445f41e3"
|
||||
),
|
||||
( "00" * 32,
|
||||
"01" + "00" * 7,
|
||||
"ef3fdfd6c61578fbf5cf35bd3dd33b8009631634d21e42ac33960bd1"
|
||||
"38e50d32111e4caf237ee53ca8ad6426194a88545ddc497a0b466e7d"
|
||||
"6bbdb0041b2f586b"
|
||||
),
|
||||
( "000102030405060708090a0b0c0d0e0f101112131415161718191a1b"
|
||||
"1c1d1e1f",
|
||||
"0001020304050607",
|
||||
"f798a189f195e66982105ffb640bb7757f579da31602fc93ec01ac56"
|
||||
"f85ac3c134a4547b733b46413042c9440049176905d3be59ea1c53f1"
|
||||
"5916155c2be8241a38008b9a26bc35941e2444177c8ade6689de9526"
|
||||
"4986d95889fb60e84629c9bd9a5acb1cc118be563eb9b3a4a472f82e"
|
||||
"09a7e778492b562ef7130e88dfe031c79db9d4f7c7a899151b9a4750"
|
||||
"32b63fc385245fe054e3dd5a97a5f576fe064025d3ce042c566ab2c5"
|
||||
"07b138db853e3d6959660996546cc9c4a6eafdc777c040d70eaf46f7"
|
||||
"6dad3979e5c5360c3317166a1c894c94a371876a94df7628fe4eaaf2"
|
||||
"ccb27d5aaae0ad7ad0f9d4b6ad3b54098746d4524d38407a6deb3ab7"
|
||||
"8fab78c9"
|
||||
),
|
||||
( "00" * 32,
|
||||
"00" * 7 + "02",
|
||||
"c2c64d378cd536374ae204b9ef933fcd"
|
||||
"1a8b2288b3dfa49672ab765b54ee27c7"
|
||||
"8a970e0e955c14f3a88e741b97c286f7"
|
||||
"5f8fc299e8148362fa198a39531bed6d"
|
||||
),
|
||||
]
|
||||
|
||||
def runTest(self):
|
||||
for (key, nonce, stream) in self.tv:
|
||||
c = ChaCha20.new(key=unhexlify(b(key)), nonce=unhexlify(b(nonce)))
|
||||
ct = unhexlify(b(stream))
|
||||
pt = b("\x00") * len(ct)
|
||||
self.assertEqual(c.encrypt(pt), ct)
|
||||
|
||||
def get_tests(config={}):
|
||||
tests = []
|
||||
tests += list_test_cases(ChaCha20Test)
|
||||
tests.append(ChaCha20_AGL_NIR())
|
||||
return tests
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import unittest
|
||||
suite = lambda: unittest.TestSuite(get_tests())
|
||||
unittest.main(defaultTest='suite')
|
336
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_DES.py
Normal file
336
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_DES.py
Normal file
|
@ -0,0 +1,336 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# SelfTest/Cipher/DES.py: Self-test for the (Single) DES cipher
|
||||
#
|
||||
# Written in 2008 by Dwayne C. Litzenberger <dlitz@dlitz.net>
|
||||
#
|
||||
# ===================================================================
|
||||
# The contents of this file are dedicated to the public domain. To
|
||||
# the extent that dedication to the public domain is not available,
|
||||
# everyone is granted a worldwide, perpetual, royalty-free,
|
||||
# non-exclusive license to exercise all rights associated with the
|
||||
# contents of this file for any purpose whatsoever.
|
||||
# No rights are reserved.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
# ===================================================================
|
||||
|
||||
"""Self-test suite for Crypto.Cipher.DES"""
|
||||
|
||||
from Crypto.Util.py3compat import *
|
||||
import unittest
|
||||
|
||||
# This is a list of (plaintext, ciphertext, key, description) tuples.
|
||||
SP800_17_B1_KEY = '01' * 8
|
||||
SP800_17_B2_PT = '00' * 8
|
||||
test_data = [
|
||||
# Test vectors from Appendix A of NIST SP 800-17
|
||||
# "Modes of Operation Validation System (MOVS): Requirements and Procedures"
|
||||
# http://csrc.nist.gov/publications/nistpubs/800-17/800-17.pdf
|
||||
|
||||
# Appendix A - "Sample Round Outputs for the DES"
|
||||
('0000000000000000', '82dcbafbdeab6602', '10316e028c8f3b4a',
|
||||
"NIST SP800-17 A"),
|
||||
|
||||
# Table B.1 - Variable Plaintext Known Answer Test
|
||||
('8000000000000000', '95f8a5e5dd31d900', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #0'),
|
||||
('4000000000000000', 'dd7f121ca5015619', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #1'),
|
||||
('2000000000000000', '2e8653104f3834ea', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #2'),
|
||||
('1000000000000000', '4bd388ff6cd81d4f', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #3'),
|
||||
('0800000000000000', '20b9e767b2fb1456', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #4'),
|
||||
('0400000000000000', '55579380d77138ef', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #5'),
|
||||
('0200000000000000', '6cc5defaaf04512f', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #6'),
|
||||
('0100000000000000', '0d9f279ba5d87260', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #7'),
|
||||
('0080000000000000', 'd9031b0271bd5a0a', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #8'),
|
||||
('0040000000000000', '424250b37c3dd951', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #9'),
|
||||
('0020000000000000', 'b8061b7ecd9a21e5', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #10'),
|
||||
('0010000000000000', 'f15d0f286b65bd28', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #11'),
|
||||
('0008000000000000', 'add0cc8d6e5deba1', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #12'),
|
||||
('0004000000000000', 'e6d5f82752ad63d1', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #13'),
|
||||
('0002000000000000', 'ecbfe3bd3f591a5e', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #14'),
|
||||
('0001000000000000', 'f356834379d165cd', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #15'),
|
||||
('0000800000000000', '2b9f982f20037fa9', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #16'),
|
||||
('0000400000000000', '889de068a16f0be6', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #17'),
|
||||
('0000200000000000', 'e19e275d846a1298', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #18'),
|
||||
('0000100000000000', '329a8ed523d71aec', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #19'),
|
||||
('0000080000000000', 'e7fce22557d23c97', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #20'),
|
||||
('0000040000000000', '12a9f5817ff2d65d', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #21'),
|
||||
('0000020000000000', 'a484c3ad38dc9c19', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #22'),
|
||||
('0000010000000000', 'fbe00a8a1ef8ad72', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #23'),
|
||||
('0000008000000000', '750d079407521363', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #24'),
|
||||
('0000004000000000', '64feed9c724c2faf', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #25'),
|
||||
('0000002000000000', 'f02b263b328e2b60', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #26'),
|
||||
('0000001000000000', '9d64555a9a10b852', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #27'),
|
||||
('0000000800000000', 'd106ff0bed5255d7', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #28'),
|
||||
('0000000400000000', 'e1652c6b138c64a5', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #29'),
|
||||
('0000000200000000', 'e428581186ec8f46', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #30'),
|
||||
('0000000100000000', 'aeb5f5ede22d1a36', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #31'),
|
||||
('0000000080000000', 'e943d7568aec0c5c', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #32'),
|
||||
('0000000040000000', 'df98c8276f54b04b', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #33'),
|
||||
('0000000020000000', 'b160e4680f6c696f', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #34'),
|
||||
('0000000010000000', 'fa0752b07d9c4ab8', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #35'),
|
||||
('0000000008000000', 'ca3a2b036dbc8502', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #36'),
|
||||
('0000000004000000', '5e0905517bb59bcf', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #37'),
|
||||
('0000000002000000', '814eeb3b91d90726', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #38'),
|
||||
('0000000001000000', '4d49db1532919c9f', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #39'),
|
||||
('0000000000800000', '25eb5fc3f8cf0621', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #40'),
|
||||
('0000000000400000', 'ab6a20c0620d1c6f', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #41'),
|
||||
('0000000000200000', '79e90dbc98f92cca', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #42'),
|
||||
('0000000000100000', '866ecedd8072bb0e', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #43'),
|
||||
('0000000000080000', '8b54536f2f3e64a8', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #44'),
|
||||
('0000000000040000', 'ea51d3975595b86b', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #45'),
|
||||
('0000000000020000', 'caffc6ac4542de31', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #46'),
|
||||
('0000000000010000', '8dd45a2ddf90796c', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #47'),
|
||||
('0000000000008000', '1029d55e880ec2d0', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #48'),
|
||||
('0000000000004000', '5d86cb23639dbea9', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #49'),
|
||||
('0000000000002000', '1d1ca853ae7c0c5f', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #50'),
|
||||
('0000000000001000', 'ce332329248f3228', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #51'),
|
||||
('0000000000000800', '8405d1abe24fb942', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #52'),
|
||||
('0000000000000400', 'e643d78090ca4207', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #53'),
|
||||
('0000000000000200', '48221b9937748a23', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #54'),
|
||||
('0000000000000100', 'dd7c0bbd61fafd54', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #55'),
|
||||
('0000000000000080', '2fbc291a570db5c4', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #56'),
|
||||
('0000000000000040', 'e07c30d7e4e26e12', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #57'),
|
||||
('0000000000000020', '0953e2258e8e90a1', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #58'),
|
||||
('0000000000000010', '5b711bc4ceebf2ee', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #59'),
|
||||
('0000000000000008', 'cc083f1e6d9e85f6', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #60'),
|
||||
('0000000000000004', 'd2fd8867d50d2dfe', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #61'),
|
||||
('0000000000000002', '06e7ea22ce92708f', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #62'),
|
||||
('0000000000000001', '166b40b44aba4bd6', SP800_17_B1_KEY,
|
||||
'NIST SP800-17 B.1 #63'),
|
||||
|
||||
# Table B.2 - Variable Key Known Answer Test
|
||||
(SP800_17_B2_PT, '95a8d72813daa94d', '8001010101010101',
|
||||
'NIST SP800-17 B.2 #0'),
|
||||
(SP800_17_B2_PT, '0eec1487dd8c26d5', '4001010101010101',
|
||||
'NIST SP800-17 B.2 #1'),
|
||||
(SP800_17_B2_PT, '7ad16ffb79c45926', '2001010101010101',
|
||||
'NIST SP800-17 B.2 #2'),
|
||||
(SP800_17_B2_PT, 'd3746294ca6a6cf3', '1001010101010101',
|
||||
'NIST SP800-17 B.2 #3'),
|
||||
(SP800_17_B2_PT, '809f5f873c1fd761', '0801010101010101',
|
||||
'NIST SP800-17 B.2 #4'),
|
||||
(SP800_17_B2_PT, 'c02faffec989d1fc', '0401010101010101',
|
||||
'NIST SP800-17 B.2 #5'),
|
||||
(SP800_17_B2_PT, '4615aa1d33e72f10', '0201010101010101',
|
||||
'NIST SP800-17 B.2 #6'),
|
||||
(SP800_17_B2_PT, '2055123350c00858', '0180010101010101',
|
||||
'NIST SP800-17 B.2 #7'),
|
||||
(SP800_17_B2_PT, 'df3b99d6577397c8', '0140010101010101',
|
||||
'NIST SP800-17 B.2 #8'),
|
||||
(SP800_17_B2_PT, '31fe17369b5288c9', '0120010101010101',
|
||||
'NIST SP800-17 B.2 #9'),
|
||||
(SP800_17_B2_PT, 'dfdd3cc64dae1642', '0110010101010101',
|
||||
'NIST SP800-17 B.2 #10'),
|
||||
(SP800_17_B2_PT, '178c83ce2b399d94', '0108010101010101',
|
||||
'NIST SP800-17 B.2 #11'),
|
||||
(SP800_17_B2_PT, '50f636324a9b7f80', '0104010101010101',
|
||||
'NIST SP800-17 B.2 #12'),
|
||||
(SP800_17_B2_PT, 'a8468ee3bc18f06d', '0102010101010101',
|
||||
'NIST SP800-17 B.2 #13'),
|
||||
(SP800_17_B2_PT, 'a2dc9e92fd3cde92', '0101800101010101',
|
||||
'NIST SP800-17 B.2 #14'),
|
||||
(SP800_17_B2_PT, 'cac09f797d031287', '0101400101010101',
|
||||
'NIST SP800-17 B.2 #15'),
|
||||
(SP800_17_B2_PT, '90ba680b22aeb525', '0101200101010101',
|
||||
'NIST SP800-17 B.2 #16'),
|
||||
(SP800_17_B2_PT, 'ce7a24f350e280b6', '0101100101010101',
|
||||
'NIST SP800-17 B.2 #17'),
|
||||
(SP800_17_B2_PT, '882bff0aa01a0b87', '0101080101010101',
|
||||
'NIST SP800-17 B.2 #18'),
|
||||
(SP800_17_B2_PT, '25610288924511c2', '0101040101010101',
|
||||
'NIST SP800-17 B.2 #19'),
|
||||
(SP800_17_B2_PT, 'c71516c29c75d170', '0101020101010101',
|
||||
'NIST SP800-17 B.2 #20'),
|
||||
(SP800_17_B2_PT, '5199c29a52c9f059', '0101018001010101',
|
||||
'NIST SP800-17 B.2 #21'),
|
||||
(SP800_17_B2_PT, 'c22f0a294a71f29f', '0101014001010101',
|
||||
'NIST SP800-17 B.2 #22'),
|
||||
(SP800_17_B2_PT, 'ee371483714c02ea', '0101012001010101',
|
||||
'NIST SP800-17 B.2 #23'),
|
||||
(SP800_17_B2_PT, 'a81fbd448f9e522f', '0101011001010101',
|
||||
'NIST SP800-17 B.2 #24'),
|
||||
(SP800_17_B2_PT, '4f644c92e192dfed', '0101010801010101',
|
||||
'NIST SP800-17 B.2 #25'),
|
||||
(SP800_17_B2_PT, '1afa9a66a6df92ae', '0101010401010101',
|
||||
'NIST SP800-17 B.2 #26'),
|
||||
(SP800_17_B2_PT, 'b3c1cc715cb879d8', '0101010201010101',
|
||||
'NIST SP800-17 B.2 #27'),
|
||||
(SP800_17_B2_PT, '19d032e64ab0bd8b', '0101010180010101',
|
||||
'NIST SP800-17 B.2 #28'),
|
||||
(SP800_17_B2_PT, '3cfaa7a7dc8720dc', '0101010140010101',
|
||||
'NIST SP800-17 B.2 #29'),
|
||||
(SP800_17_B2_PT, 'b7265f7f447ac6f3', '0101010120010101',
|
||||
'NIST SP800-17 B.2 #30'),
|
||||
(SP800_17_B2_PT, '9db73b3c0d163f54', '0101010110010101',
|
||||
'NIST SP800-17 B.2 #31'),
|
||||
(SP800_17_B2_PT, '8181b65babf4a975', '0101010108010101',
|
||||
'NIST SP800-17 B.2 #32'),
|
||||
(SP800_17_B2_PT, '93c9b64042eaa240', '0101010104010101',
|
||||
'NIST SP800-17 B.2 #33'),
|
||||
(SP800_17_B2_PT, '5570530829705592', '0101010102010101',
|
||||
'NIST SP800-17 B.2 #34'),
|
||||
(SP800_17_B2_PT, '8638809e878787a0', '0101010101800101',
|
||||
'NIST SP800-17 B.2 #35'),
|
||||
(SP800_17_B2_PT, '41b9a79af79ac208', '0101010101400101',
|
||||
'NIST SP800-17 B.2 #36'),
|
||||
(SP800_17_B2_PT, '7a9be42f2009a892', '0101010101200101',
|
||||
'NIST SP800-17 B.2 #37'),
|
||||
(SP800_17_B2_PT, '29038d56ba6d2745', '0101010101100101',
|
||||
'NIST SP800-17 B.2 #38'),
|
||||
(SP800_17_B2_PT, '5495c6abf1e5df51', '0101010101080101',
|
||||
'NIST SP800-17 B.2 #39'),
|
||||
(SP800_17_B2_PT, 'ae13dbd561488933', '0101010101040101',
|
||||
'NIST SP800-17 B.2 #40'),
|
||||
(SP800_17_B2_PT, '024d1ffa8904e389', '0101010101020101',
|
||||
'NIST SP800-17 B.2 #41'),
|
||||
(SP800_17_B2_PT, 'd1399712f99bf02e', '0101010101018001',
|
||||
'NIST SP800-17 B.2 #42'),
|
||||
(SP800_17_B2_PT, '14c1d7c1cffec79e', '0101010101014001',
|
||||
'NIST SP800-17 B.2 #43'),
|
||||
(SP800_17_B2_PT, '1de5279dae3bed6f', '0101010101012001',
|
||||
'NIST SP800-17 B.2 #44'),
|
||||
(SP800_17_B2_PT, 'e941a33f85501303', '0101010101011001',
|
||||
'NIST SP800-17 B.2 #45'),
|
||||
(SP800_17_B2_PT, 'da99dbbc9a03f379', '0101010101010801',
|
||||
'NIST SP800-17 B.2 #46'),
|
||||
(SP800_17_B2_PT, 'b7fc92f91d8e92e9', '0101010101010401',
|
||||
'NIST SP800-17 B.2 #47'),
|
||||
(SP800_17_B2_PT, 'ae8e5caa3ca04e85', '0101010101010201',
|
||||
'NIST SP800-17 B.2 #48'),
|
||||
(SP800_17_B2_PT, '9cc62df43b6eed74', '0101010101010180',
|
||||
'NIST SP800-17 B.2 #49'),
|
||||
(SP800_17_B2_PT, 'd863dbb5c59a91a0', '0101010101010140',
|
||||
'NIST SP800-17 B.2 #50'),
|
||||
(SP800_17_B2_PT, 'a1ab2190545b91d7', '0101010101010120',
|
||||
'NIST SP800-17 B.2 #51'),
|
||||
(SP800_17_B2_PT, '0875041e64c570f7', '0101010101010110',
|
||||
'NIST SP800-17 B.2 #52'),
|
||||
(SP800_17_B2_PT, '5a594528bebef1cc', '0101010101010108',
|
||||
'NIST SP800-17 B.2 #53'),
|
||||
(SP800_17_B2_PT, 'fcdb3291de21f0c0', '0101010101010104',
|
||||
'NIST SP800-17 B.2 #54'),
|
||||
(SP800_17_B2_PT, '869efd7f9f265a09', '0101010101010102',
|
||||
'NIST SP800-17 B.2 #55'),
|
||||
]
|
||||
|
||||
class RonRivestTest(unittest.TestCase):
|
||||
""" Ronald L. Rivest's DES test, see
|
||||
http://people.csail.mit.edu/rivest/Destest.txt
|
||||
ABSTRACT
|
||||
--------
|
||||
|
||||
We present a simple way to test the correctness of a DES implementation:
|
||||
Use the recurrence relation:
|
||||
|
||||
X0 = 9474B8E8C73BCA7D (hexadecimal)
|
||||
|
||||
X(i+1) = IF (i is even) THEN E(Xi,Xi) ELSE D(Xi,Xi)
|
||||
|
||||
to compute a sequence of 64-bit values: X0, X1, X2, ..., X16. Here
|
||||
E(X,K) denotes the DES encryption of X using key K, and D(X,K) denotes
|
||||
the DES decryption of X using key K. If you obtain
|
||||
|
||||
X16 = 1B1A2DDB4C642438
|
||||
|
||||
your implementation does not have any of the 36,568 possible single-fault
|
||||
errors described herein.
|
||||
"""
|
||||
def runTest(self):
|
||||
from Crypto.Cipher import DES
|
||||
from binascii import b2a_hex
|
||||
|
||||
X = []
|
||||
X[0:] = [b('\x94\x74\xB8\xE8\xC7\x3B\xCA\x7D')]
|
||||
|
||||
for i in range(16):
|
||||
c = DES.new(X[i],DES.MODE_ECB)
|
||||
if not (i&1): # (num&1) returns 1 for odd numbers
|
||||
X[i+1:] = [c.encrypt(X[i])] # even
|
||||
else:
|
||||
X[i+1:] = [c.decrypt(X[i])] # odd
|
||||
|
||||
self.assertEqual(b2a_hex(X[16]),
|
||||
b2a_hex(b('\x1B\x1A\x2D\xDB\x4C\x64\x24\x38')))
|
||||
|
||||
def get_tests(config={}):
|
||||
from Crypto.Cipher import DES
|
||||
from .common import make_block_tests
|
||||
return make_block_tests(DES, "DES", test_data) + [RonRivestTest()]
|
||||
|
||||
if __name__ == '__main__':
|
||||
import unittest
|
||||
suite = lambda: unittest.TestSuite(get_tests())
|
||||
unittest.main(defaultTest='suite')
|
||||
|
||||
# vim:set ts=4 sw=4 sts=4 expandtab:
|
155
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_DES3.py
Normal file
155
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_DES3.py
Normal file
|
@ -0,0 +1,155 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# SelfTest/Cipher/DES3.py: Self-test for the Triple-DES cipher
|
||||
#
|
||||
# Written in 2008 by Dwayne C. Litzenberger <dlitz@dlitz.net>
|
||||
#
|
||||
# ===================================================================
|
||||
# The contents of this file are dedicated to the public domain. To
|
||||
# the extent that dedication to the public domain is not available,
|
||||
# everyone is granted a worldwide, perpetual, royalty-free,
|
||||
# non-exclusive license to exercise all rights associated with the
|
||||
# contents of this file for any purpose whatsoever.
|
||||
# No rights are reserved.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
# ===================================================================
|
||||
|
||||
"""Self-test suite for Crypto.Cipher.DES3"""
|
||||
|
||||
import unittest
|
||||
from binascii import hexlify
|
||||
|
||||
from Crypto.Cipher import DES3
|
||||
|
||||
from Crypto.Util.strxor import strxor_c
|
||||
from Crypto.Util.py3compat import bchr, unhexlify, tostr
|
||||
from Crypto.SelfTest.loader import load_tests
|
||||
from Crypto.SelfTest.st_common import list_test_cases
|
||||
|
||||
# This is a list of (plaintext, ciphertext, key, description) tuples.
|
||||
test_data = [
|
||||
# Test vector from Appendix B of NIST SP 800-67
|
||||
# "Recommendation for the Triple Data Encryption Algorithm (TDEA) Block
|
||||
# Cipher"
|
||||
# http://csrc.nist.gov/publications/nistpubs/800-67/SP800-67.pdf
|
||||
('54686520717566636b2062726f776e20666f78206a756d70',
|
||||
'a826fd8ce53b855fcce21c8112256fe668d5c05dd9b6b900',
|
||||
'0123456789abcdef23456789abcdef01456789abcdef0123',
|
||||
'NIST SP800-67 B.1'),
|
||||
|
||||
# This test is designed to test the DES3 API, not the correctness of the
|
||||
# output.
|
||||
('21e81b7ade88a259', '5c577d4d9b20c0f8',
|
||||
'9b397ebf81b1181e282f4bb8adbadc6b', 'Two-key 3DES'),
|
||||
]
|
||||
|
||||
# NIST CAVP test vectors
|
||||
|
||||
nist_tdes_mmt_files = ("TECBMMT2.rsp", "TECBMMT3.rsp")
|
||||
|
||||
for tdes_file in nist_tdes_mmt_files:
|
||||
test_vectors = load_tests(("Crypto", "SelfTest", "Cipher", "test_vectors", "TDES"),
|
||||
tdes_file,
|
||||
"TDES ECB (%s)" % tdes_file,
|
||||
{ "count" : lambda x: int(x) } )
|
||||
assert(test_vectors)
|
||||
for index, tv in enumerate(test_vectors):
|
||||
|
||||
# The test vector file contains some directive lines
|
||||
if isinstance(tv, str):
|
||||
continue
|
||||
|
||||
key = tv.key1 + tv.key2 + tv.key3
|
||||
test_data_item = (tostr(hexlify(tv.plaintext)),
|
||||
tostr(hexlify(tv.ciphertext)),
|
||||
tostr(hexlify(key)),
|
||||
"%s (%s)" % (tdes_file, index))
|
||||
test_data.append(test_data_item)
|
||||
|
||||
|
||||
class CheckParity(unittest.TestCase):
|
||||
|
||||
def test_parity_option2(self):
|
||||
before_2k = unhexlify("CABF326FA56734324FFCCABCDEFACABF")
|
||||
after_2k = DES3.adjust_key_parity(before_2k)
|
||||
self.assertEqual(after_2k,
|
||||
unhexlify("CBBF326EA46734324FFDCBBCDFFBCBBF"))
|
||||
|
||||
def test_parity_option3(self):
|
||||
before_3k = unhexlify("AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCC")
|
||||
after_3k = DES3.adjust_key_parity(before_3k)
|
||||
self.assertEqual(after_3k,
|
||||
unhexlify("ABABABABABABABABBABABABABABABABACDCDCDCDCDCDCDCD"))
|
||||
|
||||
def test_degradation(self):
|
||||
sub_key1 = bchr(1) * 8
|
||||
sub_key2 = bchr(255) * 8
|
||||
|
||||
# K1 == K2
|
||||
self.assertRaises(ValueError, DES3.adjust_key_parity,
|
||||
sub_key1 * 2 + sub_key2)
|
||||
|
||||
# K2 == K3
|
||||
self.assertRaises(ValueError, DES3.adjust_key_parity,
|
||||
sub_key1 + sub_key2 * 2)
|
||||
|
||||
# K1 == K2 == K3
|
||||
self.assertRaises(ValueError, DES3.adjust_key_parity,
|
||||
sub_key1 * 3)
|
||||
|
||||
# K1 == K2 (with different parity)
|
||||
self.assertRaises(ValueError, DES3.adjust_key_parity,
|
||||
sub_key1 + strxor_c(sub_key1, 1) + sub_key2)
|
||||
|
||||
|
||||
class DegenerateToDESTest(unittest.TestCase):
|
||||
|
||||
def runTest(self):
|
||||
sub_key1 = bchr(1) * 8
|
||||
sub_key2 = bchr(255) * 8
|
||||
|
||||
# K1 == K2
|
||||
self.assertRaises(ValueError, DES3.new,
|
||||
sub_key1 * 2 + sub_key2,
|
||||
DES3.MODE_ECB)
|
||||
|
||||
# K2 == K3
|
||||
self.assertRaises(ValueError, DES3.new,
|
||||
sub_key1 + sub_key2 * 2,
|
||||
DES3.MODE_ECB)
|
||||
|
||||
# K1 == K2 == K3
|
||||
self.assertRaises(ValueError, DES3.new,
|
||||
sub_key1 *3,
|
||||
DES3.MODE_ECB)
|
||||
|
||||
# K2 == K3 (parity is ignored)
|
||||
self.assertRaises(ValueError, DES3.new,
|
||||
sub_key1 + sub_key2 + strxor_c(sub_key2, 0x1),
|
||||
DES3.MODE_ECB)
|
||||
|
||||
|
||||
def get_tests(config={}):
|
||||
from .common import make_block_tests
|
||||
|
||||
tests = []
|
||||
tests = make_block_tests(DES3, "DES3", test_data)
|
||||
tests.append(DegenerateToDESTest())
|
||||
tests += list_test_cases(CheckParity)
|
||||
return tests
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import unittest
|
||||
suite = lambda: unittest.TestSuite(get_tests())
|
||||
unittest.main(defaultTest='suite')
|
||||
|
||||
# vim:set ts=4 sw=4 sts=4 expandtab:
|
528
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_EAX.py
Normal file
528
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_EAX.py
Normal file
|
@ -0,0 +1,528 @@
|
|||
# ===================================================================
|
||||
#
|
||||
# Copyright (c) 2015, Legrandin <helderijs@gmail.com>
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
# ===================================================================
|
||||
|
||||
import unittest
|
||||
|
||||
from Crypto.SelfTest.st_common import list_test_cases
|
||||
from Crypto.Util.py3compat import unhexlify, tobytes, bchr, b
|
||||
from Crypto.Cipher import AES, DES3
|
||||
from Crypto.Hash import SHAKE128
|
||||
|
||||
|
||||
def get_tag_random(tag, length):
|
||||
return SHAKE128.new(data=tobytes(tag)).read(length)
|
||||
|
||||
|
||||
class EaxTests(unittest.TestCase):
|
||||
|
||||
key_128 = get_tag_random("key_128", 16)
|
||||
key_192 = get_tag_random("key_192", 16)
|
||||
nonce_96 = get_tag_random("nonce_128", 12)
|
||||
data_128 = get_tag_random("data_128", 16)
|
||||
|
||||
def test_loopback_128(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
pt = get_tag_random("plaintext", 16 * 100)
|
||||
ct = cipher.encrypt(pt)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
pt2 = cipher.decrypt(ct)
|
||||
self.assertEqual(pt, pt2)
|
||||
|
||||
def test_loopback_64(self):
|
||||
cipher = DES3.new(self.key_192, DES3.MODE_EAX, nonce=self.nonce_96)
|
||||
pt = get_tag_random("plaintext", 8 * 100)
|
||||
ct = cipher.encrypt(pt)
|
||||
|
||||
cipher = DES3.new(self.key_192, DES3.MODE_EAX, nonce=self.nonce_96)
|
||||
pt2 = cipher.decrypt(ct)
|
||||
self.assertEqual(pt, pt2)
|
||||
|
||||
def test_nonce(self):
|
||||
# If not passed, the nonce is created randomly
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX)
|
||||
nonce1 = cipher.nonce
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX)
|
||||
nonce2 = cipher.nonce
|
||||
self.assertEqual(len(nonce1), 16)
|
||||
self.assertNotEqual(nonce1, nonce2)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, self.nonce_96)
|
||||
ct = cipher.encrypt(self.data_128)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
self.assertEqual(ct, cipher.encrypt(self.data_128))
|
||||
|
||||
def test_nonce_must_be_bytes(self):
|
||||
self.assertRaises(TypeError, AES.new, self.key_128, AES.MODE_EAX,
|
||||
nonce='test12345678')
|
||||
|
||||
def test_nonce_length(self):
|
||||
# nonce can be of any length (but not empty)
|
||||
self.assertRaises(ValueError, AES.new, self.key_128, AES.MODE_EAX,
|
||||
nonce=b(""))
|
||||
|
||||
for x in range(1, 128):
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=bchr(1) * x)
|
||||
cipher.encrypt(bchr(1))
|
||||
|
||||
def test_block_size_128(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
self.assertEqual(cipher.block_size, AES.block_size)
|
||||
|
||||
def test_block_size_64(self):
|
||||
cipher = DES3.new(self.key_192, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
self.assertEqual(cipher.block_size, DES3.block_size)
|
||||
|
||||
def test_nonce_attribute(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
self.assertEqual(cipher.nonce, self.nonce_96)
|
||||
|
||||
# By default, a 16 bytes long nonce is randomly generated
|
||||
nonce1 = AES.new(self.key_128, AES.MODE_EAX).nonce
|
||||
nonce2 = AES.new(self.key_128, AES.MODE_EAX).nonce
|
||||
self.assertEqual(len(nonce1), 16)
|
||||
self.assertNotEqual(nonce1, nonce2)
|
||||
|
||||
def test_unknown_parameters(self):
|
||||
self.assertRaises(TypeError, AES.new, self.key_128, AES.MODE_EAX,
|
||||
self.nonce_96, 7)
|
||||
self.assertRaises(TypeError, AES.new, self.key_128, AES.MODE_EAX,
|
||||
nonce=self.nonce_96, unknown=7)
|
||||
|
||||
# But some are only known by the base cipher
|
||||
# (e.g. use_aesni consumed by the AES module)
|
||||
AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96,
|
||||
use_aesni=False)
|
||||
|
||||
def test_null_encryption_decryption(self):
|
||||
for func in "encrypt", "decrypt":
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
result = getattr(cipher, func)(b(""))
|
||||
self.assertEqual(result, b(""))
|
||||
|
||||
def test_either_encrypt_or_decrypt(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
cipher.encrypt(b(""))
|
||||
self.assertRaises(TypeError, cipher.decrypt, b(""))
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
cipher.decrypt(b(""))
|
||||
self.assertRaises(TypeError, cipher.encrypt, b(""))
|
||||
|
||||
def test_data_must_be_bytes(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
self.assertRaises(TypeError, cipher.encrypt, 'test1234567890-*')
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
self.assertRaises(TypeError, cipher.decrypt, 'test1234567890-*')
|
||||
|
||||
def test_mac_len(self):
|
||||
# Invalid MAC length
|
||||
self.assertRaises(ValueError, AES.new, self.key_128, AES.MODE_EAX,
|
||||
nonce=self.nonce_96, mac_len=3)
|
||||
self.assertRaises(ValueError, AES.new, self.key_128, AES.MODE_EAX,
|
||||
nonce=self.nonce_96, mac_len=16+1)
|
||||
|
||||
# Valid MAC length
|
||||
for mac_len in range(5, 16 + 1):
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96,
|
||||
mac_len=mac_len)
|
||||
_, mac = cipher.encrypt_and_digest(self.data_128)
|
||||
self.assertEqual(len(mac), mac_len)
|
||||
|
||||
# Default MAC length
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
_, mac = cipher.encrypt_and_digest(self.data_128)
|
||||
self.assertEqual(len(mac), 16)
|
||||
|
||||
def test_invalid_mac(self):
|
||||
from Crypto.Util.strxor import strxor_c
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
ct, mac = cipher.encrypt_and_digest(self.data_128)
|
||||
|
||||
invalid_mac = strxor_c(mac, 0x01)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
self.assertRaises(ValueError, cipher.decrypt_and_verify, ct,
|
||||
invalid_mac)
|
||||
|
||||
def test_hex_mac(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
mac_hex = cipher.hexdigest()
|
||||
self.assertEqual(cipher.digest(), unhexlify(mac_hex))
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
cipher.hexverify(mac_hex)
|
||||
|
||||
def test_message_chunks(self):
|
||||
# Validate that both associated data and plaintext/ciphertext
|
||||
# can be broken up in chunks of arbitrary length
|
||||
|
||||
auth_data = get_tag_random("authenticated data", 127)
|
||||
plaintext = get_tag_random("plaintext", 127)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
cipher.update(auth_data)
|
||||
ciphertext, ref_mac = cipher.encrypt_and_digest(plaintext)
|
||||
|
||||
def break_up(data, chunk_length):
|
||||
return [data[i:i+chunk_length] for i in range(0, len(data),
|
||||
chunk_length)]
|
||||
|
||||
# Encryption
|
||||
for chunk_length in 1, 2, 3, 7, 10, 13, 16, 40, 80, 128:
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
|
||||
for chunk in break_up(auth_data, chunk_length):
|
||||
cipher.update(chunk)
|
||||
pt2 = b("")
|
||||
for chunk in break_up(ciphertext, chunk_length):
|
||||
pt2 += cipher.decrypt(chunk)
|
||||
self.assertEqual(plaintext, pt2)
|
||||
cipher.verify(ref_mac)
|
||||
|
||||
# Decryption
|
||||
for chunk_length in 1, 2, 3, 7, 10, 13, 16, 40, 80, 128:
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
|
||||
for chunk in break_up(auth_data, chunk_length):
|
||||
cipher.update(chunk)
|
||||
ct2 = b("")
|
||||
for chunk in break_up(plaintext, chunk_length):
|
||||
ct2 += cipher.encrypt(chunk)
|
||||
self.assertEqual(ciphertext, ct2)
|
||||
self.assertEqual(cipher.digest(), ref_mac)
|
||||
|
||||
|
||||
class EaxFSMTests(unittest.TestCase):
|
||||
|
||||
key_128 = get_tag_random("key_128", 16)
|
||||
nonce_96 = get_tag_random("nonce_128", 12)
|
||||
data_128 = get_tag_random("data_128", 16)
|
||||
|
||||
def test_valid_init_encrypt_decrypt_digest_verify(self):
|
||||
# No authenticated data, fixed plaintext
|
||||
# Verify path INIT->ENCRYPT->DIGEST
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX,
|
||||
nonce=self.nonce_96)
|
||||
ct = cipher.encrypt(self.data_128)
|
||||
mac = cipher.digest()
|
||||
|
||||
# Verify path INIT->DECRYPT->VERIFY
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX,
|
||||
nonce=self.nonce_96)
|
||||
cipher.decrypt(ct)
|
||||
cipher.verify(mac)
|
||||
|
||||
def test_valid_init_update_digest_verify(self):
|
||||
# No plaintext, fixed authenticated data
|
||||
# Verify path INIT->UPDATE->DIGEST
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX,
|
||||
nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
mac = cipher.digest()
|
||||
|
||||
# Verify path INIT->UPDATE->VERIFY
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX,
|
||||
nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
cipher.verify(mac)
|
||||
|
||||
def test_valid_full_path(self):
|
||||
# Fixed authenticated data, fixed plaintext
|
||||
# Verify path INIT->UPDATE->ENCRYPT->DIGEST
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX,
|
||||
nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
ct = cipher.encrypt(self.data_128)
|
||||
mac = cipher.digest()
|
||||
|
||||
# Verify path INIT->UPDATE->DECRYPT->VERIFY
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX,
|
||||
nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
cipher.decrypt(ct)
|
||||
cipher.verify(mac)
|
||||
|
||||
def test_valid_init_digest(self):
|
||||
# Verify path INIT->DIGEST
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
cipher.digest()
|
||||
|
||||
def test_valid_init_verify(self):
|
||||
# Verify path INIT->VERIFY
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
mac = cipher.digest()
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
cipher.verify(mac)
|
||||
|
||||
def test_valid_multiple_encrypt_or_decrypt(self):
|
||||
for method_name in "encrypt", "decrypt":
|
||||
for auth_data in (None, b("333"), self.data_128,
|
||||
self.data_128 + b("3")):
|
||||
if auth_data is None:
|
||||
assoc_len = None
|
||||
else:
|
||||
assoc_len = len(auth_data)
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX,
|
||||
nonce=self.nonce_96)
|
||||
if auth_data is not None:
|
||||
cipher.update(auth_data)
|
||||
method = getattr(cipher, method_name)
|
||||
method(self.data_128)
|
||||
method(self.data_128)
|
||||
method(self.data_128)
|
||||
method(self.data_128)
|
||||
|
||||
def test_valid_multiple_digest_or_verify(self):
|
||||
# Multiple calls to digest
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
first_mac = cipher.digest()
|
||||
for x in range(4):
|
||||
self.assertEqual(first_mac, cipher.digest())
|
||||
|
||||
# Multiple calls to verify
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
for x in range(5):
|
||||
cipher.verify(first_mac)
|
||||
|
||||
def test_valid_encrypt_and_digest_decrypt_and_verify(self):
|
||||
# encrypt_and_digest
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
ct, mac = cipher.encrypt_and_digest(self.data_128)
|
||||
|
||||
# decrypt_and_verify
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
pt = cipher.decrypt_and_verify(ct, mac)
|
||||
self.assertEqual(self.data_128, pt)
|
||||
|
||||
def test_invalid_mixing_encrypt_decrypt(self):
|
||||
# Once per method, with or without assoc. data
|
||||
for method1_name, method2_name in (("encrypt", "decrypt"),
|
||||
("decrypt", "encrypt")):
|
||||
for assoc_data_present in (True, False):
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX,
|
||||
nonce=self.nonce_96)
|
||||
if assoc_data_present:
|
||||
cipher.update(self.data_128)
|
||||
getattr(cipher, method1_name)(self.data_128)
|
||||
self.assertRaises(TypeError, getattr(cipher, method2_name),
|
||||
self.data_128)
|
||||
|
||||
def test_invalid_encrypt_or_update_after_digest(self):
|
||||
for method_name in "encrypt", "update":
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
cipher.encrypt(self.data_128)
|
||||
cipher.digest()
|
||||
self.assertRaises(TypeError, getattr(cipher, method_name),
|
||||
self.data_128)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
cipher.encrypt_and_digest(self.data_128)
|
||||
|
||||
def test_invalid_decrypt_or_update_after_verify(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
ct = cipher.encrypt(self.data_128)
|
||||
mac = cipher.digest()
|
||||
|
||||
for method_name in "decrypt", "update":
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
cipher.decrypt(ct)
|
||||
cipher.verify(mac)
|
||||
self.assertRaises(TypeError, getattr(cipher, method_name),
|
||||
self.data_128)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_EAX, nonce=self.nonce_96)
|
||||
cipher.decrypt_and_verify(ct, mac)
|
||||
self.assertRaises(TypeError, getattr(cipher, method_name),
|
||||
self.data_128)
|
||||
|
||||
|
||||
class TestVectors(unittest.TestCase):
|
||||
"""Class exercising the EAX test vectors found in
|
||||
http://www.cs.ucdavis.edu/~rogaway/papers/eax.pdf"""
|
||||
|
||||
test_vectors = [
|
||||
( '6bfb914fd07eae6b',
|
||||
'',
|
||||
'',
|
||||
'e037830e8389f27b025a2d6527e79d01',
|
||||
'233952dee4d5ed5f9b9c6d6ff80ff478',
|
||||
'62EC67F9C3A4A407FCB2A8C49031A8B3'
|
||||
),
|
||||
(
|
||||
'fa3bfd4806eb53fa',
|
||||
'f7fb',
|
||||
'19dd',
|
||||
'5c4c9331049d0bdab0277408f67967e5',
|
||||
'91945d3f4dcbee0bf45ef52255f095a4',
|
||||
'BECAF043B0A23D843194BA972C66DEBD'
|
||||
),
|
||||
( '234a3463c1264ac6',
|
||||
'1a47cb4933',
|
||||
'd851d5bae0',
|
||||
'3a59f238a23e39199dc9266626c40f80',
|
||||
'01f74ad64077f2e704c0f60ada3dd523',
|
||||
'70C3DB4F0D26368400A10ED05D2BFF5E'
|
||||
),
|
||||
(
|
||||
'33cce2eabff5a79d',
|
||||
'481c9e39b1',
|
||||
'632a9d131a',
|
||||
'd4c168a4225d8e1ff755939974a7bede',
|
||||
'd07cf6cbb7f313bdde66b727afd3c5e8',
|
||||
'8408DFFF3C1A2B1292DC199E46B7D617'
|
||||
),
|
||||
(
|
||||
'aeb96eaebe2970e9',
|
||||
'40d0c07da5e4',
|
||||
'071dfe16c675',
|
||||
'cb0677e536f73afe6a14b74ee49844dd',
|
||||
'35b6d0580005bbc12b0587124557d2c2',
|
||||
'FDB6B06676EEDC5C61D74276E1F8E816'
|
||||
),
|
||||
(
|
||||
'd4482d1ca78dce0f',
|
||||
'4de3b35c3fc039245bd1fb7d',
|
||||
'835bb4f15d743e350e728414',
|
||||
'abb8644fd6ccb86947c5e10590210a4f',
|
||||
'bd8e6e11475e60b268784c38c62feb22',
|
||||
'6EAC5C93072D8E8513F750935E46DA1B'
|
||||
),
|
||||
(
|
||||
'65d2017990d62528',
|
||||
'8b0a79306c9ce7ed99dae4f87f8dd61636',
|
||||
'02083e3979da014812f59f11d52630da30',
|
||||
'137327d10649b0aa6e1c181db617d7f2',
|
||||
'7c77d6e813bed5ac98baa417477a2e7d',
|
||||
'1A8C98DCD73D38393B2BF1569DEEFC19'
|
||||
),
|
||||
(
|
||||
'54b9f04e6a09189a',
|
||||
'1bda122bce8a8dbaf1877d962b8592dd2d56',
|
||||
'2ec47b2c4954a489afc7ba4897edcdae8cc3',
|
||||
'3b60450599bd02c96382902aef7f832a',
|
||||
'5fff20cafab119ca2fc73549e20f5b0d',
|
||||
'DDE59B97D722156D4D9AFF2BC7559826'
|
||||
),
|
||||
(
|
||||
'899a175897561d7e',
|
||||
'6cf36720872b8513f6eab1a8a44438d5ef11',
|
||||
'0de18fd0fdd91e7af19f1d8ee8733938b1e8',
|
||||
'e7f6d2231618102fdb7fe55ff1991700',
|
||||
'a4a4782bcffd3ec5e7ef6d8c34a56123',
|
||||
'B781FCF2F75FA5A8DE97A9CA48E522EC'
|
||||
),
|
||||
(
|
||||
'126735fcc320d25a',
|
||||
'ca40d7446e545ffaed3bd12a740a659ffbbb3ceab7',
|
||||
'cb8920f87a6c75cff39627b56e3ed197c552d295a7',
|
||||
'cfc46afc253b4652b1af3795b124ab6e',
|
||||
'8395fcf1e95bebd697bd010bc766aac3',
|
||||
'22E7ADD93CFC6393C57EC0B3C17D6B44'
|
||||
),
|
||||
]
|
||||
|
||||
for index, tv in enumerate(test_vectors):
|
||||
test_vectors[index] = (unhexlify(x) for x in tv)
|
||||
|
||||
def runTest(self):
|
||||
for assoc_data, pt, ct, mac, key, nonce in self.test_vectors:
|
||||
# Encrypt
|
||||
cipher = AES.new(key, AES.MODE_EAX, nonce, mac_len=len(mac))
|
||||
cipher.update(assoc_data)
|
||||
ct2, mac2 = cipher.encrypt_and_digest(pt)
|
||||
self.assertEqual(ct, ct2)
|
||||
self.assertEqual(mac, mac2)
|
||||
|
||||
# Decrypt
|
||||
cipher = AES.new(key, AES.MODE_EAX, nonce, mac_len=len(mac))
|
||||
cipher.update(assoc_data)
|
||||
pt2 = cipher.decrypt_and_verify(ct, mac)
|
||||
self.assertEqual(pt, pt2)
|
||||
|
||||
|
||||
class TestOtherCiphers(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def create_test(cls, name, factory, key_size):
|
||||
|
||||
def test_template(self, factory=factory, key_size=key_size):
|
||||
cipher = factory.new(get_tag_random("cipher", key_size),
|
||||
factory.MODE_EAX,
|
||||
nonce=b("nonce"))
|
||||
ct, mac = cipher.encrypt_and_digest(b("plaintext"))
|
||||
|
||||
cipher = factory.new(get_tag_random("cipher", key_size),
|
||||
factory.MODE_EAX,
|
||||
nonce=b("nonce"))
|
||||
pt2 = cipher.decrypt_and_verify(ct, mac)
|
||||
|
||||
self.assertEqual(b("plaintext"), pt2)
|
||||
|
||||
setattr(cls, "test_" + name, test_template)
|
||||
|
||||
|
||||
from Crypto.Cipher import DES, DES3, ARC2, CAST, Blowfish
|
||||
|
||||
for name, factory in (('DES', DES),
|
||||
('DES3', DES3),
|
||||
('ARC2', ARC2),
|
||||
('CAST', CAST),
|
||||
('Blowfish', Blowfish)):
|
||||
key_sizes = []
|
||||
try:
|
||||
key_sizes += factory.key_size
|
||||
except TypeError:
|
||||
key_sizes = [factory.key_size]
|
||||
for ks in key_sizes:
|
||||
TestOtherCiphers.create_test(name + "_" + str(ks), factory, ks)
|
||||
|
||||
|
||||
def get_tests(config={}):
|
||||
tests = []
|
||||
tests += list_test_cases(EaxTests)
|
||||
tests += list_test_cases(EaxFSMTests)
|
||||
tests += [TestVectors()]
|
||||
tests += list_test_cases(TestOtherCiphers)
|
||||
return tests
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
suite = lambda: unittest.TestSuite(get_tests())
|
||||
unittest.main(defaultTest='suite')
|
658
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_GCM.py
Normal file
658
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_GCM.py
Normal file
|
@ -0,0 +1,658 @@
|
|||
# ===================================================================
|
||||
#
|
||||
# Copyright (c) 2015, Legrandin <helderijs@gmail.com>
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
# ===================================================================
|
||||
|
||||
import unittest
|
||||
|
||||
from Crypto.SelfTest.st_common import list_test_cases
|
||||
from Crypto.Util.py3compat import unhexlify, tobytes, bchr, b
|
||||
from Crypto.Cipher import AES
|
||||
from Crypto.Hash import SHAKE128
|
||||
|
||||
|
||||
def get_tag_random(tag, length):
|
||||
return SHAKE128.new(data=tobytes(tag)).read(length)
|
||||
|
||||
|
||||
class GcmTests(unittest.TestCase):
|
||||
|
||||
key_128 = get_tag_random("key_128", 16)
|
||||
nonce_96 = get_tag_random("nonce_128", 12)
|
||||
data_128 = get_tag_random("data_128", 16)
|
||||
|
||||
def test_loopback_128(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
pt = get_tag_random("plaintext", 16 * 100)
|
||||
ct = cipher.encrypt(pt)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
pt2 = cipher.decrypt(ct)
|
||||
self.assertEqual(pt, pt2)
|
||||
|
||||
def test_nonce(self):
|
||||
# Nonce is optional (a random one will be created)
|
||||
AES.new(self.key_128, AES.MODE_GCM)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, self.nonce_96)
|
||||
ct = cipher.encrypt(self.data_128)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
self.assertEqual(ct, cipher.encrypt(self.data_128))
|
||||
|
||||
def test_nonce_must_be_bytes(self):
|
||||
self.assertRaises(TypeError, AES.new, self.key_128, AES.MODE_GCM,
|
||||
nonce='test12345678')
|
||||
|
||||
def test_nonce_length(self):
|
||||
# nonce can be of any length (but not empty)
|
||||
self.assertRaises(ValueError, AES.new, self.key_128, AES.MODE_GCM,
|
||||
nonce=b(""))
|
||||
|
||||
for x in range(1, 128):
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=bchr(1) * x)
|
||||
cipher.encrypt(bchr(1))
|
||||
|
||||
def test_block_size_128(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
self.assertEqual(cipher.block_size, AES.block_size)
|
||||
|
||||
def test_nonce_attribute(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
self.assertEqual(cipher.nonce, self.nonce_96)
|
||||
|
||||
# By default, a 15 bytes long nonce is randomly generated
|
||||
nonce1 = AES.new(self.key_128, AES.MODE_GCM).nonce
|
||||
nonce2 = AES.new(self.key_128, AES.MODE_GCM).nonce
|
||||
self.assertEqual(len(nonce1), 16)
|
||||
self.assertNotEqual(nonce1, nonce2)
|
||||
|
||||
def test_unknown_parameters(self):
|
||||
self.assertRaises(TypeError, AES.new, self.key_128, AES.MODE_GCM,
|
||||
self.nonce_96, 7)
|
||||
self.assertRaises(TypeError, AES.new, self.key_128, AES.MODE_GCM,
|
||||
nonce=self.nonce_96, unknown=7)
|
||||
|
||||
# But some are only known by the base cipher
|
||||
# (e.g. use_aesni consumed by the AES module)
|
||||
AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96,
|
||||
use_aesni=False)
|
||||
|
||||
def test_null_encryption_decryption(self):
|
||||
for func in "encrypt", "decrypt":
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
result = getattr(cipher, func)(b(""))
|
||||
self.assertEqual(result, b(""))
|
||||
|
||||
def test_either_encrypt_or_decrypt(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
cipher.encrypt(b(""))
|
||||
self.assertRaises(TypeError, cipher.decrypt, b(""))
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
cipher.decrypt(b(""))
|
||||
self.assertRaises(TypeError, cipher.encrypt, b(""))
|
||||
|
||||
def test_data_must_be_bytes(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
self.assertRaises(TypeError, cipher.encrypt, 'test1234567890-*')
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
self.assertRaises(TypeError, cipher.decrypt, 'test1234567890-*')
|
||||
|
||||
def test_mac_len(self):
|
||||
# Invalid MAC length
|
||||
self.assertRaises(ValueError, AES.new, self.key_128, AES.MODE_GCM,
|
||||
nonce=self.nonce_96, mac_len=3)
|
||||
self.assertRaises(ValueError, AES.new, self.key_128, AES.MODE_GCM,
|
||||
nonce=self.nonce_96, mac_len=16+1)
|
||||
|
||||
# Valid MAC length
|
||||
for mac_len in range(5, 16 + 1):
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96,
|
||||
mac_len=mac_len)
|
||||
_, mac = cipher.encrypt_and_digest(self.data_128)
|
||||
self.assertEqual(len(mac), mac_len)
|
||||
|
||||
# Default MAC length
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
_, mac = cipher.encrypt_and_digest(self.data_128)
|
||||
self.assertEqual(len(mac), 16)
|
||||
|
||||
def test_invalid_mac(self):
|
||||
from Crypto.Util.strxor import strxor_c
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
ct, mac = cipher.encrypt_and_digest(self.data_128)
|
||||
|
||||
invalid_mac = strxor_c(mac, 0x01)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
self.assertRaises(ValueError, cipher.decrypt_and_verify, ct,
|
||||
invalid_mac)
|
||||
|
||||
def test_hex_mac(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
mac_hex = cipher.hexdigest()
|
||||
self.assertEqual(cipher.digest(), unhexlify(mac_hex))
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
cipher.hexverify(mac_hex)
|
||||
|
||||
def test_message_chunks(self):
|
||||
# Validate that both associated data and plaintext/ciphertext
|
||||
# can be broken up in chunks of arbitrary length
|
||||
|
||||
auth_data = get_tag_random("authenticated data", 127)
|
||||
plaintext = get_tag_random("plaintext", 127)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
cipher.update(auth_data)
|
||||
ciphertext, ref_mac = cipher.encrypt_and_digest(plaintext)
|
||||
|
||||
def break_up(data, chunk_length):
|
||||
return [data[i:i+chunk_length] for i in range(0, len(data),
|
||||
chunk_length)]
|
||||
|
||||
# Encryption
|
||||
for chunk_length in 1, 2, 3, 7, 10, 13, 16, 40, 80, 128:
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
|
||||
for chunk in break_up(auth_data, chunk_length):
|
||||
cipher.update(chunk)
|
||||
pt2 = b("")
|
||||
for chunk in break_up(ciphertext, chunk_length):
|
||||
pt2 += cipher.decrypt(chunk)
|
||||
self.assertEqual(plaintext, pt2)
|
||||
cipher.verify(ref_mac)
|
||||
|
||||
# Decryption
|
||||
for chunk_length in 1, 2, 3, 7, 10, 13, 16, 40, 80, 128:
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
|
||||
for chunk in break_up(auth_data, chunk_length):
|
||||
cipher.update(chunk)
|
||||
ct2 = b("")
|
||||
for chunk in break_up(plaintext, chunk_length):
|
||||
ct2 += cipher.encrypt(chunk)
|
||||
self.assertEqual(ciphertext, ct2)
|
||||
self.assertEqual(cipher.digest(), ref_mac)
|
||||
|
||||
|
||||
class GcmFSMTests(unittest.TestCase):
|
||||
|
||||
key_128 = get_tag_random("key_128", 16)
|
||||
nonce_96 = get_tag_random("nonce_128", 12)
|
||||
data_128 = get_tag_random("data_128", 16)
|
||||
|
||||
def test_valid_init_encrypt_decrypt_digest_verify(self):
|
||||
# No authenticated data, fixed plaintext
|
||||
# Verify path INIT->ENCRYPT->DIGEST
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM,
|
||||
nonce=self.nonce_96)
|
||||
ct = cipher.encrypt(self.data_128)
|
||||
mac = cipher.digest()
|
||||
|
||||
# Verify path INIT->DECRYPT->VERIFY
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM,
|
||||
nonce=self.nonce_96)
|
||||
cipher.decrypt(ct)
|
||||
cipher.verify(mac)
|
||||
|
||||
def test_valid_init_update_digest_verify(self):
|
||||
# No plaintext, fixed authenticated data
|
||||
# Verify path INIT->UPDATE->DIGEST
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM,
|
||||
nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
mac = cipher.digest()
|
||||
|
||||
# Verify path INIT->UPDATE->VERIFY
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM,
|
||||
nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
cipher.verify(mac)
|
||||
|
||||
def test_valid_full_path(self):
|
||||
# Fixed authenticated data, fixed plaintext
|
||||
# Verify path INIT->UPDATE->ENCRYPT->DIGEST
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM,
|
||||
nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
ct = cipher.encrypt(self.data_128)
|
||||
mac = cipher.digest()
|
||||
|
||||
# Verify path INIT->UPDATE->DECRYPT->VERIFY
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM,
|
||||
nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
cipher.decrypt(ct)
|
||||
cipher.verify(mac)
|
||||
|
||||
def test_valid_init_digest(self):
|
||||
# Verify path INIT->DIGEST
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
cipher.digest()
|
||||
|
||||
def test_valid_init_verify(self):
|
||||
# Verify path INIT->VERIFY
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
mac = cipher.digest()
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
cipher.verify(mac)
|
||||
|
||||
def test_valid_multiple_encrypt_or_decrypt(self):
|
||||
for method_name in "encrypt", "decrypt":
|
||||
for auth_data in (None, b("333"), self.data_128,
|
||||
self.data_128 + b("3")):
|
||||
if auth_data is None:
|
||||
assoc_len = None
|
||||
else:
|
||||
assoc_len = len(auth_data)
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM,
|
||||
nonce=self.nonce_96)
|
||||
if auth_data is not None:
|
||||
cipher.update(auth_data)
|
||||
method = getattr(cipher, method_name)
|
||||
method(self.data_128)
|
||||
method(self.data_128)
|
||||
method(self.data_128)
|
||||
method(self.data_128)
|
||||
|
||||
def test_valid_multiple_digest_or_verify(self):
|
||||
# Multiple calls to digest
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
first_mac = cipher.digest()
|
||||
for x in range(4):
|
||||
self.assertEqual(first_mac, cipher.digest())
|
||||
|
||||
# Multiple calls to verify
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
for x in range(5):
|
||||
cipher.verify(first_mac)
|
||||
|
||||
def test_valid_encrypt_and_digest_decrypt_and_verify(self):
|
||||
# encrypt_and_digest
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
ct, mac = cipher.encrypt_and_digest(self.data_128)
|
||||
|
||||
# decrypt_and_verify
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
pt = cipher.decrypt_and_verify(ct, mac)
|
||||
self.assertEqual(self.data_128, pt)
|
||||
|
||||
def test_invalid_mixing_encrypt_decrypt(self):
|
||||
# Once per method, with or without assoc. data
|
||||
for method1_name, method2_name in (("encrypt", "decrypt"),
|
||||
("decrypt", "encrypt")):
|
||||
for assoc_data_present in (True, False):
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM,
|
||||
nonce=self.nonce_96)
|
||||
if assoc_data_present:
|
||||
cipher.update(self.data_128)
|
||||
getattr(cipher, method1_name)(self.data_128)
|
||||
self.assertRaises(TypeError, getattr(cipher, method2_name),
|
||||
self.data_128)
|
||||
|
||||
def test_invalid_encrypt_or_update_after_digest(self):
|
||||
for method_name in "encrypt", "update":
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
cipher.encrypt(self.data_128)
|
||||
cipher.digest()
|
||||
self.assertRaises(TypeError, getattr(cipher, method_name),
|
||||
self.data_128)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
cipher.encrypt_and_digest(self.data_128)
|
||||
|
||||
def test_invalid_decrypt_or_update_after_verify(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
ct = cipher.encrypt(self.data_128)
|
||||
mac = cipher.digest()
|
||||
|
||||
for method_name in "decrypt", "update":
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
cipher.decrypt(ct)
|
||||
cipher.verify(mac)
|
||||
self.assertRaises(TypeError, getattr(cipher, method_name),
|
||||
self.data_128)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_GCM, nonce=self.nonce_96)
|
||||
cipher.decrypt_and_verify(ct, mac)
|
||||
self.assertRaises(TypeError, getattr(cipher, method_name),
|
||||
self.data_128)
|
||||
|
||||
|
||||
class TestVectors(unittest.TestCase):
|
||||
"""Class exercising the GCM test vectors found in
|
||||
http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/gcm/gcm-revised-spec.pdf"""
|
||||
|
||||
# List of test vectors, each made up of:
|
||||
# - authenticated data
|
||||
# - plaintext
|
||||
# - ciphertext
|
||||
# - MAC
|
||||
# - AES key
|
||||
# - nonce
|
||||
test_vectors = [
|
||||
(
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'58e2fccefa7e3061367f1d57a4e7455a',
|
||||
'00000000000000000000000000000000',
|
||||
'000000000000000000000000'
|
||||
),
|
||||
(
|
||||
'',
|
||||
'00000000000000000000000000000000',
|
||||
'0388dace60b6a392f328c2b971b2fe78',
|
||||
'ab6e47d42cec13bdf53a67b21257bddf',
|
||||
'00000000000000000000000000000000',
|
||||
'000000000000000000000000'
|
||||
),
|
||||
(
|
||||
'',
|
||||
'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a72' +
|
||||
'1c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255',
|
||||
'42831ec2217774244b7221b784d0d49ce3aa212f2c02a4e035c17e2329aca12e' +
|
||||
'21d514b25466931c7d8f6a5aac84aa051ba30b396a0aac973d58e091473f5985',
|
||||
'4d5c2af327cd64a62cf35abd2ba6fab4',
|
||||
'feffe9928665731c6d6a8f9467308308',
|
||||
'cafebabefacedbaddecaf888'
|
||||
),
|
||||
(
|
||||
'feedfacedeadbeeffeedfacedeadbeefabaddad2',
|
||||
'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a72' +
|
||||
'1c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39',
|
||||
'42831ec2217774244b7221b784d0d49ce3aa212f2c02a4e035c17e2329aca12e' +
|
||||
'21d514b25466931c7d8f6a5aac84aa051ba30b396a0aac973d58e091',
|
||||
'5bc94fbc3221a5db94fae95ae7121a47',
|
||||
'feffe9928665731c6d6a8f9467308308',
|
||||
'cafebabefacedbaddecaf888'
|
||||
),
|
||||
(
|
||||
'feedfacedeadbeeffeedfacedeadbeefabaddad2',
|
||||
'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a72' +
|
||||
'1c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39',
|
||||
'61353b4c2806934a777ff51fa22a4755699b2a714fcdc6f83766e5f97b6c7423' +
|
||||
'73806900e49f24b22b097544d4896b424989b5e1ebac0f07c23f4598',
|
||||
'3612d2e79e3b0785561be14aaca2fccb',
|
||||
'feffe9928665731c6d6a8f9467308308',
|
||||
'cafebabefacedbad'
|
||||
),
|
||||
(
|
||||
'feedfacedeadbeeffeedfacedeadbeefabaddad2',
|
||||
'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a72' +
|
||||
'1c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39',
|
||||
'8ce24998625615b603a033aca13fb894be9112a5c3a211a8ba262a3cca7e2ca7' +
|
||||
'01e4a9a4fba43c90ccdcb281d48c7c6fd62875d2aca417034c34aee5',
|
||||
'619cc5aefffe0bfa462af43c1699d050',
|
||||
'feffe9928665731c6d6a8f9467308308',
|
||||
'9313225df88406e555909c5aff5269aa' +
|
||||
'6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b5254'+
|
||||
'16aedbf5a0de6a57a637b39b'
|
||||
),
|
||||
(
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'cd33b28ac773f74ba00ed1f312572435',
|
||||
'000000000000000000000000000000000000000000000000',
|
||||
'000000000000000000000000'
|
||||
),
|
||||
(
|
||||
'',
|
||||
'00000000000000000000000000000000',
|
||||
'98e7247c07f0fe411c267e4384b0f600',
|
||||
'2ff58d80033927ab8ef4d4587514f0fb',
|
||||
'000000000000000000000000000000000000000000000000',
|
||||
'000000000000000000000000'
|
||||
),
|
||||
(
|
||||
'',
|
||||
'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a72' +
|
||||
'1c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255',
|
||||
'3980ca0b3c00e841eb06fac4872a2757859e1ceaa6efd984628593b40ca1e19c' +
|
||||
'7d773d00c144c525ac619d18c84a3f4718e2448b2fe324d9ccda2710acade256',
|
||||
'9924a7c8587336bfb118024db8674a14',
|
||||
'feffe9928665731c6d6a8f9467308308feffe9928665731c',
|
||||
'cafebabefacedbaddecaf888'
|
||||
),
|
||||
(
|
||||
'feedfacedeadbeeffeedfacedeadbeefabaddad2',
|
||||
'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a72' +
|
||||
'1c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39',
|
||||
'3980ca0b3c00e841eb06fac4872a2757859e1ceaa6efd984628593b40ca1e19c' +
|
||||
'7d773d00c144c525ac619d18c84a3f4718e2448b2fe324d9ccda2710',
|
||||
'2519498e80f1478f37ba55bd6d27618c',
|
||||
'feffe9928665731c6d6a8f9467308308feffe9928665731c',
|
||||
'cafebabefacedbaddecaf888'
|
||||
),
|
||||
(
|
||||
'feedfacedeadbeeffeedfacedeadbeefabaddad2',
|
||||
'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a72' +
|
||||
'1c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39',
|
||||
'0f10f599ae14a154ed24b36e25324db8c566632ef2bbb34f8347280fc4507057' +
|
||||
'fddc29df9a471f75c66541d4d4dad1c9e93a19a58e8b473fa0f062f7',
|
||||
'65dcc57fcf623a24094fcca40d3533f8',
|
||||
'feffe9928665731c6d6a8f9467308308feffe9928665731c',
|
||||
'cafebabefacedbad'
|
||||
),
|
||||
(
|
||||
'feedfacedeadbeeffeedfacedeadbeefabaddad2',
|
||||
'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a72' +
|
||||
'1c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39',
|
||||
'd27e88681ce3243c4830165a8fdcf9ff1de9a1d8e6b447ef6ef7b79828666e45' +
|
||||
'81e79012af34ddd9e2f037589b292db3e67c036745fa22e7e9b7373b',
|
||||
'dcf566ff291c25bbb8568fc3d376a6d9',
|
||||
'feffe9928665731c6d6a8f9467308308feffe9928665731c',
|
||||
'9313225df88406e555909c5aff5269aa' +
|
||||
'6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b5254' +
|
||||
'16aedbf5a0de6a57a637b39b'
|
||||
),
|
||||
(
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'530f8afbc74536b9a963b4f1c4cb738b',
|
||||
'0000000000000000000000000000000000000000000000000000000000000000',
|
||||
'000000000000000000000000'
|
||||
),
|
||||
(
|
||||
'',
|
||||
'00000000000000000000000000000000',
|
||||
'cea7403d4d606b6e074ec5d3baf39d18',
|
||||
'd0d1c8a799996bf0265b98b5d48ab919',
|
||||
'0000000000000000000000000000000000000000000000000000000000000000',
|
||||
'000000000000000000000000'
|
||||
),
|
||||
( '',
|
||||
'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a72' +
|
||||
'1c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255',
|
||||
'522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa' +
|
||||
'8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f662898015ad',
|
||||
'b094dac5d93471bdec1a502270e3cc6c',
|
||||
'feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308',
|
||||
'cafebabefacedbaddecaf888'
|
||||
),
|
||||
(
|
||||
'feedfacedeadbeeffeedfacedeadbeefabaddad2',
|
||||
'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a72' +
|
||||
'1c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39',
|
||||
'522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa' +
|
||||
'8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f662',
|
||||
'76fc6ece0f4e1768cddf8853bb2d551b',
|
||||
'feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308',
|
||||
'cafebabefacedbaddecaf888'
|
||||
),
|
||||
(
|
||||
'feedfacedeadbeeffeedfacedeadbeefabaddad2',
|
||||
'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a72' +
|
||||
'1c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39',
|
||||
'c3762df1ca787d32ae47c13bf19844cbaf1ae14d0b976afac52ff7d79bba9de0' +
|
||||
'feb582d33934a4f0954cc2363bc73f7862ac430e64abe499f47c9b1f',
|
||||
'3a337dbf46a792c45e454913fe2ea8f2',
|
||||
'feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308',
|
||||
'cafebabefacedbad'
|
||||
),
|
||||
(
|
||||
'feedfacedeadbeeffeedfacedeadbeefabaddad2',
|
||||
'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a72' +
|
||||
'1c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39',
|
||||
'5a8def2f0c9e53f1f75d7853659e2a20eeb2b22aafde6419a058ab4f6f746bf4' +
|
||||
'0fc0c3b780f244452da3ebf1c5d82cdea2418997200ef82e44ae7e3f',
|
||||
'a44a8266ee1c8eb0c8b5d4cf5ae9f19a',
|
||||
'feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308',
|
||||
'9313225df88406e555909c5aff5269aa' +
|
||||
'6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b5254'+
|
||||
'16aedbf5a0de6a57a637b39b'
|
||||
)
|
||||
]
|
||||
|
||||
for index, tv in enumerate(test_vectors):
|
||||
test_vectors[index] = (unhexlify(x) for x in tv)
|
||||
|
||||
def runTest(self):
|
||||
for assoc_data, pt, ct, mac, key, nonce in self.test_vectors:
|
||||
|
||||
# Encrypt
|
||||
cipher = AES.new(key, AES.MODE_GCM, nonce, mac_len=len(mac))
|
||||
cipher.update(assoc_data)
|
||||
ct2, mac2 = cipher.encrypt_and_digest(pt)
|
||||
self.assertEqual(ct, ct2)
|
||||
self.assertEqual(mac, mac2)
|
||||
|
||||
# Decrypt
|
||||
cipher = AES.new(key, AES.MODE_GCM, nonce, mac_len=len(mac))
|
||||
cipher.update(assoc_data)
|
||||
pt2 = cipher.decrypt_and_verify(ct, mac)
|
||||
self.assertEqual(pt, pt2)
|
||||
|
||||
|
||||
class TestVectorsGueronKrasnov(unittest.TestCase):
|
||||
"""Class exercising the GCM test vectors found in
|
||||
'The fragility of AES-GCM authentication algorithm', Gueron, Krasnov
|
||||
https://eprint.iacr.org/2013/157.pdf"""
|
||||
|
||||
def test_1(self):
|
||||
key = unhexlify("3da6c536d6295579c0959a7043efb503")
|
||||
iv = unhexlify("2b926197d34e091ef722db94")
|
||||
aad = unhexlify("00000000000000000000000000000000" +
|
||||
"000102030405060708090a0b0c0d0e0f" +
|
||||
"101112131415161718191a1b1c1d1e1f" +
|
||||
"202122232425262728292a2b2c2d2e2f" +
|
||||
"303132333435363738393a3b3c3d3e3f")
|
||||
digest = unhexlify("69dd586555ce3fcc89663801a71d957b")
|
||||
|
||||
cipher = AES.new(key, AES.MODE_GCM, iv).update(aad)
|
||||
self.assertEqual(digest, cipher.digest())
|
||||
|
||||
def test_2(self):
|
||||
key = unhexlify("843ffcf5d2b72694d19ed01d01249412")
|
||||
iv = unhexlify("dbcca32ebf9b804617c3aa9e")
|
||||
aad = unhexlify("00000000000000000000000000000000" +
|
||||
"101112131415161718191a1b1c1d1e1f")
|
||||
pt = unhexlify("000102030405060708090a0b0c0d0e0f" +
|
||||
"101112131415161718191a1b1c1d1e1f" +
|
||||
"202122232425262728292a2b2c2d2e2f" +
|
||||
"303132333435363738393a3b3c3d3e3f" +
|
||||
"404142434445464748494a4b4c4d4e4f")
|
||||
ct = unhexlify("6268c6fa2a80b2d137467f092f657ac0" +
|
||||
"4d89be2beaa623d61b5a868c8f03ff95" +
|
||||
"d3dcee23ad2f1ab3a6c80eaf4b140eb0" +
|
||||
"5de3457f0fbc111a6b43d0763aa422a3" +
|
||||
"013cf1dc37fe417d1fbfc449b75d4cc5")
|
||||
digest = unhexlify("3b629ccfbc1119b7319e1dce2cd6fd6d")
|
||||
|
||||
cipher = AES.new(key, AES.MODE_GCM, iv).update(aad)
|
||||
ct2, digest2 = cipher.encrypt_and_digest(pt)
|
||||
|
||||
self.assertEqual(ct, ct2)
|
||||
self.assertEqual(digest, digest2)
|
||||
|
||||
|
||||
from Crypto.SelfTest.loader import load_tests
|
||||
|
||||
|
||||
class NISTTestVectorsGCM(unittest.TestCase):
|
||||
pass
|
||||
|
||||
test_vectors_nist = load_tests(
|
||||
("Crypto", "SelfTest", "Cipher", "test_vectors", "AES"),
|
||||
"gcmDecrypt128.rsp",
|
||||
"GCM decrypt",
|
||||
{ "count" : lambda x: int(x) })
|
||||
|
||||
test_vectors_nist += load_tests(
|
||||
("Crypto", "SelfTest", "Cipher", "test_vectors", "AES"),
|
||||
"gcmEncryptExtIV128.rsp",
|
||||
"GCM encrypt",
|
||||
{ "count" : lambda x: int(x) })
|
||||
|
||||
for idx, tv in enumerate(test_vectors_nist):
|
||||
|
||||
# The test vector file contains some directive lines
|
||||
if isinstance(tv, str):
|
||||
continue
|
||||
|
||||
def single_test(self, tv=tv):
|
||||
|
||||
self.description = tv.desc
|
||||
cipher = AES.new(tv.key, AES.MODE_GCM, nonce=tv.iv,
|
||||
mac_len=len(tv.tag))
|
||||
cipher.update(tv.aad)
|
||||
if "FAIL" in tv.others:
|
||||
self.assertRaises(ValueError, cipher.decrypt_and_verify,
|
||||
tv.ct, tv.tag)
|
||||
else:
|
||||
pt = cipher.decrypt_and_verify(tv.ct, tv.tag)
|
||||
self.assertEqual(pt, tv.pt)
|
||||
|
||||
setattr(NISTTestVectorsGCM, "test_%d" % idx, single_test)
|
||||
|
||||
|
||||
def get_tests(config={}):
|
||||
tests = []
|
||||
tests += list_test_cases(GcmTests)
|
||||
tests += list_test_cases(GcmFSMTests)
|
||||
tests += [TestVectors()]
|
||||
tests += list_test_cases(TestVectorsGueronKrasnov)
|
||||
tests += list_test_cases(NISTTestVectorsGCM)
|
||||
return tests
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
suite = lambda: unittest.TestSuite(get_tests())
|
||||
unittest.main(defaultTest='suite')
|
648
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_OCB.py
Normal file
648
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_OCB.py
Normal file
|
@ -0,0 +1,648 @@
|
|||
# ===================================================================
|
||||
#
|
||||
# Copyright (c) 2014, Legrandin <helderijs@gmail.com>
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
# ===================================================================
|
||||
|
||||
import os
|
||||
import re
|
||||
import unittest
|
||||
from binascii import hexlify
|
||||
|
||||
from Crypto.Util.py3compat import b, tobytes, bchr, unhexlify
|
||||
from Crypto.Util.strxor import strxor_c
|
||||
from Crypto.Util.number import long_to_bytes
|
||||
from Crypto.SelfTest.st_common import list_test_cases
|
||||
|
||||
from Crypto.Cipher import AES
|
||||
from Crypto.Hash import SHAKE128
|
||||
|
||||
|
||||
def get_tag_random(tag, length):
|
||||
return SHAKE128.new(data=tobytes(tag)).read(length)
|
||||
|
||||
|
||||
class OcbTests(unittest.TestCase):
|
||||
|
||||
key_128 = get_tag_random("key_128", 16)
|
||||
nonce_96 = get_tag_random("nonce_128", 12)
|
||||
data_128 = get_tag_random("data_128", 16)
|
||||
|
||||
def test_loopback_128(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
pt = get_tag_random("plaintext", 16 * 100)
|
||||
ct, mac = cipher.encrypt_and_digest(pt)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
pt2 = cipher.decrypt_and_verify(ct, mac)
|
||||
self.assertEqual(pt, pt2)
|
||||
|
||||
def test_nonce(self):
|
||||
# Nonce is optional
|
||||
AES.new(self.key_128, AES.MODE_OCB)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, self.nonce_96)
|
||||
ct = cipher.encrypt(self.data_128)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
self.assertEqual(ct, cipher.encrypt(self.data_128))
|
||||
|
||||
def test_nonce_must_be_bytes(self):
|
||||
self.assertRaises(TypeError, AES.new, self.key_128, AES.MODE_OCB,
|
||||
nonce='test12345678')
|
||||
|
||||
def test_nonce_length(self):
|
||||
# nonce cannot be empty
|
||||
self.assertRaises(ValueError, AES.new, self.key_128, AES.MODE_OCB,
|
||||
nonce=b(""))
|
||||
|
||||
# nonce can be up to 15 bytes long
|
||||
for length in range(1, 16):
|
||||
AES.new(self.key_128, AES.MODE_OCB, nonce=self.data_128[:length])
|
||||
|
||||
self.assertRaises(ValueError, AES.new, self.key_128, AES.MODE_OCB,
|
||||
nonce=self.data_128)
|
||||
|
||||
def test_block_size_128(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
self.assertEqual(cipher.block_size, AES.block_size)
|
||||
|
||||
# By default, a 15 bytes long nonce is randomly generated
|
||||
nonce1 = AES.new(self.key_128, AES.MODE_OCB).nonce
|
||||
nonce2 = AES.new(self.key_128, AES.MODE_OCB).nonce
|
||||
self.assertEqual(len(nonce1), 15)
|
||||
self.assertNotEqual(nonce1, nonce2)
|
||||
|
||||
def test_nonce_attribute(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
self.assertEqual(cipher.nonce, self.nonce_96)
|
||||
|
||||
# By default, a 15 bytes long nonce is randomly generated
|
||||
nonce1 = AES.new(self.key_128, AES.MODE_OCB).nonce
|
||||
nonce2 = AES.new(self.key_128, AES.MODE_OCB).nonce
|
||||
self.assertEqual(len(nonce1), 15)
|
||||
self.assertNotEqual(nonce1, nonce2)
|
||||
|
||||
def test_unknown_parameters(self):
|
||||
self.assertRaises(TypeError, AES.new, self.key_128, AES.MODE_OCB,
|
||||
self.nonce_96, 7)
|
||||
self.assertRaises(TypeError, AES.new, self.key_128, AES.MODE_OCB,
|
||||
nonce=self.nonce_96, unknown=7)
|
||||
|
||||
# But some are only known by the base cipher
|
||||
# (e.g. use_aesni consumed by the AES module)
|
||||
AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96,
|
||||
use_aesni=False)
|
||||
|
||||
def test_null_encryption_decryption(self):
|
||||
for func in "encrypt", "decrypt":
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
result = getattr(cipher, func)(b(""))
|
||||
self.assertEqual(result, b(""))
|
||||
|
||||
def test_either_encrypt_or_decrypt(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
cipher.encrypt(b("xyz"))
|
||||
self.assertRaises(TypeError, cipher.decrypt, b("xyz"))
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
cipher.decrypt(b("xyz"))
|
||||
self.assertRaises(TypeError, cipher.encrypt, b("xyz"))
|
||||
|
||||
def test_data_must_be_bytes(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
self.assertRaises(TypeError, cipher.encrypt, 'test1234567890-*')
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
self.assertRaises(TypeError, cipher.decrypt, 'test1234567890-*')
|
||||
|
||||
def test_mac_len(self):
|
||||
# Invalid MAC length
|
||||
self.assertRaises(ValueError, AES.new, self.key_128, AES.MODE_OCB,
|
||||
nonce=self.nonce_96, mac_len=7)
|
||||
self.assertRaises(ValueError, AES.new, self.key_128, AES.MODE_OCB,
|
||||
nonce=self.nonce_96, mac_len=16+1)
|
||||
|
||||
# Valid MAC length
|
||||
for mac_len in range(8, 16 + 1):
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96,
|
||||
mac_len=mac_len)
|
||||
_, mac = cipher.encrypt_and_digest(self.data_128)
|
||||
self.assertEqual(len(mac), mac_len)
|
||||
|
||||
# Default MAC length
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
_, mac = cipher.encrypt_and_digest(self.data_128)
|
||||
self.assertEqual(len(mac), 16)
|
||||
|
||||
def test_invalid_mac(self):
|
||||
from Crypto.Util.strxor import strxor_c
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
ct, mac = cipher.encrypt_and_digest(self.data_128)
|
||||
|
||||
invalid_mac = strxor_c(mac, 0x01)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
self.assertRaises(ValueError, cipher.decrypt_and_verify, ct,
|
||||
invalid_mac)
|
||||
|
||||
def test_hex_mac(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
mac_hex = cipher.hexdigest()
|
||||
self.assertEqual(cipher.digest(), unhexlify(mac_hex))
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
cipher.hexverify(mac_hex)
|
||||
|
||||
def test_message_chunks(self):
|
||||
# Validate that both associated data and plaintext/ciphertext
|
||||
# can be broken up in chunks of arbitrary length
|
||||
|
||||
auth_data = get_tag_random("authenticated data", 127)
|
||||
plaintext = get_tag_random("plaintext", 127)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
cipher.update(auth_data)
|
||||
ciphertext, ref_mac = cipher.encrypt_and_digest(plaintext)
|
||||
|
||||
def break_up(data, chunk_length):
|
||||
return [data[i:i+chunk_length] for i in range(0, len(data),
|
||||
chunk_length)]
|
||||
|
||||
# Encryption
|
||||
for chunk_length in 1, 2, 3, 7, 10, 13, 16, 40, 80, 128:
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
|
||||
for chunk in break_up(auth_data, chunk_length):
|
||||
cipher.update(chunk)
|
||||
pt2 = b("")
|
||||
for chunk in break_up(ciphertext, chunk_length):
|
||||
pt2 += cipher.decrypt(chunk)
|
||||
pt2 += cipher.decrypt()
|
||||
self.assertEqual(plaintext, pt2)
|
||||
cipher.verify(ref_mac)
|
||||
|
||||
# Decryption
|
||||
for chunk_length in 1, 2, 3, 7, 10, 13, 16, 40, 80, 128:
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
|
||||
for chunk in break_up(auth_data, chunk_length):
|
||||
cipher.update(chunk)
|
||||
ct2 = b("")
|
||||
for chunk in break_up(plaintext, chunk_length):
|
||||
ct2 += cipher.encrypt(chunk)
|
||||
ct2 += cipher.encrypt()
|
||||
self.assertEqual(ciphertext, ct2)
|
||||
self.assertEqual(cipher.digest(), ref_mac)
|
||||
|
||||
|
||||
class OcbFSMTests(unittest.TestCase):
|
||||
|
||||
key_128 = get_tag_random("key_128", 16)
|
||||
nonce_96 = get_tag_random("nonce_128", 12)
|
||||
data_128 = get_tag_random("data_128", 16)
|
||||
|
||||
def test_valid_init_encrypt_decrypt_digest_verify(self):
|
||||
# No authenticated data, fixed plaintext
|
||||
# Verify path INIT->ENCRYPT->ENCRYPT(NONE)->DIGEST
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB,
|
||||
nonce=self.nonce_96)
|
||||
ct = cipher.encrypt(self.data_128)
|
||||
ct += cipher.encrypt()
|
||||
mac = cipher.digest()
|
||||
|
||||
# Verify path INIT->DECRYPT->DECRYPT(NONCE)->VERIFY
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB,
|
||||
nonce=self.nonce_96)
|
||||
cipher.decrypt(ct)
|
||||
cipher.decrypt()
|
||||
cipher.verify(mac)
|
||||
|
||||
def test_invalid_init_encrypt_decrypt_digest_verify(self):
|
||||
# No authenticated data, fixed plaintext
|
||||
# Verify path INIT->ENCRYPT->DIGEST
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB,
|
||||
nonce=self.nonce_96)
|
||||
ct = cipher.encrypt(self.data_128)
|
||||
self.assertRaises(TypeError, cipher.digest)
|
||||
|
||||
# Verify path INIT->DECRYPT->VERIFY
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB,
|
||||
nonce=self.nonce_96)
|
||||
cipher.decrypt(ct)
|
||||
self.assertRaises(TypeError, cipher.verify)
|
||||
|
||||
def test_valid_init_update_digest_verify(self):
|
||||
# No plaintext, fixed authenticated data
|
||||
# Verify path INIT->UPDATE->DIGEST
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB,
|
||||
nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
mac = cipher.digest()
|
||||
|
||||
# Verify path INIT->UPDATE->VERIFY
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB,
|
||||
nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
cipher.verify(mac)
|
||||
|
||||
def test_valid_full_path(self):
|
||||
# Fixed authenticated data, fixed plaintext
|
||||
# Verify path INIT->UPDATE->ENCRYPT->ENCRYPT(NONE)->DIGEST
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB,
|
||||
nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
ct = cipher.encrypt(self.data_128)
|
||||
ct += cipher.encrypt()
|
||||
mac = cipher.digest()
|
||||
|
||||
# Verify path INIT->UPDATE->DECRYPT->DECRYPT(NONE)->VERIFY
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB,
|
||||
nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
cipher.decrypt(ct)
|
||||
cipher.decrypt()
|
||||
cipher.verify(mac)
|
||||
|
||||
def test_invalid_encrypt_after_final(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB,
|
||||
nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
cipher.encrypt(self.data_128)
|
||||
cipher.encrypt()
|
||||
self.assertRaises(TypeError, cipher.encrypt, self.data_128)
|
||||
|
||||
def test_invalid_decrypt_after_final(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB,
|
||||
nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
cipher.decrypt(self.data_128)
|
||||
cipher.decrypt()
|
||||
self.assertRaises(TypeError, cipher.decrypt, self.data_128)
|
||||
|
||||
def test_valid_init_digest(self):
|
||||
# Verify path INIT->DIGEST
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
cipher.digest()
|
||||
|
||||
def test_valid_init_verify(self):
|
||||
# Verify path INIT->VERIFY
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
mac = cipher.digest()
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
cipher.verify(mac)
|
||||
|
||||
def test_valid_multiple_encrypt_or_decrypt(self):
|
||||
for method_name in "encrypt", "decrypt":
|
||||
for auth_data in (None, b("333"), self.data_128,
|
||||
self.data_128 + b("3")):
|
||||
if auth_data is None:
|
||||
assoc_len = None
|
||||
else:
|
||||
assoc_len = len(auth_data)
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB,
|
||||
nonce=self.nonce_96)
|
||||
if auth_data is not None:
|
||||
cipher.update(auth_data)
|
||||
method = getattr(cipher, method_name)
|
||||
method(self.data_128)
|
||||
method(self.data_128)
|
||||
method(self.data_128)
|
||||
method(self.data_128)
|
||||
method()
|
||||
|
||||
def test_valid_multiple_digest_or_verify(self):
|
||||
# Multiple calls to digest
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
first_mac = cipher.digest()
|
||||
for x in range(4):
|
||||
self.assertEqual(first_mac, cipher.digest())
|
||||
|
||||
# Multiple calls to verify
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
for x in range(5):
|
||||
cipher.verify(first_mac)
|
||||
|
||||
def test_valid_encrypt_and_digest_decrypt_and_verify(self):
|
||||
# encrypt_and_digest
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
ct, mac = cipher.encrypt_and_digest(self.data_128)
|
||||
|
||||
# decrypt_and_verify
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
pt = cipher.decrypt_and_verify(ct, mac)
|
||||
self.assertEqual(self.data_128, pt)
|
||||
|
||||
def test_invalid_mixing_encrypt_decrypt(self):
|
||||
# Once per method, with or without assoc. data
|
||||
for method1_name, method2_name in (("encrypt", "decrypt"),
|
||||
("decrypt", "encrypt")):
|
||||
for assoc_data_present in (True, False):
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB,
|
||||
nonce=self.nonce_96)
|
||||
if assoc_data_present:
|
||||
cipher.update(self.data_128)
|
||||
getattr(cipher, method1_name)(self.data_128)
|
||||
self.assertRaises(TypeError, getattr(cipher, method2_name),
|
||||
self.data_128)
|
||||
|
||||
def test_invalid_encrypt_or_update_after_digest(self):
|
||||
for method_name in "encrypt", "update":
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
cipher.encrypt(self.data_128)
|
||||
cipher.encrypt()
|
||||
cipher.digest()
|
||||
self.assertRaises(TypeError, getattr(cipher, method_name),
|
||||
self.data_128)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
cipher.encrypt_and_digest(self.data_128)
|
||||
|
||||
def test_invalid_decrypt_or_update_after_verify(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
ct = cipher.encrypt(self.data_128)
|
||||
ct += cipher.encrypt()
|
||||
mac = cipher.digest()
|
||||
|
||||
for method_name in "decrypt", "update":
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
cipher.decrypt(ct)
|
||||
cipher.decrypt()
|
||||
cipher.verify(mac)
|
||||
self.assertRaises(TypeError, getattr(cipher, method_name),
|
||||
self.data_128)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_OCB, nonce=self.nonce_96)
|
||||
cipher.decrypt_and_verify(ct, mac)
|
||||
self.assertRaises(TypeError, getattr(cipher, method_name),
|
||||
self.data_128)
|
||||
|
||||
|
||||
class OcbRfc7253Test(unittest.TestCase):
|
||||
|
||||
# Tuple with
|
||||
# - nonce
|
||||
# - authenticated data
|
||||
# - plaintext
|
||||
# - ciphertext and 16 byte MAC tag
|
||||
tv1_key = "000102030405060708090A0B0C0D0E0F"
|
||||
tv1 = (
|
||||
(
|
||||
"BBAA99887766554433221100",
|
||||
"",
|
||||
"",
|
||||
"785407BFFFC8AD9EDCC5520AC9111EE6"
|
||||
),
|
||||
(
|
||||
"BBAA99887766554433221101",
|
||||
"0001020304050607",
|
||||
"0001020304050607",
|
||||
"6820B3657B6F615A5725BDA0D3B4EB3A257C9AF1F8F03009"
|
||||
),
|
||||
(
|
||||
"BBAA99887766554433221102",
|
||||
"0001020304050607",
|
||||
"",
|
||||
"81017F8203F081277152FADE694A0A00"
|
||||
),
|
||||
(
|
||||
"BBAA99887766554433221103",
|
||||
"",
|
||||
"0001020304050607",
|
||||
"45DD69F8F5AAE72414054CD1F35D82760B2CD00D2F99BFA9"
|
||||
),
|
||||
(
|
||||
"BBAA99887766554433221104",
|
||||
"000102030405060708090A0B0C0D0E0F",
|
||||
"000102030405060708090A0B0C0D0E0F",
|
||||
"571D535B60B277188BE5147170A9A22C3AD7A4FF3835B8C5"
|
||||
"701C1CCEC8FC3358"
|
||||
),
|
||||
(
|
||||
"BBAA99887766554433221105",
|
||||
"000102030405060708090A0B0C0D0E0F",
|
||||
"",
|
||||
"8CF761B6902EF764462AD86498CA6B97"
|
||||
),
|
||||
(
|
||||
"BBAA99887766554433221106",
|
||||
"",
|
||||
"000102030405060708090A0B0C0D0E0F",
|
||||
"5CE88EC2E0692706A915C00AEB8B2396F40E1C743F52436B"
|
||||
"DF06D8FA1ECA343D"
|
||||
),
|
||||
(
|
||||
"BBAA99887766554433221107",
|
||||
"000102030405060708090A0B0C0D0E0F1011121314151617",
|
||||
"000102030405060708090A0B0C0D0E0F1011121314151617",
|
||||
"1CA2207308C87C010756104D8840CE1952F09673A448A122"
|
||||
"C92C62241051F57356D7F3C90BB0E07F"
|
||||
),
|
||||
(
|
||||
"BBAA99887766554433221108",
|
||||
"000102030405060708090A0B0C0D0E0F1011121314151617",
|
||||
"",
|
||||
"6DC225A071FC1B9F7C69F93B0F1E10DE"
|
||||
),
|
||||
(
|
||||
"BBAA99887766554433221109",
|
||||
"",
|
||||
"000102030405060708090A0B0C0D0E0F1011121314151617",
|
||||
"221BD0DE7FA6FE993ECCD769460A0AF2D6CDED0C395B1C3C"
|
||||
"E725F32494B9F914D85C0B1EB38357FF"
|
||||
),
|
||||
(
|
||||
"BBAA9988776655443322110A",
|
||||
"000102030405060708090A0B0C0D0E0F1011121314151617"
|
||||
"18191A1B1C1D1E1F",
|
||||
"000102030405060708090A0B0C0D0E0F1011121314151617"
|
||||
"18191A1B1C1D1E1F",
|
||||
"BD6F6C496201C69296C11EFD138A467ABD3C707924B964DE"
|
||||
"AFFC40319AF5A48540FBBA186C5553C68AD9F592A79A4240"
|
||||
),
|
||||
(
|
||||
"BBAA9988776655443322110B",
|
||||
"000102030405060708090A0B0C0D0E0F1011121314151617"
|
||||
"18191A1B1C1D1E1F",
|
||||
"",
|
||||
"FE80690BEE8A485D11F32965BC9D2A32"
|
||||
),
|
||||
(
|
||||
"BBAA9988776655443322110C",
|
||||
"",
|
||||
"000102030405060708090A0B0C0D0E0F1011121314151617"
|
||||
"18191A1B1C1D1E1F",
|
||||
"2942BFC773BDA23CABC6ACFD9BFD5835BD300F0973792EF4"
|
||||
"6040C53F1432BCDFB5E1DDE3BC18A5F840B52E653444D5DF"
|
||||
),
|
||||
(
|
||||
"BBAA9988776655443322110D",
|
||||
"000102030405060708090A0B0C0D0E0F1011121314151617"
|
||||
"18191A1B1C1D1E1F2021222324252627",
|
||||
"000102030405060708090A0B0C0D0E0F1011121314151617"
|
||||
"18191A1B1C1D1E1F2021222324252627",
|
||||
"D5CA91748410C1751FF8A2F618255B68A0A12E093FF45460"
|
||||
"6E59F9C1D0DDC54B65E8628E568BAD7AED07BA06A4A69483"
|
||||
"A7035490C5769E60"
|
||||
),
|
||||
(
|
||||
"BBAA9988776655443322110E",
|
||||
"000102030405060708090A0B0C0D0E0F1011121314151617"
|
||||
"18191A1B1C1D1E1F2021222324252627",
|
||||
"",
|
||||
"C5CD9D1850C141E358649994EE701B68"
|
||||
),
|
||||
(
|
||||
"BBAA9988776655443322110F",
|
||||
"",
|
||||
"000102030405060708090A0B0C0D0E0F1011121314151617"
|
||||
"18191A1B1C1D1E1F2021222324252627",
|
||||
"4412923493C57D5DE0D700F753CCE0D1D2D95060122E9F15"
|
||||
"A5DDBFC5787E50B5CC55EE507BCB084E479AD363AC366B95"
|
||||
"A98CA5F3000B1479"
|
||||
)
|
||||
)
|
||||
|
||||
# Tuple with
|
||||
# - key
|
||||
# - nonce
|
||||
# - authenticated data
|
||||
# - plaintext
|
||||
# - ciphertext and 12 byte MAC tag
|
||||
tv2 = (
|
||||
"0F0E0D0C0B0A09080706050403020100",
|
||||
"BBAA9988776655443322110D",
|
||||
"000102030405060708090A0B0C0D0E0F1011121314151617"
|
||||
"18191A1B1C1D1E1F2021222324252627",
|
||||
"000102030405060708090A0B0C0D0E0F1011121314151617"
|
||||
"18191A1B1C1D1E1F2021222324252627",
|
||||
"1792A4E31E0755FB03E31B22116E6C2DDF9EFD6E33D536F1"
|
||||
"A0124B0A55BAE884ED93481529C76B6AD0C515F4D1CDD4FD"
|
||||
"AC4F02AA"
|
||||
)
|
||||
|
||||
# Tuple with
|
||||
# - key length
|
||||
# - MAC tag length
|
||||
# - Expected output
|
||||
tv3 = (
|
||||
(128, 128, "67E944D23256C5E0B6C61FA22FDF1EA2"),
|
||||
(192, 128, "F673F2C3E7174AAE7BAE986CA9F29E17"),
|
||||
(256, 128, "D90EB8E9C977C88B79DD793D7FFA161C"),
|
||||
(128, 96, "77A3D8E73589158D25D01209"),
|
||||
(192, 96, "05D56EAD2752C86BE6932C5E"),
|
||||
(256, 96, "5458359AC23B0CBA9E6330DD"),
|
||||
(128, 64, "192C9B7BD90BA06A"),
|
||||
(192, 64, "0066BC6E0EF34E24"),
|
||||
(256, 64, "7D4EA5D445501CBE"),
|
||||
)
|
||||
|
||||
def test1(self):
|
||||
key = unhexlify(b(self.tv1_key))
|
||||
for tv in self.tv1:
|
||||
nonce, aad, pt, ct = [ unhexlify(b(x)) for x in tv ]
|
||||
ct, mac_tag = ct[:-16], ct[-16:]
|
||||
|
||||
cipher = AES.new(key, AES.MODE_OCB, nonce=nonce)
|
||||
cipher.update(aad)
|
||||
ct2 = cipher.encrypt(pt) + cipher.encrypt()
|
||||
self.assertEqual(ct, ct2)
|
||||
self.assertEqual(mac_tag, cipher.digest())
|
||||
|
||||
cipher = AES.new(key, AES.MODE_OCB, nonce=nonce)
|
||||
cipher.update(aad)
|
||||
pt2 = cipher.decrypt(ct) + cipher.decrypt()
|
||||
self.assertEqual(pt, pt2)
|
||||
cipher.verify(mac_tag)
|
||||
|
||||
def test2(self):
|
||||
|
||||
key, nonce, aad, pt, ct = [ unhexlify(b(x)) for x in self.tv2 ]
|
||||
ct, mac_tag = ct[:-12], ct[-12:]
|
||||
|
||||
cipher = AES.new(key, AES.MODE_OCB, nonce=nonce, mac_len=12)
|
||||
cipher.update(aad)
|
||||
ct2 = cipher.encrypt(pt) + cipher.encrypt()
|
||||
self.assertEqual(ct, ct2)
|
||||
self.assertEqual(mac_tag, cipher.digest())
|
||||
|
||||
cipher = AES.new(key, AES.MODE_OCB, nonce=nonce, mac_len=12)
|
||||
cipher.update(aad)
|
||||
pt2 = cipher.decrypt(ct) + cipher.decrypt()
|
||||
self.assertEqual(pt, pt2)
|
||||
cipher.verify(mac_tag)
|
||||
|
||||
def test3(self):
|
||||
|
||||
for keylen, taglen, result in self.tv3:
|
||||
|
||||
key = bchr(0) * (keylen // 8 - 1) + bchr(taglen)
|
||||
C = b("")
|
||||
|
||||
for i in range(128):
|
||||
S = bchr(0) * i
|
||||
|
||||
N = long_to_bytes(3 * i + 1, 12)
|
||||
cipher = AES.new(key, AES.MODE_OCB, nonce=N, mac_len=taglen // 8)
|
||||
cipher.update(S)
|
||||
C += cipher.encrypt(S) + cipher.encrypt() + cipher.digest()
|
||||
|
||||
N = long_to_bytes(3 * i + 2, 12)
|
||||
cipher = AES.new(key, AES.MODE_OCB, nonce=N, mac_len=taglen // 8)
|
||||
C += cipher.encrypt(S) + cipher.encrypt() + cipher.digest()
|
||||
|
||||
N = long_to_bytes(3 * i + 3, 12)
|
||||
cipher = AES.new(key, AES.MODE_OCB, nonce=N, mac_len=taglen // 8)
|
||||
cipher.update(S)
|
||||
C += cipher.encrypt() + cipher.digest()
|
||||
|
||||
N = long_to_bytes(385, 12)
|
||||
cipher = AES.new(key, AES.MODE_OCB, nonce=N, mac_len=taglen // 8)
|
||||
cipher.update(C)
|
||||
result2 = cipher.encrypt() + cipher.digest()
|
||||
self.assertEqual(unhexlify(b(result)), result2)
|
||||
|
||||
|
||||
def get_tests(config={}):
|
||||
tests = []
|
||||
tests += list_test_cases(OcbTests)
|
||||
tests += list_test_cases(OcbFSMTests)
|
||||
tests += list_test_cases(OcbRfc7253Test)
|
||||
return tests
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import unittest
|
||||
suite = lambda: unittest.TestSuite(get_tests())
|
||||
unittest.main(defaultTest='suite')
|
235
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_OFB.py
Normal file
235
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_OFB.py
Normal file
|
@ -0,0 +1,235 @@
|
|||
# ===================================================================
|
||||
#
|
||||
# Copyright (c) 2015, Legrandin <helderijs@gmail.com>
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
# ===================================================================
|
||||
|
||||
import unittest
|
||||
|
||||
from Crypto.SelfTest.st_common import list_test_cases
|
||||
from Crypto.Util.py3compat import tobytes, b, unhexlify
|
||||
from Crypto.Cipher import AES, DES3, DES
|
||||
from Crypto.Hash import SHAKE128
|
||||
|
||||
def get_tag_random(tag, length):
|
||||
return SHAKE128.new(data=tobytes(tag)).read(length)
|
||||
|
||||
from Crypto.SelfTest.Cipher.test_CBC import BlockChainingTests
|
||||
|
||||
class OfbTests(BlockChainingTests):
|
||||
|
||||
aes_mode = AES.MODE_OFB
|
||||
des3_mode = DES3.MODE_OFB
|
||||
|
||||
# Redefine test_unaligned_data_128/64
|
||||
|
||||
def test_unaligned_data_128(self):
|
||||
plaintexts = [ b("7777777") ] * 100
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_CFB, self.iv_128, segment_size=8)
|
||||
ciphertexts = [ cipher.encrypt(x) for x in plaintexts ]
|
||||
cipher = AES.new(self.key_128, AES.MODE_CFB, self.iv_128, segment_size=8)
|
||||
self.assertEqual(b("").join(ciphertexts), cipher.encrypt(b("").join(plaintexts)))
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_CFB, self.iv_128, segment_size=128)
|
||||
ciphertexts = [ cipher.encrypt(x) for x in plaintexts ]
|
||||
cipher = AES.new(self.key_128, AES.MODE_CFB, self.iv_128, segment_size=128)
|
||||
self.assertEqual(b("").join(ciphertexts), cipher.encrypt(b("").join(plaintexts)))
|
||||
|
||||
def test_unaligned_data_64(self):
|
||||
plaintexts = [ b("7777777") ] * 100
|
||||
cipher = DES3.new(self.key_192, DES3.MODE_CFB, self.iv_64, segment_size=8)
|
||||
ciphertexts = [ cipher.encrypt(x) for x in plaintexts ]
|
||||
cipher = DES3.new(self.key_192, DES3.MODE_CFB, self.iv_64, segment_size=8)
|
||||
self.assertEqual(b("").join(ciphertexts), cipher.encrypt(b("").join(plaintexts)))
|
||||
|
||||
cipher = DES3.new(self.key_192, DES3.MODE_CFB, self.iv_64, segment_size=64)
|
||||
ciphertexts = [ cipher.encrypt(x) for x in plaintexts ]
|
||||
cipher = DES3.new(self.key_192, DES3.MODE_CFB, self.iv_64, segment_size=64)
|
||||
self.assertEqual(b("").join(ciphertexts), cipher.encrypt(b("").join(plaintexts)))
|
||||
|
||||
|
||||
from Crypto.SelfTest.Cipher.test_CBC import NistBlockChainingVectors
|
||||
|
||||
class NistOfbVectors(NistBlockChainingVectors):
|
||||
aes_mode = AES.MODE_OFB
|
||||
des_mode = DES.MODE_OFB
|
||||
des3_mode = DES3.MODE_OFB
|
||||
|
||||
|
||||
# Create one test method per file
|
||||
nist_aes_kat_mmt_files = (
|
||||
# KAT
|
||||
"OFBGFSbox128.rsp",
|
||||
"OFBGFSbox192.rsp",
|
||||
"OFBGFSbox256.rsp",
|
||||
"OFBKeySbox128.rsp",
|
||||
"OFBKeySbox192.rsp",
|
||||
"OFBKeySbox256.rsp",
|
||||
"OFBVarKey128.rsp",
|
||||
"OFBVarKey192.rsp",
|
||||
"OFBVarKey256.rsp",
|
||||
"OFBVarTxt128.rsp",
|
||||
"OFBVarTxt192.rsp",
|
||||
"OFBVarTxt256.rsp",
|
||||
# MMT
|
||||
"OFBMMT128.rsp",
|
||||
"OFBMMT192.rsp",
|
||||
"OFBMMT256.rsp",
|
||||
)
|
||||
nist_aes_mct_files = (
|
||||
"OFBMCT128.rsp",
|
||||
"OFBMCT192.rsp",
|
||||
"OFBMCT256.rsp",
|
||||
)
|
||||
|
||||
for file_name in nist_aes_kat_mmt_files:
|
||||
def new_func(self, file_name=file_name):
|
||||
self._do_kat_aes_test(file_name)
|
||||
setattr(NistOfbVectors, "test_AES_" + file_name, new_func)
|
||||
|
||||
for file_name in nist_aes_mct_files:
|
||||
def new_func(self, file_name=file_name):
|
||||
self._do_mct_aes_test(file_name)
|
||||
setattr(NistOfbVectors, "test_AES_" + file_name, new_func)
|
||||
del file_name, new_func
|
||||
|
||||
nist_tdes_files = (
|
||||
"TOFBMMT2.rsp", # 2TDES
|
||||
"TOFBMMT3.rsp", # 3TDES
|
||||
"TOFBinvperm.rsp", # Single DES
|
||||
"TOFBpermop.rsp",
|
||||
"TOFBsubtab.rsp",
|
||||
"TOFBvarkey.rsp",
|
||||
"TOFBvartext.rsp",
|
||||
)
|
||||
|
||||
for file_name in nist_tdes_files:
|
||||
def new_func(self, file_name=file_name):
|
||||
self._do_tdes_test(file_name)
|
||||
setattr(NistOfbVectors, "test_TDES_" + file_name, new_func)
|
||||
|
||||
# END OF NIST OFB TEST VECTORS
|
||||
|
||||
|
||||
class SP800TestVectors(unittest.TestCase):
|
||||
"""Class exercising the OFB test vectors found in Section F.4
|
||||
of NIST SP 800-3A"""
|
||||
|
||||
def test_aes_128(self):
|
||||
plaintext = '6bc1bee22e409f96e93d7e117393172a' +\
|
||||
'ae2d8a571e03ac9c9eb76fac45af8e51' +\
|
||||
'30c81c46a35ce411e5fbc1191a0a52ef' +\
|
||||
'f69f2445df4f9b17ad2b417be66c3710'
|
||||
ciphertext = '3b3fd92eb72dad20333449f8e83cfb4a' +\
|
||||
'7789508d16918f03f53c52dac54ed825' +\
|
||||
'9740051e9c5fecf64344f7a82260edcc' +\
|
||||
'304c6528f659c77866a510d9c1d6ae5e'
|
||||
key = '2b7e151628aed2a6abf7158809cf4f3c'
|
||||
iv = '000102030405060708090a0b0c0d0e0f'
|
||||
|
||||
key = unhexlify(key)
|
||||
iv = unhexlify(iv)
|
||||
plaintext = unhexlify(plaintext)
|
||||
ciphertext = unhexlify(ciphertext)
|
||||
|
||||
cipher = AES.new(key, AES.MODE_OFB, iv)
|
||||
self.assertEqual(cipher.encrypt(plaintext), ciphertext)
|
||||
cipher = AES.new(key, AES.MODE_OFB, iv)
|
||||
self.assertEqual(cipher.decrypt(ciphertext), plaintext)
|
||||
|
||||
cipher = AES.new(key, AES.MODE_OFB, iv)
|
||||
self.assertEqual(cipher.encrypt(plaintext[:-8]), ciphertext[:-8])
|
||||
cipher = AES.new(key, AES.MODE_OFB, iv)
|
||||
self.assertEqual(cipher.decrypt(ciphertext[:-8]), plaintext[:-8])
|
||||
|
||||
def test_aes_192(self):
|
||||
plaintext = '6bc1bee22e409f96e93d7e117393172a' +\
|
||||
'ae2d8a571e03ac9c9eb76fac45af8e51' +\
|
||||
'30c81c46a35ce411e5fbc1191a0a52ef' +\
|
||||
'f69f2445df4f9b17ad2b417be66c3710'
|
||||
ciphertext = 'cdc80d6fddf18cab34c25909c99a4174' +\
|
||||
'fcc28b8d4c63837c09e81700c1100401' +\
|
||||
'8d9a9aeac0f6596f559c6d4daf59a5f2' +\
|
||||
'6d9f200857ca6c3e9cac524bd9acc92a'
|
||||
key = '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b'
|
||||
iv = '000102030405060708090a0b0c0d0e0f'
|
||||
|
||||
key = unhexlify(key)
|
||||
iv = unhexlify(iv)
|
||||
plaintext = unhexlify(plaintext)
|
||||
ciphertext = unhexlify(ciphertext)
|
||||
|
||||
cipher = AES.new(key, AES.MODE_OFB, iv)
|
||||
self.assertEqual(cipher.encrypt(plaintext), ciphertext)
|
||||
cipher = AES.new(key, AES.MODE_OFB, iv)
|
||||
self.assertEqual(cipher.decrypt(ciphertext), plaintext)
|
||||
|
||||
cipher = AES.new(key, AES.MODE_OFB, iv)
|
||||
self.assertEqual(cipher.encrypt(plaintext[:-8]), ciphertext[:-8])
|
||||
cipher = AES.new(key, AES.MODE_OFB, iv)
|
||||
self.assertEqual(cipher.decrypt(ciphertext[:-8]), plaintext[:-8])
|
||||
|
||||
def test_aes_256(self):
|
||||
plaintext = '6bc1bee22e409f96e93d7e117393172a' +\
|
||||
'ae2d8a571e03ac9c9eb76fac45af8e51' +\
|
||||
'30c81c46a35ce411e5fbc1191a0a52ef' +\
|
||||
'f69f2445df4f9b17ad2b417be66c3710'
|
||||
ciphertext = 'dc7e84bfda79164b7ecd8486985d3860' +\
|
||||
'4febdc6740d20b3ac88f6ad82a4fb08d' +\
|
||||
'71ab47a086e86eedf39d1c5bba97c408' +\
|
||||
'0126141d67f37be8538f5a8be740e484'
|
||||
key = '603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4'
|
||||
iv = '000102030405060708090a0b0c0d0e0f'
|
||||
|
||||
key = unhexlify(key)
|
||||
iv = unhexlify(iv)
|
||||
plaintext = unhexlify(plaintext)
|
||||
ciphertext = unhexlify(ciphertext)
|
||||
|
||||
cipher = AES.new(key, AES.MODE_OFB, iv)
|
||||
self.assertEqual(cipher.encrypt(plaintext), ciphertext)
|
||||
cipher = AES.new(key, AES.MODE_OFB, iv)
|
||||
self.assertEqual(cipher.decrypt(ciphertext), plaintext)
|
||||
|
||||
cipher = AES.new(key, AES.MODE_OFB, iv)
|
||||
self.assertEqual(cipher.encrypt(plaintext[:-8]), ciphertext[:-8])
|
||||
cipher = AES.new(key, AES.MODE_OFB, iv)
|
||||
self.assertEqual(cipher.decrypt(ciphertext[:-8]), plaintext[:-8])
|
||||
|
||||
|
||||
def get_tests(config={}):
|
||||
tests = []
|
||||
tests += list_test_cases(OfbTests)
|
||||
tests += list_test_cases(NistOfbVectors)
|
||||
tests += list_test_cases(SP800TestVectors)
|
||||
return tests
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
suite = lambda: unittest.TestSuite(get_tests())
|
||||
unittest.main(defaultTest='suite')
|
205
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_OpenPGP.py
Normal file
205
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_OpenPGP.py
Normal file
|
@ -0,0 +1,205 @@
|
|||
# ===================================================================
|
||||
#
|
||||
# Copyright (c) 2015, Legrandin <helderijs@gmail.com>
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
# ===================================================================
|
||||
|
||||
import unittest
|
||||
|
||||
from Crypto.SelfTest.st_common import list_test_cases
|
||||
from Crypto.Util.py3compat import tobytes, b, unhexlify
|
||||
from Crypto.Cipher import AES, DES3, DES
|
||||
from Crypto.Hash import SHAKE128
|
||||
|
||||
def get_tag_random(tag, length):
|
||||
return SHAKE128.new(data=tobytes(tag)).read(length)
|
||||
|
||||
|
||||
from Crypto.SelfTest.Cipher.test_CBC import BlockChainingTests
|
||||
|
||||
class OpenPGPTests(BlockChainingTests):
|
||||
|
||||
aes_mode = AES.MODE_OPENPGP
|
||||
des3_mode = DES3.MODE_OPENPGP
|
||||
|
||||
# Redefine test_unaligned_data_128/64
|
||||
|
||||
key_128 = get_tag_random("key_128", 16)
|
||||
key_192 = get_tag_random("key_192", 24)
|
||||
iv_128 = get_tag_random("iv_128", 16)
|
||||
iv_64 = get_tag_random("iv_64", 8)
|
||||
data_128 = get_tag_random("data_128", 16)
|
||||
|
||||
def test_loopback_128(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_OPENPGP, self.iv_128)
|
||||
pt = get_tag_random("plaintext", 16 * 100)
|
||||
ct = cipher.encrypt(pt)
|
||||
|
||||
eiv, ct = ct[:18], ct[18:]
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_OPENPGP, eiv)
|
||||
pt2 = cipher.decrypt(ct)
|
||||
self.assertEqual(pt, pt2)
|
||||
|
||||
def test_loopback_64(self):
|
||||
cipher = DES3.new(self.key_192, DES3.MODE_OPENPGP, self.iv_64)
|
||||
pt = get_tag_random("plaintext", 8 * 100)
|
||||
ct = cipher.encrypt(pt)
|
||||
|
||||
eiv, ct = ct[:10], ct[10:]
|
||||
|
||||
cipher = DES3.new(self.key_192, DES3.MODE_OPENPGP, eiv)
|
||||
pt2 = cipher.decrypt(ct)
|
||||
self.assertEqual(pt, pt2)
|
||||
|
||||
def test_IV_iv_attributes(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_OPENPGP, self.iv_128)
|
||||
eiv = cipher.encrypt(b(""))
|
||||
self.assertEqual(cipher.iv, self.iv_128)
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_OPENPGP, eiv)
|
||||
self.assertEqual(cipher.iv, self.iv_128)
|
||||
|
||||
def test_null_encryption_decryption(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_OPENPGP, self.iv_128)
|
||||
eiv = cipher.encrypt(b(""))
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_OPENPGP, eiv)
|
||||
self.assertEqual(cipher.decrypt(b("")), b(""))
|
||||
|
||||
def test_either_encrypt_or_decrypt(self):
|
||||
cipher = AES.new(self.key_128, AES.MODE_OPENPGP, self.iv_128)
|
||||
eiv = cipher.encrypt(b(""))
|
||||
self.assertRaises(TypeError, cipher.decrypt, b(""))
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_OPENPGP, eiv)
|
||||
cipher.decrypt(b(""))
|
||||
self.assertRaises(TypeError, cipher.encrypt, b(""))
|
||||
|
||||
def test_unaligned_data_128(self):
|
||||
plaintexts = [ b("7777777") ] * 100
|
||||
|
||||
cipher = AES.new(self.key_128, AES.MODE_OPENPGP, self.iv_128)
|
||||
ciphertexts = [ cipher.encrypt(x) for x in plaintexts ]
|
||||
cipher = AES.new(self.key_128, AES.MODE_OPENPGP, self.iv_128)
|
||||
self.assertEqual(b("").join(ciphertexts), cipher.encrypt(b("").join(plaintexts)))
|
||||
|
||||
def test_unaligned_data_64(self):
|
||||
plaintexts = [ b("7777777") ] * 100
|
||||
|
||||
cipher = DES3.new(self.key_192, DES3.MODE_OPENPGP, self.iv_64)
|
||||
ciphertexts = [ cipher.encrypt(x) for x in plaintexts ]
|
||||
cipher = DES3.new(self.key_192, DES3.MODE_OPENPGP, self.iv_64)
|
||||
self.assertEqual(b("").join(ciphertexts), cipher.encrypt(b("").join(plaintexts)))
|
||||
|
||||
|
||||
class TestVectors(unittest.TestCase):
|
||||
|
||||
def test_aes(self):
|
||||
# The following test vectors have been generated with gpg v1.4.0.
|
||||
# The command line used was:
|
||||
#
|
||||
# gpg -c -z 0 --cipher-algo AES --passphrase secret_passphrase \
|
||||
# --disable-mdc --s2k-mode 0 --output ct pt
|
||||
#
|
||||
# As result, the content of the file 'pt' is encrypted with a key derived
|
||||
# from 'secret_passphrase' and written to file 'ct'.
|
||||
# Test vectors must be extracted from 'ct', which is a collection of
|
||||
# TLVs (see RFC4880 for all details):
|
||||
# - the encrypted data (with the encrypted IV as prefix) is the payload
|
||||
# of the TLV with tag 9 (Symmetrical Encrypted Data Packet).
|
||||
# This is the ciphertext in the test vector.
|
||||
# - inside the encrypted part, there is a further layer of TLVs. One must
|
||||
# look for tag 11 (Literal Data Packet); in its payload, after a short
|
||||
# but time dependent header, there is the content of file 'pt'.
|
||||
# In the test vector, the plaintext is the complete set of TLVs that gets
|
||||
# encrypted. It is not just the content of 'pt'.
|
||||
# - the key is the leftmost 16 bytes of the SHA1 digest of the password.
|
||||
# The test vector contains such shortened digest.
|
||||
#
|
||||
# Note that encryption uses a clear IV, and decryption an encrypted IV
|
||||
|
||||
plaintext = 'ac18620270744fb4f647426c61636b4361745768697465436174'
|
||||
ciphertext = 'dc6b9e1f095de609765c59983db5956ae4f63aea7405389d2ebb'
|
||||
key = '5baa61e4c9b93f3f0682250b6cf8331b'
|
||||
iv = '3d7d3e62282add7eb203eeba5c800733'
|
||||
encrypted_iv='fd934601ef49cb58b6d9aebca6056bdb96ef'
|
||||
|
||||
plaintext = unhexlify(plaintext)
|
||||
ciphertext = unhexlify(ciphertext)
|
||||
key = unhexlify(key)
|
||||
iv = unhexlify(iv)
|
||||
encrypted_iv = unhexlify(encrypted_iv)
|
||||
|
||||
cipher = AES.new(key, AES.MODE_OPENPGP, iv)
|
||||
ct = cipher.encrypt(plaintext)
|
||||
self.assertEqual(ct[:18], encrypted_iv)
|
||||
self.assertEqual(ct[18:], ciphertext)
|
||||
|
||||
cipher = AES.new(key, AES.MODE_OPENPGP, encrypted_iv)
|
||||
pt = cipher.decrypt(ciphertext)
|
||||
self.assertEqual(pt, plaintext)
|
||||
|
||||
def test_des3(self):
|
||||
# The following test vectors have been generated with gpg v1.4.0.
|
||||
# The command line used was:
|
||||
# gpg -c -z 0 --cipher-algo 3DES --passphrase secret_passphrase \
|
||||
# --disable-mdc --s2k-mode 0 --output ct pt
|
||||
# For an explanation, see test_AES.py .
|
||||
|
||||
plaintext = 'ac1762037074324fb53ba3596f73656d69746556616c6c6579'
|
||||
ciphertext = '9979238528357b90e2e0be549cb0b2d5999b9a4a447e5c5c7d'
|
||||
key = '7ade65b460f5ea9be35f9e14aa883a2048e3824aa616c0b2'
|
||||
iv='cd47e2afb8b7e4b0'
|
||||
encrypted_iv='6a7eef0b58050e8b904a'
|
||||
|
||||
plaintext = unhexlify(plaintext)
|
||||
ciphertext = unhexlify(ciphertext)
|
||||
key = unhexlify(key)
|
||||
iv = unhexlify(iv)
|
||||
encrypted_iv = unhexlify(encrypted_iv)
|
||||
|
||||
cipher = DES3.new(key, DES3.MODE_OPENPGP, iv)
|
||||
ct = cipher.encrypt(plaintext)
|
||||
self.assertEqual(ct[:10], encrypted_iv)
|
||||
self.assertEqual(ct[10:], ciphertext)
|
||||
|
||||
cipher = DES3.new(key, DES3.MODE_OPENPGP, encrypted_iv)
|
||||
pt = cipher.decrypt(ciphertext)
|
||||
self.assertEqual(pt, plaintext)
|
||||
|
||||
|
||||
def get_tests(config={}):
|
||||
tests = []
|
||||
tests += list_test_cases(OpenPGPTests)
|
||||
tests += list_test_cases(TestVectors)
|
||||
return tests
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
suite = lambda: unittest.TestSuite(get_tests())
|
||||
unittest.main(defaultTest='suite')
|
359
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_SIV.py
Normal file
359
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_SIV.py
Normal file
|
@ -0,0 +1,359 @@
|
|||
# ===================================================================
|
||||
#
|
||||
# Copyright (c) 2015, Legrandin <helderijs@gmail.com>
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
# ===================================================================
|
||||
|
||||
import unittest
|
||||
|
||||
from Crypto.SelfTest.st_common import list_test_cases
|
||||
from Crypto.Util.py3compat import unhexlify, tobytes, bchr, b
|
||||
from Crypto.Cipher import AES
|
||||
from Crypto.Hash import SHAKE128
|
||||
|
||||
|
||||
def get_tag_random(tag, length):
|
||||
return SHAKE128.new(data=tobytes(tag)).read(length)
|
||||
|
||||
|
||||
class SivTests(unittest.TestCase):
|
||||
|
||||
key_256 = get_tag_random("key_256", 32)
|
||||
key_384 = get_tag_random("key_384", 48)
|
||||
key_512 = get_tag_random("key_512", 64)
|
||||
nonce_96 = get_tag_random("nonce_128", 12)
|
||||
data_128 = get_tag_random("data_128", 16)
|
||||
|
||||
def test_loopback_128(self):
|
||||
for key in self.key_256, self.key_384, self.key_512:
|
||||
cipher = AES.new(key, AES.MODE_SIV, nonce=self.nonce_96)
|
||||
pt = get_tag_random("plaintext", 16 * 100)
|
||||
ct, mac = cipher.encrypt_and_digest(pt)
|
||||
|
||||
cipher = AES.new(key, AES.MODE_SIV, nonce=self.nonce_96)
|
||||
pt2 = cipher.decrypt_and_verify(ct, mac)
|
||||
self.assertEqual(pt, pt2)
|
||||
|
||||
def test_nonce(self):
|
||||
# Deterministic encryption
|
||||
AES.new(self.key_256, AES.MODE_SIV)
|
||||
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV, self.nonce_96)
|
||||
ct = cipher.encrypt(self.data_128)
|
||||
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV, nonce=self.nonce_96)
|
||||
self.assertEqual(ct, cipher.encrypt(self.data_128))
|
||||
|
||||
def test_nonce_must_be_bytes(self):
|
||||
self.assertRaises(TypeError, AES.new, self.key_256, AES.MODE_SIV,
|
||||
nonce='test12345678')
|
||||
|
||||
def test_nonce_length(self):
|
||||
# nonce can be of any length (but not empty)
|
||||
self.assertRaises(ValueError, AES.new, self.key_256, AES.MODE_SIV,
|
||||
nonce=b(""))
|
||||
|
||||
for x in range(1, 128):
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV, nonce=bchr(1) * x)
|
||||
cipher.encrypt(bchr(1))
|
||||
|
||||
def test_block_size_128(self):
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV, nonce=self.nonce_96)
|
||||
self.assertEqual(cipher.block_size, AES.block_size)
|
||||
|
||||
def test_nonce_attribute(self):
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV, nonce=self.nonce_96)
|
||||
self.assertEqual(cipher.nonce, self.nonce_96)
|
||||
|
||||
# By default, no nonce is randomly generated
|
||||
self.assertFalse(hasattr(AES.new(self.key_256, AES.MODE_SIV), "nonce"))
|
||||
|
||||
def test_unknown_parameters(self):
|
||||
self.assertRaises(TypeError, AES.new, self.key_256, AES.MODE_SIV,
|
||||
self.nonce_96, 7)
|
||||
self.assertRaises(TypeError, AES.new, self.key_256, AES.MODE_SIV,
|
||||
nonce=self.nonce_96, unknown=7)
|
||||
|
||||
# But some are only known by the base cipher
|
||||
# (e.g. use_aesni consumed by the AES module)
|
||||
AES.new(self.key_256, AES.MODE_SIV, nonce=self.nonce_96,
|
||||
use_aesni=False)
|
||||
|
||||
def test_invalid_null_encryption(self):
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV, nonce=self.nonce_96)
|
||||
self.assertRaises(ValueError, cipher.encrypt, b(""))
|
||||
|
||||
def test_invalid_null_component(self):
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV, nonce=self.nonce_96)
|
||||
self.assertRaises(ValueError, cipher.update, b(""))
|
||||
|
||||
def test_encrypt_excludes_decrypt(self):
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV, nonce=self.nonce_96)
|
||||
cipher.encrypt(self.data_128)
|
||||
self.assertRaises(TypeError, cipher.decrypt, self.data_128)
|
||||
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV, nonce=self.nonce_96)
|
||||
cipher.encrypt(self.data_128)
|
||||
self.assertRaises(TypeError, cipher.decrypt_and_verify,
|
||||
self.data_128, self.data_128)
|
||||
|
||||
def test_data_must_be_bytes(self):
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV, nonce=self.nonce_96)
|
||||
self.assertRaises(TypeError, cipher.encrypt, 'test1234567890-*')
|
||||
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV, nonce=self.nonce_96)
|
||||
self.assertRaises(TypeError, cipher.decrypt_and_verify,
|
||||
'test1234567890-*', b("xxxx"))
|
||||
|
||||
def test_mac_len(self):
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV, nonce=self.nonce_96)
|
||||
_, mac = cipher.encrypt_and_digest(self.data_128)
|
||||
self.assertEqual(len(mac), 16)
|
||||
|
||||
def test_invalid_mac(self):
|
||||
from Crypto.Util.strxor import strxor_c
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV, nonce=self.nonce_96)
|
||||
ct, mac = cipher.encrypt_and_digest(self.data_128)
|
||||
|
||||
invalid_mac = strxor_c(mac, 0x01)
|
||||
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV, nonce=self.nonce_96)
|
||||
self.assertRaises(ValueError, cipher.decrypt_and_verify, ct,
|
||||
invalid_mac)
|
||||
|
||||
def test_hex_mac(self):
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV, nonce=self.nonce_96)
|
||||
mac_hex = cipher.hexdigest()
|
||||
self.assertEqual(cipher.digest(), unhexlify(mac_hex))
|
||||
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV, nonce=self.nonce_96)
|
||||
cipher.hexverify(mac_hex)
|
||||
|
||||
|
||||
class SivFSMTests(unittest.TestCase):
|
||||
|
||||
key_256 = get_tag_random("key_256", 32)
|
||||
nonce_96 = get_tag_random("nonce_96", 12)
|
||||
data_128 = get_tag_random("data_128", 16)
|
||||
|
||||
def test_valid_init_encrypt_decrypt_verify(self):
|
||||
# No authenticated data, fixed plaintext
|
||||
# Verify path INIT->ENCRYPT->DIGEST
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV,
|
||||
nonce=self.nonce_96)
|
||||
ct = cipher.encrypt(self.data_128)
|
||||
mac = cipher.digest()
|
||||
|
||||
# Verify path INIT->DECRYPT_AND_VERIFY
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV,
|
||||
nonce=self.nonce_96)
|
||||
cipher.decrypt_and_verify(ct, mac)
|
||||
|
||||
def test_invalid_init_decrypt(self):
|
||||
# Path INIT->DECRYPT fails
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV,
|
||||
nonce=self.nonce_96)
|
||||
self.assertRaises(TypeError, cipher.decrypt, b("xxx"))
|
||||
|
||||
def test_valid_init_update_digest_verify(self):
|
||||
# No plaintext, fixed authenticated data
|
||||
# Verify path INIT->UPDATE->DIGEST
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV,
|
||||
nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
mac = cipher.digest()
|
||||
|
||||
# Verify path INIT->UPDATE->VERIFY
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV,
|
||||
nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
cipher.verify(mac)
|
||||
|
||||
def test_valid_full_path(self):
|
||||
# Fixed authenticated data, fixed plaintext
|
||||
# Verify path INIT->UPDATE->ENCRYPT->DIGEST
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV,
|
||||
nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
ct = cipher.encrypt(self.data_128)
|
||||
mac = cipher.digest()
|
||||
|
||||
# Verify path INIT->UPDATE->DECRYPT_AND_VERIFY
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV,
|
||||
nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
cipher.decrypt_and_verify(ct, mac)
|
||||
|
||||
def test_valid_init_digest(self):
|
||||
# Verify path INIT->DIGEST
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV, nonce=self.nonce_96)
|
||||
cipher.digest()
|
||||
|
||||
def test_valid_init_verify(self):
|
||||
# Verify path INIT->VERIFY
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV, nonce=self.nonce_96)
|
||||
mac = cipher.digest()
|
||||
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV, nonce=self.nonce_96)
|
||||
cipher.verify(mac)
|
||||
|
||||
def test_invalid_multiple_encrypt(self):
|
||||
# Without AAD
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV, nonce=self.nonce_96)
|
||||
cipher.encrypt(b("xxx"))
|
||||
self.assertRaises(TypeError, cipher.encrypt, b("xxx"))
|
||||
|
||||
# With AAD
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV, nonce=self.nonce_96)
|
||||
cipher.update(b("yyy"))
|
||||
cipher.encrypt(b("xxx"))
|
||||
self.assertRaises(TypeError, cipher.encrypt, b("xxx"))
|
||||
|
||||
def test_valid_multiple_digest_or_verify(self):
|
||||
# Multiple calls to digest
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV, nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
first_mac = cipher.digest()
|
||||
for x in range(4):
|
||||
self.assertEqual(first_mac, cipher.digest())
|
||||
|
||||
# Multiple calls to verify
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV, nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
for x in range(5):
|
||||
cipher.verify(first_mac)
|
||||
|
||||
def test_valid_encrypt_and_digest_decrypt_and_verify(self):
|
||||
# encrypt_and_digest
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV, nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
ct, mac = cipher.encrypt_and_digest(self.data_128)
|
||||
|
||||
# decrypt_and_verify
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV, nonce=self.nonce_96)
|
||||
cipher.update(self.data_128)
|
||||
pt = cipher.decrypt_and_verify(ct, mac)
|
||||
self.assertEqual(self.data_128, pt)
|
||||
|
||||
def test_invalid_encrypt_or_update_after_digest(self):
|
||||
for method_name in "encrypt", "update":
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV, nonce=self.nonce_96)
|
||||
cipher.encrypt(self.data_128)
|
||||
cipher.digest()
|
||||
self.assertRaises(TypeError, getattr(cipher, method_name),
|
||||
self.data_128)
|
||||
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV, nonce=self.nonce_96)
|
||||
cipher.encrypt_and_digest(self.data_128)
|
||||
|
||||
def test_invalid_decrypt_or_update_after_verify(self):
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV, nonce=self.nonce_96)
|
||||
ct = cipher.encrypt(self.data_128)
|
||||
mac = cipher.digest()
|
||||
|
||||
for method_name in "decrypt", "update":
|
||||
cipher = AES.new(self.key_256, AES.MODE_SIV, nonce=self.nonce_96)
|
||||
cipher.decrypt_and_verify(ct, mac)
|
||||
self.assertRaises(TypeError, getattr(cipher, method_name),
|
||||
self.data_128)
|
||||
|
||||
|
||||
class TestVectors(unittest.TestCase):
|
||||
"""Class exercising the SIV test vectors found in RFC5297"""
|
||||
|
||||
# This is a list of tuples with 5 items:
|
||||
#
|
||||
# 1. Header + '|' + plaintext
|
||||
# 2. Header + '|' + ciphertext + '|' + MAC
|
||||
# 3. AES-128 key
|
||||
# 4. Description
|
||||
# 5. Dictionary of parameters to be passed to AES.new().
|
||||
# It must include the nonce.
|
||||
#
|
||||
# A "Header" is a dash ('-') separated sequece of components.
|
||||
#
|
||||
test_vectors = [
|
||||
(
|
||||
'101112131415161718191a1b1c1d1e1f2021222324252627',
|
||||
'112233445566778899aabbccddee',
|
||||
'40c02b9690c4dc04daef7f6afe5c',
|
||||
'85632d07c6e8f37f950acd320a2ecc93',
|
||||
'fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff',
|
||||
None
|
||||
),
|
||||
(
|
||||
'00112233445566778899aabbccddeeffdeaddadadeaddadaffeeddccbbaa9988' +
|
||||
'7766554433221100-102030405060708090a0',
|
||||
'7468697320697320736f6d6520706c61696e7465787420746f20656e63727970' +
|
||||
'74207573696e67205349562d414553',
|
||||
'cb900f2fddbe404326601965c889bf17dba77ceb094fa663b7a3f748ba8af829' +
|
||||
'ea64ad544a272e9c485b62a3fd5c0d',
|
||||
'7bdb6e3b432667eb06f4d14bff2fbd0f',
|
||||
'7f7e7d7c7b7a79787776757473727170404142434445464748494a4b4c4d4e4f',
|
||||
'09f911029d74e35bd84156c5635688c0'
|
||||
),
|
||||
]
|
||||
|
||||
for index, tv in enumerate(test_vectors):
|
||||
test_vectors[index] = [[unhexlify(x) for x in tv[0].split("-")]]
|
||||
test_vectors[index] += [unhexlify(x) for x in tv[1:5]]
|
||||
if tv[5]:
|
||||
nonce = unhexlify(tv[5])
|
||||
else:
|
||||
nonce = None
|
||||
test_vectors[index].append(nonce)
|
||||
|
||||
def runTest(self):
|
||||
for assoc_data, pt, ct, mac, key, nonce in self.test_vectors:
|
||||
|
||||
# Encrypt
|
||||
cipher = AES.new(key, AES.MODE_SIV, nonce=nonce)
|
||||
for x in assoc_data:
|
||||
cipher.update(x)
|
||||
ct2, mac2 = cipher.encrypt_and_digest(pt)
|
||||
self.assertEqual(ct, ct2)
|
||||
self.assertEqual(mac, mac2)
|
||||
|
||||
# Decrypt
|
||||
cipher = AES.new(key, AES.MODE_SIV, nonce=nonce)
|
||||
for x in assoc_data:
|
||||
cipher.update(x)
|
||||
pt2 = cipher.decrypt_and_verify(ct, mac)
|
||||
self.assertEqual(pt, pt2)
|
||||
|
||||
|
||||
def get_tests(config={}):
|
||||
tests = []
|
||||
tests += list_test_cases(SivTests)
|
||||
tests += list_test_cases(SivFSMTests)
|
||||
tests += [TestVectors()]
|
||||
return tests
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
suite = lambda: unittest.TestSuite(get_tests())
|
||||
unittest.main(defaultTest='suite')
|
239
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_Salsa20.py
Normal file
239
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_Salsa20.py
Normal file
|
@ -0,0 +1,239 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# SelfTest/Cipher/Salsa20.py: Self-test for the Salsa20 stream cipher
|
||||
#
|
||||
# Written in 2013 by Fabrizio Tarizzo <fabrizio@fabriziotarizzo.org>
|
||||
#
|
||||
# ===================================================================
|
||||
# The contents of this file are dedicated to the public domain. To
|
||||
# the extent that dedication to the public domain is not available,
|
||||
# everyone is granted a worldwide, perpetual, royalty-free,
|
||||
# non-exclusive license to exercise all rights associated with the
|
||||
# contents of this file for any purpose whatsoever.
|
||||
# No rights are reserved.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
# ===================================================================
|
||||
|
||||
"""Self-test suite for Crypto.Cipher.Salsa20"""
|
||||
|
||||
import unittest
|
||||
|
||||
from Crypto.Util.py3compat import bchr
|
||||
|
||||
from Crypto.SelfTest.st_common import list_test_cases
|
||||
|
||||
from Crypto.Cipher import Salsa20
|
||||
|
||||
# This is a list of (plaintext, ciphertext, key[, description[, params]])
|
||||
# tuples.
|
||||
test_data = [
|
||||
# Test vectors are taken from
|
||||
# http://www.ecrypt.eu.org/stream/svn/viewcvs.cgi/ecrypt/trunk/submissions/salsa20/full/verified.test-vectors
|
||||
( '00' * 512,
|
||||
'4dfa5e481da23ea09a31022050859936da52fcee218005164f267cb65f5cfd7f'
|
||||
+ '2b4f97e0ff16924a52df269515110a07f9e460bc65ef95da58f740b7d1dbb0aa'
|
||||
+ 'd64cec189c7eb8c6bbf3d7376c80a481d43e628701f6a27afb9fe23919f24114'
|
||||
+ '8db44f70d7063efcc3dd55a0893a613c3c6fe1c127bd6f59910589293bb6ef9e'
|
||||
+ 'e24819066dee1a64f49b0bbad5988635272b169af861f85df881939f29ada6fd'
|
||||
+ '0241410e8d332ae4798d929434a2630de451ec4e0169694cbaa7ebb121ea6a2b'
|
||||
+ 'da9c1581f429e0a00f7d67e23b730676783b262e8eb43a25f55fb90b3e753aef'
|
||||
+ '8c6713ec66c51881111593ccb3e8cb8f8de124080501eeeb389c4bcb6977cf95'
|
||||
+ '7d5789631eb4554400e1e025935dfa7b3e9039d61bdc58a8697d36815bf1985c'
|
||||
+ 'efdf7ae112e5bb81e37ecf0616ce7147fc08a93a367e08631f23c03b00a8da2f'
|
||||
+ 'aa5024e5c8d30aca43fc2d5082067b21b234bc741d68fb292c6012c3764ccee3'
|
||||
+ '1e364a5403e00cfee338a21a01e7d3cefd5a770ca0ab48c435ea6116435f7ad8'
|
||||
+ '30b217b49f978a68e207ed9f462af7fb195b2115fe8f24f152e4ddc32202d6f2'
|
||||
+ 'b52fafbcfbc202d8a259a611e901d3f62d065eb13f09bbc45cd45119b843efaa'
|
||||
+ 'b375703739daced4dd4059fd71c3c47fc2f9939670fad4a46066adcc6a564578'
|
||||
+ '3308b90ffb72be04a6b147cbe38cc0c3b9267c296a92a7c69873f9f263be9703',
|
||||
'80000000000000000000000000000000',
|
||||
'128 bits key, set 1, vector 0',
|
||||
dict (iv='00'*8)),
|
||||
|
||||
( '00' * 512,
|
||||
'e3be8fdd8beca2e3ea8ef9475b29a6e7003951e1097a5c38d23b7a5fad9f6844'
|
||||
+ 'b22c97559e2723c7cbbd3fe4fc8d9a0744652a83e72a9c461876af4d7ef1a117'
|
||||
+ '8da2b74eef1b6283e7e20166abcae538e9716e4669e2816b6b20c5c356802001'
|
||||
+ 'cc1403a9a117d12a2669f456366d6ebb0f1246f1265150f793cdb4b253e348ae'
|
||||
+ '203d89bc025e802a7e0e00621d70aa36b7e07cb1e7d5b38d5e222b8b0e4b8407'
|
||||
+ '0142b1e29504767d76824850320b5368129fdd74e861b498e3be8d16f2d7d169'
|
||||
+ '57be81f47b17d9ae7c4ff15429a73e10acf250ed3a90a93c711308a74c6216a9'
|
||||
+ 'ed84cd126da7f28e8abf8bb63517e1ca98e712f4fb2e1a6aed9fdc73291faa17'
|
||||
+ '958211c4ba2ebd5838c635edb81f513a91a294e194f1c039aeec657dce40aa7e'
|
||||
+ '7c0af57cacefa40c9f14b71a4b3456a63e162ec7d8d10b8ffb1810d71001b618'
|
||||
+ '2f9f73da53b85405c11f7b2d890fa8ae0c7f2e926d8a98c7ec4e91b65120e988'
|
||||
+ '349631a700c6facec3471cb0413656e75e309456584084d7e12c5b43a41c43ed'
|
||||
+ '9a048abd9b880da65f6a665a20fe7b77cd292fe62cae644b7f7df69f32bdb331'
|
||||
+ '903e6505ce44fdc293920c6a9ec7057e23df7dad298f82ddf4efb7fdc7bfc622'
|
||||
+ '696afcfd0cddcc83c7e77f11a649d79acdc3354e9635ff137e929933a0bd6f53'
|
||||
+ '77efa105a3a4266b7c0d089d08f1e855cc32b15b93784a36e56a76cc64bc8477',
|
||||
'8000000000000000000000000000000000000000000000000000000000000000',
|
||||
'256 bits key, set 1, vector 0',
|
||||
dict (iv='00'*8)),
|
||||
|
||||
( '00' * 512,
|
||||
'169060ccb42bea7bee4d8012a02f3635eb7bca12859fa159cd559094b3507db8'
|
||||
+ '01735d1a1300102a9c9415546829cbd2021ba217b39b81d89c55b13d0c603359'
|
||||
+ '3f84159a3c84f4b4f4a0edcd9d38ff261a737909e0b66d68b5cac496f3a5be99'
|
||||
+ 'cb12c321ab711afaab36cc0947955e1a9bb952ed54425e7711279fbc81bb83f5'
|
||||
+ '6e55cea44e6daddb05858a153ea6213b3350c12aa1a83ef2726f09485fa71790'
|
||||
+ 'f9b9f922c7dda1113b1f9d56658ed3402803f511bc1f122601d5e7f0ff036e23'
|
||||
+ '23ef24bb24195b9fd574823cd8a40c29d86bd35c191e2038779ff696c712b6d8'
|
||||
+ '2e7014dbe1ac5d527af076c088c4a8d44317958189f6ef54933a7e0816b5b916'
|
||||
+ 'd8f12ed8afe9422b85e5cc9b8adec9d6cfabe8dbc1082bccc02f5a7266aa074c'
|
||||
+ 'a284e583a35837798cc0e69d4ce937653b8cdd65ce414b89138615ccb165ad19'
|
||||
+ '3c6b9c3d05eef4be921a10ea811fe61d11c6867600188e065daff90b509ec56b'
|
||||
+ 'd41e7e8968c478c78d590c2d2ee24ea009c8f49bc3d81672cfc47895a9e21c9a'
|
||||
+ '471ebf8e294bee5d2de436ac8d052bf31111b345f1da23c3a4d13b9fc5f0900a'
|
||||
+ 'a298f98f538973b8fad40d4d159777de2cfe2a3dead1645ddb49794827dba040'
|
||||
+ 'f70a0ff4ecd155e0f033604693a51e2363880e2ecf98699e7174af7c2c6b0fc6'
|
||||
+ '59ae329599a3949272a37b9b2183a0910922a3f325ae124dcbdd735364055ceb',
|
||||
'09090909090909090909090909090909',
|
||||
'128 bits key, set 2, vector 9',
|
||||
dict (iv='00'*8)),
|
||||
|
||||
( '00' * 512,
|
||||
'7041e747ceb22ed7812985465f50333124f971da1c5d6efe5ca201b886f31046'
|
||||
+ 'e757e5c3ec914f60ed1f6bce2819b6810953f12b8ba1199bf82d746a8b8a88f1'
|
||||
+ '142002978ec4c35b95dc2c82990f9e847a0ab45f2ca72625f5190c820f29f3aa'
|
||||
+ 'f5f0b5572b06b70a144f2a240c3b3098d4831fa1ce1459f8d1df226a6a79b0ab'
|
||||
+ '41e91799ef31b5ff3d756c19126b19025858ee70fbd69f2be955cb011c005e31'
|
||||
+ '32b271b378f39b0cb594e95c99ce6ff17735a541891845bbf0450afcb4a850b9'
|
||||
+ '4ee90afb713ae7e01295c74381180a3816d7020d5a396c0d97aaa783eaabb6ec'
|
||||
+ '44d5111157f2212d1b1b8fca7893e8b520cd482418c272ab119b569a2b9598eb'
|
||||
+ '355624d12e79adab81153b58cd22eaf1b2a32395dedc4a1c66f4d274070b9800'
|
||||
+ 'ea95766f0245a8295f8aadb36ddbbdfa936417c8dbc6235d19494036964d3e70'
|
||||
+ 'b125b0f800c3d53881d9d11e7970f827c2f9556935cd29e927b0aceb8cae5fd4'
|
||||
+ '0fd88a8854010a33db94c96c98735858f1c5df6844f864feaca8f41539313e7f'
|
||||
+ '3c0610214912cd5e6362197646207e2d64cd5b26c9dfe0822629dcbeb16662e8'
|
||||
+ '9ff5bf5cf2e499138a5e27bd5027329d0e68ddf53103e9e409523662e27f61f6'
|
||||
+ '5cf38c1232023e6a6ef66c315bcb2a4328642faabb7ca1e889e039e7c444b34b'
|
||||
+ 'b3443f596ac730f3df3dfcdb343c307c80f76e43e8898c5e8f43dc3bb280add0',
|
||||
'0909090909090909090909090909090909090909090909090909090909090909',
|
||||
'256 bits key, set 2, vector 9',
|
||||
dict (iv='00'*8)),
|
||||
|
||||
( '00' * 1024,
|
||||
'71daee5142d0728b41b6597933ebf467e43279e30978677078941602629cbf68'
|
||||
+ 'b73d6bd2c95f118d2b3e6ec955dabb6dc61c4143bc9a9b32b99dbe6866166dc0'
|
||||
+ '8631b7d6553050303d7252c264d3a90d26c853634813e09ad7545a6ce7e84a5d'
|
||||
+ 'fc75ec43431207d5319970b0faadb0e1510625bb54372c8515e28e2accf0a993'
|
||||
+ '0ad15f431874923d2a59e20d9f2a5367dba6051564f150287debb1db536ff9b0'
|
||||
+ '9ad981f25e5010d85d76ee0c305f755b25e6f09341e0812f95c94f42eead346e'
|
||||
+ '81f39c58c5faa2c88953dc0cac90469db2063cb5cdb22c9eae22afbf0506fca4'
|
||||
+ '1dc710b846fbdfe3c46883dd118f3a5e8b11b6afd9e71680d8666557301a2daa'
|
||||
+ 'fb9496c559784d35a035360885f9b17bd7191977deea932b981ebdb29057ae3c'
|
||||
+ '92cfeff5e6c5d0cb62f209ce342d4e35c69646ccd14e53350e488bb310a32f8b'
|
||||
+ '0248e70acc5b473df537ced3f81a014d4083932bedd62ed0e447b6766cd2604b'
|
||||
+ '706e9b346c4468beb46a34ecf1610ebd38331d52bf33346afec15eefb2a7699e'
|
||||
+ '8759db5a1f636a48a039688e39de34d995df9f27ed9edc8dd795e39e53d9d925'
|
||||
+ 'b278010565ff665269042f05096d94da3433d957ec13d2fd82a0066283d0d1ee'
|
||||
+ 'b81bf0ef133b7fd90248b8ffb499b2414cd4fa003093ff0864575a43749bf596'
|
||||
+ '02f26c717fa96b1d057697db08ebc3fa664a016a67dcef8807577cc3a09385d3'
|
||||
+ 'f4dc79b34364bb3b166ce65fe1dd28e3950fe6fa81063f7b16ce1c0e6daac1f8'
|
||||
+ '188455b77752045e863c9b256ad92bc6e2d08314c5bba191c274f42dfbb3d652'
|
||||
+ 'bb771956555e880f84cd8b827a4c5a52f3a099fa0259bd4aac3efd541f191170'
|
||||
+ '4412d6e85fbcc628b335875b9fef24807f6e1bc66c3186159e1e7f5a13913e02'
|
||||
+ 'd241ce2efdbcaa275039fb14eac5923d17ffbc7f1abd3b45e92127575bfbabf9'
|
||||
+ '3a257ebef0aa1437b326e41b585af572f7239c33b32981a1577a4f629b027e1e'
|
||||
+ 'b49d58cc497e944d79cef44357c2bf25442ab779651e991147bf79d6fd3a8868'
|
||||
+ '0cd3b1748e07fd10d78aceef6db8a5e563570d40127f754146c34a440f2a991a'
|
||||
+ '23fa39d365141f255041f2135c5cba4373452c114da1801bacca38610e3a6524'
|
||||
+ '2b822d32de4ab5a7d3cf9b61b37493c863bd12e2cae10530cddcda2cb7a5436b'
|
||||
+ 'ef8988d4d24e8cdc31b2d2a3586340bc5141f8f6632d0dd543bfed81eb471ba1'
|
||||
+ 'f3dc2225a15ffddcc03eb48f44e27e2aa390598adf83f15c6608a5f18d4dfcf0'
|
||||
+ 'f547d467a4d70b281c83a595d7660d0b62de78b9cca023cca89d7b1f83484638'
|
||||
+ '0e228c25f049184a612ef5bb3d37454e6cfa5b10dceda619d898a699b3c8981a'
|
||||
+ '173407844bb89b4287bf57dd6600c79e352c681d74b03fa7ea0d7bf6ad69f8a6'
|
||||
+ '8ecb001963bd2dd8a2baa0083ec09751cd9742402ad716be16d5c052304cfca1',
|
||||
'0F62B5085BAE0154A7FA4DA0F34699EC',
|
||||
'128 bits key, Set 6, vector# 3',
|
||||
dict (iv='288FF65DC42B92F9')),
|
||||
|
||||
( '00' * 1024,
|
||||
'5e5e71f90199340304abb22a37b6625bf883fb89ce3b21f54a10b81066ef87da'
|
||||
+ '30b77699aa7379da595c77dd59542da208e5954f89e40eb7aa80a84a6176663f'
|
||||
+ 'd910cde567cf1ff60f7040548d8f376bfd1f44c4774aac37410ede7d5c3463fc'
|
||||
+ '4508a603201d8495ad257894e5eb1914b53e8da5e4bf2bc83ac87ce55cc67df7'
|
||||
+ '093d9853d2a83a9c8be969175df7c807a17156df768445dd0874a9271c6537f5'
|
||||
+ 'ce0466473582375f067fa4fcdaf65dbc0139cd75e8c21a482f28c0fb8c3d9f94'
|
||||
+ '22606cc8e88fe28fe73ec3cb10ff0e8cc5f2a49e540f007265c65b7130bfdb98'
|
||||
+ '795b1df9522da46e48b30e55d9f0d787955ece720205b29c85f3ad9be33b4459'
|
||||
+ '7d21b54d06c9a60b04b8e640c64e566e51566730e86cf128ab14174f91bd8981'
|
||||
+ 'a6fb00fe587bbd6c38b5a1dfdb04ea7e61536fd229f957aa9b070ca931358e85'
|
||||
+ '11b92c53c523cb54828fb1513c5636fa9a0645b4a3c922c0db94986d92f314ff'
|
||||
+ '7852c03b231e4dceea5dd8cced621869cff818daf3c270ff3c8be2e5c74be767'
|
||||
+ 'a4e1fdf3327a934fe31e46df5a74ae2021cee021d958c4f615263d99a5ddae7f'
|
||||
+ 'eab45e6eccbafefe4761c57750847b7e75ee2e2f14333c0779ce4678f47b1e1b'
|
||||
+ '760a03a5f17d6e91d4b42313b3f1077ee270e432fe04917ed1fc8babebf7c941'
|
||||
+ '42b80dfb44a28a2a3e59093027606f6860bfb8c2e5897078cfccda7314c70035'
|
||||
+ 'f137de6f05daa035891d5f6f76e1df0fce1112a2ff0ac2bd3534b5d1bf4c7165'
|
||||
+ 'fb40a1b6eacb7f295711c4907ae457514a7010f3a342b4427593d61ba993bc59'
|
||||
+ '8bd09c56b9ee53aac5dd861fa4b4bb53888952a4aa9d8ca8671582de716270e1'
|
||||
+ '97375b3ee49e51fa2bf4ef32015dd9a764d966aa2ae541592d0aa650849e99ca'
|
||||
+ '5c6c39beebf516457cc32fe4c105bff314a12f1ec94bdf4d626f5d9b1cbbde42'
|
||||
+ 'e5733f0885765ba29e2e82c829d312f5fc7e180679ac84826c08d0a644b326d0'
|
||||
+ '44da0fdcc75fa53cfe4ced0437fa4df5a7ecbca8b4cb7c4a9ecf9a60d00a56eb'
|
||||
+ '81da52adc21f508dbb60a9503a3cc94a896616d86020d5b0e5c637329b6d396a'
|
||||
+ '41a21ba2c4a9493cf33fa2d4f10f77d5b12fdad7e478ccfe79b74851fc96a7ca'
|
||||
+ '6320c5efd561a222c0ab0fb44bbda0e42149611d2262bb7d1719150fa798718a'
|
||||
+ '0eec63ee297cad459869c8b0f06c4e2b56cbac03cd2605b2a924efedf85ec8f1'
|
||||
+ '9b0b6c90e7cbd933223ffeb1b3a3f9677657905829294c4c70acdb8b0891b47d'
|
||||
+ '0875d0cd6c0f4efe2917fc44b581ef0d1e4280197065d07da34ab33283364552'
|
||||
+ 'efad0bd9257b059acdd0a6f246812feb69e7e76065f27dbc2eee94da9cc41835'
|
||||
+ 'bf826e36e5cebe5d4d6a37a6a666246290ce51a0c082718ab0ec855668db1add'
|
||||
+ 'a658e5f257e0db39384d02e6145c4c00eaa079098f6d820d872de711b6ed08cf',
|
||||
'0F62B5085BAE0154A7FA4DA0F34699EC3F92E5388BDE3184D72A7DD02376C91C',
|
||||
'256 bits key, Set 6, vector# 3',
|
||||
dict (iv='288FF65DC42B92F9')),
|
||||
|
||||
]
|
||||
|
||||
|
||||
class KeyLength(unittest.TestCase):
|
||||
|
||||
def runTest(self):
|
||||
|
||||
nonce = bchr(0) * 8
|
||||
for key_length in (15, 30, 33):
|
||||
key = bchr(1) * key_length
|
||||
self.assertRaises(ValueError, Salsa20.new, key, nonce)
|
||||
|
||||
|
||||
class NonceTests(unittest.TestCase):
|
||||
|
||||
def test_invalid_nonce_length(self):
|
||||
key = bchr(1) * 16
|
||||
self.assertRaises(ValueError, Salsa20.new, key, bchr(0) * 7)
|
||||
self.assertRaises(ValueError, Salsa20.new, key, bchr(0) * 9)
|
||||
|
||||
def test_default_nonce(self):
|
||||
|
||||
cipher1 = Salsa20.new(bchr(1) * 16)
|
||||
cipher2 = Salsa20.new(bchr(1) * 16)
|
||||
self.assertEqual(len(cipher1.nonce), 8)
|
||||
self.assertNotEqual(cipher1.nonce, cipher2.nonce)
|
||||
|
||||
|
||||
def get_tests(config={}):
|
||||
from .common import make_stream_tests
|
||||
tests = make_stream_tests(Salsa20, "Salsa20", test_data)
|
||||
tests.append(KeyLength())
|
||||
tests += list_test_cases(NonceTests)
|
||||
return tests
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import unittest
|
||||
suite = lambda: unittest.TestSuite(get_tests())
|
||||
unittest.main(defaultTest='suite')
|
||||
|
||||
# vim:set ts=4 sw=4 sts=4 expandtab:
|
172
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_pkcs1_15.py
Normal file
172
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_pkcs1_15.py
Normal file
|
@ -0,0 +1,172 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# SelfTest/Cipher/test_pkcs1_15.py: Self-test for PKCS#1 v1.5 encryption
|
||||
#
|
||||
# ===================================================================
|
||||
# The contents of this file are dedicated to the public domain. To
|
||||
# the extent that dedication to the public domain is not available,
|
||||
# everyone is granted a worldwide, perpetual, royalty-free,
|
||||
# non-exclusive license to exercise all rights associated with the
|
||||
# contents of this file for any purpose whatsoever.
|
||||
# No rights are reserved.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
# ===================================================================
|
||||
|
||||
import unittest
|
||||
|
||||
from Crypto.PublicKey import RSA
|
||||
from Crypto.SelfTest.st_common import list_test_cases, a2b_hex, b2a_hex
|
||||
from Crypto import Random
|
||||
from Crypto.Cipher import PKCS1_v1_5 as PKCS
|
||||
from Crypto.Util.py3compat import *
|
||||
from Crypto.Util.number import bytes_to_long, long_to_bytes
|
||||
|
||||
def rws(t):
|
||||
"""Remove white spaces, tabs, and new lines from a string"""
|
||||
for c in ['\n', '\t', ' ']:
|
||||
t = t.replace(c,'')
|
||||
return t
|
||||
|
||||
def t2b(t):
|
||||
"""Convert a text string with bytes in hex form to a byte string"""
|
||||
clean = b(rws(t))
|
||||
if len(clean)%2 == 1:
|
||||
print(clean)
|
||||
raise ValueError("Even number of characters expected")
|
||||
return a2b_hex(clean)
|
||||
|
||||
class PKCS1_15_Tests(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.rng = Random.new().read
|
||||
self.key1024 = RSA.generate(1024, self.rng)
|
||||
|
||||
# List of tuples with test data for PKCS#1 v1.5.
|
||||
# Each tuple is made up by:
|
||||
# Item #0: dictionary with RSA key component, or key to import
|
||||
# Item #1: plaintext
|
||||
# Item #2: ciphertext
|
||||
# Item #3: random data
|
||||
|
||||
_testData = (
|
||||
|
||||
#
|
||||
# Generated with openssl 0.9.8o
|
||||
#
|
||||
(
|
||||
# Private key
|
||||
'''-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICXAIBAAKBgQDAiAnvIAOvqVwJTaYzsKnefZftgtXGE2hPJppGsWl78yz9jeXY
|
||||
W/FxX/gTPURArNhdnhP6n3p2ZaDIBrO2zizbgIXs0IsljTTcr4vnI8fMXzyNUOjA
|
||||
zP3nzMqZDZK6757XQAobOssMkBFqRWwilT/3DsBhRpl3iMUhF+wvpTSHewIDAQAB
|
||||
AoGAC4HV/inOrpgTvSab8Wj0riyZgQOZ3U3ZpSlsfR8ra9Ib9Uee3jCYnKscu6Gk
|
||||
y6zI/cdt8EPJ4PuwAWSNJzbpbVaDvUq25OD+CX8/uRT08yBS4J8TzBitZJTD4lS7
|
||||
atdTnKT0Wmwk+u8tDbhvMKwnUHdJLcuIsycts9rwJVapUtkCQQDvDpx2JMun0YKG
|
||||
uUttjmL8oJ3U0m3ZvMdVwBecA0eebZb1l2J5PvI3EJD97eKe91Nsw8T3lwpoN40k
|
||||
IocSVDklAkEAzi1HLHE6EzVPOe5+Y0kGvrIYRRhncOb72vCvBZvD6wLZpQgqo6c4
|
||||
d3XHFBBQWA6xcvQb5w+VVEJZzw64y25sHwJBAMYReRl6SzL0qA0wIYrYWrOt8JeQ
|
||||
8mthulcWHXmqTgC6FEXP9Es5GD7/fuKl4wqLKZgIbH4nqvvGay7xXLCXD/ECQH9a
|
||||
1JYNMtRen5unSAbIOxRcKkWz92F0LKpm9ZW/S9vFHO+mBcClMGoKJHiuQxLBsLbT
|
||||
NtEZfSJZAeS2sUtn3/0CQDb2M2zNBTF8LlM0nxmh0k9VGm5TVIyBEMcipmvOgqIs
|
||||
HKukWBcq9f/UOmS0oEhai/6g+Uf7VHJdWaeO5LzuvwU=
|
||||
-----END RSA PRIVATE KEY-----''',
|
||||
# Plaintext
|
||||
'''THIS IS PLAINTEXT\x0A''',
|
||||
# Ciphertext
|
||||
'''3f dc fd 3c cd 5c 9b 12 af 65 32 e3 f7 d0 da 36
|
||||
8f 8f d9 e3 13 1c 7f c8 b3 f9 c1 08 e4 eb 79 9c
|
||||
91 89 1f 96 3b 94 77 61 99 a4 b1 ee 5d e6 17 c9
|
||||
5d 0a b5 63 52 0a eb 00 45 38 2a fb b0 71 3d 11
|
||||
f7 a1 9e a7 69 b3 af 61 c0 bb 04 5b 5d 4b 27 44
|
||||
1f 5b 97 89 ba 6a 08 95 ee 4f a2 eb 56 64 e5 0f
|
||||
da 7c f9 9a 61 61 06 62 ed a0 bc 5f aa 6c 31 78
|
||||
70 28 1a bb 98 3c e3 6a 60 3c d1 0b 0f 5a f4 75''',
|
||||
# Random data
|
||||
'''eb d7 7d 86 a4 35 23 a3 54 7e 02 0b 42 1d
|
||||
61 6c af 67 b8 4e 17 56 80 66 36 04 64 34 26 8a
|
||||
47 dd 44 b3 1a b2 17 60 f4 91 2e e2 b5 95 64 cc
|
||||
f9 da c8 70 94 54 86 4c ef 5b 08 7d 18 c4 ab 8d
|
||||
04 06 33 8f ca 15 5f 52 60 8a a1 0c f5 08 b5 4c
|
||||
bb 99 b8 94 25 04 9c e6 01 75 e6 f9 63 7a 65 61
|
||||
13 8a a7 47 77 81 ae 0d b8 2c 4d 50 a5'''
|
||||
),
|
||||
)
|
||||
|
||||
def testEncrypt1(self):
|
||||
for test in self._testData:
|
||||
# Build the key
|
||||
key = RSA.importKey(test[0])
|
||||
# RNG that takes its random numbers from a pool given
|
||||
# at initialization
|
||||
class randGen:
|
||||
def __init__(self, data):
|
||||
self.data = data
|
||||
self.idx = 0
|
||||
def __call__(self, N):
|
||||
r = self.data[self.idx:self.idx+N]
|
||||
self.idx += N
|
||||
return r
|
||||
# The real test
|
||||
cipher = PKCS.new(key, randfunc=randGen(t2b(test[3])))
|
||||
ct = cipher.encrypt(b(test[1]))
|
||||
self.assertEqual(ct, t2b(test[2]))
|
||||
|
||||
def testEncrypt2(self):
|
||||
# Verify that encryption fail if plaintext is too long
|
||||
pt = '\x00'*(128-11+1)
|
||||
cipher = PKCS.new(self.key1024)
|
||||
self.assertRaises(ValueError, cipher.encrypt, pt)
|
||||
|
||||
def testVerify1(self):
|
||||
for test in self._testData:
|
||||
# Build the key
|
||||
key = RSA.importKey(test[0])
|
||||
# The real test
|
||||
cipher = PKCS.new(key)
|
||||
pt = cipher.decrypt(t2b(test[2]), "---")
|
||||
self.assertEqual(pt, b(test[1]))
|
||||
|
||||
def testVerify2(self):
|
||||
# Verify that decryption fails if ciphertext is not as long as
|
||||
# RSA modulus
|
||||
cipher = PKCS.new(self.key1024)
|
||||
self.assertRaises(ValueError, cipher.decrypt, '\x00'*127, "---")
|
||||
self.assertRaises(ValueError, cipher.decrypt, '\x00'*129, "---")
|
||||
|
||||
# Verify that decryption fails if there are less then 8 non-zero padding
|
||||
# bytes
|
||||
pt = b('\x00\x02' + '\xFF'*7 + '\x00' + '\x45'*118)
|
||||
pt_int = bytes_to_long(pt)
|
||||
ct_int = self.key1024._encrypt(pt_int)
|
||||
ct = long_to_bytes(ct_int, 128)
|
||||
self.assertEqual("---", cipher.decrypt(ct, "---"))
|
||||
|
||||
def testEncryptVerify1(self):
|
||||
# Encrypt/Verify messages of length [0..RSAlen-11]
|
||||
# and therefore padding [8..117]
|
||||
for pt_len in range(0,128-11+1):
|
||||
pt = self.rng(pt_len)
|
||||
cipher = PKCS.new(self.key1024)
|
||||
ct = cipher.encrypt(pt)
|
||||
pt2 = cipher.decrypt(ct, "---")
|
||||
self.assertEqual(pt,pt2)
|
||||
|
||||
|
||||
def get_tests(config={}):
|
||||
tests = []
|
||||
tests += list_test_cases(PKCS1_15_Tests)
|
||||
return tests
|
||||
|
||||
if __name__ == '__main__':
|
||||
suite = lambda: unittest.TestSuite(get_tests())
|
||||
unittest.main(defaultTest='suite')
|
||||
|
||||
# vim:set ts=4 sw=4 sts=4 expandtab:
|
367
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_pkcs1_oaep.py
Normal file
367
venv/Lib/site-packages/Crypto/SelfTest/Cipher/test_pkcs1_oaep.py
Normal file
|
@ -0,0 +1,367 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# SelfTest/Cipher/test_pkcs1_oaep.py: Self-test for PKCS#1 OAEP encryption
|
||||
#
|
||||
# ===================================================================
|
||||
# The contents of this file are dedicated to the public domain. To
|
||||
# the extent that dedication to the public domain is not available,
|
||||
# everyone is granted a worldwide, perpetual, royalty-free,
|
||||
# non-exclusive license to exercise all rights associated with the
|
||||
# contents of this file for any purpose whatsoever.
|
||||
# No rights are reserved.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
# ===================================================================
|
||||
|
||||
import unittest
|
||||
|
||||
from Crypto.SelfTest.st_common import list_test_cases, a2b_hex, b2a_hex
|
||||
|
||||
from Crypto.Util.py3compat import *
|
||||
from Crypto.PublicKey import RSA
|
||||
from Crypto.Cipher import PKCS1_OAEP as PKCS
|
||||
from Crypto.Hash import MD2,MD5,SHA1,SHA256,RIPEMD160
|
||||
from Crypto import Random
|
||||
|
||||
def rws(t):
|
||||
"""Remove white spaces, tabs, and new lines from a string"""
|
||||
for c in ['\n', '\t', ' ']:
|
||||
t = t.replace(c,'')
|
||||
return t
|
||||
|
||||
def t2b(t):
|
||||
"""Convert a text string with bytes in hex form to a byte string"""
|
||||
clean = rws(t)
|
||||
if len(clean)%2 == 1:
|
||||
raise ValueError("Even number of characters expected")
|
||||
return a2b_hex(clean)
|
||||
|
||||
class PKCS1_OAEP_Tests(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.rng = Random.new().read
|
||||
self.key1024 = RSA.generate(1024, self.rng)
|
||||
|
||||
# List of tuples with test data for PKCS#1 OAEP
|
||||
# Each tuple is made up by:
|
||||
# Item #0: dictionary with RSA key component
|
||||
# Item #1: plaintext
|
||||
# Item #2: ciphertext
|
||||
# Item #3: random data (=seed)
|
||||
# Item #4: hash object
|
||||
|
||||
_testData = (
|
||||
|
||||
#
|
||||
# From in oaep-int.txt to be found in
|
||||
# ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-1/pkcs-1v2-1-vec.zip
|
||||
#
|
||||
(
|
||||
# Private key
|
||||
{
|
||||
'n':'''bb f8 2f 09 06 82 ce 9c 23 38 ac 2b 9d a8 71 f7
|
||||
36 8d 07 ee d4 10 43 a4 40 d6 b6 f0 74 54 f5 1f
|
||||
b8 df ba af 03 5c 02 ab 61 ea 48 ce eb 6f cd 48
|
||||
76 ed 52 0d 60 e1 ec 46 19 71 9d 8a 5b 8b 80 7f
|
||||
af b8 e0 a3 df c7 37 72 3e e6 b4 b7 d9 3a 25 84
|
||||
ee 6a 64 9d 06 09 53 74 88 34 b2 45 45 98 39 4e
|
||||
e0 aa b1 2d 7b 61 a5 1f 52 7a 9a 41 f6 c1 68 7f
|
||||
e2 53 72 98 ca 2a 8f 59 46 f8 e5 fd 09 1d bd cb''',
|
||||
# Public key
|
||||
'e':'11',
|
||||
# In the test vector, only p and q were given...
|
||||
# d is computed offline as e^{-1} mod (p-1)(q-1)
|
||||
'd':'''a5dafc5341faf289c4b988db30c1cdf83f31251e0
|
||||
668b42784813801579641b29410b3c7998d6bc465745e5c3
|
||||
92669d6870da2c082a939e37fdcb82ec93edac97ff3ad595
|
||||
0accfbc111c76f1a9529444e56aaf68c56c092cd38dc3bef
|
||||
5d20a939926ed4f74a13eddfbe1a1cecc4894af9428c2b7b
|
||||
8883fe4463a4bc85b1cb3c1'''
|
||||
}
|
||||
,
|
||||
# Plaintext
|
||||
'''d4 36 e9 95 69 fd 32 a7 c8 a0 5b bc 90 d3 2c 49''',
|
||||
# Ciphertext
|
||||
'''12 53 e0 4d c0 a5 39 7b b4 4a 7a b8 7e 9b f2 a0
|
||||
39 a3 3d 1e 99 6f c8 2a 94 cc d3 00 74 c9 5d f7
|
||||
63 72 20 17 06 9e 52 68 da 5d 1c 0b 4f 87 2c f6
|
||||
53 c1 1d f8 23 14 a6 79 68 df ea e2 8d ef 04 bb
|
||||
6d 84 b1 c3 1d 65 4a 19 70 e5 78 3b d6 eb 96 a0
|
||||
24 c2 ca 2f 4a 90 fe 9f 2e f5 c9 c1 40 e5 bb 48
|
||||
da 95 36 ad 87 00 c8 4f c9 13 0a de a7 4e 55 8d
|
||||
51 a7 4d df 85 d8 b5 0d e9 68 38 d6 06 3e 09 55''',
|
||||
# Random
|
||||
'''aa fd 12 f6 59 ca e6 34 89 b4 79 e5 07 6d de c2
|
||||
f0 6c b5 8f''',
|
||||
# Hash
|
||||
SHA1,
|
||||
),
|
||||
|
||||
#
|
||||
# From in oaep-vect.txt to be found in Example 1.1
|
||||
# ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-1/pkcs-1v2-1-vec.zip
|
||||
#
|
||||
(
|
||||
# Private key
|
||||
{
|
||||
'n':'''a8 b3 b2 84 af 8e b5 0b 38 70 34 a8 60 f1 46 c4
|
||||
91 9f 31 87 63 cd 6c 55 98 c8 ae 48 11 a1 e0 ab
|
||||
c4 c7 e0 b0 82 d6 93 a5 e7 fc ed 67 5c f4 66 85
|
||||
12 77 2c 0c bc 64 a7 42 c6 c6 30 f5 33 c8 cc 72
|
||||
f6 2a e8 33 c4 0b f2 58 42 e9 84 bb 78 bd bf 97
|
||||
c0 10 7d 55 bd b6 62 f5 c4 e0 fa b9 84 5c b5 14
|
||||
8e f7 39 2d d3 aa ff 93 ae 1e 6b 66 7b b3 d4 24
|
||||
76 16 d4 f5 ba 10 d4 cf d2 26 de 88 d3 9f 16 fb''',
|
||||
'e':'''01 00 01''',
|
||||
'd':'''53 33 9c fd b7 9f c8 46 6a 65 5c 73 16 ac a8 5c
|
||||
55 fd 8f 6d d8 98 fd af 11 95 17 ef 4f 52 e8 fd
|
||||
8e 25 8d f9 3f ee 18 0f a0 e4 ab 29 69 3c d8 3b
|
||||
15 2a 55 3d 4a c4 d1 81 2b 8b 9f a5 af 0e 7f 55
|
||||
fe 73 04 df 41 57 09 26 f3 31 1f 15 c4 d6 5a 73
|
||||
2c 48 31 16 ee 3d 3d 2d 0a f3 54 9a d9 bf 7c bf
|
||||
b7 8a d8 84 f8 4d 5b eb 04 72 4d c7 36 9b 31 de
|
||||
f3 7d 0c f5 39 e9 cf cd d3 de 65 37 29 ea d5 d1 '''
|
||||
}
|
||||
,
|
||||
# Plaintext
|
||||
'''66 28 19 4e 12 07 3d b0 3b a9 4c da 9e f9 53 23
|
||||
97 d5 0d ba 79 b9 87 00 4a fe fe 34''',
|
||||
# Ciphertext
|
||||
'''35 4f e6 7b 4a 12 6d 5d 35 fe 36 c7 77 79 1a 3f
|
||||
7b a1 3d ef 48 4e 2d 39 08 af f7 22 fa d4 68 fb
|
||||
21 69 6d e9 5d 0b e9 11 c2 d3 17 4f 8a fc c2 01
|
||||
03 5f 7b 6d 8e 69 40 2d e5 45 16 18 c2 1a 53 5f
|
||||
a9 d7 bf c5 b8 dd 9f c2 43 f8 cf 92 7d b3 13 22
|
||||
d6 e8 81 ea a9 1a 99 61 70 e6 57 a0 5a 26 64 26
|
||||
d9 8c 88 00 3f 84 77 c1 22 70 94 a0 d9 fa 1e 8c
|
||||
40 24 30 9c e1 ec cc b5 21 00 35 d4 7a c7 2e 8a''',
|
||||
# Random
|
||||
'''18 b7 76 ea 21 06 9d 69 77 6a 33 e9 6b ad 48 e1
|
||||
dd a0 a5 ef''',
|
||||
SHA1
|
||||
),
|
||||
|
||||
#
|
||||
# From in oaep-vect.txt to be found in Example 2.1
|
||||
# ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-1/pkcs-1v2-1-vec.zip
|
||||
#
|
||||
(
|
||||
# Private key
|
||||
{
|
||||
'n':'''01 94 7c 7f ce 90 42 5f 47 27 9e 70 85 1f 25 d5
|
||||
e6 23 16 fe 8a 1d f1 93 71 e3 e6 28 e2 60 54 3e
|
||||
49 01 ef 60 81 f6 8c 0b 81 41 19 0d 2a e8 da ba
|
||||
7d 12 50 ec 6d b6 36 e9 44 ec 37 22 87 7c 7c 1d
|
||||
0a 67 f1 4b 16 94 c5 f0 37 94 51 a4 3e 49 a3 2d
|
||||
de 83 67 0b 73 da 91 a1 c9 9b c2 3b 43 6a 60 05
|
||||
5c 61 0f 0b af 99 c1 a0 79 56 5b 95 a3 f1 52 66
|
||||
32 d1 d4 da 60 f2 0e da 25 e6 53 c4 f0 02 76 6f
|
||||
45''',
|
||||
'e':'''01 00 01''',
|
||||
'd':'''08 23 f2 0f ad b5 da 89 08 8a 9d 00 89 3e 21 fa
|
||||
4a 1b 11 fb c9 3c 64 a3 be 0b aa ea 97 fb 3b 93
|
||||
c3 ff 71 37 04 c1 9c 96 3c 1d 10 7a ae 99 05 47
|
||||
39 f7 9e 02 e1 86 de 86 f8 7a 6d de fe a6 d8 cc
|
||||
d1 d3 c8 1a 47 bf a7 25 5b e2 06 01 a4 a4 b2 f0
|
||||
8a 16 7b 5e 27 9d 71 5b 1b 45 5b dd 7e ab 24 59
|
||||
41 d9 76 8b 9a ce fb 3c cd a5 95 2d a3 ce e7 25
|
||||
25 b4 50 16 63 a8 ee 15 c9 e9 92 d9 24 62 fe 39'''
|
||||
},
|
||||
# Plaintext
|
||||
'''8f f0 0c aa 60 5c 70 28 30 63 4d 9a 6c 3d 42 c6
|
||||
52 b5 8c f1 d9 2f ec 57 0b ee e7''',
|
||||
# Ciphertext
|
||||
'''01 81 af 89 22 b9 fc b4 d7 9d 92 eb e1 98 15 99
|
||||
2f c0 c1 43 9d 8b cd 49 13 98 a0 f4 ad 3a 32 9a
|
||||
5b d9 38 55 60 db 53 26 83 c8 b7 da 04 e4 b1 2a
|
||||
ed 6a ac df 47 1c 34 c9 cd a8 91 ad dc c2 df 34
|
||||
56 65 3a a6 38 2e 9a e5 9b 54 45 52 57 eb 09 9d
|
||||
56 2b be 10 45 3f 2b 6d 13 c5 9c 02 e1 0f 1f 8a
|
||||
bb 5d a0 d0 57 09 32 da cf 2d 09 01 db 72 9d 0f
|
||||
ef cc 05 4e 70 96 8e a5 40 c8 1b 04 bc ae fe 72
|
||||
0e''',
|
||||
# Random
|
||||
'''8c 40 7b 5e c2 89 9e 50 99 c5 3e 8c e7 93 bf 94
|
||||
e7 1b 17 82''',
|
||||
SHA1
|
||||
),
|
||||
|
||||
#
|
||||
# From in oaep-vect.txt to be found in Example 10.1
|
||||
# ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-1/pkcs-1v2-1-vec.zip
|
||||
#
|
||||
(
|
||||
# Private key
|
||||
{
|
||||
'n':'''ae 45 ed 56 01 ce c6 b8 cc 05 f8 03 93 5c 67 4d
|
||||
db e0 d7 5c 4c 09 fd 79 51 fc 6b 0c ae c3 13 a8
|
||||
df 39 97 0c 51 8b ff ba 5e d6 8f 3f 0d 7f 22 a4
|
||||
02 9d 41 3f 1a e0 7e 4e be 9e 41 77 ce 23 e7 f5
|
||||
40 4b 56 9e 4e e1 bd cf 3c 1f b0 3e f1 13 80 2d
|
||||
4f 85 5e b9 b5 13 4b 5a 7c 80 85 ad ca e6 fa 2f
|
||||
a1 41 7e c3 76 3b e1 71 b0 c6 2b 76 0e de 23 c1
|
||||
2a d9 2b 98 08 84 c6 41 f5 a8 fa c2 6b da d4 a0
|
||||
33 81 a2 2f e1 b7 54 88 50 94 c8 25 06 d4 01 9a
|
||||
53 5a 28 6a fe b2 71 bb 9b a5 92 de 18 dc f6 00
|
||||
c2 ae ea e5 6e 02 f7 cf 79 fc 14 cf 3b dc 7c d8
|
||||
4f eb bb f9 50 ca 90 30 4b 22 19 a7 aa 06 3a ef
|
||||
a2 c3 c1 98 0e 56 0c d6 4a fe 77 95 85 b6 10 76
|
||||
57 b9 57 85 7e fd e6 01 09 88 ab 7d e4 17 fc 88
|
||||
d8 f3 84 c4 e6 e7 2c 3f 94 3e 0c 31 c0 c4 a5 cc
|
||||
36 f8 79 d8 a3 ac 9d 7d 59 86 0e aa da 6b 83 bb''',
|
||||
'e':'''01 00 01''',
|
||||
'd':'''05 6b 04 21 6f e5 f3 54 ac 77 25 0a 4b 6b 0c 85
|
||||
25 a8 5c 59 b0 bd 80 c5 64 50 a2 2d 5f 43 8e 59
|
||||
6a 33 3a a8 75 e2 91 dd 43 f4 8c b8 8b 9d 5f c0
|
||||
d4 99 f9 fc d1 c3 97 f9 af c0 70 cd 9e 39 8c 8d
|
||||
19 e6 1d b7 c7 41 0a 6b 26 75 df bf 5d 34 5b 80
|
||||
4d 20 1a dd 50 2d 5c e2 df cb 09 1c e9 99 7b be
|
||||
be 57 30 6f 38 3e 4d 58 81 03 f0 36 f7 e8 5d 19
|
||||
34 d1 52 a3 23 e4 a8 db 45 1d 6f 4a 5b 1b 0f 10
|
||||
2c c1 50 e0 2f ee e2 b8 8d ea 4a d4 c1 ba cc b2
|
||||
4d 84 07 2d 14 e1 d2 4a 67 71 f7 40 8e e3 05 64
|
||||
fb 86 d4 39 3a 34 bc f0 b7 88 50 1d 19 33 03 f1
|
||||
3a 22 84 b0 01 f0 f6 49 ea f7 93 28 d4 ac 5c 43
|
||||
0a b4 41 49 20 a9 46 0e d1 b7 bc 40 ec 65 3e 87
|
||||
6d 09 ab c5 09 ae 45 b5 25 19 01 16 a0 c2 61 01
|
||||
84 82 98 50 9c 1c 3b f3 a4 83 e7 27 40 54 e1 5e
|
||||
97 07 50 36 e9 89 f6 09 32 80 7b 52 57 75 1e 79'''
|
||||
},
|
||||
# Plaintext
|
||||
'''8b ba 6b f8 2a 6c 0f 86 d5 f1 75 6e 97 95 68 70
|
||||
b0 89 53 b0 6b 4e b2 05 bc 16 94 ee''',
|
||||
# Ciphertext
|
||||
'''53 ea 5d c0 8c d2 60 fb 3b 85 85 67 28 7f a9 15
|
||||
52 c3 0b 2f eb fb a2 13 f0 ae 87 70 2d 06 8d 19
|
||||
ba b0 7f e5 74 52 3d fb 42 13 9d 68 c3 c5 af ee
|
||||
e0 bf e4 cb 79 69 cb f3 82 b8 04 d6 e6 13 96 14
|
||||
4e 2d 0e 60 74 1f 89 93 c3 01 4b 58 b9 b1 95 7a
|
||||
8b ab cd 23 af 85 4f 4c 35 6f b1 66 2a a7 2b fc
|
||||
c7 e5 86 55 9d c4 28 0d 16 0c 12 67 85 a7 23 eb
|
||||
ee be ff 71 f1 15 94 44 0a ae f8 7d 10 79 3a 87
|
||||
74 a2 39 d4 a0 4c 87 fe 14 67 b9 da f8 52 08 ec
|
||||
6c 72 55 79 4a 96 cc 29 14 2f 9a 8b d4 18 e3 c1
|
||||
fd 67 34 4b 0c d0 82 9d f3 b2 be c6 02 53 19 62
|
||||
93 c6 b3 4d 3f 75 d3 2f 21 3d d4 5c 62 73 d5 05
|
||||
ad f4 cc ed 10 57 cb 75 8f c2 6a ee fa 44 12 55
|
||||
ed 4e 64 c1 99 ee 07 5e 7f 16 64 61 82 fd b4 64
|
||||
73 9b 68 ab 5d af f0 e6 3e 95 52 01 68 24 f0 54
|
||||
bf 4d 3c 8c 90 a9 7b b6 b6 55 32 84 eb 42 9f cc''',
|
||||
# Random
|
||||
'''47 e1 ab 71 19 fe e5 6c 95 ee 5e aa d8 6f 40 d0
|
||||
aa 63 bd 33''',
|
||||
SHA1
|
||||
),
|
||||
)
|
||||
|
||||
def testEncrypt1(self):
|
||||
# Verify encryption using all test vectors
|
||||
for test in self._testData:
|
||||
# Build the key
|
||||
comps = [ int(rws(test[0][x]),16) for x in ('n','e') ]
|
||||
key = RSA.construct(comps)
|
||||
# RNG that takes its random numbers from a pool given
|
||||
# at initialization
|
||||
class randGen:
|
||||
def __init__(self, data):
|
||||
self.data = data
|
||||
self.idx = 0
|
||||
def __call__(self, N):
|
||||
r = self.data[self.idx:N]
|
||||
self.idx += N
|
||||
return r
|
||||
# The real test
|
||||
cipher = PKCS.new(key, test[4], randfunc=randGen(t2b(test[3])))
|
||||
ct = cipher.encrypt(t2b(test[1]))
|
||||
self.assertEqual(ct, t2b(test[2]))
|
||||
|
||||
def testEncrypt2(self):
|
||||
# Verify that encryption fails if plaintext is too long
|
||||
pt = '\x00'*(128-2*20-2+1)
|
||||
cipher = PKCS.new(self.key1024)
|
||||
self.assertRaises(ValueError, cipher.encrypt, pt)
|
||||
|
||||
def testDecrypt1(self):
|
||||
# Verify decryption using all test vectors
|
||||
for test in self._testData:
|
||||
# Build the key
|
||||
comps = [ int(rws(test[0][x]),16) for x in ('n','e','d') ]
|
||||
key = RSA.construct(comps)
|
||||
# The real test
|
||||
cipher = PKCS.new(key, test[4])
|
||||
pt = cipher.decrypt(t2b(test[2]))
|
||||
self.assertEqual(pt, t2b(test[1]))
|
||||
|
||||
def testDecrypt2(self):
|
||||
# Simplest possible negative tests
|
||||
for ct_size in (127,128,129):
|
||||
cipher = PKCS.new(self.key1024)
|
||||
self.assertRaises(ValueError, cipher.decrypt, bchr(0x00)*ct_size)
|
||||
|
||||
def testEncryptDecrypt1(self):
|
||||
# Encrypt/Decrypt messages of length [0..128-2*20-2]
|
||||
for pt_len in range(0,128-2*20-2):
|
||||
pt = self.rng(pt_len)
|
||||
cipher = PKCS.new(self.key1024)
|
||||
ct = cipher.encrypt(pt)
|
||||
pt2 = cipher.decrypt(ct)
|
||||
self.assertEqual(pt,pt2)
|
||||
|
||||
def testEncryptDecrypt2(self):
|
||||
# Helper function to monitor what's requested from RNG
|
||||
global asked
|
||||
def localRng(N):
|
||||
global asked
|
||||
asked += N
|
||||
return self.rng(N)
|
||||
# Verify that OAEP is friendly to all hashes
|
||||
for hashmod in (MD2,MD5,SHA1,SHA256,RIPEMD160):
|
||||
# Verify that encrypt() asks for as many random bytes
|
||||
# as the hash output size
|
||||
asked = 0
|
||||
pt = self.rng(40)
|
||||
cipher = PKCS.new(self.key1024, hashmod, randfunc=localRng)
|
||||
ct = cipher.encrypt(pt)
|
||||
self.assertEqual(cipher.decrypt(ct), pt)
|
||||
self.assertEqual(asked, hashmod.digest_size)
|
||||
|
||||
def testEncryptDecrypt3(self):
|
||||
# Verify that OAEP supports labels
|
||||
pt = self.rng(35)
|
||||
xlabel = self.rng(22)
|
||||
cipher = PKCS.new(self.key1024, label=xlabel)
|
||||
ct = cipher.encrypt(pt)
|
||||
self.assertEqual(cipher.decrypt(ct), pt)
|
||||
|
||||
def testEncryptDecrypt4(self):
|
||||
# Verify that encrypt() uses the custom MGF
|
||||
global mgfcalls
|
||||
# Helper function to monitor what's requested from MGF
|
||||
def newMGF(seed,maskLen):
|
||||
global mgfcalls
|
||||
mgfcalls += 1
|
||||
return bchr(0x00)*maskLen
|
||||
mgfcalls = 0
|
||||
pt = self.rng(32)
|
||||
cipher = PKCS.new(self.key1024, mgfunc=newMGF)
|
||||
ct = cipher.encrypt(pt)
|
||||
self.assertEqual(mgfcalls, 2)
|
||||
self.assertEqual(cipher.decrypt(ct), pt)
|
||||
|
||||
def get_tests(config={}):
|
||||
tests = []
|
||||
tests += list_test_cases(PKCS1_OAEP_Tests)
|
||||
return tests
|
||||
|
||||
if __name__ == '__main__':
|
||||
suite = lambda: unittest.TestSuite(get_tests())
|
||||
unittest.main(defaultTest='suite')
|
||||
|
||||
# vim:set ts=4 sw=4 sts=4 expandtab:
|
|
@ -0,0 +1,95 @@
|
|||
# CAVS 11.1
|
||||
# Config info for aes_values
|
||||
# AESVS GFSbox test data for CBC
|
||||
# State : Encrypt and Decrypt
|
||||
# Key Length : 128
|
||||
# Generated on Fri Apr 22 15:11:33 2011
|
||||
|
||||
[ENCRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = f34481ec3cc627bacd5dc3fb08f273e6
|
||||
CIPHERTEXT = 0336763e966d92595a567cc9ce537f5e
|
||||
|
||||
COUNT = 1
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 9798c4640bad75c7c3227db910174e72
|
||||
CIPHERTEXT = a9a1631bf4996954ebc093957b234589
|
||||
|
||||
COUNT = 2
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 96ab5c2ff612d9dfaae8c31f30c42168
|
||||
CIPHERTEXT = ff4f8391a6a40ca5b25d23bedd44a597
|
||||
|
||||
COUNT = 3
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 6a118a874519e64e9963798a503f1d35
|
||||
CIPHERTEXT = dc43be40be0e53712f7e2bf5ca707209
|
||||
|
||||
COUNT = 4
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = cb9fceec81286ca3e989bd979b0cb284
|
||||
CIPHERTEXT = 92beedab1895a94faa69b632e5cc47ce
|
||||
|
||||
COUNT = 5
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = b26aeb1874e47ca8358ff22378f09144
|
||||
CIPHERTEXT = 459264f4798f6a78bacb89c15ed3d601
|
||||
|
||||
COUNT = 6
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 58c8e00b2631686d54eab84b91f0aca1
|
||||
CIPHERTEXT = 08a4e2efec8a8e3312ca7460b9040bbf
|
||||
|
||||
[DECRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 0336763e966d92595a567cc9ce537f5e
|
||||
PLAINTEXT = f34481ec3cc627bacd5dc3fb08f273e6
|
||||
|
||||
COUNT = 1
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = a9a1631bf4996954ebc093957b234589
|
||||
PLAINTEXT = 9798c4640bad75c7c3227db910174e72
|
||||
|
||||
COUNT = 2
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = ff4f8391a6a40ca5b25d23bedd44a597
|
||||
PLAINTEXT = 96ab5c2ff612d9dfaae8c31f30c42168
|
||||
|
||||
COUNT = 3
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = dc43be40be0e53712f7e2bf5ca707209
|
||||
PLAINTEXT = 6a118a874519e64e9963798a503f1d35
|
||||
|
||||
COUNT = 4
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 92beedab1895a94faa69b632e5cc47ce
|
||||
PLAINTEXT = cb9fceec81286ca3e989bd979b0cb284
|
||||
|
||||
COUNT = 5
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 459264f4798f6a78bacb89c15ed3d601
|
||||
PLAINTEXT = b26aeb1874e47ca8358ff22378f09144
|
||||
|
||||
COUNT = 6
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 08a4e2efec8a8e3312ca7460b9040bbf
|
||||
PLAINTEXT = 58c8e00b2631686d54eab84b91f0aca1
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
# CAVS 11.1
|
||||
# Config info for aes_values
|
||||
# AESVS GFSbox test data for CBC
|
||||
# State : Encrypt and Decrypt
|
||||
# Key Length : 192
|
||||
# Generated on Fri Apr 22 15:11:35 2011
|
||||
|
||||
[ENCRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 1b077a6af4b7f98229de786d7516b639
|
||||
CIPHERTEXT = 275cfc0413d8ccb70513c3859b1d0f72
|
||||
|
||||
COUNT = 1
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 9c2d8842e5f48f57648205d39a239af1
|
||||
CIPHERTEXT = c9b8135ff1b5adc413dfd053b21bd96d
|
||||
|
||||
COUNT = 2
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = bff52510095f518ecca60af4205444bb
|
||||
CIPHERTEXT = 4a3650c3371ce2eb35e389a171427440
|
||||
|
||||
COUNT = 3
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 51719783d3185a535bd75adc65071ce1
|
||||
CIPHERTEXT = 4f354592ff7c8847d2d0870ca9481b7c
|
||||
|
||||
COUNT = 4
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 26aa49dcfe7629a8901a69a9914e6dfd
|
||||
CIPHERTEXT = d5e08bf9a182e857cf40b3a36ee248cc
|
||||
|
||||
COUNT = 5
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 941a4773058224e1ef66d10e0a6ee782
|
||||
CIPHERTEXT = 067cd9d3749207791841562507fa9626
|
||||
|
||||
[DECRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 275cfc0413d8ccb70513c3859b1d0f72
|
||||
PLAINTEXT = 1b077a6af4b7f98229de786d7516b639
|
||||
|
||||
COUNT = 1
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = c9b8135ff1b5adc413dfd053b21bd96d
|
||||
PLAINTEXT = 9c2d8842e5f48f57648205d39a239af1
|
||||
|
||||
COUNT = 2
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 4a3650c3371ce2eb35e389a171427440
|
||||
PLAINTEXT = bff52510095f518ecca60af4205444bb
|
||||
|
||||
COUNT = 3
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 4f354592ff7c8847d2d0870ca9481b7c
|
||||
PLAINTEXT = 51719783d3185a535bd75adc65071ce1
|
||||
|
||||
COUNT = 4
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = d5e08bf9a182e857cf40b3a36ee248cc
|
||||
PLAINTEXT = 26aa49dcfe7629a8901a69a9914e6dfd
|
||||
|
||||
COUNT = 5
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 067cd9d3749207791841562507fa9626
|
||||
PLAINTEXT = 941a4773058224e1ef66d10e0a6ee782
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
# CAVS 11.1
|
||||
# Config info for aes_values
|
||||
# AESVS GFSbox test data for CBC
|
||||
# State : Encrypt and Decrypt
|
||||
# Key Length : 256
|
||||
# Generated on Fri Apr 22 15:11:38 2011
|
||||
|
||||
[ENCRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 014730f80ac625fe84f026c60bfd547d
|
||||
CIPHERTEXT = 5c9d844ed46f9885085e5d6a4f94c7d7
|
||||
|
||||
COUNT = 1
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 0b24af36193ce4665f2825d7b4749c98
|
||||
CIPHERTEXT = a9ff75bd7cf6613d3731c77c3b6d0c04
|
||||
|
||||
COUNT = 2
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 761c1fe41a18acf20d241650611d90f1
|
||||
CIPHERTEXT = 623a52fcea5d443e48d9181ab32c7421
|
||||
|
||||
COUNT = 3
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 8a560769d605868ad80d819bdba03771
|
||||
CIPHERTEXT = 38f2c7ae10612415d27ca190d27da8b4
|
||||
|
||||
COUNT = 4
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 91fbef2d15a97816060bee1feaa49afe
|
||||
CIPHERTEXT = 1bc704f1bce135ceb810341b216d7abe
|
||||
|
||||
[DECRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 5c9d844ed46f9885085e5d6a4f94c7d7
|
||||
PLAINTEXT = 014730f80ac625fe84f026c60bfd547d
|
||||
|
||||
COUNT = 1
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = a9ff75bd7cf6613d3731c77c3b6d0c04
|
||||
PLAINTEXT = 0b24af36193ce4665f2825d7b4749c98
|
||||
|
||||
COUNT = 2
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 623a52fcea5d443e48d9181ab32c7421
|
||||
PLAINTEXT = 761c1fe41a18acf20d241650611d90f1
|
||||
|
||||
COUNT = 3
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 38f2c7ae10612415d27ca190d27da8b4
|
||||
PLAINTEXT = 8a560769d605868ad80d819bdba03771
|
||||
|
||||
COUNT = 4
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 1bc704f1bce135ceb810341b216d7abe
|
||||
PLAINTEXT = 91fbef2d15a97816060bee1feaa49afe
|
||||
|
|
@ -0,0 +1,263 @@
|
|||
# CAVS 11.1
|
||||
# Config info for aes_values
|
||||
# AESVS KeySbox test data for CBC
|
||||
# State : Encrypt and Decrypt
|
||||
# Key Length : 128
|
||||
# Generated on Fri Apr 22 15:11:33 2011
|
||||
|
||||
[ENCRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 10a58869d74be5a374cf867cfb473859
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 6d251e6944b051e04eaa6fb4dbf78465
|
||||
|
||||
COUNT = 1
|
||||
KEY = caea65cdbb75e9169ecd22ebe6e54675
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 6e29201190152df4ee058139def610bb
|
||||
|
||||
COUNT = 2
|
||||
KEY = a2e2fa9baf7d20822ca9f0542f764a41
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = c3b44b95d9d2f25670eee9a0de099fa3
|
||||
|
||||
COUNT = 3
|
||||
KEY = b6364ac4e1de1e285eaf144a2415f7a0
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 5d9b05578fc944b3cf1ccf0e746cd581
|
||||
|
||||
COUNT = 4
|
||||
KEY = 64cf9c7abc50b888af65f49d521944b2
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = f7efc89d5dba578104016ce5ad659c05
|
||||
|
||||
COUNT = 5
|
||||
KEY = 47d6742eefcc0465dc96355e851b64d9
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 0306194f666d183624aa230a8b264ae7
|
||||
|
||||
COUNT = 6
|
||||
KEY = 3eb39790678c56bee34bbcdeccf6cdb5
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 858075d536d79ccee571f7d7204b1f67
|
||||
|
||||
COUNT = 7
|
||||
KEY = 64110a924f0743d500ccadae72c13427
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 35870c6a57e9e92314bcb8087cde72ce
|
||||
|
||||
COUNT = 8
|
||||
KEY = 18d8126516f8a12ab1a36d9f04d68e51
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 6c68e9be5ec41e22c825b7c7affb4363
|
||||
|
||||
COUNT = 9
|
||||
KEY = f530357968578480b398a3c251cd1093
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = f5df39990fc688f1b07224cc03e86cea
|
||||
|
||||
COUNT = 10
|
||||
KEY = da84367f325d42d601b4326964802e8e
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = bba071bcb470f8f6586e5d3add18bc66
|
||||
|
||||
COUNT = 11
|
||||
KEY = e37b1c6aa2846f6fdb413f238b089f23
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 43c9f7e62f5d288bb27aa40ef8fe1ea8
|
||||
|
||||
COUNT = 12
|
||||
KEY = 6c002b682483e0cabcc731c253be5674
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 3580d19cff44f1014a7c966a69059de5
|
||||
|
||||
COUNT = 13
|
||||
KEY = 143ae8ed6555aba96110ab58893a8ae1
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 806da864dd29d48deafbe764f8202aef
|
||||
|
||||
COUNT = 14
|
||||
KEY = b69418a85332240dc82492353956ae0c
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = a303d940ded8f0baff6f75414cac5243
|
||||
|
||||
COUNT = 15
|
||||
KEY = 71b5c08a1993e1362e4d0ce9b22b78d5
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = c2dabd117f8a3ecabfbb11d12194d9d0
|
||||
|
||||
COUNT = 16
|
||||
KEY = e234cdca2606b81f29408d5f6da21206
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = fff60a4740086b3b9c56195b98d91a7b
|
||||
|
||||
COUNT = 17
|
||||
KEY = 13237c49074a3da078dc1d828bb78c6f
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 8146a08e2357f0caa30ca8c94d1a0544
|
||||
|
||||
COUNT = 18
|
||||
KEY = 3071a2a48fe6cbd04f1a129098e308f8
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 4b98e06d356deb07ebb824e5713f7be3
|
||||
|
||||
COUNT = 19
|
||||
KEY = 90f42ec0f68385f2ffc5dfc03a654dce
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 7a20a53d460fc9ce0423a7a0764c6cf2
|
||||
|
||||
COUNT = 20
|
||||
KEY = febd9a24d8b65c1c787d50a4ed3619a9
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = f4a70d8af877f9b02b4c40df57d45b17
|
||||
|
||||
[DECRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 10a58869d74be5a374cf867cfb473859
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 6d251e6944b051e04eaa6fb4dbf78465
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 1
|
||||
KEY = caea65cdbb75e9169ecd22ebe6e54675
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 6e29201190152df4ee058139def610bb
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 2
|
||||
KEY = a2e2fa9baf7d20822ca9f0542f764a41
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = c3b44b95d9d2f25670eee9a0de099fa3
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 3
|
||||
KEY = b6364ac4e1de1e285eaf144a2415f7a0
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 5d9b05578fc944b3cf1ccf0e746cd581
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 4
|
||||
KEY = 64cf9c7abc50b888af65f49d521944b2
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = f7efc89d5dba578104016ce5ad659c05
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 5
|
||||
KEY = 47d6742eefcc0465dc96355e851b64d9
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 0306194f666d183624aa230a8b264ae7
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 6
|
||||
KEY = 3eb39790678c56bee34bbcdeccf6cdb5
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 858075d536d79ccee571f7d7204b1f67
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 7
|
||||
KEY = 64110a924f0743d500ccadae72c13427
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 35870c6a57e9e92314bcb8087cde72ce
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 8
|
||||
KEY = 18d8126516f8a12ab1a36d9f04d68e51
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 6c68e9be5ec41e22c825b7c7affb4363
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 9
|
||||
KEY = f530357968578480b398a3c251cd1093
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = f5df39990fc688f1b07224cc03e86cea
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 10
|
||||
KEY = da84367f325d42d601b4326964802e8e
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = bba071bcb470f8f6586e5d3add18bc66
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 11
|
||||
KEY = e37b1c6aa2846f6fdb413f238b089f23
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 43c9f7e62f5d288bb27aa40ef8fe1ea8
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 12
|
||||
KEY = 6c002b682483e0cabcc731c253be5674
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 3580d19cff44f1014a7c966a69059de5
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 13
|
||||
KEY = 143ae8ed6555aba96110ab58893a8ae1
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 806da864dd29d48deafbe764f8202aef
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 14
|
||||
KEY = b69418a85332240dc82492353956ae0c
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = a303d940ded8f0baff6f75414cac5243
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 15
|
||||
KEY = 71b5c08a1993e1362e4d0ce9b22b78d5
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = c2dabd117f8a3ecabfbb11d12194d9d0
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 16
|
||||
KEY = e234cdca2606b81f29408d5f6da21206
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = fff60a4740086b3b9c56195b98d91a7b
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 17
|
||||
KEY = 13237c49074a3da078dc1d828bb78c6f
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 8146a08e2357f0caa30ca8c94d1a0544
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 18
|
||||
KEY = 3071a2a48fe6cbd04f1a129098e308f8
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 4b98e06d356deb07ebb824e5713f7be3
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 19
|
||||
KEY = 90f42ec0f68385f2ffc5dfc03a654dce
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 7a20a53d460fc9ce0423a7a0764c6cf2
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 20
|
||||
KEY = febd9a24d8b65c1c787d50a4ed3619a9
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = f4a70d8af877f9b02b4c40df57d45b17
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
|
@ -0,0 +1,299 @@
|
|||
# CAVS 11.1
|
||||
# Config info for aes_values
|
||||
# AESVS KeySbox test data for CBC
|
||||
# State : Encrypt and Decrypt
|
||||
# Key Length : 192
|
||||
# Generated on Fri Apr 22 15:11:35 2011
|
||||
|
||||
[ENCRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = e9f065d7c13573587f7875357dfbb16c53489f6a4bd0f7cd
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 0956259c9cd5cfd0181cca53380cde06
|
||||
|
||||
COUNT = 1
|
||||
KEY = 15d20f6ebc7e649fd95b76b107e6daba967c8a9484797f29
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 8e4e18424e591a3d5b6f0876f16f8594
|
||||
|
||||
COUNT = 2
|
||||
KEY = a8a282ee31c03fae4f8e9b8930d5473c2ed695a347e88b7c
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 93f3270cfc877ef17e106ce938979cb0
|
||||
|
||||
COUNT = 3
|
||||
KEY = cd62376d5ebb414917f0c78f05266433dc9192a1ec943300
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 7f6c25ff41858561bb62f36492e93c29
|
||||
|
||||
COUNT = 4
|
||||
KEY = 502a6ab36984af268bf423c7f509205207fc1552af4a91e5
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 8e06556dcbb00b809a025047cff2a940
|
||||
|
||||
COUNT = 5
|
||||
KEY = 25a39dbfd8034f71a81f9ceb55026e4037f8f6aa30ab44ce
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 3608c344868e94555d23a120f8a5502d
|
||||
|
||||
COUNT = 6
|
||||
KEY = e08c15411774ec4a908b64eadc6ac4199c7cd453f3aaef53
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 77da2021935b840b7f5dcc39132da9e5
|
||||
|
||||
COUNT = 7
|
||||
KEY = 3b375a1ff7e8d44409696e6326ec9dec86138e2ae010b980
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 3b7c24f825e3bf9873c9f14d39a0e6f4
|
||||
|
||||
COUNT = 8
|
||||
KEY = 950bb9f22cc35be6fe79f52c320af93dec5bc9c0c2f9cd53
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 64ebf95686b353508c90ecd8b6134316
|
||||
|
||||
COUNT = 9
|
||||
KEY = 7001c487cc3e572cfc92f4d0e697d982e8856fdcc957da40
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = ff558c5d27210b7929b73fc708eb4cf1
|
||||
|
||||
COUNT = 10
|
||||
KEY = f029ce61d4e5a405b41ead0a883cc6a737da2cf50a6c92ae
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = a2c3b2a818075490a7b4c14380f02702
|
||||
|
||||
COUNT = 11
|
||||
KEY = 61257134a518a0d57d9d244d45f6498cbc32f2bafc522d79
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = cfe4d74002696ccf7d87b14a2f9cafc9
|
||||
|
||||
COUNT = 12
|
||||
KEY = b0ab0a6a818baef2d11fa33eac947284fb7d748cfb75e570
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = d2eafd86f63b109b91f5dbb3a3fb7e13
|
||||
|
||||
COUNT = 13
|
||||
KEY = ee053aa011c8b428cdcc3636313c54d6a03cac01c71579d6
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 9b9fdd1c5975655f539998b306a324af
|
||||
|
||||
COUNT = 14
|
||||
KEY = d2926527e0aa9f37b45e2ec2ade5853ef807576104c7ace3
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = dd619e1cf204446112e0af2b9afa8f8c
|
||||
|
||||
COUNT = 15
|
||||
KEY = 982215f4e173dfa0fcffe5d3da41c4812c7bcc8ed3540f93
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = d4f0aae13c8fe9339fbf9e69ed0ad74d
|
||||
|
||||
COUNT = 16
|
||||
KEY = 98c6b8e01e379fbd14e61af6af891596583565f2a27d59e9
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 19c80ec4a6deb7e5ed1033dda933498f
|
||||
|
||||
COUNT = 17
|
||||
KEY = b3ad5cea1dddc214ca969ac35f37dae1a9a9d1528f89bb35
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 3cf5e1d21a17956d1dffad6a7c41c659
|
||||
|
||||
COUNT = 18
|
||||
KEY = 45899367c3132849763073c435a9288a766c8b9ec2308516
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 69fd12e8505f8ded2fdcb197a121b362
|
||||
|
||||
COUNT = 19
|
||||
KEY = ec250e04c3903f602647b85a401a1ae7ca2f02f67fa4253e
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 8aa584e2cc4d17417a97cb9a28ba29c8
|
||||
|
||||
COUNT = 20
|
||||
KEY = d077a03bd8a38973928ccafe4a9d2f455130bd0af5ae46a9
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = abc786fb1edb504580c4d882ef29a0c7
|
||||
|
||||
COUNT = 21
|
||||
KEY = d184c36cf0dddfec39e654195006022237871a47c33d3198
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 2e19fb60a3e1de0166f483c97824a978
|
||||
|
||||
COUNT = 22
|
||||
KEY = 4c6994ffa9dcdc805b60c2c0095334c42d95a8fc0ca5b080
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 7656709538dd5fec41e0ce6a0f8e207d
|
||||
|
||||
COUNT = 23
|
||||
KEY = c88f5b00a4ef9a6840e2acaf33f00a3bdc4e25895303fa72
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = a67cf333b314d411d3c0ae6e1cfcd8f5
|
||||
|
||||
[DECRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = e9f065d7c13573587f7875357dfbb16c53489f6a4bd0f7cd
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 0956259c9cd5cfd0181cca53380cde06
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 1
|
||||
KEY = 15d20f6ebc7e649fd95b76b107e6daba967c8a9484797f29
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 8e4e18424e591a3d5b6f0876f16f8594
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 2
|
||||
KEY = a8a282ee31c03fae4f8e9b8930d5473c2ed695a347e88b7c
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 93f3270cfc877ef17e106ce938979cb0
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 3
|
||||
KEY = cd62376d5ebb414917f0c78f05266433dc9192a1ec943300
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 7f6c25ff41858561bb62f36492e93c29
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 4
|
||||
KEY = 502a6ab36984af268bf423c7f509205207fc1552af4a91e5
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 8e06556dcbb00b809a025047cff2a940
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 5
|
||||
KEY = 25a39dbfd8034f71a81f9ceb55026e4037f8f6aa30ab44ce
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 3608c344868e94555d23a120f8a5502d
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 6
|
||||
KEY = e08c15411774ec4a908b64eadc6ac4199c7cd453f3aaef53
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 77da2021935b840b7f5dcc39132da9e5
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 7
|
||||
KEY = 3b375a1ff7e8d44409696e6326ec9dec86138e2ae010b980
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 3b7c24f825e3bf9873c9f14d39a0e6f4
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 8
|
||||
KEY = 950bb9f22cc35be6fe79f52c320af93dec5bc9c0c2f9cd53
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 64ebf95686b353508c90ecd8b6134316
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 9
|
||||
KEY = 7001c487cc3e572cfc92f4d0e697d982e8856fdcc957da40
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = ff558c5d27210b7929b73fc708eb4cf1
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 10
|
||||
KEY = f029ce61d4e5a405b41ead0a883cc6a737da2cf50a6c92ae
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = a2c3b2a818075490a7b4c14380f02702
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 11
|
||||
KEY = 61257134a518a0d57d9d244d45f6498cbc32f2bafc522d79
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = cfe4d74002696ccf7d87b14a2f9cafc9
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 12
|
||||
KEY = b0ab0a6a818baef2d11fa33eac947284fb7d748cfb75e570
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = d2eafd86f63b109b91f5dbb3a3fb7e13
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 13
|
||||
KEY = ee053aa011c8b428cdcc3636313c54d6a03cac01c71579d6
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 9b9fdd1c5975655f539998b306a324af
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 14
|
||||
KEY = d2926527e0aa9f37b45e2ec2ade5853ef807576104c7ace3
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = dd619e1cf204446112e0af2b9afa8f8c
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 15
|
||||
KEY = 982215f4e173dfa0fcffe5d3da41c4812c7bcc8ed3540f93
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = d4f0aae13c8fe9339fbf9e69ed0ad74d
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 16
|
||||
KEY = 98c6b8e01e379fbd14e61af6af891596583565f2a27d59e9
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 19c80ec4a6deb7e5ed1033dda933498f
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 17
|
||||
KEY = b3ad5cea1dddc214ca969ac35f37dae1a9a9d1528f89bb35
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 3cf5e1d21a17956d1dffad6a7c41c659
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 18
|
||||
KEY = 45899367c3132849763073c435a9288a766c8b9ec2308516
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 69fd12e8505f8ded2fdcb197a121b362
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 19
|
||||
KEY = ec250e04c3903f602647b85a401a1ae7ca2f02f67fa4253e
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 8aa584e2cc4d17417a97cb9a28ba29c8
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 20
|
||||
KEY = d077a03bd8a38973928ccafe4a9d2f455130bd0af5ae46a9
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = abc786fb1edb504580c4d882ef29a0c7
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 21
|
||||
KEY = d184c36cf0dddfec39e654195006022237871a47c33d3198
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 2e19fb60a3e1de0166f483c97824a978
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 22
|
||||
KEY = 4c6994ffa9dcdc805b60c2c0095334c42d95a8fc0ca5b080
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 7656709538dd5fec41e0ce6a0f8e207d
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 23
|
||||
KEY = c88f5b00a4ef9a6840e2acaf33f00a3bdc4e25895303fa72
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = a67cf333b314d411d3c0ae6e1cfcd8f5
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
|
@ -0,0 +1,203 @@
|
|||
# CAVS 11.1
|
||||
# Config info for aes_values
|
||||
# AESVS KeySbox test data for CBC
|
||||
# State : Encrypt and Decrypt
|
||||
# Key Length : 256
|
||||
# Generated on Fri Apr 22 15:11:38 2011
|
||||
|
||||
[ENCRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = c47b0294dbbbee0fec4757f22ffeee3587ca4730c3d33b691df38bab076bc558
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 46f2fb342d6f0ab477476fc501242c5f
|
||||
|
||||
COUNT = 1
|
||||
KEY = 28d46cffa158533194214a91e712fc2b45b518076675affd910edeca5f41ac64
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 4bf3b0a69aeb6657794f2901b1440ad4
|
||||
|
||||
COUNT = 2
|
||||
KEY = c1cc358b449909a19436cfbb3f852ef8bcb5ed12ac7058325f56e6099aab1a1c
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 352065272169abf9856843927d0674fd
|
||||
|
||||
COUNT = 3
|
||||
KEY = 984ca75f4ee8d706f46c2d98c0bf4a45f5b00d791c2dfeb191b5ed8e420fd627
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 4307456a9e67813b452e15fa8fffe398
|
||||
|
||||
COUNT = 4
|
||||
KEY = b43d08a447ac8609baadae4ff12918b9f68fc1653f1269222f123981ded7a92f
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 4663446607354989477a5c6f0f007ef4
|
||||
|
||||
COUNT = 5
|
||||
KEY = 1d85a181b54cde51f0e098095b2962fdc93b51fe9b88602b3f54130bf76a5bd9
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 531c2c38344578b84d50b3c917bbb6e1
|
||||
|
||||
COUNT = 6
|
||||
KEY = dc0eba1f2232a7879ded34ed8428eeb8769b056bbaf8ad77cb65c3541430b4cf
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = fc6aec906323480005c58e7e1ab004ad
|
||||
|
||||
COUNT = 7
|
||||
KEY = f8be9ba615c5a952cabbca24f68f8593039624d524c816acda2c9183bd917cb9
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = a3944b95ca0b52043584ef02151926a8
|
||||
|
||||
COUNT = 8
|
||||
KEY = 797f8b3d176dac5b7e34a2d539c4ef367a16f8635f6264737591c5c07bf57a3e
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = a74289fe73a4c123ca189ea1e1b49ad5
|
||||
|
||||
COUNT = 9
|
||||
KEY = 6838d40caf927749c13f0329d331f448e202c73ef52c5f73a37ca635d4c47707
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = b91d4ea4488644b56cf0812fa7fcf5fc
|
||||
|
||||
COUNT = 10
|
||||
KEY = ccd1bc3c659cd3c59bc437484e3c5c724441da8d6e90ce556cd57d0752663bbc
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 304f81ab61a80c2e743b94d5002a126b
|
||||
|
||||
COUNT = 11
|
||||
KEY = 13428b5e4c005e0636dd338405d173ab135dec2a25c22c5df0722d69dcc43887
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 649a71545378c783e368c9ade7114f6c
|
||||
|
||||
COUNT = 12
|
||||
KEY = 07eb03a08d291d1b07408bf3512ab40c91097ac77461aad4bb859647f74f00ee
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 47cb030da2ab051dfc6c4bf6910d12bb
|
||||
|
||||
COUNT = 13
|
||||
KEY = 90143ae20cd78c5d8ebdd6cb9dc1762427a96c78c639bccc41a61424564eafe1
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 798c7c005dee432b2c8ea5dfa381ecc3
|
||||
|
||||
COUNT = 14
|
||||
KEY = b7a5794d52737475d53d5a377200849be0260a67a2b22ced8bbef12882270d07
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 637c31dc2591a07636f646b72daabbe7
|
||||
|
||||
COUNT = 15
|
||||
KEY = fca02f3d5011cfc5c1e23165d413a049d4526a991827424d896fe3435e0bf68e
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 179a49c712154bbffbe6e7a84a18e220
|
||||
|
||||
[DECRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = c47b0294dbbbee0fec4757f22ffeee3587ca4730c3d33b691df38bab076bc558
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 46f2fb342d6f0ab477476fc501242c5f
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 1
|
||||
KEY = 28d46cffa158533194214a91e712fc2b45b518076675affd910edeca5f41ac64
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 4bf3b0a69aeb6657794f2901b1440ad4
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 2
|
||||
KEY = c1cc358b449909a19436cfbb3f852ef8bcb5ed12ac7058325f56e6099aab1a1c
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 352065272169abf9856843927d0674fd
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 3
|
||||
KEY = 984ca75f4ee8d706f46c2d98c0bf4a45f5b00d791c2dfeb191b5ed8e420fd627
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 4307456a9e67813b452e15fa8fffe398
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 4
|
||||
KEY = b43d08a447ac8609baadae4ff12918b9f68fc1653f1269222f123981ded7a92f
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 4663446607354989477a5c6f0f007ef4
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 5
|
||||
KEY = 1d85a181b54cde51f0e098095b2962fdc93b51fe9b88602b3f54130bf76a5bd9
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 531c2c38344578b84d50b3c917bbb6e1
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 6
|
||||
KEY = dc0eba1f2232a7879ded34ed8428eeb8769b056bbaf8ad77cb65c3541430b4cf
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = fc6aec906323480005c58e7e1ab004ad
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 7
|
||||
KEY = f8be9ba615c5a952cabbca24f68f8593039624d524c816acda2c9183bd917cb9
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = a3944b95ca0b52043584ef02151926a8
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 8
|
||||
KEY = 797f8b3d176dac5b7e34a2d539c4ef367a16f8635f6264737591c5c07bf57a3e
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = a74289fe73a4c123ca189ea1e1b49ad5
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 9
|
||||
KEY = 6838d40caf927749c13f0329d331f448e202c73ef52c5f73a37ca635d4c47707
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = b91d4ea4488644b56cf0812fa7fcf5fc
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 10
|
||||
KEY = ccd1bc3c659cd3c59bc437484e3c5c724441da8d6e90ce556cd57d0752663bbc
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 304f81ab61a80c2e743b94d5002a126b
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 11
|
||||
KEY = 13428b5e4c005e0636dd338405d173ab135dec2a25c22c5df0722d69dcc43887
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 649a71545378c783e368c9ade7114f6c
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 12
|
||||
KEY = 07eb03a08d291d1b07408bf3512ab40c91097ac77461aad4bb859647f74f00ee
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 47cb030da2ab051dfc6c4bf6910d12bb
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 13
|
||||
KEY = 90143ae20cd78c5d8ebdd6cb9dc1762427a96c78c639bccc41a61424564eafe1
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 798c7c005dee432b2c8ea5dfa381ecc3
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 14
|
||||
KEY = b7a5794d52737475d53d5a377200849be0260a67a2b22ced8bbef12882270d07
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 637c31dc2591a07636f646b72daabbe7
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 15
|
||||
KEY = fca02f3d5011cfc5c1e23165d413a049d4526a991827424d896fe3435e0bf68e
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 179a49c712154bbffbe6e7a84a18e220
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,131 @@
|
|||
# CAVS 11.1
|
||||
# Config info for aes_values
|
||||
# AESVS MMT test data for CBC
|
||||
# State : Encrypt and Decrypt
|
||||
# Key Length : 128
|
||||
# Generated on Fri Apr 22 15:11:33 2011
|
||||
|
||||
[ENCRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 1f8e4973953f3fb0bd6b16662e9a3c17
|
||||
IV = 2fe2b333ceda8f98f4a99b40d2cd34a8
|
||||
PLAINTEXT = 45cf12964fc824ab76616ae2f4bf0822
|
||||
CIPHERTEXT = 0f61c4d44c5147c03c195ad7e2cc12b2
|
||||
|
||||
COUNT = 1
|
||||
KEY = 0700d603a1c514e46b6191ba430a3a0c
|
||||
IV = aad1583cd91365e3bb2f0c3430d065bb
|
||||
PLAINTEXT = 068b25c7bfb1f8bdd4cfc908f69dffc5ddc726a197f0e5f720f730393279be91
|
||||
CIPHERTEXT = c4dc61d9725967a3020104a9738f23868527ce839aab1752fd8bdb95a82c4d00
|
||||
|
||||
COUNT = 2
|
||||
KEY = 3348aa51e9a45c2dbe33ccc47f96e8de
|
||||
IV = 19153c673160df2b1d38c28060e59b96
|
||||
PLAINTEXT = 9b7cee827a26575afdbb7c7a329f887238052e3601a7917456ba61251c214763d5e1847a6ad5d54127a399ab07ee3599
|
||||
CIPHERTEXT = d5aed6c9622ec451a15db12819952b6752501cf05cdbf8cda34a457726ded97818e1f127a28d72db5652749f0c6afee5
|
||||
|
||||
COUNT = 3
|
||||
KEY = b7f3c9576e12dd0db63e8f8fac2b9a39
|
||||
IV = c80f095d8bb1a060699f7c19974a1aa0
|
||||
PLAINTEXT = 9ac19954ce1319b354d3220460f71c1e373f1cd336240881160cfde46ebfed2e791e8d5a1a136ebd1dc469dec00c4187722b841cdabcb22c1be8a14657da200e
|
||||
CIPHERTEXT = 19b9609772c63f338608bf6eb52ca10be65097f89c1e0905c42401fd47791ae2c5440b2d473116ca78bd9ff2fb6015cfd316524eae7dcb95ae738ebeae84a467
|
||||
|
||||
COUNT = 4
|
||||
KEY = b6f9afbfe5a1562bba1368fc72ac9d9c
|
||||
IV = 3f9d5ebe250ee7ce384b0d00ee849322
|
||||
PLAINTEXT = db397ec22718dbffb9c9d13de0efcd4611bf792be4fce0dc5f25d4f577ed8cdbd4eb9208d593dda3d4653954ab64f05676caa3ce9bfa795b08b67ceebc923fdc89a8c431188e9e482d8553982cf304d1
|
||||
CIPHERTEXT = 10ea27b19e16b93af169c4a88e06e35c99d8b420980b058e34b4b8f132b13766f72728202b089f428fecdb41c79f8aa0d0ef68f5786481cca29e2126f69bc14160f1ae2187878ba5c49cf3961e1b7ee9
|
||||
|
||||
COUNT = 5
|
||||
KEY = bbe7b7ba07124ff1ae7c3416fe8b465e
|
||||
IV = 7f65b5ee3630bed6b84202d97fb97a1e
|
||||
PLAINTEXT = 2aad0c2c4306568bad7447460fd3dac054346d26feddbc9abd9110914011b4794be2a9a00a519a51a5b5124014f4ed2735480db21b434e99a911bb0b60fe0253763725b628d5739a5117b7ee3aefafc5b4c1bf446467e7bf5f78f31ff7caf187
|
||||
CIPHERTEXT = 3b8611bfc4973c5cd8e982b073b33184cd26110159172e44988eb5ff5661a1e16fad67258fcbfee55469267a12dc374893b4e3533d36f5634c3095583596f135aa8cd1138dc898bc5651ee35a92ebf89ab6aeb5366653bc60a70e0074fc11efe
|
||||
|
||||
COUNT = 6
|
||||
KEY = 89a553730433f7e6d67d16d373bd5360
|
||||
IV = f724558db3433a523f4e51a5bea70497
|
||||
PLAINTEXT = 807bc4ea684eedcfdcca30180680b0f1ae2814f35f36d053c5aea6595a386c1442770f4d7297d8b91825ee7237241da8925dd594ccf676aecd46ca2068e8d37a3a0ec8a7d5185a201e663b5ff36ae197110188a23503763b8218826d23ced74b31e9f6e2d7fbfa6cb43420c7807a8625
|
||||
CIPHERTEXT = 406af1429a478c3d07e555c5287a60500d37fc39b68e5bbb9bafd6ddb223828561d6171a308d5b1a4551e8a5e7d572918d25c968d3871848d2f16635caa9847f38590b1df58ab5efb985f2c66cfaf86f61b3f9c0afad6c963c49cee9b8bc81a2ddb06c967f325515a4849eec37ce721a
|
||||
|
||||
COUNT = 7
|
||||
KEY = c491ca31f91708458e29a925ec558d78
|
||||
IV = 9ef934946e5cd0ae97bd58532cb49381
|
||||
PLAINTEXT = cb6a787e0dec56f9a165957f81af336ca6b40785d9e94093c6190e5152649f882e874d79ac5e167bd2a74ce5ae088d2ee854f6539e0a94796b1e1bd4c9fcdbc79acbef4d01eeb89776d18af71ae2a4fc47dd66df6c4dbe1d1850e466549a47b636bcc7c2b3a62495b56bb67b6d455f1eebd9bfefecbca6c7f335cfce9b45cb9d
|
||||
CIPHERTEXT = 7b2931f5855f717145e00f152a9f4794359b1ffcb3e55f594e33098b51c23a6c74a06c1d94fded7fd2ae42c7db7acaef5844cb33aeddc6852585ed0020a6699d2cb53809cefd169148ce42292afab063443978306c582c18b9ce0da3d084ce4d3c482cfd8fcf1a85084e89fb88b40a084d5e972466d07666126fb761f84078f2
|
||||
|
||||
COUNT = 8
|
||||
KEY = f6e87d71b0104d6eb06a68dc6a71f498
|
||||
IV = 1c245f26195b76ebebc2edcac412a2f8
|
||||
PLAINTEXT = f82bef3c73a6f7f80db285726d691db6bf55eec25a859d3ba0e0445f26b9bb3b16a3161ed1866e4dd8f2e5f8ecb4e46d74a7a78c20cdfc7bcc9e479ba7a0caba9438238ad0c01651d5d98de37f03ddce6e6b4bd4ab03cf9e8ed818aedfa1cf963b932067b97d776dce1087196e7e913f7448e38244509f0caf36bd8217e15336d35c149fd4e41707893fdb84014f8729
|
||||
CIPHERTEXT = b09512f3eff9ed0d85890983a73dadbb7c3678d52581be64a8a8fc586f490f2521297a478a0598040ebd0f5509fafb0969f9d9e600eaef33b1b93eed99687b167f89a5065aac439ce46f3b8d22d30865e64e45ef8cd30b6984353a844a11c8cd60dba0e8866b3ee30d24b3fa8a643b328353e06010fa8273c8fd54ef0a2b6930e5520aae5cd5902f9b86a33592ca4365
|
||||
|
||||
COUNT = 9
|
||||
KEY = 2c14413751c31e2730570ba3361c786b
|
||||
IV = 1dbbeb2f19abb448af849796244a19d7
|
||||
PLAINTEXT = 40d930f9a05334d9816fe204999c3f82a03f6a0457a8c475c94553d1d116693adc618049f0a769a2eed6a6cb14c0143ec5cccdbc8dec4ce560cfd206225709326d4de7948e54d603d01b12d7fed752fb23f1aa4494fbb00130e9ded4e77e37c079042d828040c325b1a5efd15fc842e44014ca4374bf38f3c3fc3ee327733b0c8aee1abcd055772f18dc04603f7b2c1ea69ff662361f2be0a171bbdcea1e5d3f
|
||||
CIPHERTEXT = 6be8a12800455a320538853e0cba31bd2d80ea0c85164a4c5c261ae485417d93effe2ebc0d0a0b51d6ea18633d210cf63c0c4ddbc27607f2e81ed9113191ef86d56f3b99be6c415a4150299fb846ce7160b40b63baf1179d19275a2e83698376d28b92548c68e06e6d994e2c1501ed297014e702cdefee2f656447706009614d801de1caaf73f8b7fa56cf1ba94b631933bbe577624380850f117435a0355b2b
|
||||
|
||||
[DECRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 6a7082cf8cda13eff48c8158dda206ae
|
||||
IV = bd4172934078c2011cb1f31cffaf486e
|
||||
CIPHERTEXT = f8eb31b31e374e960030cd1cadb0ef0c
|
||||
PLAINTEXT = 940bc76d61e2c49dddd5df7f37fcf105
|
||||
|
||||
COUNT = 1
|
||||
KEY = 625eefa18a4756454e218d8bfed56e36
|
||||
IV = 73d9d0e27c2ec568fbc11f6a0998d7c8
|
||||
CIPHERTEXT = 5d6fed86f0c4fe59a078d6361a142812514b295dc62ff5d608a42ea37614e6a1
|
||||
PLAINTEXT = 360dc1896ce601dfb2a949250067aad96737847a4580ede2654a329b842fe81e
|
||||
|
||||
COUNT = 2
|
||||
KEY = fd6e0b954ae2e3b723d6c9fcae6ab09b
|
||||
IV = f08b65c9f4dd950039941da2e8058c4e
|
||||
CIPHERTEXT = e29e3114c8000eb484395b256b1b3267894f290d3999819ff35da03e6463c186c4d7ebb964941f1986a2d69572fcaba8
|
||||
PLAINTEXT = a206385945b21f812a9475f47fddbb7fbdda958a8d14c0dbcdaec36e8b28f1f6ececa1ceae4ce17721d162c1d42a66c1
|
||||
|
||||
COUNT = 3
|
||||
KEY = 7b1ab9144b0239315cd5eec6c75663bd
|
||||
IV = 0b1e74f45c17ff304d99c059ce5cde09
|
||||
CIPHERTEXT = d3f89b71e033070f9d7516a6cb4ea5ef51d6fb63d4f0fea089d0a60e47bbb3c2e10e9ba3b282c7cb79aefe3068ce228377c21a58fe5a0f8883d0dbd3d096beca
|
||||
PLAINTEXT = b968aeb199ad6b3c8e01f26c2edad444538c78bfa36ed68ca76123b8cdce615a01f6112bb80bfc3f17490578fb1f909a52e162637b062db04efee291a1f1af60
|
||||
|
||||
COUNT = 4
|
||||
KEY = 36466b6bd25ea3857ea42f0cac1919b1
|
||||
IV = 7186fb6bdfa98a16189544b228f3bcd3
|
||||
CIPHERTEXT = 9ed957bd9bc52bba76f68cfbcde52157a8ca4f71ac050a3d92bdebbfd7c78316b4c9f0ba509fad0235fdafe90056ad115dfdbf08338b2acb1c807a88182dd2a882d1810d4302d598454e34ef2b23687d
|
||||
PLAINTEXT = 999983467c47bb1d66d7327ab5c58f61ddb09b93bd2460cb78cbc12b5fa1ea0c5f759ccc5e478697687012ff4673f6e61eecaeda0ccad2d674d3098c7d17f887b62b56f56b03b4d055bf3a4460e83efa
|
||||
|
||||
COUNT = 5
|
||||
KEY = 89373ee6e28397640d5082eed4123239
|
||||
IV = 1a74d7c859672c804b82472f7e6d3c6b
|
||||
CIPHERTEXT = 1bcba44ddff503db7c8c2ec4c4eea0e827957740cce125c1e11769842fa97e25f1b89269e6d77923a512a358312f4ba1cd33f2d111280cd83e1ef9e7cf7036d55048d5c273652afa611cc81b4e9dac7b5078b7c4716062e1032ead1e3329588a
|
||||
PLAINTEXT = 45efd00daa4cdc8273ef785cae9e944a7664a2391e1e2c449f475acec0124bbc22944331678617408a1702917971f4654310ffb9229bec6173715ae512d37f93aaa6abf009f7e30d65669d1db0366b5bce4c7b00f871014f5753744a1878dc57
|
||||
|
||||
COUNT = 6
|
||||
KEY = bab0cceddc0abd63e3f82e9fbff7b8aa
|
||||
IV = 68b9140f300490c5c942f66e777eb806
|
||||
CIPHERTEXT = c65b94b1f291fa9f0600f22c3c0432c895ad5d177bcccc9ea44e8ec339c9adf43855b326179d6d81aa36ef59462fd86127e9d81b0f286f93306bf74d4c79e47c1b3d4b74edd3a16290e3c63b742e41f20d66ceee794316bb63d3bd002712a1b136ba6185bd5c1dab81b07db90d2af5e5
|
||||
PLAINTEXT = c5585ff215bbb73ba5393440852fb199436de0d15e55c631f877670aa3eda9f672eb1f876f09544e63558436b8928000db2f02a5ad90f95b05ac4cf49e198e617e7678480fdf0efacc6aae691271e6cdd3541ebf719a1ccaedb24e2f80f92455dd5910cb5086b0960a3942ec182dcbd7
|
||||
|
||||
COUNT = 7
|
||||
KEY = 9c702898efa44557b29ed283f5bc0293
|
||||
IV = cec6e1b82e8b2a591a9fa5ff1cf5cc51
|
||||
CIPHERTEXT = ba9f646755dacc22911f51d7de2f7e7cb0bc0b75257ea44fe883edb055c7c28ede04c3a0adcb10128ad4517d0093fa16bb0bcd2635e7a0ba92c7609bc8d8568002a7a983473724d256513aa7d51b477aabec1975ab5faf2872a6407e922180eff02f1ef86a4591c8bd3d143da6f0ef0e4806f94ace0d5b0151c99640fccbc843
|
||||
PLAINTEXT = 1d1f8d81bdc3e2c7cb057f408e6450000c5aaed3260ff1e87fbb6f324df6887ffd8f78d7e2a04c9ed9deda9d64482d2b002f4a2b78d8b4f691875c8295d4a64b22257ceaf713ed2f4b92530d7ad7151d629acda882b4829577a43990b0948c1149c22fe4273656d1b08833930e8b06709a94579a78fc220f7057bbc1fa9f6563
|
||||
|
||||
COUNT = 8
|
||||
KEY = 5674636dbdb38f705f0b08c372ef4785
|
||||
IV = 3f20ce0509b57420d53b6be4d0b7f0a9
|
||||
CIPHERTEXT = 198351f453103face6655666fe90bdbd9630e3733b2d66c013a634e91f2bf015bd2d975d71b26322e44defa32d4e9dce50363557046ece08ba38f258dae5fd3e5049c647476c81e73482e40c171d89f9fea29452caf995733589b0061464fbd5dabe27dc5ea463a3deeb7dcb43664ae6a65c498c143883ab8e83b51e5410b181647602443dc3cfffe86f0205398fa83c
|
||||
PLAINTEXT = 6d40fd2f908f48ce19241b6b278b1b1676dffd4a97ce9f8a1574c33bc59237deb536bee376fd6c381e6987700e39283aa111cf1a59f26fae6fb6700bf012646a2ab80239bf5e1632329043aa87d7911978b36523a2bc0bed9a9737ccf7a00baa2f3822b4e9e742e168e7069290705fed2eb63aa044b78f97dd33a8d6b24741ec1fd8c8db79d93b884e762dba0f406961
|
||||
|
||||
COUNT = 9
|
||||
KEY = 97a1025529b9925e25bbe78770ca2f99
|
||||
IV = d4b4eab92aa9637e87d366384ed6915c
|
||||
CIPHERTEXT = 22cdc3306fcd4d31ccd32720cbb61bad28d855670657c48c7b88c31f4fa1f93c01b57da90be63ead67d6a325525e6ed45083e6fb70a53529d1fa0f55653b942af59d78a2660361d63a7290155ac5c43312a25b235dacbbc863faf00940c99624076dfa44068e7c554c9038176953e571751dfc0954d41d113771b06466b1c8d13e0d4cb675ed58d1a619e1540970983781dc11d2dd8525ab5745958d615defda
|
||||
PLAINTEXT = e8b89150d8438bf5b17449d6ed26bd72127e10e4aa57cad85283e8359e089208e84921649f5b60ea21f7867cbc9620560c4c6238db021216db453c9943f1f1a60546173daef2557c3cdd855031b353d4bf176f28439e48785c37d38f270aa4a6faad2baabcb0c0b2d1dd5322937498ce803ba1148440a52e227ddba4872fe4d81d2d76a939d24755adb8a7b8452ceed2d179e1a5848f316f5c016300a390bfa7
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
# CAVS 11.1
|
||||
# Config info for aes_values
|
||||
# AESVS MMT test data for CBC
|
||||
# State : Encrypt and Decrypt
|
||||
# Key Length : 192
|
||||
# Generated on Fri Apr 22 15:11:35 2011
|
||||
|
||||
[ENCRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = ba75f4d1d9d7cf7f551445d56cc1a8ab2a078e15e049dc2c
|
||||
IV = 531ce78176401666aa30db94ec4a30eb
|
||||
PLAINTEXT = c51fc276774dad94bcdc1d2891ec8668
|
||||
CIPHERTEXT = 70dd95a14ee975e239df36ff4aee1d5d
|
||||
|
||||
COUNT = 1
|
||||
KEY = eab3b19c581aa873e1981c83ab8d83bbf8025111fb2e6b21
|
||||
IV = f3d6667e8d4d791e60f7505ba383eb05
|
||||
PLAINTEXT = 9d4e4cccd1682321856df069e3f1c6fa391a083a9fb02d59db74c14081b3acc4
|
||||
CIPHERTEXT = 51d44779f90d40a80048276c035cb49ca2a47bcb9b9cf7270b9144793787d53f
|
||||
|
||||
COUNT = 2
|
||||
KEY = 16c93bb398f1fc0cf6d68fc7a5673cdf431fa147852b4a2d
|
||||
IV = eaaeca2e07ddedf562f94df63f0a650f
|
||||
PLAINTEXT = c5ce958613bf741718c17444484ebaf1050ddcacb59b9590178cbe69d7ad7919608cb03af13bbe04f3506b718a301ea0
|
||||
CIPHERTEXT = ed6a50e0c6921d52d6647f75d67b4fd56ace1fedb8b5a6a997b4d131640547d22c5d884a75e6752b5846b5b33a5181f4
|
||||
|
||||
COUNT = 3
|
||||
KEY = 067bb17b4df785697eaccf961f98e212cb75e6797ce935cb
|
||||
IV = 8b59c9209c529ca8391c9fc0ce033c38
|
||||
PLAINTEXT = db3785a889b4bd387754da222f0e4c2d2bfe0d79e05bc910fba941beea30f1239eacf0068f4619ec01c368e986fca6b7c58e490579d29611bd10087986eff54f
|
||||
CIPHERTEXT = d5f5589760bf9c762228fde236de1fa2dd2dad448db3fa9be0c4196efd46a35c84dd1ac77d9db58c95918cb317a6430a08d2fb6a8e8b0f1c9b72c7a344dc349f
|
||||
|
||||
COUNT = 4
|
||||
KEY = 0fd39de83e0be77a79c8a4a612e3dd9c8aae2ce35e7a2bf8
|
||||
IV = 7e1d629b84f93b079be51f9a5f5cb23c
|
||||
PLAINTEXT = 38fbda37e28fa86d9d83a4345e419dea95d28c7818ff25925db6ac3aedaf0a86154e20a4dfcc5b1b4192895393e5eb5846c88bdbd41ecf7af3104f410eaee470f5d9017ed460475f626953035a13db1f
|
||||
CIPHERTEXT = edadae2f9a45ff3473e02d904c94d94a30a4d92da4deb6bcb4b0774472694571842039f21c496ef93fd658842c735f8a81fcd0aa578442ab893b18f606aed1bab11f81452dd45e9b56adf2eccf4ea095
|
||||
|
||||
COUNT = 5
|
||||
KEY = e3fecc75f0075a09b383dfd389a3d33cc9b854b3b254c0f4
|
||||
IV = 36eab883afef936cc38f63284619cd19
|
||||
PLAINTEXT = 931b2f5f3a5820d53a6beaaa6431083a3488f4eb03b0f5b57ef838e1579623103bd6e6800377538b2e51ef708f3c4956432e8a8ee6a34e190642b26ad8bdae6c2af9a6c7996f3b6004d2671e41f1c9f40ee03d1c4a52b0a0654a331f15f34dce
|
||||
CIPHERTEXT = 75395974bd32b3665654a6c8e396b88ae34b123575872a7ab687d8e76b46df911a8a590cd01d2f5c330be3a6626e9dd3aa5e10ed14e8ff829811b6fed50f3f533ca4385a1cbca78f5c4744e50f2f8359165c2485d1324e76c3eae76a0ccac629
|
||||
|
||||
COUNT = 6
|
||||
KEY = f9c27565eb07947c8cb51b79248430f7b1066c3d2fdc3d13
|
||||
IV = 2bd67cc89ab7948d644a49672843cbd9
|
||||
PLAINTEXT = 6abcc270173cf114d44847e911a050db57ba7a2e2c161c6f37ccb6aaa4677bddcaf50cad0b5f8758fcf7c0ebc650ceb5cd52cafb8f8dd3edcece55d9f1f08b9fa8f54365cf56e28b9596a7e1dd1d3418e4444a7724add4cf79d527b183ec88de4be4eeff29c80a97e54f85351cb189ee
|
||||
CIPHERTEXT = ca282924a61187feb40520979106e5cc861957f23828dcb7285e0eaac8a0ca2a6b60503d63d6039f4693dba32fa1f73ae2e709ca94911f28a5edd1f30eaddd54680c43acc9c74cd90d8bb648b4e544275f47e514daa20697f66c738eb30337f017fca1a26da4d1a0cc0a0e98e2463070
|
||||
|
||||
COUNT = 7
|
||||
KEY = fb09cf9e00dbf883689d079c920077c0073c31890b55bab5
|
||||
IV = e3c89bd097c3abddf64f4881db6dbfe2
|
||||
PLAINTEXT = c1a37683fb289467dd1b2c89efba16bbd2ee24cf18d19d44596ded2682c79a2f711c7a32bf6a24badd32a4ee637c73b7a41da6258635650f91fb9ffa45bdfc3cb122136241b3deced8996aa51ea8d3e81c9d70e006a44bc0571ed48623a0d622a93fa9da290baaedf5d9e876c94620945ff8ecc83f27379ed55cf490c5790f27
|
||||
CIPHERTEXT = 8158e21420f25b59d6ae943fa1cbf21f02e979f419dab0126a721b7eef55bee9ad97f5ccff7d239057bbc19a8c378142f7672f1d5e7e17d7bebcb0070e8355cace6660171a53b61816ae824a6ef69ce470b6ffd3b5bb4b438874d91d27854d3b6f25860d3868958de3307d62b1339bdddb8a318c0ce0f33c17caf0e9f6040820
|
||||
|
||||
COUNT = 8
|
||||
KEY = bca6fa3c67fd294e958f66fe8bd64f45f428f5bc8e9733a7
|
||||
IV = 92a47f2833f1450d1da41717bdc6e83c
|
||||
PLAINTEXT = 5becbc31d8bead6d36ae014a5863d14a431e6b55d29ea6baaa417271716db3a33b2e506b452086dfe690834ac2de30bc41254ec5401ec47d064237c7792fdcd7914d8af20eb114756642d519021a8c75a92f6bc53d326ae9a5b7e1b10a9756574692934d9939fc399e0c203f7edf8e7e6482eadd31a0400770e897b48c6bca2b404593045080e93377358c42a0f4dede
|
||||
CIPHERTEXT = 926db248cc1ba20f0c57631a7c8aef094f791937b905949e3460240e8bfa6fa483115a1b310b6e4369caebc5262888377b1ddaa5800ea496a2bdff0f9a1031e7129c9a20e35621e7f0b8baca0d87030f2ae7ca8593c8599677a06fd4b26009ead08fecac24caa9cf2cad3b470c8227415a7b1e0f2eab3fad96d70a209c8bb26c627677e2531b9435ca6e3c444d195b5f
|
||||
|
||||
COUNT = 9
|
||||
KEY = 162ad50ee64a0702aa551f571dedc16b2c1b6a1e4d4b5eee
|
||||
IV = 24408038161a2ccae07b029bb66355c1
|
||||
PLAINTEXT = be8abf00901363987a82cc77d0ec91697ba3857f9e4f84bd79406c138d02698f003276d0449120bef4578d78fecabe8e070e11710b3f0a2744bd52434ec70015884c181ebdfd51c604a71c52e4c0e110bc408cd462b248a80b8a8ac06bb952ac1d7faed144807f1a731b7febcaf7835762defe92eccfc7a9944e1c702cffe6bc86733ed321423121085ac02df8962bcbc1937092eebf0e90a8b20e3dd8c244ae
|
||||
CIPHERTEXT = c82cf2c476dea8cb6a6e607a40d2f0391be82ea9ec84a537a6820f9afb997b76397d005424faa6a74dc4e8c7aa4a8900690f894b6d1dca80675393d2243adac762f159301e357e98b724762310cd5a7bafe1c2a030dba46fd93a9fdb89cc132ca9c17dc72031ec6822ee5a9d99dbca66c784c01b0885cbb62e29d97801927ec415a5d215158d325f9ee689437ad1b7684ad33c0d92739451ac87f39ff8c31b84
|
||||
|
||||
[DECRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 8e2740fba157aef2422e442312d15c14d312553684fcdc15
|
||||
IV = 324015878cdc82bfae59a2dc1ff34ea6
|
||||
CIPHERTEXT = 39a9b42de19e512ab7f3043564c3515a
|
||||
PLAINTEXT = aa41179d880e6fe3b14818d6e4a62eb5
|
||||
|
||||
COUNT = 1
|
||||
KEY = 0ac0d2add273d1a260c432c662b4be4d8d366edc3f402e40
|
||||
IV = 0cc3744fa9cef13fe04a5ab6ac9b8de4
|
||||
CIPHERTEXT = 2cd57dce7465d5ecde153e87ce45e62286c6b023a446dae3ec0fdc0648f29308
|
||||
PLAINTEXT = 854e97e19b5c4fbd7a2ac7f8ddccdc8eac1a166832b58f05ae5088d7caba8fee
|
||||
|
||||
COUNT = 2
|
||||
KEY = 3915d786c786731cfe35abe39fac714f5fa32c7ef3c6681b
|
||||
IV = a2d326a8226576e32e48f62b3da96c40
|
||||
CIPHERTEXT = a9968021d6df78ff2c4c236bdd9a55bc727b0dc506f44958b2041f0948860a3444588242ffbdcf2726001e2f6b5bd5fb
|
||||
PLAINTEXT = 4a7a4dca5c555d3f0358be7db4af14f1322a8861a3cb977f029fdcbd8ee4a8d451f32d7865e6a2376edf67e4d1092e15
|
||||
|
||||
COUNT = 3
|
||||
KEY = 92317d4d38168a359118a0df0b7b45cbfdcc2011e7175d3c
|
||||
IV = 75be95a6a54400b2e1b485e24ead18ed
|
||||
CIPHERTEXT = f67581763d23326f699e05696043b4c553928c2a9f857377f12029fcae4acee992dba50697f617a51899fbd6367214d97bf5dbd9bdab7fd745cd2be431118793
|
||||
PLAINTEXT = 7b88fb0195a57ac61ccb3198a05517717523444da92d2e8c37840a7f7614c9effa6dd6f1d1a730ec350cd64b99738cfb3b962c791b2674929f936e894cbcb994
|
||||
|
||||
COUNT = 4
|
||||
KEY = cd00048ce8ead5b5dff2346a86eac594b2a4194ca99fc89f
|
||||
IV = 154cb1d42ad9e8d85ebb0b5189b6e1bc
|
||||
CIPHERTEXT = a12b32199ae6484418ac7097fda9bb33f2ae421dfd795c9b553615e17546dcec6f3e7caf83334e6df035ac660a19a8b58d7cfe79310448337ee9716fe2b46ca7014726644c1eb9a6d5d4e28661e9b51a
|
||||
PLAINTEXT = 07d471fa87fb5f267346aa4956c8bdb6c95493b1c19be8ca09deffd690d57463229352faf2878bc66a20f199d9f6b2378e6073c2cef002c628ce94d1adb5539bd15c4a51156f98f52bbe90a1905d35de
|
||||
|
||||
COUNT = 5
|
||||
KEY = c4b39f1d90658aa1769a777956026573567bd0f3d6333b3b
|
||||
IV = f6085f2331e851db9c2654dacb5baf19
|
||||
CIPHERTEXT = 69e771f860e0291e4477dce2a48f2c6ae2922b9337667b86f79cb38c16ea0523ecdb1e5135c54e385cfce9ebf945ed80988de466bcdb0cf92384b6544c9eec6637b656496cc65fce3e61935d51314bfc5aa38dad26e12efdde0139da897b95a5
|
||||
PLAINTEXT = 8ab7b8b3c3c7d79b6d5cc605d3094a33756a8755140782967fb86297cf599eaea03e384018631b18425363e9ada971412d3eab03c63748749001e5b1a4a2e80ed7b915e6b9fa38e490301d6b45e27c0c72fd8cf6895de950d8d02774a8c33a6a
|
||||
|
||||
COUNT = 6
|
||||
KEY = 62cff862e7bef3569a380ea7ff40918e3afb5c7ad265cd5f
|
||||
IV = 04d1cab2b002d9dd6c5b66add5d6148b
|
||||
CIPHERTEXT = 65cfb38f922f1716225472eb36a127327007f8f5c08479ca7beac4b0aee26f3bb130bbf1ff390ef344c2a4e0b8fa81f6acbbaa7a620d945a22ecdd128a4b3acc2658b1cb41020809fab87d1f9a74b76624f9fd5c2e59a649f0b9d0229b5855adeccefbe60092eba26abf65728318b1ca
|
||||
PLAINTEXT = 839238a996e51b542ab7aa55eae3150097291ca19e756325c326803926ea45ad6ef6b7790ce89d084bbb2ad2d95bc889f5d19ffd3092aff609d5e63b7324ea207ce22f8598f189563cc6e611f5ef25be06b6a78fc6a68270683542de69b0a44aee456d1138d0fd9ad4df68083633defc
|
||||
|
||||
COUNT = 7
|
||||
KEY = 2c25af9d60e1af42c7f0fc2fbf011637e6119bd0e8e9bab9
|
||||
IV = c264b21a1eca4b2c8bd8606d87e38471
|
||||
CIPHERTEXT = f5f05cedea55a4f47ce943463bd15ccc7ae4f6bda2b3f5c3ccc6495a8e2965791428f2757356c5223bd40f3b4bcfd404ea4b9f2d131f73fa0f4104a14a4427f45f1f883f75309b74ce81d5859d491b1218b67b44cfe91af93c436d219bdfac67fc5f841596ec0d315e78fbecd846183e2dadf2ca7f19d0077952eba12a01db1d
|
||||
PLAINTEXT = d50a55ea83ccd556e1d663424d3e19c1ad9b8d16ff01f5422accadf3dae07d597f1375aaa319994ef71e1753485660e418dc1d6767a37ae93d8e700fc639e5d7283a9ecc2945b4429e8203f33178f25ed67d231667af7b8f2994e3d904437fed121612a04eb3e4c230789d46e4409e24c7bd1f86ae502eee5a11af1cad5c98b5
|
||||
|
||||
COUNT = 8
|
||||
KEY = c6680fe9a1968f899479eca1092beaac18ad945a42ce8f93
|
||||
IV = 54130eea9e96a1199d3c090f690a479f
|
||||
CIPHERTEXT = 8a21ea1381284bcdf818c2d4dfa976c13e5a3c253164ba1d30eccc27947c263457b43bff1c3d5e9c6fff27544d9419b0e7fc81d4a392a10e643e0eaf0bed571a3e3ee71a687e2d7900d7face0fc42a96ecc886864a60e9207536a285d9971a8ac427b70d6dd4ff8a340801e92b23f09ad62812e42fb6d87aed3b4f500664b7ac73d8708033251ef792fa054eab98b5e5
|
||||
PLAINTEXT = c970a819cfb715f777e8b63167999ebe17c71ff505c3ff24cc6995430fad4013e1fc69ba5123072a7123e376d1f7de8cc610ada3fdd905a1476bc23724861e85dcf950db2b4982b60271752b49e438a20ef4e8e09cac0dc49ed15b84e32627e243814fee0430744ac675c7e5673d3f57a52360ec6ff8d18ed4b5bd8f1456c1f688825cb999789cad5e1b37a4b92ace3b
|
||||
|
||||
COUNT = 9
|
||||
KEY = 509baf46fb9de34281dafcc3db79593bffa8426904302688
|
||||
IV = d6d86e0c82dd8788f4147a26f9a71c74
|
||||
CIPHERTEXT = 6928299c52b4f047926f8a541529da2d6bbaa399143ced8efb77ab47409d9a953a386c7abd6026f49831c717627c2a5e77bd2d433d4d130dacd927ea0d13a23d01a7cf39c6716dafb6ed552410ef5d27fb947be2c8782eee7829196c7edcf151c65f9a01f54f8d20f38b7da4a7e83a2f0127d59d3e2405d8674fc9f41b604f788f4715f9d3624eee57f387bfadd18a1f905e839c26b8617482347fab6d08845a
|
||||
PLAINTEXT = 67d2dda6da26e21307973400600725727ae81415511772f4a09ad9903bcf90cc2c0dac58ba559a0109c54a9d6117b15bb574ca473e848047e9a54ee4abde76aff9849c44109d161f46442e1610d8b015cf36a010ed8efa3207fdfc8fcc548f145c027e44c5b0ec35c9886f4b9d6513a5bc10d0ea6bbbc26f54b183bcae27fb799d8872ff748fc459d55cfa255aae29d71b076d9b44c14d5ceba9332a763d9c94
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
# CAVS 11.1
|
||||
# Config info for aes_values
|
||||
# AESVS MMT test data for CBC
|
||||
# State : Encrypt and Decrypt
|
||||
# Key Length : 256
|
||||
# Generated on Fri Apr 22 15:11:38 2011
|
||||
|
||||
[ENCRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 6ed76d2d97c69fd1339589523931f2a6cff554b15f738f21ec72dd97a7330907
|
||||
IV = 851e8764776e6796aab722dbb644ace8
|
||||
PLAINTEXT = 6282b8c05c5c1530b97d4816ca434762
|
||||
CIPHERTEXT = 6acc04142e100a65f51b97adf5172c41
|
||||
|
||||
COUNT = 1
|
||||
KEY = dce26c6b4cfb286510da4eecd2cffe6cdf430f33db9b5f77b460679bd49d13ae
|
||||
IV = fdeaa134c8d7379d457175fd1a57d3fc
|
||||
PLAINTEXT = 50e9eee1ac528009e8cbcd356975881f957254b13f91d7c6662d10312052eb00
|
||||
CIPHERTEXT = 2fa0df722a9fd3b64cb18fb2b3db55ff2267422757289413f8f657507412a64c
|
||||
|
||||
COUNT = 2
|
||||
KEY = fe8901fecd3ccd2ec5fdc7c7a0b50519c245b42d611a5ef9e90268d59f3edf33
|
||||
IV = bd416cb3b9892228d8f1df575692e4d0
|
||||
PLAINTEXT = 8d3aa196ec3d7c9b5bb122e7fe77fb1295a6da75abe5d3a510194d3a8a4157d5c89d40619716619859da3ec9b247ced9
|
||||
CIPHERTEXT = 608e82c7ab04007adb22e389a44797fed7de090c8c03ca8a2c5acd9e84df37fbc58ce8edb293e98f02b640d6d1d72464
|
||||
|
||||
COUNT = 3
|
||||
KEY = 0493ff637108af6a5b8e90ac1fdf035a3d4bafd1afb573be7ade9e8682e663e5
|
||||
IV = c0cd2bebccbb6c49920bd5482ac756e8
|
||||
PLAINTEXT = 8b37f9148df4bb25956be6310c73c8dc58ea9714ff49b643107b34c9bff096a94fedd6823526abc27a8e0b16616eee254ab4567dd68e8ccd4c38ac563b13639c
|
||||
CIPHERTEXT = 05d5c77729421b08b737e41119fa4438d1f570cc772a4d6c3df7ffeda0384ef84288ce37fc4c4c7d1125a499b051364c389fd639bdda647daa3bdadab2eb5594
|
||||
|
||||
COUNT = 4
|
||||
KEY = 9adc8fbd506e032af7fa20cf5343719de6d1288c158c63d6878aaf64ce26ca85
|
||||
IV = 11958dc6ab81e1c7f01631e9944e620f
|
||||
PLAINTEXT = c7917f84f747cd8c4b4fedc2219bdbc5f4d07588389d8248854cf2c2f89667a2d7bcf53e73d32684535f42318e24cd45793950b3825e5d5c5c8fcd3e5dda4ce9246d18337ef3052d8b21c5561c8b660e
|
||||
CIPHERTEXT = 9c99e68236bb2e929db1089c7750f1b356d39ab9d0c40c3e2f05108ae9d0c30b04832ccdbdc08ebfa426b7f5efde986ed05784ce368193bb3699bc691065ac62e258b9aa4cc557e2b45b49ce05511e65
|
||||
|
||||
COUNT = 5
|
||||
KEY = 73b8faf00b3302ac99855cf6f9e9e48518690a5906a4869d4dcf48d282faae2a
|
||||
IV = b3cb97a80a539912b8c21f450d3b9395
|
||||
PLAINTEXT = 3adea6e06e42c4f041021491f2775ef6378cb08824165edc4f6448e232175b60d0345b9f9c78df6596ec9d22b7b9e76e8f3c76b32d5d67273f1d83fe7a6fc3dd3c49139170fa5701b3beac61b490f0a9e13f844640c4500f9ad3087adfb0ae10
|
||||
CIPHERTEXT = ac3d6dbafe2e0f740632fd9e820bf6044cd5b1551cbb9cc03c0b25c39ccb7f33b83aacfca40a3265f2bbff879153448acacb88fcfb3bb7b10fe463a68c0109f028382e3e557b1adf02ed648ab6bb895df0205d26ebbfa9a5fd8cebd8e4bee3dc
|
||||
|
||||
COUNT = 6
|
||||
KEY = 9ddf3745896504ff360a51a3eb49c01b79fccebc71c3abcb94a949408b05b2c9
|
||||
IV = e79026639d4aa230b5ccffb0b29d79bc
|
||||
PLAINTEXT = cf52e5c3954c51b94c9e38acb8c9a7c76aebdaa9943eae0a1ce155a2efdb4d46985d935511471452d9ee64d2461cb2991d59fc0060697f9a671672163230f367fed1422316e52d29eceacb8768f56d9b80f6d278093c9a8acd3cfd7edd8ebd5c293859f64d2f8486ae1bd593c65bc014
|
||||
CIPHERTEXT = 34df561bd2cfebbcb7af3b4b8d21ca5258312e7e2e4e538e35ad2490b6112f0d7f148f6aa8d522a7f3c61d785bd667db0e1dc4606c318ea4f26af4fe7d11d4dcff0456511b4aed1a0d91ba4a1fd6cd9029187bc5881a5a07fe02049d39368e83139b12825bae2c7be81e6f12c61bb5c5
|
||||
|
||||
COUNT = 7
|
||||
KEY = 458b67bf212d20f3a57fce392065582dcefbf381aa22949f8338ab9052260e1d
|
||||
IV = 4c12effc5963d40459602675153e9649
|
||||
PLAINTEXT = 256fd73ce35ae3ea9c25dd2a9454493e96d8633fe633b56176dce8785ce5dbbb84dbf2c8a2eeb1e96b51899605e4f13bbc11b93bf6f39b3469be14858b5b720d4a522d36feed7a329c9b1e852c9280c47db8039c17c4921571a07d1864128330e09c308ddea1694e95c84500f1a61e614197e86a30ecc28df64ccb3ccf5437aa
|
||||
CIPHERTEXT = 90b7b9630a2378f53f501ab7beff039155008071bc8438e789932cfd3eb1299195465e6633849463fdb44375278e2fdb1310821e6492cf80ff15cb772509fb426f3aeee27bd4938882fd2ae6b5bd9d91fa4a43b17bb439ebbe59c042310163a82a5fe5388796eee35a181a1271f00be29b852d8fa759bad01ff4678f010594cd
|
||||
|
||||
COUNT = 8
|
||||
KEY = d2412db0845d84e5732b8bbd642957473b81fb99ca8bff70e7920d16c1dbec89
|
||||
IV = 51c619fcf0b23f0c7925f400a6cacb6d
|
||||
PLAINTEXT = 026006c4a71a180c9929824d9d095b8faaa86fc4fa25ecac61d85ff6de92dfa8702688c02a282c1b8af4449707f22d75e91991015db22374c95f8f195d5bb0afeb03040ff8965e0e1339dba5653e174f8aa5a1b39fe3ac839ce307a4e44b4f8f1b0063f738ec18acdbff2ebfe07383e734558723e741f0a1836dafdf9de82210a9248bc113b3c1bc8b4e252ca01bd803
|
||||
CIPHERTEXT = 0254b23463bcabec5a395eb74c8fb0eb137a07bc6f5e9f61ec0b057de305714f8fa294221c91a159c315939b81e300ee902192ec5f15254428d8772f79324ec43298ca21c00b370273ee5e5ed90e43efa1e05a5d171209fe34f9f29237dba2a6726650fd3b1321747d1208863c6c3c6b3e2d879ab5f25782f08ba8f2abbe63e0bedb4a227e81afb36bb6645508356d34
|
||||
|
||||
COUNT = 9
|
||||
KEY = 48be597e632c16772324c8d3fa1d9c5a9ecd010f14ec5d110d3bfec376c5532b
|
||||
IV = d6d581b8cf04ebd3b6eaa1b53f047ee1
|
||||
PLAINTEXT = 0c63d413d3864570e70bb6618bf8a4b9585586688c32bba0a5ecc1362fada74ada32c52acfd1aa7444ba567b4e7daaecf7cc1cb29182af164ae5232b002868695635599807a9a7f07a1f137e97b1e1c9dabc89b6a5e4afa9db5855edaa575056a8f4f8242216242bb0c256310d9d329826ac353d715fa39f80cec144d6424558f9f70b98c920096e0f2c855d594885a00625880e9dfb734163cecef72cf030b8
|
||||
CIPHERTEXT = fc5873e50de8faf4c6b84ba707b0854e9db9ab2e9f7d707fbba338c6843a18fc6facebaf663d26296fb329b4d26f18494c79e09e779647f9bafa87489630d79f4301610c2300c19dbf3148b7cac8c4f4944102754f332e92b6f7c5e75bc6179eb877a078d4719009021744c14f13fd2a55a2b9c44d18000685a845a4f632c7c56a77306efa66a24d05d088dcd7c13fe24fc447275965db9e4d37fbc9304448cd
|
||||
|
||||
[DECRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 43e953b2aea08a3ad52d182f58c72b9c60fbe4a9ca46a3cb89e3863845e22c9e
|
||||
IV = ddbbb0173f1e2deb2394a62aa2a0240e
|
||||
CIPHERTEXT = d51d19ded5ca4ae14b2b20b027ffb020
|
||||
PLAINTEXT = 07270d0e63aa36daed8c6ade13ac1af1
|
||||
|
||||
COUNT = 1
|
||||
KEY = addf88c1ab997eb58c0455288c3a4fa320ada8c18a69cc90aa99c73b174dfde6
|
||||
IV = 60cc50e0887532e0d4f3d2f20c3c5d58
|
||||
CIPHERTEXT = 6cb4e2f4ddf79a8e08c96c7f4040e8a83266c07fc88dd0074ee25b00d445985a
|
||||
PLAINTEXT = 98a8a9d84356bf403a9ccc384a06fe043dfeecb89e59ce0cb8bd0a495ef76cf0
|
||||
|
||||
COUNT = 2
|
||||
KEY = 54682728db5035eb04b79645c64a95606abb6ba392b6633d79173c027c5acf77
|
||||
IV = 2eb94297772851963dd39a1eb95d438f
|
||||
CIPHERTEXT = e4046d05385ab789c6a72866e08350f93f583e2a005ca0faecc32b5cfc323d461c76c107307654db5566a5bd693e227c
|
||||
PLAINTEXT = 0faa5d01b9afad3bb519575daaf4c60a5ed4ca2ba20c625bc4f08799addcf89d19796d1eff0bd790c622dc22c1094ec7
|
||||
|
||||
COUNT = 3
|
||||
KEY = 7482c47004aef406115ca5fd499788d582efc0b29dc9e951b1f959406693a54f
|
||||
IV = 485ebf2215d20b816ea53944829717ce
|
||||
CIPHERTEXT = 6c24f19b9c0b18d7126bf68090cb8ae72db3ca7eabb594f506aae7a2493e5326a5afae4ec4d109375b56e2b6ff4c9cf639e72c63dc8114c796df95b3c6b62021
|
||||
PLAINTEXT = 82fec664466d585023821c2e39a0c43345669a41244d05018a23d7159515f8ff4d88b01cd0eb83070d0077e065d74d7373816b61505718f8d4f270286a59d45e
|
||||
|
||||
COUNT = 4
|
||||
KEY = 3ae38d4ebf7e7f6dc0a1e31e5efa7ca123fdc321e533e79fedd5132c5999ef5b
|
||||
IV = 36d55dc9edf8669beecd9a2a029092b9
|
||||
CIPHERTEXT = d50ea48c8962962f7c3d301fa9f877245026c204a7771292cddca1e7ffebbef00e86d72910b7d8a756dfb45c9f1040978bb748ca537edd90b670ecee375e15d98582b9f93b6355adc9f80f4fb2108fb9
|
||||
PLAINTEXT = 8d22db30c4253c3e3add9685c14d55b05f7cf7626c52cccfcbe9b99fd8913663b8b1f22e277a4cc3d0e7e978a34782eb876867556ad4728486d5e890ea738243e3700a696d6eb58cd81c0e60eb121c50
|
||||
|
||||
COUNT = 5
|
||||
KEY = d30bfc0b2a19d5b8b6f8f46ab7f444ee136a7fa3fbdaf530cc3e8976339afcc4
|
||||
IV = 80be76a7f885d2c06b37d6a528fae0cd
|
||||
CIPHERTEXT = 31e4677a17aed120bd3af69fbb0e4b645b9e8c104e280b799ddd49f1e241c3ccb7d40e1c6ff226bf04f8049c51a86e2981cf1331c824d7d451746ccf77fc22fd3717001ee51913d81f7a06fb0037f309957579f695670f2c4c7397d2d990374e
|
||||
PLAINTEXT = 0b6e2a8213169b3b78db6de324e286f0366044e035c6970afbf0a1a5c32a05b24ba706cd9c6609737651a81b2bcf4c681dc0861983a5aec76e6c8b244112d64d489e84328974737394b83a39459011727162652b7aa793bfb1b71488b7dec96b
|
||||
|
||||
COUNT = 6
|
||||
KEY = 64a256a663527ebea71f8d770990b4cee4a2d3afbfd33fb12c7ac300ef59e49a
|
||||
IV = 18cce9147f295c5c00dbe0424089d3b4
|
||||
CIPHERTEXT = d99771963b7ae5202e382ff8c06e035367909cd24fe5ada7f3d39bfaeb5de98b04eaf4989648e00112f0d2aadb8c5f2157b64581450359965140c141e5fb631e43469d65d1b7370eb3b396399fec32cced294a5eee46d6547f7bbd49dee148b4bc31d6c493cfd28f3908e36cb698629d
|
||||
PLAINTEXT = f7e0f79cfddd15ed3600ab2d29c56ba3c8e96d1a896aff6dec773e6ea4710a77f2f4ec646b76efda6428c175d007c84aa9f4b18c5e1bac5f27f7307b737655eee813f7e1f5880a37ac63ad1666e7883083b648454d45786f53ea3db1b5129291138abe40c79fcb7ab7c6f6b9ea133b5f
|
||||
|
||||
COUNT = 7
|
||||
KEY = 31358e8af34d6ac31c958bbd5c8fb33c334714bffb41700d28b07f11cfe891e7
|
||||
IV = 144516246a752c329056d884daf3c89d
|
||||
CIPHERTEXT = b32e2b171b63827034ebb0d1909f7ef1d51c5f82c1bb9bc26bc4ac4dccdee8357dca6154c2510ae1c87b1b422b02b621bb06cac280023894fcff3406af08ee9be1dd72419beccddff77c722d992cdcc87e9c7486f56ab406ea608d8c6aeb060c64cf2785ad1a159147567e39e303370da445247526d95942bf4d7e88057178b0
|
||||
PLAINTEXT = cfc155a3967de347f58fa2e8bbeb4183d6d32f7427155e6ab39cddf2e627c572acae02f1f243f3b784e73e21e7e520eacd3befafbee814867334c6ee8c2f0ee7376d3c72728cde7813173dbdfe3357deac41d3ae2a04229c0262f2d109d01f5d03e7f848fb50c28849146c02a2f4ebf7d7ffe3c9d40e31970bf151873672ef2b
|
||||
|
||||
COUNT = 8
|
||||
KEY = 5b4b69339891db4e3337c3486f439dfbd0fb2a782ca71ef0059819d51669d93c
|
||||
IV = 2b28a2d19ba9ecd149dae96622c21769
|
||||
CIPHERTEXT = ba21db8ec170fa4d73cfc381687f3fa188dd2d012bef48007f3dc88329e22ba32fe235a315be362546468b9db6af6705c6e5d4d36822f42883c08d4a994cc454a7db292c4ca1f4b62ebf8e479a5d545d6af9978d2cfee7bc80999192c2c8662ce9b4be11af40bd68f3e2d5685bb28c0f3dc08017c0aba8263e6fdc45ed7f9893bf14fd3a86c418a35c5667e642d59985
|
||||
PLAINTEXT = a0bb1d2fdeb7e6bf34c690fe7b72a5e9d65796aa57982fe340c286d6923dbddb426566ff58e9c0b3af52e4db446f6cc5daa5bfcf4e3c85db5a5638e670c370cce128db22c97542a64a63846f18a228d3462a11376dcb71f66ec52ebda474f7b6752915b0801797974bc51eb1218127fed60f1009430eb5089fb3ba5f28fad24c518ccddc2501393ceb6dffc46a159421
|
||||
|
||||
COUNT = 9
|
||||
KEY = 87725bd43a45608814180773f0e7ab95a3c859d83a2130e884190e44d14c6996
|
||||
IV = e49651988ebbb72eb8bb80bb9abbca34
|
||||
CIPHERTEXT = 5b97a9d423f4b97413f388d9a341e727bb339f8e18a3fac2f2fb85abdc8f135deb30054a1afdc9b6ed7da16c55eba6b0d4d10c74e1d9a7cf8edfaeaa684ac0bd9f9d24ba674955c79dc6be32aee1c260b558ff07e3a4d49d24162011ff254db8be078e8ad07e648e6bf5679376cb4321a5ef01afe6ad8816fcc7634669c8c4389295c9241e45fff39f3225f7745032daeebe99d4b19bcb215d1bfdb36eda2c24
|
||||
PLAINTEXT = bfe5c6354b7a3ff3e192e05775b9b75807de12e38a626b8bf0e12d5fff78e4f1775aa7d792d885162e66d88930f9c3b2cdf8654f56972504803190386270f0aa43645db187af41fcea639b1f8026ccdd0c23e0de37094a8b941ecb7602998a4b2604e69fc04219585d854600e0ad6f99a53b2504043c08b1c3e214d17cde053cbdf91daa999ed5b47c37983ba3ee254bc5c793837daaa8c85cfc12f7f54f699f
|
||||
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,95 @@
|
|||
# CAVS 11.1
|
||||
# Config info for aes_values
|
||||
# AESVS GFSbox test data for CFB128
|
||||
# State : Encrypt and Decrypt
|
||||
# Key Length : 128
|
||||
# Generated on Fri Apr 22 15:11:53 2011
|
||||
|
||||
[ENCRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = f34481ec3cc627bacd5dc3fb08f273e6
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 0336763e966d92595a567cc9ce537f5e
|
||||
|
||||
COUNT = 1
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 9798c4640bad75c7c3227db910174e72
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = a9a1631bf4996954ebc093957b234589
|
||||
|
||||
COUNT = 2
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 96ab5c2ff612d9dfaae8c31f30c42168
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = ff4f8391a6a40ca5b25d23bedd44a597
|
||||
|
||||
COUNT = 3
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 6a118a874519e64e9963798a503f1d35
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = dc43be40be0e53712f7e2bf5ca707209
|
||||
|
||||
COUNT = 4
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = cb9fceec81286ca3e989bd979b0cb284
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 92beedab1895a94faa69b632e5cc47ce
|
||||
|
||||
COUNT = 5
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = b26aeb1874e47ca8358ff22378f09144
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 459264f4798f6a78bacb89c15ed3d601
|
||||
|
||||
COUNT = 6
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 58c8e00b2631686d54eab84b91f0aca1
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 08a4e2efec8a8e3312ca7460b9040bbf
|
||||
|
||||
[DECRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = f34481ec3cc627bacd5dc3fb08f273e6
|
||||
CIPHERTEXT = 0336763e966d92595a567cc9ce537f5e
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 1
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 9798c4640bad75c7c3227db910174e72
|
||||
CIPHERTEXT = a9a1631bf4996954ebc093957b234589
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 2
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 96ab5c2ff612d9dfaae8c31f30c42168
|
||||
CIPHERTEXT = ff4f8391a6a40ca5b25d23bedd44a597
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 3
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 6a118a874519e64e9963798a503f1d35
|
||||
CIPHERTEXT = dc43be40be0e53712f7e2bf5ca707209
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 4
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = cb9fceec81286ca3e989bd979b0cb284
|
||||
CIPHERTEXT = 92beedab1895a94faa69b632e5cc47ce
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 5
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = b26aeb1874e47ca8358ff22378f09144
|
||||
CIPHERTEXT = 459264f4798f6a78bacb89c15ed3d601
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 6
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 58c8e00b2631686d54eab84b91f0aca1
|
||||
CIPHERTEXT = 08a4e2efec8a8e3312ca7460b9040bbf
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
# CAVS 11.1
|
||||
# Config info for aes_values
|
||||
# AESVS GFSbox test data for CFB128
|
||||
# State : Encrypt and Decrypt
|
||||
# Key Length : 192
|
||||
# Generated on Fri Apr 22 15:11:55 2011
|
||||
|
||||
[ENCRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 1b077a6af4b7f98229de786d7516b639
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 275cfc0413d8ccb70513c3859b1d0f72
|
||||
|
||||
COUNT = 1
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 9c2d8842e5f48f57648205d39a239af1
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = c9b8135ff1b5adc413dfd053b21bd96d
|
||||
|
||||
COUNT = 2
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = bff52510095f518ecca60af4205444bb
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 4a3650c3371ce2eb35e389a171427440
|
||||
|
||||
COUNT = 3
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 51719783d3185a535bd75adc65071ce1
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 4f354592ff7c8847d2d0870ca9481b7c
|
||||
|
||||
COUNT = 4
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 26aa49dcfe7629a8901a69a9914e6dfd
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = d5e08bf9a182e857cf40b3a36ee248cc
|
||||
|
||||
COUNT = 5
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 941a4773058224e1ef66d10e0a6ee782
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 067cd9d3749207791841562507fa9626
|
||||
|
||||
[DECRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 1b077a6af4b7f98229de786d7516b639
|
||||
CIPHERTEXT = 275cfc0413d8ccb70513c3859b1d0f72
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 1
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 9c2d8842e5f48f57648205d39a239af1
|
||||
CIPHERTEXT = c9b8135ff1b5adc413dfd053b21bd96d
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 2
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = bff52510095f518ecca60af4205444bb
|
||||
CIPHERTEXT = 4a3650c3371ce2eb35e389a171427440
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 3
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 51719783d3185a535bd75adc65071ce1
|
||||
CIPHERTEXT = 4f354592ff7c8847d2d0870ca9481b7c
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 4
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 26aa49dcfe7629a8901a69a9914e6dfd
|
||||
CIPHERTEXT = d5e08bf9a182e857cf40b3a36ee248cc
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 5
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 941a4773058224e1ef66d10e0a6ee782
|
||||
CIPHERTEXT = 067cd9d3749207791841562507fa9626
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
# CAVS 11.1
|
||||
# Config info for aes_values
|
||||
# AESVS GFSbox test data for CFB128
|
||||
# State : Encrypt and Decrypt
|
||||
# Key Length : 256
|
||||
# Generated on Fri Apr 22 15:11:57 2011
|
||||
|
||||
[ENCRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 014730f80ac625fe84f026c60bfd547d
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 5c9d844ed46f9885085e5d6a4f94c7d7
|
||||
|
||||
COUNT = 1
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 0b24af36193ce4665f2825d7b4749c98
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = a9ff75bd7cf6613d3731c77c3b6d0c04
|
||||
|
||||
COUNT = 2
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 761c1fe41a18acf20d241650611d90f1
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 623a52fcea5d443e48d9181ab32c7421
|
||||
|
||||
COUNT = 3
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 8a560769d605868ad80d819bdba03771
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 38f2c7ae10612415d27ca190d27da8b4
|
||||
|
||||
COUNT = 4
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 91fbef2d15a97816060bee1feaa49afe
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 1bc704f1bce135ceb810341b216d7abe
|
||||
|
||||
[DECRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 014730f80ac625fe84f026c60bfd547d
|
||||
CIPHERTEXT = 5c9d844ed46f9885085e5d6a4f94c7d7
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 1
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 0b24af36193ce4665f2825d7b4749c98
|
||||
CIPHERTEXT = a9ff75bd7cf6613d3731c77c3b6d0c04
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 2
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 761c1fe41a18acf20d241650611d90f1
|
||||
CIPHERTEXT = 623a52fcea5d443e48d9181ab32c7421
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 3
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 8a560769d605868ad80d819bdba03771
|
||||
CIPHERTEXT = 38f2c7ae10612415d27ca190d27da8b4
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 4
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 91fbef2d15a97816060bee1feaa49afe
|
||||
CIPHERTEXT = 1bc704f1bce135ceb810341b216d7abe
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
|
@ -0,0 +1,263 @@
|
|||
# CAVS 11.1
|
||||
# Config info for aes_values
|
||||
# AESVS KeySbox test data for CFB128
|
||||
# State : Encrypt and Decrypt
|
||||
# Key Length : 128
|
||||
# Generated on Fri Apr 22 15:11:53 2011
|
||||
|
||||
[ENCRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 10a58869d74be5a374cf867cfb473859
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 6d251e6944b051e04eaa6fb4dbf78465
|
||||
|
||||
COUNT = 1
|
||||
KEY = caea65cdbb75e9169ecd22ebe6e54675
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 6e29201190152df4ee058139def610bb
|
||||
|
||||
COUNT = 2
|
||||
KEY = a2e2fa9baf7d20822ca9f0542f764a41
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = c3b44b95d9d2f25670eee9a0de099fa3
|
||||
|
||||
COUNT = 3
|
||||
KEY = b6364ac4e1de1e285eaf144a2415f7a0
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 5d9b05578fc944b3cf1ccf0e746cd581
|
||||
|
||||
COUNT = 4
|
||||
KEY = 64cf9c7abc50b888af65f49d521944b2
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = f7efc89d5dba578104016ce5ad659c05
|
||||
|
||||
COUNT = 5
|
||||
KEY = 47d6742eefcc0465dc96355e851b64d9
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 0306194f666d183624aa230a8b264ae7
|
||||
|
||||
COUNT = 6
|
||||
KEY = 3eb39790678c56bee34bbcdeccf6cdb5
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 858075d536d79ccee571f7d7204b1f67
|
||||
|
||||
COUNT = 7
|
||||
KEY = 64110a924f0743d500ccadae72c13427
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 35870c6a57e9e92314bcb8087cde72ce
|
||||
|
||||
COUNT = 8
|
||||
KEY = 18d8126516f8a12ab1a36d9f04d68e51
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 6c68e9be5ec41e22c825b7c7affb4363
|
||||
|
||||
COUNT = 9
|
||||
KEY = f530357968578480b398a3c251cd1093
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = f5df39990fc688f1b07224cc03e86cea
|
||||
|
||||
COUNT = 10
|
||||
KEY = da84367f325d42d601b4326964802e8e
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = bba071bcb470f8f6586e5d3add18bc66
|
||||
|
||||
COUNT = 11
|
||||
KEY = e37b1c6aa2846f6fdb413f238b089f23
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 43c9f7e62f5d288bb27aa40ef8fe1ea8
|
||||
|
||||
COUNT = 12
|
||||
KEY = 6c002b682483e0cabcc731c253be5674
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 3580d19cff44f1014a7c966a69059de5
|
||||
|
||||
COUNT = 13
|
||||
KEY = 143ae8ed6555aba96110ab58893a8ae1
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 806da864dd29d48deafbe764f8202aef
|
||||
|
||||
COUNT = 14
|
||||
KEY = b69418a85332240dc82492353956ae0c
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = a303d940ded8f0baff6f75414cac5243
|
||||
|
||||
COUNT = 15
|
||||
KEY = 71b5c08a1993e1362e4d0ce9b22b78d5
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = c2dabd117f8a3ecabfbb11d12194d9d0
|
||||
|
||||
COUNT = 16
|
||||
KEY = e234cdca2606b81f29408d5f6da21206
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = fff60a4740086b3b9c56195b98d91a7b
|
||||
|
||||
COUNT = 17
|
||||
KEY = 13237c49074a3da078dc1d828bb78c6f
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 8146a08e2357f0caa30ca8c94d1a0544
|
||||
|
||||
COUNT = 18
|
||||
KEY = 3071a2a48fe6cbd04f1a129098e308f8
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 4b98e06d356deb07ebb824e5713f7be3
|
||||
|
||||
COUNT = 19
|
||||
KEY = 90f42ec0f68385f2ffc5dfc03a654dce
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 7a20a53d460fc9ce0423a7a0764c6cf2
|
||||
|
||||
COUNT = 20
|
||||
KEY = febd9a24d8b65c1c787d50a4ed3619a9
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = f4a70d8af877f9b02b4c40df57d45b17
|
||||
|
||||
[DECRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 10a58869d74be5a374cf867cfb473859
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 6d251e6944b051e04eaa6fb4dbf78465
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 1
|
||||
KEY = caea65cdbb75e9169ecd22ebe6e54675
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 6e29201190152df4ee058139def610bb
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 2
|
||||
KEY = a2e2fa9baf7d20822ca9f0542f764a41
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = c3b44b95d9d2f25670eee9a0de099fa3
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 3
|
||||
KEY = b6364ac4e1de1e285eaf144a2415f7a0
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 5d9b05578fc944b3cf1ccf0e746cd581
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 4
|
||||
KEY = 64cf9c7abc50b888af65f49d521944b2
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = f7efc89d5dba578104016ce5ad659c05
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 5
|
||||
KEY = 47d6742eefcc0465dc96355e851b64d9
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 0306194f666d183624aa230a8b264ae7
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 6
|
||||
KEY = 3eb39790678c56bee34bbcdeccf6cdb5
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 858075d536d79ccee571f7d7204b1f67
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 7
|
||||
KEY = 64110a924f0743d500ccadae72c13427
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 35870c6a57e9e92314bcb8087cde72ce
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 8
|
||||
KEY = 18d8126516f8a12ab1a36d9f04d68e51
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 6c68e9be5ec41e22c825b7c7affb4363
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 9
|
||||
KEY = f530357968578480b398a3c251cd1093
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = f5df39990fc688f1b07224cc03e86cea
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 10
|
||||
KEY = da84367f325d42d601b4326964802e8e
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = bba071bcb470f8f6586e5d3add18bc66
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 11
|
||||
KEY = e37b1c6aa2846f6fdb413f238b089f23
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 43c9f7e62f5d288bb27aa40ef8fe1ea8
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 12
|
||||
KEY = 6c002b682483e0cabcc731c253be5674
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 3580d19cff44f1014a7c966a69059de5
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 13
|
||||
KEY = 143ae8ed6555aba96110ab58893a8ae1
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 806da864dd29d48deafbe764f8202aef
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 14
|
||||
KEY = b69418a85332240dc82492353956ae0c
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = a303d940ded8f0baff6f75414cac5243
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 15
|
||||
KEY = 71b5c08a1993e1362e4d0ce9b22b78d5
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = c2dabd117f8a3ecabfbb11d12194d9d0
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 16
|
||||
KEY = e234cdca2606b81f29408d5f6da21206
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = fff60a4740086b3b9c56195b98d91a7b
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 17
|
||||
KEY = 13237c49074a3da078dc1d828bb78c6f
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 8146a08e2357f0caa30ca8c94d1a0544
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 18
|
||||
KEY = 3071a2a48fe6cbd04f1a129098e308f8
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 4b98e06d356deb07ebb824e5713f7be3
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 19
|
||||
KEY = 90f42ec0f68385f2ffc5dfc03a654dce
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 7a20a53d460fc9ce0423a7a0764c6cf2
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 20
|
||||
KEY = febd9a24d8b65c1c787d50a4ed3619a9
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = f4a70d8af877f9b02b4c40df57d45b17
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
|
@ -0,0 +1,299 @@
|
|||
# CAVS 11.1
|
||||
# Config info for aes_values
|
||||
# AESVS KeySbox test data for CFB128
|
||||
# State : Encrypt and Decrypt
|
||||
# Key Length : 192
|
||||
# Generated on Fri Apr 22 15:11:55 2011
|
||||
|
||||
[ENCRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = e9f065d7c13573587f7875357dfbb16c53489f6a4bd0f7cd
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 0956259c9cd5cfd0181cca53380cde06
|
||||
|
||||
COUNT = 1
|
||||
KEY = 15d20f6ebc7e649fd95b76b107e6daba967c8a9484797f29
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 8e4e18424e591a3d5b6f0876f16f8594
|
||||
|
||||
COUNT = 2
|
||||
KEY = a8a282ee31c03fae4f8e9b8930d5473c2ed695a347e88b7c
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 93f3270cfc877ef17e106ce938979cb0
|
||||
|
||||
COUNT = 3
|
||||
KEY = cd62376d5ebb414917f0c78f05266433dc9192a1ec943300
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 7f6c25ff41858561bb62f36492e93c29
|
||||
|
||||
COUNT = 4
|
||||
KEY = 502a6ab36984af268bf423c7f509205207fc1552af4a91e5
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 8e06556dcbb00b809a025047cff2a940
|
||||
|
||||
COUNT = 5
|
||||
KEY = 25a39dbfd8034f71a81f9ceb55026e4037f8f6aa30ab44ce
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 3608c344868e94555d23a120f8a5502d
|
||||
|
||||
COUNT = 6
|
||||
KEY = e08c15411774ec4a908b64eadc6ac4199c7cd453f3aaef53
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 77da2021935b840b7f5dcc39132da9e5
|
||||
|
||||
COUNT = 7
|
||||
KEY = 3b375a1ff7e8d44409696e6326ec9dec86138e2ae010b980
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 3b7c24f825e3bf9873c9f14d39a0e6f4
|
||||
|
||||
COUNT = 8
|
||||
KEY = 950bb9f22cc35be6fe79f52c320af93dec5bc9c0c2f9cd53
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 64ebf95686b353508c90ecd8b6134316
|
||||
|
||||
COUNT = 9
|
||||
KEY = 7001c487cc3e572cfc92f4d0e697d982e8856fdcc957da40
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = ff558c5d27210b7929b73fc708eb4cf1
|
||||
|
||||
COUNT = 10
|
||||
KEY = f029ce61d4e5a405b41ead0a883cc6a737da2cf50a6c92ae
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = a2c3b2a818075490a7b4c14380f02702
|
||||
|
||||
COUNT = 11
|
||||
KEY = 61257134a518a0d57d9d244d45f6498cbc32f2bafc522d79
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = cfe4d74002696ccf7d87b14a2f9cafc9
|
||||
|
||||
COUNT = 12
|
||||
KEY = b0ab0a6a818baef2d11fa33eac947284fb7d748cfb75e570
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = d2eafd86f63b109b91f5dbb3a3fb7e13
|
||||
|
||||
COUNT = 13
|
||||
KEY = ee053aa011c8b428cdcc3636313c54d6a03cac01c71579d6
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 9b9fdd1c5975655f539998b306a324af
|
||||
|
||||
COUNT = 14
|
||||
KEY = d2926527e0aa9f37b45e2ec2ade5853ef807576104c7ace3
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = dd619e1cf204446112e0af2b9afa8f8c
|
||||
|
||||
COUNT = 15
|
||||
KEY = 982215f4e173dfa0fcffe5d3da41c4812c7bcc8ed3540f93
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = d4f0aae13c8fe9339fbf9e69ed0ad74d
|
||||
|
||||
COUNT = 16
|
||||
KEY = 98c6b8e01e379fbd14e61af6af891596583565f2a27d59e9
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 19c80ec4a6deb7e5ed1033dda933498f
|
||||
|
||||
COUNT = 17
|
||||
KEY = b3ad5cea1dddc214ca969ac35f37dae1a9a9d1528f89bb35
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 3cf5e1d21a17956d1dffad6a7c41c659
|
||||
|
||||
COUNT = 18
|
||||
KEY = 45899367c3132849763073c435a9288a766c8b9ec2308516
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 69fd12e8505f8ded2fdcb197a121b362
|
||||
|
||||
COUNT = 19
|
||||
KEY = ec250e04c3903f602647b85a401a1ae7ca2f02f67fa4253e
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 8aa584e2cc4d17417a97cb9a28ba29c8
|
||||
|
||||
COUNT = 20
|
||||
KEY = d077a03bd8a38973928ccafe4a9d2f455130bd0af5ae46a9
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = abc786fb1edb504580c4d882ef29a0c7
|
||||
|
||||
COUNT = 21
|
||||
KEY = d184c36cf0dddfec39e654195006022237871a47c33d3198
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 2e19fb60a3e1de0166f483c97824a978
|
||||
|
||||
COUNT = 22
|
||||
KEY = 4c6994ffa9dcdc805b60c2c0095334c42d95a8fc0ca5b080
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 7656709538dd5fec41e0ce6a0f8e207d
|
||||
|
||||
COUNT = 23
|
||||
KEY = c88f5b00a4ef9a6840e2acaf33f00a3bdc4e25895303fa72
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = a67cf333b314d411d3c0ae6e1cfcd8f5
|
||||
|
||||
[DECRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = e9f065d7c13573587f7875357dfbb16c53489f6a4bd0f7cd
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 0956259c9cd5cfd0181cca53380cde06
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 1
|
||||
KEY = 15d20f6ebc7e649fd95b76b107e6daba967c8a9484797f29
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 8e4e18424e591a3d5b6f0876f16f8594
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 2
|
||||
KEY = a8a282ee31c03fae4f8e9b8930d5473c2ed695a347e88b7c
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 93f3270cfc877ef17e106ce938979cb0
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 3
|
||||
KEY = cd62376d5ebb414917f0c78f05266433dc9192a1ec943300
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 7f6c25ff41858561bb62f36492e93c29
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 4
|
||||
KEY = 502a6ab36984af268bf423c7f509205207fc1552af4a91e5
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 8e06556dcbb00b809a025047cff2a940
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 5
|
||||
KEY = 25a39dbfd8034f71a81f9ceb55026e4037f8f6aa30ab44ce
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 3608c344868e94555d23a120f8a5502d
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 6
|
||||
KEY = e08c15411774ec4a908b64eadc6ac4199c7cd453f3aaef53
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 77da2021935b840b7f5dcc39132da9e5
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 7
|
||||
KEY = 3b375a1ff7e8d44409696e6326ec9dec86138e2ae010b980
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 3b7c24f825e3bf9873c9f14d39a0e6f4
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 8
|
||||
KEY = 950bb9f22cc35be6fe79f52c320af93dec5bc9c0c2f9cd53
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 64ebf95686b353508c90ecd8b6134316
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 9
|
||||
KEY = 7001c487cc3e572cfc92f4d0e697d982e8856fdcc957da40
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = ff558c5d27210b7929b73fc708eb4cf1
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 10
|
||||
KEY = f029ce61d4e5a405b41ead0a883cc6a737da2cf50a6c92ae
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = a2c3b2a818075490a7b4c14380f02702
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 11
|
||||
KEY = 61257134a518a0d57d9d244d45f6498cbc32f2bafc522d79
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = cfe4d74002696ccf7d87b14a2f9cafc9
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 12
|
||||
KEY = b0ab0a6a818baef2d11fa33eac947284fb7d748cfb75e570
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = d2eafd86f63b109b91f5dbb3a3fb7e13
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 13
|
||||
KEY = ee053aa011c8b428cdcc3636313c54d6a03cac01c71579d6
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 9b9fdd1c5975655f539998b306a324af
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 14
|
||||
KEY = d2926527e0aa9f37b45e2ec2ade5853ef807576104c7ace3
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = dd619e1cf204446112e0af2b9afa8f8c
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 15
|
||||
KEY = 982215f4e173dfa0fcffe5d3da41c4812c7bcc8ed3540f93
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = d4f0aae13c8fe9339fbf9e69ed0ad74d
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 16
|
||||
KEY = 98c6b8e01e379fbd14e61af6af891596583565f2a27d59e9
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 19c80ec4a6deb7e5ed1033dda933498f
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 17
|
||||
KEY = b3ad5cea1dddc214ca969ac35f37dae1a9a9d1528f89bb35
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 3cf5e1d21a17956d1dffad6a7c41c659
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 18
|
||||
KEY = 45899367c3132849763073c435a9288a766c8b9ec2308516
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 69fd12e8505f8ded2fdcb197a121b362
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 19
|
||||
KEY = ec250e04c3903f602647b85a401a1ae7ca2f02f67fa4253e
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 8aa584e2cc4d17417a97cb9a28ba29c8
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 20
|
||||
KEY = d077a03bd8a38973928ccafe4a9d2f455130bd0af5ae46a9
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = abc786fb1edb504580c4d882ef29a0c7
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 21
|
||||
KEY = d184c36cf0dddfec39e654195006022237871a47c33d3198
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 2e19fb60a3e1de0166f483c97824a978
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 22
|
||||
KEY = 4c6994ffa9dcdc805b60c2c0095334c42d95a8fc0ca5b080
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 7656709538dd5fec41e0ce6a0f8e207d
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 23
|
||||
KEY = c88f5b00a4ef9a6840e2acaf33f00a3bdc4e25895303fa72
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = a67cf333b314d411d3c0ae6e1cfcd8f5
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
|
@ -0,0 +1,203 @@
|
|||
# CAVS 11.1
|
||||
# Config info for aes_values
|
||||
# AESVS KeySbox test data for CFB128
|
||||
# State : Encrypt and Decrypt
|
||||
# Key Length : 256
|
||||
# Generated on Fri Apr 22 15:11:57 2011
|
||||
|
||||
[ENCRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = c47b0294dbbbee0fec4757f22ffeee3587ca4730c3d33b691df38bab076bc558
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 46f2fb342d6f0ab477476fc501242c5f
|
||||
|
||||
COUNT = 1
|
||||
KEY = 28d46cffa158533194214a91e712fc2b45b518076675affd910edeca5f41ac64
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 4bf3b0a69aeb6657794f2901b1440ad4
|
||||
|
||||
COUNT = 2
|
||||
KEY = c1cc358b449909a19436cfbb3f852ef8bcb5ed12ac7058325f56e6099aab1a1c
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 352065272169abf9856843927d0674fd
|
||||
|
||||
COUNT = 3
|
||||
KEY = 984ca75f4ee8d706f46c2d98c0bf4a45f5b00d791c2dfeb191b5ed8e420fd627
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 4307456a9e67813b452e15fa8fffe398
|
||||
|
||||
COUNT = 4
|
||||
KEY = b43d08a447ac8609baadae4ff12918b9f68fc1653f1269222f123981ded7a92f
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 4663446607354989477a5c6f0f007ef4
|
||||
|
||||
COUNT = 5
|
||||
KEY = 1d85a181b54cde51f0e098095b2962fdc93b51fe9b88602b3f54130bf76a5bd9
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 531c2c38344578b84d50b3c917bbb6e1
|
||||
|
||||
COUNT = 6
|
||||
KEY = dc0eba1f2232a7879ded34ed8428eeb8769b056bbaf8ad77cb65c3541430b4cf
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = fc6aec906323480005c58e7e1ab004ad
|
||||
|
||||
COUNT = 7
|
||||
KEY = f8be9ba615c5a952cabbca24f68f8593039624d524c816acda2c9183bd917cb9
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = a3944b95ca0b52043584ef02151926a8
|
||||
|
||||
COUNT = 8
|
||||
KEY = 797f8b3d176dac5b7e34a2d539c4ef367a16f8635f6264737591c5c07bf57a3e
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = a74289fe73a4c123ca189ea1e1b49ad5
|
||||
|
||||
COUNT = 9
|
||||
KEY = 6838d40caf927749c13f0329d331f448e202c73ef52c5f73a37ca635d4c47707
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = b91d4ea4488644b56cf0812fa7fcf5fc
|
||||
|
||||
COUNT = 10
|
||||
KEY = ccd1bc3c659cd3c59bc437484e3c5c724441da8d6e90ce556cd57d0752663bbc
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 304f81ab61a80c2e743b94d5002a126b
|
||||
|
||||
COUNT = 11
|
||||
KEY = 13428b5e4c005e0636dd338405d173ab135dec2a25c22c5df0722d69dcc43887
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 649a71545378c783e368c9ade7114f6c
|
||||
|
||||
COUNT = 12
|
||||
KEY = 07eb03a08d291d1b07408bf3512ab40c91097ac77461aad4bb859647f74f00ee
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 47cb030da2ab051dfc6c4bf6910d12bb
|
||||
|
||||
COUNT = 13
|
||||
KEY = 90143ae20cd78c5d8ebdd6cb9dc1762427a96c78c639bccc41a61424564eafe1
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 798c7c005dee432b2c8ea5dfa381ecc3
|
||||
|
||||
COUNT = 14
|
||||
KEY = b7a5794d52737475d53d5a377200849be0260a67a2b22ced8bbef12882270d07
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 637c31dc2591a07636f646b72daabbe7
|
||||
|
||||
COUNT = 15
|
||||
KEY = fca02f3d5011cfc5c1e23165d413a049d4526a991827424d896fe3435e0bf68e
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 179a49c712154bbffbe6e7a84a18e220
|
||||
|
||||
[DECRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = c47b0294dbbbee0fec4757f22ffeee3587ca4730c3d33b691df38bab076bc558
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 46f2fb342d6f0ab477476fc501242c5f
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 1
|
||||
KEY = 28d46cffa158533194214a91e712fc2b45b518076675affd910edeca5f41ac64
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 4bf3b0a69aeb6657794f2901b1440ad4
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 2
|
||||
KEY = c1cc358b449909a19436cfbb3f852ef8bcb5ed12ac7058325f56e6099aab1a1c
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 352065272169abf9856843927d0674fd
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 3
|
||||
KEY = 984ca75f4ee8d706f46c2d98c0bf4a45f5b00d791c2dfeb191b5ed8e420fd627
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 4307456a9e67813b452e15fa8fffe398
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 4
|
||||
KEY = b43d08a447ac8609baadae4ff12918b9f68fc1653f1269222f123981ded7a92f
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 4663446607354989477a5c6f0f007ef4
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 5
|
||||
KEY = 1d85a181b54cde51f0e098095b2962fdc93b51fe9b88602b3f54130bf76a5bd9
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 531c2c38344578b84d50b3c917bbb6e1
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 6
|
||||
KEY = dc0eba1f2232a7879ded34ed8428eeb8769b056bbaf8ad77cb65c3541430b4cf
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = fc6aec906323480005c58e7e1ab004ad
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 7
|
||||
KEY = f8be9ba615c5a952cabbca24f68f8593039624d524c816acda2c9183bd917cb9
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = a3944b95ca0b52043584ef02151926a8
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 8
|
||||
KEY = 797f8b3d176dac5b7e34a2d539c4ef367a16f8635f6264737591c5c07bf57a3e
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = a74289fe73a4c123ca189ea1e1b49ad5
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 9
|
||||
KEY = 6838d40caf927749c13f0329d331f448e202c73ef52c5f73a37ca635d4c47707
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = b91d4ea4488644b56cf0812fa7fcf5fc
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 10
|
||||
KEY = ccd1bc3c659cd3c59bc437484e3c5c724441da8d6e90ce556cd57d0752663bbc
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 304f81ab61a80c2e743b94d5002a126b
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 11
|
||||
KEY = 13428b5e4c005e0636dd338405d173ab135dec2a25c22c5df0722d69dcc43887
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 649a71545378c783e368c9ade7114f6c
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 12
|
||||
KEY = 07eb03a08d291d1b07408bf3512ab40c91097ac77461aad4bb859647f74f00ee
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 47cb030da2ab051dfc6c4bf6910d12bb
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 13
|
||||
KEY = 90143ae20cd78c5d8ebdd6cb9dc1762427a96c78c639bccc41a61424564eafe1
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 798c7c005dee432b2c8ea5dfa381ecc3
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 14
|
||||
KEY = b7a5794d52737475d53d5a377200849be0260a67a2b22ced8bbef12882270d07
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 637c31dc2591a07636f646b72daabbe7
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
||||
COUNT = 15
|
||||
KEY = fca02f3d5011cfc5c1e23165d413a049d4526a991827424d896fe3435e0bf68e
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 179a49c712154bbffbe6e7a84a18e220
|
||||
PLAINTEXT = 00000000000000000000000000000000
|
||||
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,131 @@
|
|||
# CAVS 11.1
|
||||
# Config info for aes_values
|
||||
# AESVS MMT test data for CFB128
|
||||
# State : Encrypt and Decrypt
|
||||
# Key Length : 128
|
||||
# Generated on Fri Apr 22 15:11:53 2011
|
||||
|
||||
[ENCRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 085b8af6788fa6bc1a0b47dcf50fbd35
|
||||
IV = 58cb2b12bb52c6f14b56da9210524864
|
||||
PLAINTEXT = 4b5a872260293312eea1a570fd39c788
|
||||
CIPHERTEXT = e92c80e0cfb6d8b1c27fd58bc3708b16
|
||||
|
||||
COUNT = 1
|
||||
KEY = 701ccc4c0e36e512ce077f5af6ccb957
|
||||
IV = 5337ddeaf89a00dd4d58d860de968469
|
||||
PLAINTEXT = cc1172f2f80866d0768b25f70fcf6361aab7c627c8488f97525d7d88949beeea
|
||||
CIPHERTEXT = cdcf093bb7840df225683b58a479b00d5de5553a7e85eae4b70bf46dc729dd31
|
||||
|
||||
COUNT = 2
|
||||
KEY = 0a8e8876c96cddf3223069002002c99f
|
||||
IV = b125a20ecd79e8b5ae91af738037acf7
|
||||
PLAINTEXT = 4fd0ecac65bfd321c88ebca0daea35d2b061205d696aab08bea68320db65451a6d6c3679fdf633f37cf8ebcf1fa94b91
|
||||
CIPHERTEXT = cdd1ba252b2c009f34551a6a200602d71ffbf13e684a5e60478cdf74ffe61dfded344bdc7e8000c3b0b67552917f3e4c
|
||||
|
||||
COUNT = 3
|
||||
KEY = b9ba9fa32cc491d8ac2beb5f99193d57
|
||||
IV = 95511452b71e53e93afad07ba1aa4d98
|
||||
PLAINTEXT = b40382705aaeea41097c309da6cd06010f15e09c0130fa4b3af69cc8da109d1f0f0a2661f1a8b89bab7e7009dcbb8a883d46254a830c45cd87981e0ea4e490fa
|
||||
CIPHERTEXT = 800bf8840a73c9279a9cdb61436f8af20ae17c5a9b95bf25e456f48cc3cc2f9dffd86c48645fa187cac5becd058e46554ae3b4825a1ef4467849c9d13536adfc
|
||||
|
||||
COUNT = 4
|
||||
KEY = 5947bbd78b06bb5ea2fc67ed7b24216e
|
||||
IV = 8e4722ad2230b15f2eea302173bc1795
|
||||
PLAINTEXT = 9e69423653c20c982794ed35d63c1a78e8ac14f37e1888ae4bf273bfe119891b2e4ed8ac46e7a9a463c7a710298d43b02f0c5606bcfc08adceeef2ec61867f8bede498e53163803f2f86fc58782fb841
|
||||
CIPHERTEXT = b23f0fdfc1519c408ee7a8ba46ea79f2cbea0032685af82f76a7e2b377741aaa618ef3953edbe39e8df1dd283b2e54a0f1327ce332188f6572574ce59428636f3b6e37054a4705b02bedf377e465e5f6
|
||||
|
||||
COUNT = 5
|
||||
KEY = abce650e78f969b3b210151c74117fd2
|
||||
IV = bc4659fbb7073c1f2185cd8ac5314bd1
|
||||
PLAINTEXT = 322eae07df5ad2ddd64bba34e42d30c1b884f842e71efa123345a3fb0c39884c57dd4c2c6fb0c42e69ff5a269d59af3a6144853c182edb376ca65947d7ccefae6806ba25c4f527706ba85a353c0fd10e3cb244dd93a2d060d7b055058dde1dff
|
||||
CIPHERTEXT = 40ec099d74b804fe5fc3810aaa6a1f66c5dd882711b1c95f9405e43cecfe14a48518f1077c97db0b3f69d4ed7a6d287f2b71b1cbfe62b851a343d92f50b94eaf16a6c39df972afa4c2e9cd3d171f62b3a2ca699c0219db8fb4aefc9aeafd488c
|
||||
|
||||
COUNT = 6
|
||||
KEY = 9f56e19b09dd3fee0e110f71e9967b7a
|
||||
IV = 1155cf4231bf7ac55d5e6eb27a974fad
|
||||
PLAINTEXT = ad1e4d3162a5084f581117639a13fc35df5449625ffe0f01e57d9a8726875be8515926ffe7449e30cd69ed4ca0c1b8b4486051c2d0fa2f6474a69c0afce2aec349d778a22edf81678145765b714c1b7c197287da56f59141d6978618729e1d89be20ace3de7d9b3c9b2d195ab6bc0fd4
|
||||
CIPHERTEXT = d9f0e125fe7f82b22d8f6084364388fba90809640bd6cb6331fe6eb2e4586b18af5f6b589aaeccd48e66392e1bdcc733e4f2ec3c7824a77323c757a147500d8aac31d7cee4be2d063db7f709bdb0abf63b184baa7ff3280e28fd378e4d2fa24688bf3bc4ab5d970c88728dfb2d4d61c2
|
||||
|
||||
COUNT = 7
|
||||
KEY = 31c485c996d6ceb2d17e0aa05b2490e4
|
||||
IV = 8c37f33405051b4c50abd16c6456643e
|
||||
PLAINTEXT = ac68de6a2c2144c6b4fd975a8dec93447391e7c9a4fde63d36be7f23ad186f96cd92b5e8adb546880d100329e97fe8204fad860e6dd8b3c0eed4805387536b9ccc63d6c74938b83dce2c93cc0a04a6025b7563d9e5e7239ae27819fb3844848a51e4294f273401ad9e592f8a170334b042f0667233b29f92b9b13262eb73232a
|
||||
CIPHERTEXT = bcb37030075abbc91a75a302e5afe7281f7fd594c74a09737ae81f50573eb144c1d6c5190e10a61587848fefe2d3b0b3c05629f78a16758eaf40253322f3f7a8d755034be407b2af3761c3e704419686616194482cca5f603be89a1f06c7a190587c2f9338d48bcda1615c4257728ec34f2ce6ad0b58a197148ed10ede6a6561
|
||||
|
||||
COUNT = 8
|
||||
KEY = 556ccfa360ecb5025032dddb124cad4d
|
||||
IV = d54c6fdcc85dc0a28c0b06205fee8854
|
||||
PLAINTEXT = 71fbf180effac3dca0d69d40e4017dbe50455396f9fb6507ef7df26507de156cded8edd41a05fb25f352cbcdf3b2d770f90fa87f84863e0c2ed3b2dd770a1abfc489ad1ca82a28d061bd7039a6b5788da021657136def0c78d0b0cc7cfbec9512cf579811fd01185f3fdd2ab857328be4b63d293956b43df130e484b9861eccb1d06992b095e7febb0fb394c1954aeab
|
||||
CIPHERTEXT = e59b831cccd4acd94be7a9ffd3cc3167a9b6e085bfb976500d25fdfa2782f89c420241253f1b8ebdbbccd184d88a9db0da2ae1927137d1c2b08646ad50791ab66f7f88c365d567e8a8cbdf9aaae53d4e4ce964f9a14bd30a3c7cac53b245443dc16628d697afe62e0ed83bad707ad53f64a627b52bd66fb29484876919e41f8776e54cc9780841504f8c6b481cf112b2
|
||||
|
||||
COUNT = 9
|
||||
KEY = 7cb81fc4b203b0fa9bec49759bd515c2
|
||||
IV = 4d5e2fa3bf73f488b3e7e125f03dfbbe
|
||||
PLAINTEXT = 362789b376d85eb8181d4eeea52d42e873ce7741c11a2f820383a7457b15489b09fb21ac4445959dc9e851b7d40682c50d7044bda46a5da39fae2bab73b3db9ed22edc7ec5da936dfa7451cb5f0a829ff0762738cc2686148f1e1f00dc3fe38139c9a173201fc1f052ca34736fc1ab3dc4e707f864d6119b7adb6c8ddd41c80de5d357d17e9c85ed7af1e4f72cb2656932ccce469202680109eef89a9f42f10a
|
||||
CIPHERTEXT = ac23259f68d4f82604cabd2e4237821c8b6c0aad0dfb1120b6b057223c994d62b5c6f63a25edbb797cd299f81ccb86d50134ad26107865142004c2d9d52fe3f91acf7b9b8111c8b4e14b05b173730e7b812036029846f1c1c6ffb30f6abcfc3e1ea631480e0d0bda106bb87319fdae09a11b89e8dde625d53a19c65ae58fbe3f4bcbc3c99af05cb0a7cc4b793d8cdb1cfa3173ede595c8c561f92c3fe3638b8d
|
||||
|
||||
[DECRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = beb622d0228cde29b342bbcf4c1c83b4
|
||||
IV = 75c282fa581d9c671edf5d540951b680
|
||||
CIPHERTEXT = a5dd69d94112f3ffc2f267adde70b996
|
||||
PLAINTEXT = 860476c81685b58e71e2599efe083ce5
|
||||
|
||||
COUNT = 1
|
||||
KEY = c4666081e0b0eddb10a9a607c807378f
|
||||
IV = 5f23623288e4a41b03186024755a10ea
|
||||
CIPHERTEXT = 7138c2b69191cf88702f7d25e9170dd6effdb80416b44f4d54e81fd7090f17e4
|
||||
PLAINTEXT = 2fd02dab9054248073ebc0b07aed383756ccfa4fa6298722775be6a9b4ed27a5
|
||||
|
||||
COUNT = 2
|
||||
KEY = df010376a6b03279338773a70e012382
|
||||
IV = 67455decec549365742525d8dbf1fed9
|
||||
CIPHERTEXT = c8bedc6e272366e4c584d2364fac4e2980359ace3a4ebc62d5bcf472b71ff2422477477058e61ad5d3b81cacf5a0bef6
|
||||
PLAINTEXT = 9b9c3dea553ec235db0011b27191544171845b7bdda0dc04a089583959bba5ab7048f8ca87eab073a8b824fdd4e82e40
|
||||
|
||||
COUNT = 3
|
||||
KEY = ff01aa4f7106c6bd24399076f901a530
|
||||
IV = 089b4f6054eeeef76d4e13f75de64f7e
|
||||
CIPHERTEXT = 228377c8fae0edfae8cc43e5a07ceefa5d8f1b84d33842e5649efe2396831ca4c524f1361561f153ab1e7ea21de9fec026dd30419fc6c0f2aa86196131b77aa0
|
||||
PLAINTEXT = ae9cb9dfa305af83e95a3b2099f70907edcd49fbc6efc5ebe744184c76b4f56bf35774f3fe215e1c8ee42172a2dd3e6f9ccd3d9bb044325e61a6bb97e48e9986
|
||||
|
||||
COUNT = 4
|
||||
KEY = d33d4062ab32298eafcca86b5088d5fd
|
||||
IV = fcfffce8b020240f9f694adcb8ddf213
|
||||
CIPHERTEXT = 208d49796fed810f37350b85d49c575f4d64ac973e02bde5157f7e3d811e3598283fd4f7998386a5813188bd21d93aedff377679dc592083e704fe893055ca2f5fa4863fa6ad10eef4f2f6616c5b8b6f
|
||||
PLAINTEXT = 1fe1318adb99e6d4fced292902fe8c831ba488a43f85964d6ff54b322663b380bc99fed15568278cfe1d0af795c71355bf65e876855763655eec3abf3d4b27a0341d607f4bfbd82c8900fd436f7c4186
|
||||
|
||||
COUNT = 5
|
||||
KEY = 47e13544a7bbf74dd68ab5ce66e5bdaa
|
||||
IV = 69480b4dd38cf3b47e2b7652751395ae
|
||||
CIPHERTEXT = 26a7b649fd8435c5dd29ba1683ae0fb515ebb6e45cdfc4362d53f35128baf2f3a65cff33ecb3b80aa5152e118f943c8c742317a85cfa2501013b136783d522e25da8c1f398eb611d3ecb85a4125518957e960406cd01009f9a11a95a882fd586
|
||||
PLAINTEXT = 3e2e583a3a0389ca324f2aaa52b7823904ab288dae562995cf1d70c796d785fd361261434eea480ceb3d369d969652c7ff194931c0a9bd978f5ae4094d6ef32d986a092c580ccbf865e5095a7b80559be13f842f9bea9e42a3a01ef8a24a6526
|
||||
|
||||
COUNT = 6
|
||||
KEY = ae86823695b48e8c612ae5a01b597f97
|
||||
IV = b26eef7b1d14894c0c6388ce5273f4f2
|
||||
CIPHERTEXT = 34a2642a230ad03d2c688cca80baeaee9a20e1d4c548b1cede29c6a45bf4df2c8c476f1a21a4431aed23661ce96342ef7cc60712f9de51c76a2205688ce67bfe1a8ae3104ef1e1b9a6347bfde498355d58be7aa9611a3e1632a6e291d2d8585266d187b3b3d7f143df05931677410c60
|
||||
PLAINTEXT = 569a910bc6aa97b8939ca703fc10ce0d171625bc735a1fea7148650541109d955b1b686c6cc404b2d3d92ad9faaff217dc7b31b038b770959aeccd1ca55d650364fde51df8d4f0aeb05fa364f5028f709c179ca6df0bdfc1cb850f238d755ac44a733fce558402be0c70bc0871b8e62f
|
||||
|
||||
COUNT = 7
|
||||
KEY = b85df29c9244229835d73441dc37555e
|
||||
IV = c1375430efedb2d311a37bfa5ad2110e
|
||||
CIPHERTEXT = 2a0ea682b6b22122e828e2b6e1574303e7c1d32f1563a6c751dcf0077fd2d255f492740e2ef65485c28cde4995f43ca74f8a6f700d469ffd57e0af6f5137153b35f3e9e700693b0e6cc0aaaa1f5232932255464294bb1fdba056536bac40a96dd37a2c9496d37ec4ce0c6f61e539cecd466a802c128bce6b15890380f8b737f3
|
||||
PLAINTEXT = c232a0bbf967ef28b74e7b809c62bc8c1cf2d52a273a84162900da834448fd567870471498f29770619dec504922e379eaba0d3a712602583d00279d8fc6a6d568cb94a330039a189ed5802abb7a2898c13ef89c00d73fca9a2f2ffc2107ab498212c56835c0fc26f835a69c00bb3eaa695ac20e8bdb0f5b5b6684d02bee8fb2
|
||||
|
||||
COUNT = 8
|
||||
KEY = e96771f5f20a89ee871261d2d18e1e46
|
||||
IV = 8c664a37d245d26c0c55adfb424758ba
|
||||
CIPHERTEXT = 400c6d6bbfd0a676bcb88d20e41151abfed50e951e189e1d1ba2b30244de228e4ff382d39230f63576ad4728282f363b914d105689d1823f4761af631c5f80d4620d3b8eaff558fe4e8890c5ef0536b99d9cca2cf1d4cc72852ace9dacfacd8b60a3c1237ce773db2c908f7da159fa2c090b65a2bee723bbbd4437375b79b2bb33fd3c1a63cdf0d3f80e6ddba6f4299c
|
||||
PLAINTEXT = 8aaafd56c5d5d54fbe16f115c3216bd1f4376666931a2ef1ffc5468ad12150c39250dca2d63c6ea166bb0ef4aaa3d5849c1f9c621c55826a1ca362f03bcba4dcbd654b300d16519710130e5360bd949aaded6a648f96dd8937a77287d4a4ac2941729475b635b9797476b4dca4171787ff15882d3b4872ed0999a7546dbb61698e8348f70e4a14981a78156150484532
|
||||
|
||||
COUNT = 9
|
||||
KEY = aef49da33f538ee66e178d4b6121055d
|
||||
IV = 842566e68b61ff7bf001f2642da62f64
|
||||
CIPHERTEXT = 6625811419bdee71535f597f7c228bafd890fd69b805a699ed58116a82bdb251abea7a4ef879a96fce8ee49518b9877a3a1e3cf346d3cd73738936d1cb6fff4b2353c8ca500a26689813ad2f67774e2343f3e4830259094d3b342e00faabeba5b8a893108a390c649836ddd5d12489b2dd591ca25361032e2da1207f793a1e69513002a90ccc036bb63e9c10be87df2def960cd7a1b1621e311735d7aee4419f
|
||||
PLAINTEXT = 415991f65e1a95040cef9960556f61e617827c30c74bf353cdd86173dbe4cc983a2ee6bc8ca6cfb71121e7b0d0178f2e13445c710dcc176b781201971171f7489f18faf110f39accd1cf08c85a958d7698b116f1c0d75812ac9b0b39aee7f7159ccad8fdae9b99f2d695eacf12c6469d5b51a34de26eac73613dcb2f77122cb1f8dd5162786a12052dc7b6dea6acc4989dcc7eafd9374f6c29697c74749ef16d
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
# CAVS 11.1
|
||||
# Config info for aes_values
|
||||
# AESVS MMT test data for CFB128
|
||||
# State : Encrypt and Decrypt
|
||||
# Key Length : 192
|
||||
# Generated on Fri Apr 22 15:11:55 2011
|
||||
|
||||
[ENCRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 1bbb30016d3a908827693352ece9833415433618b1d97595
|
||||
IV = b2b48e8d60240bf2d9fa05cc2f90c161
|
||||
PLAINTEXT = b4e499de51e646fad80030da9dc5e7e2
|
||||
CIPHERTEXT = 8b7ba98982063a55fca3492269bbe437
|
||||
|
||||
COUNT = 1
|
||||
KEY = 69f9d29885743826d7c5afc53637e6b1fa9512a10eea9ca9
|
||||
IV = 3743793c7144a755768437f4ef5a33c8
|
||||
PLAINTEXT = f84ebf42a758971c369949e288f775c9cf6a82ab51b286576b45652cd68c3ce6
|
||||
CIPHERTEXT = a3bd28bb817bdb3f6492827f2aa3e6e134c254129d8f20dbc92389b7d89702d6
|
||||
|
||||
COUNT = 2
|
||||
KEY = 9b4c9e6410828173019caad0a2cd13dce21f318bf8b428c3
|
||||
IV = 10ba56e67d96a0b25b71ec7461bc3b3b
|
||||
PLAINTEXT = 5174f3f2eec0e7c894955401ac4b7fde3f5169690121f6088f734e53f5b1842373ac76eb818df44c100e24e313ea2466
|
||||
CIPHERTEXT = cd9967de6341671ddc172db19d0a1d432f57accfa6e931706f5f73caf78b4c8af0ad7ef9fe6a1e9b58b0fea85818b747
|
||||
|
||||
COUNT = 3
|
||||
KEY = 4484cc09871c23ee5d4fa54dcba023c6c6bed7baf64448a6
|
||||
IV = a017d75afd41d915ca1fb17a131f648b
|
||||
PLAINTEXT = 477413f19b8015ba0a12043ed1feb8fd41e696dc7bf66e7878d2a4b94ccd8eaaab5c1e88accac119cd2d863e379883cc449275983fc7a6d16bfe1493464bcfb8
|
||||
CIPHERTEXT = ae999a87b71ff778b1752df9c101cd3b072eb449f6c46578eb5b272844be0607831a89e937996b63d334c6cc159e2a065c9ef2858c66766c8d5c47706456b588
|
||||
|
||||
COUNT = 4
|
||||
KEY = 91b7e6a205c6b3907be709a0528aecd949ffb733452f06f1
|
||||
IV = 38cd832d3ba1b0ee670ed385d94e8e25
|
||||
PLAINTEXT = b5ec2ea7afae2167e7da5bc2fd68811ad86ee5c6839ffeb73b12165cc64643c406629803cdc19cd6f3adfb8aa66b7c1902793397e113f8ccf5fb1823147a4ac3d2a2e4fb55d74ee3658eb740c35308a9
|
||||
CIPHERTEXT = cdf42c51d7cf77fb5e8e9e98abb8a54ead22fccce9ec9d4049550e4fba48af42b03274f318e58a9df541a7e8d60a781239542fd4cb8dbdf7acf9e7401349e5f5118cdb5ee64b3d083cf65e67080f7b83
|
||||
|
||||
COUNT = 5
|
||||
KEY = 1c9281744ae9171f3d6faa3ab3f88c5c34fd23e4f6efecea
|
||||
IV = 8ce3daf1ee9e451a6f6650176114fb34
|
||||
PLAINTEXT = 1105a24df28300e93f78d0af8cf668eefd6131bc5b2d58df66e9c6ee6d7d53b31db036d497edc0b2c5464b92edb96dfb86b2715e4bd207fd8fef3a05d05ca3fd8e6adc645d2e38963a85b1f01b562234ca17b72ff293a1997aea0e3c13d95859
|
||||
CIPHERTEXT = 3e8787cc776f480890761418f5e408f630fbea7c504248f463e41ba22f993a0c7662cf9b58362afeade3743f027e63b12e8c9c33db1658f2a66df6400851f35843bcc240a1c12f453399bef1757608c778c5d9c15d4074e3a469c56e93b3e8d8
|
||||
|
||||
COUNT = 6
|
||||
KEY = 68bb0d29ce68ae8c0bb7ed8a285e391f3bee720039555838
|
||||
IV = 13c78c4bd70b595e7106492d654389c2
|
||||
PLAINTEXT = 49172017ac70ca3a1bd9b0644c7c66a795a710675e727719d7a35c49e6ce0ce264c134aa881ff70ca34a3e1a0e864fd2615ca2a0e63def254e688c37a20ef6297cb3ae4c76d746b5e3d6bb41bd0d05d7df3eeded74351f4eb0ac801abe6dc10ef9b635055ee1dfbf4144d0e24057b03e
|
||||
CIPHERTEXT = 29a4dff0abebae9648e1f609e7d47005a0dfa9bda922082d38df365c48320db28f9b7b4b00e98adc82ced09223532d44c9e46317529602b2603e208d275547a85f5713a4f07d6ec31755eb71b5aabf3433901f73cbfea640c589875d2b93c32a412f05a853059ecee7166bc8a4932f96
|
||||
|
||||
COUNT = 7
|
||||
KEY = 76da852fa0b0494f3e1c6ee898db09cd0b6700594d25704b
|
||||
IV = 5cc5fafd42f3111a04a845c28016934e
|
||||
PLAINTEXT = 030de1c080d602272e63d76d498d2a487fdcacb2ae41dd3ef0082badd5085ebcef1d334194d84776df743795f80c06a5950cbf93c1e65b84dd06e46ae407dbd5f327d80d08f8705d09595bb109a5d664c82a475378dd2036c74b053019d331a41513164b64a04383b5fa8bea05bf642c1d1e8d195c8ff4fbb6c1d626fdd428d0
|
||||
CIPHERTEXT = 0d8122ac2ab2368c98224b90c09627f6e7ddcba65cd7e512f77b314af08a784d9495f5904754aae146f81e06aa7b4f24166ac0c8a0fc2273138cdd67da1f60ac408189a1361db34792fb0d694af8267f5a5eaadd3e97174a3fd6bea63738f46f22c6b242d2481ea57b64127a8bc4e0cad7ca3fda5a90e345212fb38378bb2cbc
|
||||
|
||||
COUNT = 8
|
||||
KEY = dde0725789454bfd49304df0c7f1999c50f0064f8895723f
|
||||
IV = 3bdea6e648ef054fbbcd09b098797a3e
|
||||
PLAINTEXT = 8fd514121877b6d518dd905f7035ace68d06ffd63cb9e473c057c9c0239428a0c90dba3c4bcee7a4821780b9e160b04a089a307d97b8bb71406ec2212138608c509f9013b7b89e2222eddb1296ff954ee54c46b57f4e0c408b6559e536d6ecbb4b13005e053dc39521e70932361d423a49a4a9469c84bf29c8c4f8d30b75b476e3f270e7dc653e46a68d72e16abf9f56
|
||||
CIPHERTEXT = b2e50639b70dee32815f25e9857701afed3dd63e1d241494f9aca87d88177ea91a205bfd1290b1d914a3fda5d8c02b69a64273af2c91c7ded314afcd80863ade8a6f595254b99925d088783f6f235b7ee0a90af95e1bbd0a4ac6b1c8e6fb6041343186f9069e9af1624af842d2466de0103e81fb5e608725010ef6fafaf69d256a7b7a038a649c027e8605152da92806
|
||||
|
||||
COUNT = 9
|
||||
KEY = affe25a7b28fe7427aa69a89cb87bc0fb68c940d63d319b3
|
||||
IV = 89e612f77ef55ee86935d90a8c7466c2
|
||||
PLAINTEXT = b5719702560b8b214c73b9a2ea7a43707b10e0b79152d1019ac4179fb4dae34ac3be4e0ac04d4a575462d87ea5587c4770caeed5589d13cd7d412bbb51334cb1a7c70f310d24894c5c907d0c8deecf10ce843c76d50249fe75c0796b6f48c32d8a14433ee699304a8d840e124b432512c0c73161b3885bdaa9ca6879b61f3107942e53faf2b227970ec6f559865f64966c1a3560983831aa42e660abd0c27c88
|
||||
CIPHERTEXT = 5bc958b594f0e4928cee7c019ee1884bab9b6956f40c47f24c1b8ef587d68b175dbc36226b7d95e573702f5b0dc969a8c59b82816762847275c95234e3c74fba50841202c27264131ab03773b4e28ea7c68ea946efe2e2d9a89643d98c5dddd075098a930c741b535ba96ea0a08ad0cf68d11e8e98e26d0a79d3a5ef65dd137cc6c82a4e8edb1a63e9bc6e8705cef59b4b4c391924ffd33ace99808cc163272d
|
||||
|
||||
[DECRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = ecb55ffe3f5209c2eb9e6dfd46af1b90fa8fc5f1f2904623
|
||||
IV = 3e676d0a986a7308ae3cfea460d08687
|
||||
CIPHERTEXT = 0d9db2153955148d3479a90f2d4d349f
|
||||
PLAINTEXT = 4c42e9650b1a288fa03ed205a6352f7d
|
||||
|
||||
COUNT = 1
|
||||
KEY = 7413aee3e2fe9484482f1118abed66ae6c622365be423c2f
|
||||
IV = f37bacab2e94476d6b8c86744861053d
|
||||
CIPHERTEXT = b210485ae530fc44549ada94e3b08ce020daace326d6cf76c150c2bcd2b3139c
|
||||
PLAINTEXT = b92cf89ab52013a061a192fc0b60aa46c415e4084a32d527d2507a24dc80a4b8
|
||||
|
||||
COUNT = 2
|
||||
KEY = caeee8b93d38608c4abe082416de59620d2733f53261d17d
|
||||
IV = c0cd2bebccbb6c49920bd5482ac756e8
|
||||
CIPHERTEXT = bc01b40aec081aa00f2e3bc63ff61ac4b684dc7ae05f7c46b475c02845606c2494e7b5e8a9c8f8afe2b5ac658a9c960c
|
||||
PLAINTEXT = b7872a761fd09d4c60649454a099bb85081c6404299be361cd7f183339bf50676533f4619876e5758ba8d33f36602f5c
|
||||
|
||||
COUNT = 3
|
||||
KEY = a2621ee7c5eedad2e331760e3c3e49e8fa63f7c009afe8b2
|
||||
IV = 2bebd19cfa12e025798209811dac8751
|
||||
CIPHERTEXT = efb41a379f1eaf41674fbb7fca14e7c4dd78270942e547b55a8bc71cb705e845d03a07f0f9822ad7920bd9357e7a2f85d7d5308cdfa05d993a46860c5bbbe015
|
||||
PLAINTEXT = a070b01f48ad5e440017c94c77cb3af654aef9094bce94796c75c5d6f66d2172d7231cc92ca273381f3b15166b82ee6dba8810422f3cb5e3ceeb42f40ae25675
|
||||
|
||||
COUNT = 4
|
||||
KEY = 2b28a2d19ba9ecd149dae96622c21769b1927335f02aea51
|
||||
IV = 0cd6dccf5650a122b857415ee661acc9
|
||||
CIPHERTEXT = 36161b4d67bacd9d82845d611b47a41b7cbbcb66a2726889890de94caaaf360bc1b29208d399c20570467213366ed4a596498ae8db8ec657679eb08a40ff084ecc0d0cfbd9ec9c02e0c19cc68b229aad
|
||||
PLAINTEXT = 5446fff3320239680c19a5519d3dfd3ab49f62300897f626eb0c9595e80c563850a9d361c6b974853abd42e6028ea4374852ccbdfca881c6885e413a5e8db53d4ffa727cee3bee0bb9ee1b4bdccb4a68
|
||||
|
||||
COUNT = 5
|
||||
KEY = 9444991a091abdfeac81d706d58495b44cdaa39aaebb2aca
|
||||
IV = 1ea984af6c290566d777b0eee984faf2
|
||||
CIPHERTEXT = 11aae8806d780f98c4d9fbe8d7d69d6f3b054afe08650e40d58a44f9e3fa638b98d61bbe2fbda1c0afed476b19ab4fc7e6e601d0b017fb79306bc9f06824b524213ce085984c920a75adcf79fcdd2be38724df6d34771b57db9c9e36438f8584
|
||||
PLAINTEXT = 4c4c359b46dc4d30fd9f9a1895a4deaf0566c711c52fea26385720a87f1db0ab67df050c99738cb3c9e74f36e7090025b8ecc627c58f62ca05ef4365ed5d7ae1a2d0fdeb8b5cf55c20deed4a20a7ebbb3f14869e29c9bdbc5bd22ced264bdb5b
|
||||
|
||||
COUNT = 6
|
||||
KEY = 579dd4091464cd7216e109e48b5f389fc4bb510f896b83f3
|
||||
IV = 76b8af440963c7f356aba0942e2e31d2
|
||||
CIPHERTEXT = 8c3019927901233f4f2216a895114460dd277b97eb2640481a1158b3fc408d0e41b3ae78daa7d82e5e67f401ac658108d28994922dc91c5ed2fa6b0f2de5f2dae89e4c820e117f8671de7e994967f2521d263925e745af9273682d9c08ced07d4a98fc985f68a0af512ebb56b33f1fa7
|
||||
PLAINTEXT = 5dba3a42779e60f594610ca7b48b1face6e335a9ed0d83677b705b619e76853bdd4130d5ab4ddb1c12e8bdb0b84f2999013e5c1aad56527cdca78ff482a11665886c356c52806ae419c906a38f0a4da7df49b818d528f926b5aa1fe107bfc2d6fbdb1a24c517eb9b075495bb723264fa
|
||||
|
||||
COUNT = 7
|
||||
KEY = 5cd37a0f9e38067f5d165ddd4e599387af5967cae6f60e9b
|
||||
IV = 79d74d29105a3080444de5f56d7b9e3e
|
||||
CIPHERTEXT = 151e5ad05d9830b8a21130c2abc4ee3f53accf0cd5af716746174700634184538d993b3612c6c4aeae216107526c212423c10513c6c862e4db2d86bcc7519e25b740d8a8e2e4c49e0e780043553e140c29759b3b9686a4b0c77e5702ccc0dcce9afc784f535bf92fc8fc559d3da48ea06cb1d8abcc50fe7112f002faf8f704f7
|
||||
PLAINTEXT = e1f3aabbdd40d63ae1f4f2ac1abe9284ebcadfc0df1542d8ef5ba5010f89ab584c8f2c09e4f495e7f55e4085fa5fd43a279c11eb3fa4cccc84d45956a39b9ba9c5693cde86d8bc2b68278bd4afe9d4a57ff479639b8a92b4f2c5268950aeb4fe513397bd45a27bfba94bd26ede389850d5320db3472e3533ad5c134162c224d0
|
||||
|
||||
COUNT = 8
|
||||
KEY = ec93891882b2c8c67df894c882045ede26a9008ab09ea067
|
||||
IV = d96a0dcd84afabee6e4335bfea402c51
|
||||
CIPHERTEXT = 0a5d3e3ec164e844e49ba13bdf50d4f014e99c2124192d476a5a70b3c997eddca828eef83a04e1c90332ffba98812b2aa6791d083591bfa02ea3d7b41b9ce7cf2f7851d6866ebfe0ad67c24765b5ba00a402f527dd861bde817ec958c6d97c31a734b1012c084a30eb22340ccf544718186b6da7a36007aa6cd38cc751b473ab194454a0b43c4a62c44b9b2e5dc69b1d
|
||||
PLAINTEXT = 9fc3a98d8e1d00b85836b9b03d3399d671c11e7812efffc960312d2d59035977e44bfab83fb2cc7ef8abc2c65a8eea992fc8d817ca9bb4471a5da409342a4ae0a6d21a85de72a28d90b0338f2c57c518a8979a01f216e653e20b0050202ed5444c103a7379fc00054750999caa71ef4705b740f5678e5fbd78f91a56edf1687bd26082bc59cb744400653339f6fe6845
|
||||
|
||||
COUNT = 9
|
||||
KEY = dcc8702142b29e1529f23c5c3766464f6be0d2fbb16e4682
|
||||
IV = e0818769d77f2315924cf81a3691e275
|
||||
CIPHERTEXT = 1a22b1bf5775d43c66f1a73084eeefdb3ed24cebd9e2bef2f05867165fb5930b6058f53ef4503353856fa6d2c99f5b1de9795da6e314365e2d1bb3719b23e830823b744e1ec406503183203fedf41ba014e16ca65e3425a51b0abfca1908160ac8f2b5589c79541bb3559fdfb894394a0732015211e994ae024a138aa20d267f79a640c23719259c530eaa1af128bc050993a414c6dc89612c06371afeda1f79
|
||||
PLAINTEXT = cb550111bf0a03eaf4f49af214fcc05a32972d7b4dede3e9812a27ef80d680188119ead562313e400fe0a0fffbb88c55a42bd681d5c93a8a61ba909058e62d99fa109cfd49935b150862a8aab2c301b9b0a9157c838491cd737af438cb66b1f20420200dbc56aa66552ce4be04cace4ace5bfbc617e3b27f40ec6dbc85a42b410dcb7ea0b78d472297d9b98875d636b8ef08c254ec9bd05bfda01bb38e8beb6a
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
# CAVS 11.1
|
||||
# Config info for aes_values
|
||||
# AESVS MMT test data for CFB128
|
||||
# State : Encrypt and Decrypt
|
||||
# Key Length : 256
|
||||
# Generated on Fri Apr 22 15:11:57 2011
|
||||
|
||||
[ENCRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = e1c6e6884eee69552dbfee21f22ca92685d5d08ef0e3f37e5b338c533bb8d72c
|
||||
IV = cea9f23ae87a637ab0cda6381ecc1202
|
||||
PLAINTEXT = b72606c98d8e4fabf08839abf7a0ac61
|
||||
CIPHERTEXT = 2981761d979bb1765a28b2dd19125b54
|
||||
|
||||
COUNT = 1
|
||||
KEY = ae59254c66d8f533e7f5002ced480c33984a421d7816e27be66c34c19bfbc2a8
|
||||
IV = 821dd21653ece3af675cd25d26017ae3
|
||||
PLAINTEXT = 3cb4f17e775c2d6d06dd60f15d6c3a103e5131727f9c6cb80d13e00f316eb904
|
||||
CIPHERTEXT = ae375db9f28148c460f6c6b6665fcc2ff6b50b8eaf82c64bba8c649efd4731bc
|
||||
|
||||
COUNT = 2
|
||||
KEY = cdeda3ecc356c6ac4ca56187f4410a4d9aa2323fd21ba77b87f75cbbe5c86d3f
|
||||
IV = e5ed193d8c5aedafa405528a381fcb12
|
||||
PLAINTEXT = c198f566ea881d4390172a30d474dff034af593e5470f21cfee96668670934b0b4f24747bcaed698101d89bb3932dd46
|
||||
CIPHERTEXT = ce62fe00eaed5a8c639e3179bd75216cf8e60b42936ced7cde0e803c923dfcfd46be83782519e4997dc741e22c10a172
|
||||
|
||||
COUNT = 3
|
||||
KEY = 151a6d82846dd562dfb14d7096236cf5a36b8bf4c9cd2a0319a3905abb0bb22a
|
||||
IV = d1481313203fbda4fe35700b84a93e62
|
||||
PLAINTEXT = bacfb585c07fa2098e3e23826e01f31107a208202f710eff00eb13cf2ec984a0973d58d61c788bd1b06fcecdaedf7d06708ed1201dd557c7c25ba093a5233a2e
|
||||
CIPHERTEXT = eb3f304da9aadbea00b40072f0c3afda70e2fe45c2387dd03f7919ad2731efbd9ca81dcaa8e13ce15acefecae6d680ac47d7419f3740db68a8e67ce121d366fb
|
||||
|
||||
COUNT = 4
|
||||
KEY = 29849b91ed551889f79e4625f663e8a678118cf8080ec9e49a93c6872abefb03
|
||||
IV = adde8ea70e3560ed4b8f5f0cdb5ace8a
|
||||
PLAINTEXT = bcc7d50886394b83c2c048189da18bdee24e4f71cce8c2981802b8255da8a11da09fb81923ef7eec7f9f6786f2c0d319faad3f7a2390bdc91d28a15411ca7eb935a6514b9f4cfbb7576ff5e8afe83f27
|
||||
CIPHERTEXT = f975edf2d5ca7282599867c4cddb7b99de01e357ea93d4132b6a1718a4cb3d743a5603d6aa556180d84771ed5a9a0caa12b925c9d3fbfe4c351088396697afbef21fe07758c8cc68929b7aa22a6e5837
|
||||
|
||||
COUNT = 5
|
||||
KEY = 3a11ea3214add767c00bd372e509d4bc59f38598364af72430c49370259354e3
|
||||
IV = 49c7ee47c0f3f1e532fef3bb5bc03692
|
||||
PLAINTEXT = 5a306de98d4851fe4c50b1b8d4dae5dd5c98ed40027a06fa06177bf8364ebeb6a92db749b0115ca30a0f82135793f20bcf47c0263437d8690532dacaf57328ee9c813d376b5340fee5b8d81d0cf643b11ab1a21e720f9753d61a124fda6668e3
|
||||
CIPHERTEXT = 8c77e767c1a2f6adc1727fd440fb019b93058e0a36a059ada7f7453b9f0109735f318e442a1209466edce02e17abc1a7809b28585ecefa0abb0543643787dd84cf9089d2defd5d3861dc15f9b4a0def50423070594f7e5f611ef8c021233c288
|
||||
|
||||
COUNT = 6
|
||||
KEY = d8feeb749dc688fb28008f11af560b5bcb4e81262b2938648a0cd8f0de5d371a
|
||||
IV = 327beda3900f6fa33d3c8ba572295ea5
|
||||
PLAINTEXT = 3398dc27b0ce77e120d97f8c1654333ce2a182f605881d71e820d11dcdf31465055dde316335bab0f2af1c54e381f51ec945851b091f702f8b9f1511b6e91b979c134c3471cea7bf4249b075e3520b422abf493c5a0c0270e24524e248268acf6082d135c1e16796796de4f8000f9e30
|
||||
CIPHERTEXT = 3c912c51ecf32a3efda9f828e5445b4950ce099eca9feeaba4f48bba2dfea031786872054d4021a18330e95b54246228fbad1263581943e071006f799d25ba235a4f271bab056b6918e9e89950508e2c9a0197d71834d163f0dc8bdbf3bed5809e24ff1617a702ac40de9ec62541776e
|
||||
|
||||
COUNT = 7
|
||||
KEY = 533bc938d1c65b3310b7bcb2f33706b488e7e48edf6aff911d25b9e7cc421ebe
|
||||
IV = 2955458d1f1561693bf46a961872f42a
|
||||
PLAINTEXT = 6df0b42f593be79951ec4183eb589408268c89bb96e0e4e0c1cf09ddc805bfeb4aba3511853f4353bed6f127e3c73d2870b0190e8f1db4de8358fa5e46835ecc71e3d7cf5d7f28ae88ea65c03a5db32468084fb1d8aad2308660b3c947ba0dbcac14a2522924211276cfa43736417d62d73c328db9b0c640928d3a0711d55423
|
||||
CIPHERTEXT = 9c0c9256c333e1ff373446814649bda9c068bcdc879f9de394982c30b1a2f07f8aa0cea58c383105a7291f2ca149be9b2046efec9680b87c9c9a54e2118d510e498c3df43bbb423592f19357dc98c43ed1d90df2f599fa585a14b7335dc41df1dd0c8bba085b3a978578aa065d44d6c59f6e9a855b201c2ef2ac1a5f51808546
|
||||
|
||||
COUNT = 8
|
||||
KEY = 3938ac6c8326b4196cdc841963572e01338af2e635b80fd8c321d9acefe00cff
|
||||
IV = e9d58688ef6729cfc909ead7153b5bb5
|
||||
PLAINTEXT = 8e578a39840de300fa8d0208fa856d0b65272162432a87255711a594f6af91b51aeb2c3fb3c10cb73d89bad9977c1e391374372acaf310df3267efd0f2accf5ff4d310bcbc226e06f95b30b35a42a131a359c4cd00ee44d59957aaf9667dd2f74597a0784a38ef34568cca5debdedf3b3e5e30148e220c4eb56a3ed7fd2884c534c0433a030c788b7ba3f2a1f15bbf9f
|
||||
CIPHERTEXT = 8679e834f0b4e0f6e8b0d21312b4c372ad898e2da62581333fd221035acf96dd97da56be50836e0fd2c87cd12e00750205d3cf3a55dd1c183ba421d5dc9d8c7d34f98d3fd73c4e02a0a1bfbd4534129227440adc8a1b70dd3bb441de32db53567aea5f880ab05a6c9c166127f2c14d032286469383067f4268472510e5baf30c2905c04ca02a7d2b88ca7c171b11d165
|
||||
|
||||
COUNT = 9
|
||||
KEY = 04c4499a7a10a319992258726191f8087af1182ebd48f43bf6c158dce8a5c0af
|
||||
IV = 7fc268d6599fcdef7457cdbde5b9c5b6
|
||||
PLAINTEXT = 04a66003969bbe72eedb638fb188bea1564d96df873994e2cacd02596053d2ff6d72e2ca5a007e65781727e1e66b92a8b4daf4b248457dfb019f22341b43a0b8d38bbec3cb9ed2deaf89869e1992dc8eb2c8706a9bdffe8e0b3b23ad394b68c67c187c54b01ec1c6dd5a0a2e13a4a43d983f936f46af1d832eca8d2e81123110b142a5e7d327530348b13bfa9c4af09cae66e329115ce4c2b374e61ebc41037e
|
||||
CIPHERTEXT = 5235639833e022fa28ab90d2820abec07d2c3185a9c6e17618b8b68fb221bb5db242ad18c535d7694d1306ec26afdd459a53bb460485249c4f5fa73d41a0d6cc56988949f7ad82259fe3a3226f0bd8d479f40a2bd36400075981206f50f268c921338e91613b3a3c0cee1c0ff6c4e1d30c4ca0f9a311e9586d9ed29dcc876fd09eb6405023ebc180c5635d4c7987286080847d3a74e9deeafaeec0697ca8db75
|
||||
|
||||
[DECRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = ec89fb348787cf902ca973c47081438da9596f2ca51a4f699c6cf6d8621f095b
|
||||
IV = 94144fdc266588f0f4221921edd085be
|
||||
CIPHERTEXT = 939bac6c09892f39dba665383da24846
|
||||
PLAINTEXT = 759616b0c07b103256002b5f7e0cf863
|
||||
|
||||
COUNT = 1
|
||||
KEY = c0e821554e1656bf3432d3131d12aa67d029126c4d4e155118be88e4d56540fb
|
||||
IV = db2cfdabf025a53be690c3036baab1c4
|
||||
CIPHERTEXT = f25ec30d70722068477b9c72f355af8de207598c29a471bb766f3b2045423801
|
||||
PLAINTEXT = 3e5ba8e7f414010d9928101de1cd508e09db27e4a7d8a713d57934f692c6478b
|
||||
|
||||
COUNT = 2
|
||||
KEY = 9cc541d52c5dd9291a185eb952fb4f5474fc5f35e2c026e317a915553a10af5a
|
||||
IV = ba61991716e0a2af80517bd728396d4b
|
||||
CIPHERTEXT = 78fb1c2f440bd0a46e33a9658809f651860759582b30d53ac1f627910d5c5a1282589610b57b394111d328c5cc116864
|
||||
PLAINTEXT = 37b085dc650ed9110ab62c6d1394325a4d4ce583ba171c87fd09638fd933d356c96d3f392ff2174fb9aaa8083c05057c
|
||||
|
||||
COUNT = 3
|
||||
KEY = 764b93d185178639cef303ca426490c4b046a78a80b309a5a326560ccae0dba2
|
||||
IV = 557d3d096f0a461de7cace679b314b1a
|
||||
CIPHERTEXT = 34e31cce15de96667b603a3cf15499b124475adaa21e24d6e204be5f85a7749edba4bd44a93f1cd629584448539b7fce5bf650ef7b5057dbf27876fe4d5b32d5
|
||||
PLAINTEXT = b39b2a4a580168582b4e2f6afbd334d55235b611bf2178e00a6ca4536647a602243c51f410191d6b81606f90a0826e514ba1d3adbd12d1fd80f38405dcabe3c6
|
||||
|
||||
COUNT = 4
|
||||
KEY = 833bc19499fcaa8dd02ed124242a3432973b07e925bb4b14f978a2a0e15d625c
|
||||
IV = 53abdec019c879565f195a78ebdf0d92
|
||||
CIPHERTEXT = d03d8b0fad026448f2a663cd1b4388b0c396eab769b39faf75f7e002763f698cae571fabd0b6f595086810ef3c4b2a9b927e34d132173f714d149c975e954270af48714d1f2495f6245a6d410c886ce3
|
||||
PLAINTEXT = 8e2471920bd3398146f98c9cc90f7dae4ffadc0b1c8f7b5f8ab59c8d33942f9f7a565e511bfb19dd91f85fa7f4adc381242e09d3c9967c65cb7306f2b1fe21ab81f9e227205bbf6650ac174a3e5657d2
|
||||
|
||||
COUNT = 5
|
||||
KEY = f36b3e451e76b652d5f495e7bf7c6770650791d0f0a534b0346f5416eebd3a39
|
||||
IV = 6bbdbc908f4d513b8f8733246982ec3c
|
||||
CIPHERTEXT = 0d62daf9362227a9a696bf46da1724a172941ab68892a4d441702efea1f00c92a4f323288a84e6bd721885112a14604d4690c2e96f5bcccdfe3fafb6ca861fdc3dbc04d2aeb772adead5db6814858387b00935fbfa7a35467c0c75dfdf930bd8
|
||||
PLAINTEXT = c91334f7173bf05838e079554855fd100c9d32a2495c78e6f820eb3f508fc921bcc11b96631e357e28987d9f67415d7a61d974bf87d4b2beec05ba32de63aff49edd4508cf30899d2937763380ca65b550b0addaf6300e1cbd936e883435fbf6
|
||||
|
||||
COUNT = 6
|
||||
KEY = 1154d523b8ad1b9ea21e837723b4b34cb31a7e384f6a63481c4356334e1cc445
|
||||
IV = f46557dda8e63c34d01fbb79f9fb640d
|
||||
CIPHERTEXT = 30cd5e5f6e7f4300df71db26dd6478305c4ec46f7ba2f88759d14e182a11b89e8a5dd29610bd15e327c74e6f19664f156ddae5bf73000acb1dd45bb41034cceefbe79a1128dd813a51b830aeb48cfac169e3cef7f40569681776ca69eabfe6682d719e18dc68eecf044d672cd65edffc
|
||||
PLAINTEXT = eff0ac9c78bcad5f2a288d0bedf5dbc7075f626b6d07bf04737723c5c5ec99acf650382cd4d8ed0337afa6d43a02ca5d66709630334a662ae6f794a1e1e62551a7234364cd9da2005513934ec5743e08fa9772ddc0f3f9451a3260d94a5e96b27adbfcf7a18ad98946f2f592639e8ccf
|
||||
|
||||
COUNT = 7
|
||||
KEY = 36c8e29719a11210da1e96d4dc6cf51e01304c6b63709f7f45b06daa495b8749
|
||||
IV = 56a4b38b285765585c2bd96d03c1bc1b
|
||||
CIPHERTEXT = ee5673108c8ce0da35bb1827b54f6469befe36988205628c81b58aaaa02fdac27c6cf638fd8031622e1f00324c60ae151dc1511a826bfc5750b836895cf3abfad55f22a8d77aafa33c822ab7b639df4b1be68789ff9c78bf88be18057ec39721a237dea74102c26508ed7efd1a6260d46073c22b201f3c8cd2d018682f2706fe
|
||||
PLAINTEXT = 1ce5cd0d02a5963fa0007430973527a48557ce25126a568b09724c2e592dd6a3c7b49ccafa03a63df54e4ce0392aae7e0bff05428c563a0f7172ec805931885a3590e31774e48ce248c9b70c856dcb09a1cbb0d7222f49543ab20bda6ee1718d044098401a05a943281be5985f8c18fd2d309c0df17e1888651be6dd672698e1
|
||||
|
||||
COUNT = 8
|
||||
KEY = e1f4436ca31dc14e2d29de76793b0141bbcb920641fa02049e220c9807b23bb4
|
||||
IV = 00c98095550b3929a05bf72740ed2d06
|
||||
CIPHERTEXT = b86d66e22951548b102f3a930d3957c902db371b7490360834f940583e30da0ae15a668e207ba234598f73e524d6e1117e6f62e827285bcd4895e407595fccba42dfdc16c0eb60cf0bf0e4cdb6413c24d6afc746665af478eac70482533212ab232551e4d14996446f7d16b48a2570ec52c4ee9eface07f062b72930f450b6c3cc534d5f1b3c4a7bcd5b90036928864f
|
||||
PLAINTEXT = 48674fcf0eba774ca9d429455a1a8d5512d66651bcc425a0a6a4bb664d1670ebe34916b540c880711cb39525f7e71905c122e00ee92f81bc08824ca11a362034b42bfb519fa73bbbe8a7533324d03b50df2458b7fd8aaef05fdbf7b08bf7b70c32ab495b6a42415ff5f8bf1b8d82b3469a955fd6b2af82d9676793c4b20d6726136ab1b024fe1fd7a387e18a570733a0
|
||||
|
||||
COUNT = 9
|
||||
KEY = 4d3e4cec63edafbb4d600007e95124f554b352ada4966a60da4c898912cada73
|
||||
IV = 05aef5ccf46298e0feb58d77122b58d9
|
||||
CIPHERTEXT = fedc2708ce2e2471ab8e66c69a3451a94380da0e5e9998fa68541d899a5786361b7e5157757d6fe746c79a8838afe9c832cda2a4d0a44f4b1181142450a63f1176a821f66d161d75d85bfefc01e68d021288648d891dfdf8e66e0ef3a65619cb75243eeca04155a4c9133929de2066de4c77c7d26f4cc9894de2b40085ae3beb82b95241f4463ffa81b5f418b7a79ce44663747a6c78dc87b0a4ae52d3f5cef9
|
||||
PLAINTEXT = 95d6b83e1c10c721e0f0c35907b3a4e35c2794a6a8234874440be7a795dc8e2f7ec5cf739d0bb13b1fc51cf5d4d27d2ed4b93c11893c7b9a649b22cbbc96a8cd5847d135c43d1a11855811b82cffbd2287e6c55f45d124d47d549218c1ea0049281dd539a60cdbb80549db3af3b9f8d4ca127efcb5cde7ecc98e008f1edeff6980f172652806ff9395af7a62f88abaaf8974ebef1a02d78e4bd52149fa1ee183
|
||||
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,95 @@
|
|||
# CAVS 11.1
|
||||
# Config info for aes_values
|
||||
# AESVS GFSbox test data for CFB8
|
||||
# State : Encrypt and Decrypt
|
||||
# Key Length : 128
|
||||
# Generated on Fri Apr 22 15:11:46 2011
|
||||
|
||||
[ENCRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = f34481ec3cc627bacd5dc3fb08f273e6
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 03
|
||||
|
||||
COUNT = 1
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 9798c4640bad75c7c3227db910174e72
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = a9
|
||||
|
||||
COUNT = 2
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 96ab5c2ff612d9dfaae8c31f30c42168
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = ff
|
||||
|
||||
COUNT = 3
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 6a118a874519e64e9963798a503f1d35
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = dc
|
||||
|
||||
COUNT = 4
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = cb9fceec81286ca3e989bd979b0cb284
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 92
|
||||
|
||||
COUNT = 5
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = b26aeb1874e47ca8358ff22378f09144
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 45
|
||||
|
||||
COUNT = 6
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 58c8e00b2631686d54eab84b91f0aca1
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 08
|
||||
|
||||
[DECRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = f34481ec3cc627bacd5dc3fb08f273e6
|
||||
CIPHERTEXT = 03
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 1
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 9798c4640bad75c7c3227db910174e72
|
||||
CIPHERTEXT = a9
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 2
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 96ab5c2ff612d9dfaae8c31f30c42168
|
||||
CIPHERTEXT = ff
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 3
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 6a118a874519e64e9963798a503f1d35
|
||||
CIPHERTEXT = dc
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 4
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = cb9fceec81286ca3e989bd979b0cb284
|
||||
CIPHERTEXT = 92
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 5
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = b26aeb1874e47ca8358ff22378f09144
|
||||
CIPHERTEXT = 45
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 6
|
||||
KEY = 00000000000000000000000000000000
|
||||
IV = 58c8e00b2631686d54eab84b91f0aca1
|
||||
CIPHERTEXT = 08
|
||||
PLAINTEXT = 00
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
# CAVS 11.1
|
||||
# Config info for aes_values
|
||||
# AESVS GFSbox test data for CFB8
|
||||
# State : Encrypt and Decrypt
|
||||
# Key Length : 192
|
||||
# Generated on Fri Apr 22 15:11:48 2011
|
||||
|
||||
[ENCRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 1b077a6af4b7f98229de786d7516b639
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 27
|
||||
|
||||
COUNT = 1
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 9c2d8842e5f48f57648205d39a239af1
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = c9
|
||||
|
||||
COUNT = 2
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = bff52510095f518ecca60af4205444bb
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 4a
|
||||
|
||||
COUNT = 3
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 51719783d3185a535bd75adc65071ce1
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 4f
|
||||
|
||||
COUNT = 4
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 26aa49dcfe7629a8901a69a9914e6dfd
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = d5
|
||||
|
||||
COUNT = 5
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 941a4773058224e1ef66d10e0a6ee782
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 06
|
||||
|
||||
[DECRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 1b077a6af4b7f98229de786d7516b639
|
||||
CIPHERTEXT = 27
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 1
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 9c2d8842e5f48f57648205d39a239af1
|
||||
CIPHERTEXT = c9
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 2
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = bff52510095f518ecca60af4205444bb
|
||||
CIPHERTEXT = 4a
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 3
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 51719783d3185a535bd75adc65071ce1
|
||||
CIPHERTEXT = 4f
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 4
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 26aa49dcfe7629a8901a69a9914e6dfd
|
||||
CIPHERTEXT = d5
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 5
|
||||
KEY = 000000000000000000000000000000000000000000000000
|
||||
IV = 941a4773058224e1ef66d10e0a6ee782
|
||||
CIPHERTEXT = 06
|
||||
PLAINTEXT = 00
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
# CAVS 11.1
|
||||
# Config info for aes_values
|
||||
# AESVS GFSbox test data for CFB8
|
||||
# State : Encrypt and Decrypt
|
||||
# Key Length : 256
|
||||
# Generated on Fri Apr 22 15:11:50 2011
|
||||
|
||||
[ENCRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 014730f80ac625fe84f026c60bfd547d
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 5c
|
||||
|
||||
COUNT = 1
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 0b24af36193ce4665f2825d7b4749c98
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = a9
|
||||
|
||||
COUNT = 2
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 761c1fe41a18acf20d241650611d90f1
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 62
|
||||
|
||||
COUNT = 3
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 8a560769d605868ad80d819bdba03771
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 38
|
||||
|
||||
COUNT = 4
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 91fbef2d15a97816060bee1feaa49afe
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 1b
|
||||
|
||||
[DECRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 014730f80ac625fe84f026c60bfd547d
|
||||
CIPHERTEXT = 5c
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 1
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 0b24af36193ce4665f2825d7b4749c98
|
||||
CIPHERTEXT = a9
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 2
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 761c1fe41a18acf20d241650611d90f1
|
||||
CIPHERTEXT = 62
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 3
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 8a560769d605868ad80d819bdba03771
|
||||
CIPHERTEXT = 38
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 4
|
||||
KEY = 0000000000000000000000000000000000000000000000000000000000000000
|
||||
IV = 91fbef2d15a97816060bee1feaa49afe
|
||||
CIPHERTEXT = 1b
|
||||
PLAINTEXT = 00
|
||||
|
|
@ -0,0 +1,263 @@
|
|||
# CAVS 11.1
|
||||
# Config info for aes_values
|
||||
# AESVS KeySbox test data for CFB8
|
||||
# State : Encrypt and Decrypt
|
||||
# Key Length : 128
|
||||
# Generated on Fri Apr 22 15:11:46 2011
|
||||
|
||||
[ENCRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 10a58869d74be5a374cf867cfb473859
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 6d
|
||||
|
||||
COUNT = 1
|
||||
KEY = caea65cdbb75e9169ecd22ebe6e54675
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 6e
|
||||
|
||||
COUNT = 2
|
||||
KEY = a2e2fa9baf7d20822ca9f0542f764a41
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = c3
|
||||
|
||||
COUNT = 3
|
||||
KEY = b6364ac4e1de1e285eaf144a2415f7a0
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 5d
|
||||
|
||||
COUNT = 4
|
||||
KEY = 64cf9c7abc50b888af65f49d521944b2
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = f7
|
||||
|
||||
COUNT = 5
|
||||
KEY = 47d6742eefcc0465dc96355e851b64d9
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 03
|
||||
|
||||
COUNT = 6
|
||||
KEY = 3eb39790678c56bee34bbcdeccf6cdb5
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 85
|
||||
|
||||
COUNT = 7
|
||||
KEY = 64110a924f0743d500ccadae72c13427
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 35
|
||||
|
||||
COUNT = 8
|
||||
KEY = 18d8126516f8a12ab1a36d9f04d68e51
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 6c
|
||||
|
||||
COUNT = 9
|
||||
KEY = f530357968578480b398a3c251cd1093
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = f5
|
||||
|
||||
COUNT = 10
|
||||
KEY = da84367f325d42d601b4326964802e8e
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = bb
|
||||
|
||||
COUNT = 11
|
||||
KEY = e37b1c6aa2846f6fdb413f238b089f23
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 43
|
||||
|
||||
COUNT = 12
|
||||
KEY = 6c002b682483e0cabcc731c253be5674
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 35
|
||||
|
||||
COUNT = 13
|
||||
KEY = 143ae8ed6555aba96110ab58893a8ae1
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 80
|
||||
|
||||
COUNT = 14
|
||||
KEY = b69418a85332240dc82492353956ae0c
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = a3
|
||||
|
||||
COUNT = 15
|
||||
KEY = 71b5c08a1993e1362e4d0ce9b22b78d5
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = c2
|
||||
|
||||
COUNT = 16
|
||||
KEY = e234cdca2606b81f29408d5f6da21206
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = ff
|
||||
|
||||
COUNT = 17
|
||||
KEY = 13237c49074a3da078dc1d828bb78c6f
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 81
|
||||
|
||||
COUNT = 18
|
||||
KEY = 3071a2a48fe6cbd04f1a129098e308f8
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 4b
|
||||
|
||||
COUNT = 19
|
||||
KEY = 90f42ec0f68385f2ffc5dfc03a654dce
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 7a
|
||||
|
||||
COUNT = 20
|
||||
KEY = febd9a24d8b65c1c787d50a4ed3619a9
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = f4
|
||||
|
||||
[DECRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 10a58869d74be5a374cf867cfb473859
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 6d
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 1
|
||||
KEY = caea65cdbb75e9169ecd22ebe6e54675
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 6e
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 2
|
||||
KEY = a2e2fa9baf7d20822ca9f0542f764a41
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = c3
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 3
|
||||
KEY = b6364ac4e1de1e285eaf144a2415f7a0
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 5d
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 4
|
||||
KEY = 64cf9c7abc50b888af65f49d521944b2
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = f7
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 5
|
||||
KEY = 47d6742eefcc0465dc96355e851b64d9
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 03
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 6
|
||||
KEY = 3eb39790678c56bee34bbcdeccf6cdb5
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 85
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 7
|
||||
KEY = 64110a924f0743d500ccadae72c13427
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 35
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 8
|
||||
KEY = 18d8126516f8a12ab1a36d9f04d68e51
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 6c
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 9
|
||||
KEY = f530357968578480b398a3c251cd1093
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = f5
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 10
|
||||
KEY = da84367f325d42d601b4326964802e8e
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = bb
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 11
|
||||
KEY = e37b1c6aa2846f6fdb413f238b089f23
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 43
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 12
|
||||
KEY = 6c002b682483e0cabcc731c253be5674
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 35
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 13
|
||||
KEY = 143ae8ed6555aba96110ab58893a8ae1
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 80
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 14
|
||||
KEY = b69418a85332240dc82492353956ae0c
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = a3
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 15
|
||||
KEY = 71b5c08a1993e1362e4d0ce9b22b78d5
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = c2
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 16
|
||||
KEY = e234cdca2606b81f29408d5f6da21206
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = ff
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 17
|
||||
KEY = 13237c49074a3da078dc1d828bb78c6f
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 81
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 18
|
||||
KEY = 3071a2a48fe6cbd04f1a129098e308f8
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 4b
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 19
|
||||
KEY = 90f42ec0f68385f2ffc5dfc03a654dce
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 7a
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 20
|
||||
KEY = febd9a24d8b65c1c787d50a4ed3619a9
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = f4
|
||||
PLAINTEXT = 00
|
||||
|
|
@ -0,0 +1,299 @@
|
|||
# CAVS 11.1
|
||||
# Config info for aes_values
|
||||
# AESVS KeySbox test data for CFB8
|
||||
# State : Encrypt and Decrypt
|
||||
# Key Length : 192
|
||||
# Generated on Fri Apr 22 15:11:48 2011
|
||||
|
||||
[ENCRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = e9f065d7c13573587f7875357dfbb16c53489f6a4bd0f7cd
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 09
|
||||
|
||||
COUNT = 1
|
||||
KEY = 15d20f6ebc7e649fd95b76b107e6daba967c8a9484797f29
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 8e
|
||||
|
||||
COUNT = 2
|
||||
KEY = a8a282ee31c03fae4f8e9b8930d5473c2ed695a347e88b7c
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 93
|
||||
|
||||
COUNT = 3
|
||||
KEY = cd62376d5ebb414917f0c78f05266433dc9192a1ec943300
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 7f
|
||||
|
||||
COUNT = 4
|
||||
KEY = 502a6ab36984af268bf423c7f509205207fc1552af4a91e5
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 8e
|
||||
|
||||
COUNT = 5
|
||||
KEY = 25a39dbfd8034f71a81f9ceb55026e4037f8f6aa30ab44ce
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 36
|
||||
|
||||
COUNT = 6
|
||||
KEY = e08c15411774ec4a908b64eadc6ac4199c7cd453f3aaef53
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 77
|
||||
|
||||
COUNT = 7
|
||||
KEY = 3b375a1ff7e8d44409696e6326ec9dec86138e2ae010b980
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 3b
|
||||
|
||||
COUNT = 8
|
||||
KEY = 950bb9f22cc35be6fe79f52c320af93dec5bc9c0c2f9cd53
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 64
|
||||
|
||||
COUNT = 9
|
||||
KEY = 7001c487cc3e572cfc92f4d0e697d982e8856fdcc957da40
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = ff
|
||||
|
||||
COUNT = 10
|
||||
KEY = f029ce61d4e5a405b41ead0a883cc6a737da2cf50a6c92ae
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = a2
|
||||
|
||||
COUNT = 11
|
||||
KEY = 61257134a518a0d57d9d244d45f6498cbc32f2bafc522d79
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = cf
|
||||
|
||||
COUNT = 12
|
||||
KEY = b0ab0a6a818baef2d11fa33eac947284fb7d748cfb75e570
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = d2
|
||||
|
||||
COUNT = 13
|
||||
KEY = ee053aa011c8b428cdcc3636313c54d6a03cac01c71579d6
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 9b
|
||||
|
||||
COUNT = 14
|
||||
KEY = d2926527e0aa9f37b45e2ec2ade5853ef807576104c7ace3
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = dd
|
||||
|
||||
COUNT = 15
|
||||
KEY = 982215f4e173dfa0fcffe5d3da41c4812c7bcc8ed3540f93
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = d4
|
||||
|
||||
COUNT = 16
|
||||
KEY = 98c6b8e01e379fbd14e61af6af891596583565f2a27d59e9
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 19
|
||||
|
||||
COUNT = 17
|
||||
KEY = b3ad5cea1dddc214ca969ac35f37dae1a9a9d1528f89bb35
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 3c
|
||||
|
||||
COUNT = 18
|
||||
KEY = 45899367c3132849763073c435a9288a766c8b9ec2308516
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 69
|
||||
|
||||
COUNT = 19
|
||||
KEY = ec250e04c3903f602647b85a401a1ae7ca2f02f67fa4253e
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 8a
|
||||
|
||||
COUNT = 20
|
||||
KEY = d077a03bd8a38973928ccafe4a9d2f455130bd0af5ae46a9
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = ab
|
||||
|
||||
COUNT = 21
|
||||
KEY = d184c36cf0dddfec39e654195006022237871a47c33d3198
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 2e
|
||||
|
||||
COUNT = 22
|
||||
KEY = 4c6994ffa9dcdc805b60c2c0095334c42d95a8fc0ca5b080
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 76
|
||||
|
||||
COUNT = 23
|
||||
KEY = c88f5b00a4ef9a6840e2acaf33f00a3bdc4e25895303fa72
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = a6
|
||||
|
||||
[DECRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = e9f065d7c13573587f7875357dfbb16c53489f6a4bd0f7cd
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 09
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 1
|
||||
KEY = 15d20f6ebc7e649fd95b76b107e6daba967c8a9484797f29
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 8e
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 2
|
||||
KEY = a8a282ee31c03fae4f8e9b8930d5473c2ed695a347e88b7c
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 93
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 3
|
||||
KEY = cd62376d5ebb414917f0c78f05266433dc9192a1ec943300
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 7f
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 4
|
||||
KEY = 502a6ab36984af268bf423c7f509205207fc1552af4a91e5
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 8e
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 5
|
||||
KEY = 25a39dbfd8034f71a81f9ceb55026e4037f8f6aa30ab44ce
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 36
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 6
|
||||
KEY = e08c15411774ec4a908b64eadc6ac4199c7cd453f3aaef53
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 77
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 7
|
||||
KEY = 3b375a1ff7e8d44409696e6326ec9dec86138e2ae010b980
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 3b
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 8
|
||||
KEY = 950bb9f22cc35be6fe79f52c320af93dec5bc9c0c2f9cd53
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 64
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 9
|
||||
KEY = 7001c487cc3e572cfc92f4d0e697d982e8856fdcc957da40
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = ff
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 10
|
||||
KEY = f029ce61d4e5a405b41ead0a883cc6a737da2cf50a6c92ae
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = a2
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 11
|
||||
KEY = 61257134a518a0d57d9d244d45f6498cbc32f2bafc522d79
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = cf
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 12
|
||||
KEY = b0ab0a6a818baef2d11fa33eac947284fb7d748cfb75e570
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = d2
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 13
|
||||
KEY = ee053aa011c8b428cdcc3636313c54d6a03cac01c71579d6
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 9b
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 14
|
||||
KEY = d2926527e0aa9f37b45e2ec2ade5853ef807576104c7ace3
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = dd
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 15
|
||||
KEY = 982215f4e173dfa0fcffe5d3da41c4812c7bcc8ed3540f93
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = d4
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 16
|
||||
KEY = 98c6b8e01e379fbd14e61af6af891596583565f2a27d59e9
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 19
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 17
|
||||
KEY = b3ad5cea1dddc214ca969ac35f37dae1a9a9d1528f89bb35
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 3c
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 18
|
||||
KEY = 45899367c3132849763073c435a9288a766c8b9ec2308516
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 69
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 19
|
||||
KEY = ec250e04c3903f602647b85a401a1ae7ca2f02f67fa4253e
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 8a
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 20
|
||||
KEY = d077a03bd8a38973928ccafe4a9d2f455130bd0af5ae46a9
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = ab
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 21
|
||||
KEY = d184c36cf0dddfec39e654195006022237871a47c33d3198
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 2e
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 22
|
||||
KEY = 4c6994ffa9dcdc805b60c2c0095334c42d95a8fc0ca5b080
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 76
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 23
|
||||
KEY = c88f5b00a4ef9a6840e2acaf33f00a3bdc4e25895303fa72
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = a6
|
||||
PLAINTEXT = 00
|
||||
|
|
@ -0,0 +1,203 @@
|
|||
# CAVS 11.1
|
||||
# Config info for aes_values
|
||||
# AESVS KeySbox test data for CFB8
|
||||
# State : Encrypt and Decrypt
|
||||
# Key Length : 256
|
||||
# Generated on Fri Apr 22 15:11:50 2011
|
||||
|
||||
[ENCRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = c47b0294dbbbee0fec4757f22ffeee3587ca4730c3d33b691df38bab076bc558
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 46
|
||||
|
||||
COUNT = 1
|
||||
KEY = 28d46cffa158533194214a91e712fc2b45b518076675affd910edeca5f41ac64
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 4b
|
||||
|
||||
COUNT = 2
|
||||
KEY = c1cc358b449909a19436cfbb3f852ef8bcb5ed12ac7058325f56e6099aab1a1c
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 35
|
||||
|
||||
COUNT = 3
|
||||
KEY = 984ca75f4ee8d706f46c2d98c0bf4a45f5b00d791c2dfeb191b5ed8e420fd627
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 43
|
||||
|
||||
COUNT = 4
|
||||
KEY = b43d08a447ac8609baadae4ff12918b9f68fc1653f1269222f123981ded7a92f
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 46
|
||||
|
||||
COUNT = 5
|
||||
KEY = 1d85a181b54cde51f0e098095b2962fdc93b51fe9b88602b3f54130bf76a5bd9
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 53
|
||||
|
||||
COUNT = 6
|
||||
KEY = dc0eba1f2232a7879ded34ed8428eeb8769b056bbaf8ad77cb65c3541430b4cf
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = fc
|
||||
|
||||
COUNT = 7
|
||||
KEY = f8be9ba615c5a952cabbca24f68f8593039624d524c816acda2c9183bd917cb9
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = a3
|
||||
|
||||
COUNT = 8
|
||||
KEY = 797f8b3d176dac5b7e34a2d539c4ef367a16f8635f6264737591c5c07bf57a3e
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = a7
|
||||
|
||||
COUNT = 9
|
||||
KEY = 6838d40caf927749c13f0329d331f448e202c73ef52c5f73a37ca635d4c47707
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = b9
|
||||
|
||||
COUNT = 10
|
||||
KEY = ccd1bc3c659cd3c59bc437484e3c5c724441da8d6e90ce556cd57d0752663bbc
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 30
|
||||
|
||||
COUNT = 11
|
||||
KEY = 13428b5e4c005e0636dd338405d173ab135dec2a25c22c5df0722d69dcc43887
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 64
|
||||
|
||||
COUNT = 12
|
||||
KEY = 07eb03a08d291d1b07408bf3512ab40c91097ac77461aad4bb859647f74f00ee
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 47
|
||||
|
||||
COUNT = 13
|
||||
KEY = 90143ae20cd78c5d8ebdd6cb9dc1762427a96c78c639bccc41a61424564eafe1
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 79
|
||||
|
||||
COUNT = 14
|
||||
KEY = b7a5794d52737475d53d5a377200849be0260a67a2b22ced8bbef12882270d07
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 63
|
||||
|
||||
COUNT = 15
|
||||
KEY = fca02f3d5011cfc5c1e23165d413a049d4526a991827424d896fe3435e0bf68e
|
||||
IV = 00000000000000000000000000000000
|
||||
PLAINTEXT = 00
|
||||
CIPHERTEXT = 17
|
||||
|
||||
[DECRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = c47b0294dbbbee0fec4757f22ffeee3587ca4730c3d33b691df38bab076bc558
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 46
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 1
|
||||
KEY = 28d46cffa158533194214a91e712fc2b45b518076675affd910edeca5f41ac64
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 4b
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 2
|
||||
KEY = c1cc358b449909a19436cfbb3f852ef8bcb5ed12ac7058325f56e6099aab1a1c
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 35
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 3
|
||||
KEY = 984ca75f4ee8d706f46c2d98c0bf4a45f5b00d791c2dfeb191b5ed8e420fd627
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 43
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 4
|
||||
KEY = b43d08a447ac8609baadae4ff12918b9f68fc1653f1269222f123981ded7a92f
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 46
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 5
|
||||
KEY = 1d85a181b54cde51f0e098095b2962fdc93b51fe9b88602b3f54130bf76a5bd9
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 53
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 6
|
||||
KEY = dc0eba1f2232a7879ded34ed8428eeb8769b056bbaf8ad77cb65c3541430b4cf
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = fc
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 7
|
||||
KEY = f8be9ba615c5a952cabbca24f68f8593039624d524c816acda2c9183bd917cb9
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = a3
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 8
|
||||
KEY = 797f8b3d176dac5b7e34a2d539c4ef367a16f8635f6264737591c5c07bf57a3e
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = a7
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 9
|
||||
KEY = 6838d40caf927749c13f0329d331f448e202c73ef52c5f73a37ca635d4c47707
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = b9
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 10
|
||||
KEY = ccd1bc3c659cd3c59bc437484e3c5c724441da8d6e90ce556cd57d0752663bbc
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 30
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 11
|
||||
KEY = 13428b5e4c005e0636dd338405d173ab135dec2a25c22c5df0722d69dcc43887
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 64
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 12
|
||||
KEY = 07eb03a08d291d1b07408bf3512ab40c91097ac77461aad4bb859647f74f00ee
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 47
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 13
|
||||
KEY = 90143ae20cd78c5d8ebdd6cb9dc1762427a96c78c639bccc41a61424564eafe1
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 79
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 14
|
||||
KEY = b7a5794d52737475d53d5a377200849be0260a67a2b22ced8bbef12882270d07
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 63
|
||||
PLAINTEXT = 00
|
||||
|
||||
COUNT = 15
|
||||
KEY = fca02f3d5011cfc5c1e23165d413a049d4526a991827424d896fe3435e0bf68e
|
||||
IV = 00000000000000000000000000000000
|
||||
CIPHERTEXT = 17
|
||||
PLAINTEXT = 00
|
||||
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,131 @@
|
|||
# CAVS 11.1
|
||||
# Config info for aes_values
|
||||
# AESVS MMT test data for CFB8
|
||||
# State : Encrypt and Decrypt
|
||||
# Key Length : 128
|
||||
# Generated on Fri Apr 22 15:11:46 2011
|
||||
|
||||
[ENCRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = c57d699d89df7cfbef71c080a6b10ac3
|
||||
IV = fcb2bc4c006b87483978796a2ae2c42e
|
||||
PLAINTEXT = 61
|
||||
CIPHERTEXT = 24
|
||||
|
||||
COUNT = 1
|
||||
KEY = 0d8f3dc3edee60db658bb97faf46fba3
|
||||
IV = e481fdc42e606b96a383c0a1a5520ebb
|
||||
PLAINTEXT = aacd
|
||||
CIPHERTEXT = 5066
|
||||
|
||||
COUNT = 2
|
||||
KEY = c8fe9bf77b930f46d2078b8c0e657cd4
|
||||
IV = f475c64991b20eaee183a22629e21e22
|
||||
PLAINTEXT = c90635
|
||||
CIPHERTEXT = d27691
|
||||
|
||||
COUNT = 3
|
||||
KEY = 280cf81af5cc7e7363579c1da03390e6
|
||||
IV = 5d6cf4722d0e21f1d9ced53a0e36c342
|
||||
PLAINTEXT = b2a22ced
|
||||
CIPHERTEXT = 73f3aebf
|
||||
|
||||
COUNT = 4
|
||||
KEY = 5d5e7f20e0a66d3e09e0e5a9912f8a46
|
||||
IV = 052d7ea0ad1f2956a23b27afe1d87b6b
|
||||
PLAINTEXT = b84a90fc6d
|
||||
CIPHERTEXT = 1a9a61c307
|
||||
|
||||
COUNT = 5
|
||||
KEY = ec89fb348787cf902ca973c47081438d
|
||||
IV = 528fe95c711bd13f37bc52cc9e96d45c
|
||||
PLAINTEXT = 14253472e99d
|
||||
CIPHERTEXT = cfc247e33a3b
|
||||
|
||||
COUNT = 6
|
||||
KEY = 6607987c354809cba818639dcd185147
|
||||
IV = 552c101a0b7c0ca143af258453937fa3
|
||||
PLAINTEXT = 9b1a5a1369166e
|
||||
CIPHERTEXT = b7ab2a4cc71904
|
||||
|
||||
COUNT = 7
|
||||
KEY = c028e6bf2b749ffa86759f2f84e93cb0
|
||||
IV = 288c752d9faccf367e5d0cca1fa6ec3b
|
||||
PLAINTEXT = 324015878cdc82bf
|
||||
CIPHERTEXT = 873250152fc6a5bb
|
||||
|
||||
COUNT = 8
|
||||
KEY = d01da95d2c2a61da06ea78cfba59cc30
|
||||
IV = f9a393ad90814faf262e3a5b1d97592e
|
||||
PLAINTEXT = 57c1a30e48166d9640
|
||||
CIPHERTEXT = e9a8c3b776edd39e3d
|
||||
|
||||
COUNT = 9
|
||||
KEY = 3a6f9159263fa6cef2a075caface5817
|
||||
IV = 0fc23662b7dbf73827f0c7de321ca36e
|
||||
PLAINTEXT = 87efeb8d559ed3367728
|
||||
CIPHERTEXT = 8e9c50425614d540ce11
|
||||
|
||||
[DECRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 03edfe082550bd5ac8ddf64f42a0547f
|
||||
IV = 52acd8dab62c981da08e51939cc08dab
|
||||
CIPHERTEXT = 21
|
||||
PLAINTEXT = 09
|
||||
|
||||
COUNT = 1
|
||||
KEY = 38cf776750162edc63c3b5dbe311ab9f
|
||||
IV = 98fbbd288872c40f1926b16ecaec1561
|
||||
CIPHERTEXT = 4878
|
||||
PLAINTEXT = eb24
|
||||
|
||||
COUNT = 2
|
||||
KEY = c9053c87c3e56bc5e52bd31f6545f991
|
||||
IV = b8f9640d0923da13fe6eb87b01f0cfa0
|
||||
CIPHERTEXT = aeb6d2
|
||||
PLAINTEXT = 910949
|
||||
|
||||
COUNT = 3
|
||||
KEY = e96771f5f20a89ee871261d2d18e1e46
|
||||
IV = 6e86403e33396655907ae06ef192262f
|
||||
CIPHERTEXT = 83cab2f3
|
||||
PLAINTEXT = 3b7f1f1c
|
||||
|
||||
COUNT = 4
|
||||
KEY = 92ad13ecb60bde1bb3b34ce07867672b
|
||||
IV = f95a4060b8f80e3f839d4c3ca33dad94
|
||||
CIPHERTEXT = 49f73e652b
|
||||
PLAINTEXT = 17b9b9e16d
|
||||
|
||||
COUNT = 5
|
||||
KEY = eb57b8dd076e7bbb33d4bfc4d7ecb27e
|
||||
IV = 51135997a067dcd2e016c57134c5fa52
|
||||
CIPHERTEXT = b0eacbf2ca46
|
||||
PLAINTEXT = ca989fa4e818
|
||||
|
||||
COUNT = 6
|
||||
KEY = 70abc48bb1be490183f0fe3df56195ff
|
||||
IV = e251f179174b71ee1e488ab3dd200483
|
||||
CIPHERTEXT = 08fbef9b2a369a
|
||||
PLAINTEXT = 5405da1186b7e0
|
||||
|
||||
COUNT = 7
|
||||
KEY = 1273b8e0eee1a1ca827059b4d0a3a55d
|
||||
IV = 622cab49092d026f554dd98a6441dc26
|
||||
CIPHERTEXT = b3cb9d8892423aeb
|
||||
PLAINTEXT = d497df73afb9787c
|
||||
|
||||
COUNT = 8
|
||||
KEY = 49437e06b6faa5f20fd98bf71f8ff554
|
||||
IV = 63c818e0d3cb5b7054ef3e1e87df0e12
|
||||
CIPHERTEXT = 01992a986279c3685e
|
||||
PLAINTEXT = f203bcd402b65919da
|
||||
|
||||
COUNT = 9
|
||||
KEY = 6399c1dc068ba3509845628fa9ed1a96
|
||||
IV = 1157c2766c86b754df485be9dd5851df
|
||||
CIPHERTEXT = c9c284e9abbfe6fb11fe
|
||||
PLAINTEXT = feff4e2e2458addf2a54
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
# CAVS 11.1
|
||||
# Config info for aes_values
|
||||
# AESVS MMT test data for CFB8
|
||||
# State : Encrypt and Decrypt
|
||||
# Key Length : 192
|
||||
# Generated on Fri Apr 22 15:11:48 2011
|
||||
|
||||
[ENCRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 32a1b0e3da368db563d7316b9779d3327e53d9a6d287ed97
|
||||
IV = 3dd0e7e21f09d5842f3a699da9b57346
|
||||
PLAINTEXT = 54
|
||||
CIPHERTEXT = 6d
|
||||
|
||||
COUNT = 1
|
||||
KEY = a6381dcc18dd85d7729c1dce90743bbe1df580d857f5b9c4
|
||||
IV = c0ac501fad7f4a1465daf32e18fc1a4f
|
||||
PLAINTEXT = a456
|
||||
CIPHERTEXT = 8fb6
|
||||
|
||||
COUNT = 2
|
||||
KEY = d08dbee4732c7ffc544c1695b201d30e795037325ef0aa18
|
||||
IV = a1e39aeeb972a8d70aa0fc7d6fac6eac
|
||||
PLAINTEXT = fd115d
|
||||
CIPHERTEXT = c4c016
|
||||
|
||||
COUNT = 3
|
||||
KEY = 277185a4a440869920f523c4d578fc5bedd33aee8d2ebaf7
|
||||
IV = 67be00572f82aabc13d6e5a2e51d1f08
|
||||
PLAINTEXT = 88e07061
|
||||
CIPHERTEXT = 8bb630ba
|
||||
|
||||
COUNT = 4
|
||||
KEY = 83f70fdce47306fcbb8c21b6a8b3209f7ec185fef4deebd4
|
||||
IV = ff73b310cf7e62ce6f501092fa6cc888
|
||||
PLAINTEXT = 36664e222d
|
||||
CIPHERTEXT = 20855555d1
|
||||
|
||||
COUNT = 5
|
||||
KEY = c5be271a29f4a29e085e8e98196601dcb88ccc03e559a304
|
||||
IV = 9f51fa2eb8a084718f7240e47d135dce
|
||||
PLAINTEXT = b57f12342a62
|
||||
CIPHERTEXT = 73ff9bf3ec4b
|
||||
|
||||
COUNT = 6
|
||||
KEY = 9c55322e6d495be01076d4b80371ad1479ae5636ff9861f5
|
||||
IV = 2b79cfc1ff37254dedf5924a6b61e3e0
|
||||
PLAINTEXT = 6dcede43c2ee65
|
||||
CIPHERTEXT = 7c897658282220
|
||||
|
||||
COUNT = 7
|
||||
KEY = 6e78ccece7d1b2a3c08cf0de738bee33cbbbf78d9bf4922c
|
||||
IV = 4bbe15b1e94a7b97250a2136d8804e46
|
||||
PLAINTEXT = ceda42527871f802
|
||||
CIPHERTEXT = d92ff89045b1917f
|
||||
|
||||
COUNT = 8
|
||||
KEY = 13c98665746f7825b37b404916240adbd1e4364be1d05c63
|
||||
IV = 0e479fbd5f3961f38b8a26be1f2d65c5
|
||||
PLAINTEXT = 1b0a63d73464ab3c8a
|
||||
CIPHERTEXT = 5485847e5d3c2e2cc4
|
||||
|
||||
COUNT = 9
|
||||
KEY = 537e7bf661fd4024a024613f15b13690f7d0c847c1e18965
|
||||
IV = 3a81f9d9d3c155b0caad5d73349476fc
|
||||
PLAINTEXT = d3d8b9b984adc24237ee
|
||||
CIPHERTEXT = 3879fea72ac99929e53a
|
||||
|
||||
[DECRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 7dbdc15ad4034ed828dc862799b7adc9abd68eaf9d526d5d
|
||||
IV = 4359683af5a3a85c248fb7f5506f317b
|
||||
CIPHERTEXT = 25
|
||||
PLAINTEXT = 2d
|
||||
|
||||
COUNT = 1
|
||||
KEY = 3a2cdf9c9608c1dd6233d03dd855293b0885915114b25279
|
||||
IV = e7a28ee34acc52128ddae658ec6398a2
|
||||
CIPHERTEXT = 0678
|
||||
PLAINTEXT = 7b04
|
||||
|
||||
COUNT = 2
|
||||
KEY = c984b99a6cc5bc88003143cbe4b755e6e30ba94114f7ad1e
|
||||
IV = 41e3b8fd138f8c358dfeef420302f634
|
||||
CIPHERTEXT = 037cf6
|
||||
PLAINTEXT = 658d0a
|
||||
|
||||
COUNT = 3
|
||||
KEY = 39747da225bdc0c53c3463fd686dbe19d14157535171f91d
|
||||
IV = 77d3a5ad8bbdb169f8d29e5f21798651
|
||||
CIPHERTEXT = 0fb0cee2
|
||||
PLAINTEXT = 2d191f2f
|
||||
|
||||
COUNT = 4
|
||||
KEY = 4cd13179dfa16d01c6a8633dfc8783e723e72114c9b0d50a
|
||||
IV = 6657c46c99d642474c330d8016b71dbe
|
||||
CIPHERTEXT = 09d914cf0b
|
||||
PLAINTEXT = 105a64c872
|
||||
|
||||
COUNT = 5
|
||||
KEY = 5dcc9b8d8a456e9917cd8d54d7f7100b34964b4ed2d398a0
|
||||
IV = 4fa295a8987f1b010ce4e011fbf94156
|
||||
CIPHERTEXT = 288c752d9fac
|
||||
PLAINTEXT = 98f332d37b78
|
||||
|
||||
COUNT = 6
|
||||
KEY = c8baf0204ef80b8e0125efe43a0bccdfd0f356b62e6c75fe
|
||||
IV = e9144bf2cbc5720a1b4cb6f37d11edff
|
||||
CIPHERTEXT = c9981a34b7aa89
|
||||
PLAINTEXT = 56bb4c3cae53b3
|
||||
|
||||
COUNT = 7
|
||||
KEY = 64e40763f38a63ae378c32052b0ae3aa538bb868a04ac985
|
||||
IV = aacf65089e4b285438451ffdcd0f6389
|
||||
CIPHERTEXT = d8fcf83a88510a0d
|
||||
PLAINTEXT = b567411bc61b0a76
|
||||
|
||||
COUNT = 8
|
||||
KEY = 7bfdca9605f17253f203efffc92da96fde023007d22cdad0
|
||||
IV = 45c09e44036070f8a7737a5176b8cf26
|
||||
CIPHERTEXT = 9c195b1944c4af5bfb
|
||||
PLAINTEXT = 89358df65c3ef14d26
|
||||
|
||||
COUNT = 9
|
||||
KEY = baf08b76317a65c5f07ae6f57eb0e65488659324d29709e3
|
||||
IV = 0a02846b62abb693ef31d754842eed29
|
||||
CIPHERTEXT = 729c0b6deb75fa6eb5e8
|
||||
PLAINTEXT = 9895932402393dc33a60
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
# CAVS 11.1
|
||||
# Config info for aes_values
|
||||
# AESVS MMT test data for CFB8
|
||||
# State : Encrypt and Decrypt
|
||||
# Key Length : 256
|
||||
# Generated on Fri Apr 22 15:11:50 2011
|
||||
|
||||
[ENCRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 34e8091cee09f1bd3ebf1e8f05f51bfbd4899ef2ae006a3a0f7875052cdd46c8
|
||||
IV = 43eb4dcc4b04a80216a20e4a09a7abb5
|
||||
PLAINTEXT = f9
|
||||
CIPHERTEXT = 28
|
||||
|
||||
COUNT = 1
|
||||
KEY = e04e43173113109e1343393842fe6caef3f8a2e506d7f55f83dcb10444c6ad23
|
||||
IV = a38b88a293b077fb5546636aad90d663
|
||||
PLAINTEXT = 2914
|
||||
CIPHERTEXT = 69a6
|
||||
|
||||
COUNT = 2
|
||||
KEY = 064874092f7a13cc4462247ad423d0e96edf42e8b67a5a23b7a0a6477b098e66
|
||||
IV = 338c552ff1eca14408e05d8cf9f3b31b
|
||||
PLAINTEXT = b974fa
|
||||
CIPHERTEXT = 1cff95
|
||||
|
||||
COUNT = 3
|
||||
KEY = 56794adb0ef04aeddeabd650de736531d408837954b919002c33edfdff976cc2
|
||||
IV = 71b5526facea4236d33f1f4107e4b04f
|
||||
PLAINTEXT = db774912
|
||||
CIPHERTEXT = f04d9d4f
|
||||
|
||||
COUNT = 4
|
||||
KEY = dddd7f234e7d0e6ec64560b96430986a856f2ee9805443a7946e31601ef6679d
|
||||
IV = e20f39db0025eb24491bd06012887108
|
||||
PLAINTEXT = ad1d5311ea
|
||||
CIPHERTEXT = 19cc97a662
|
||||
|
||||
COUNT = 5
|
||||
KEY = ec73a760272c83f91771b3ab7b188715c6d6afb9c554feae83856e966a3863d0
|
||||
IV = ae7bfa38fd25778fcf66ce8157f6e42e
|
||||
PLAINTEXT = 02fe724fbc5d
|
||||
CIPHERTEXT = b0eca63405f4
|
||||
|
||||
COUNT = 6
|
||||
KEY = a66874ca0b70fb98b37c033ec96413f339adae02acade015b9f016b459db3309
|
||||
IV = 6ed480d9e4ed031cf66bb1e07f8d5514
|
||||
PLAINTEXT = b4777e6bcd9a05
|
||||
CIPHERTEXT = 8c017397ad5bab
|
||||
|
||||
COUNT = 7
|
||||
KEY = a3dbbb775ada92b0b8ed1632444e21c1c86ff3eba8f628307306e766b8c15b5c
|
||||
IV = 4ec56a8e541f5cfe7b8ab947bfa4fd08
|
||||
PLAINTEXT = 1d70a5a82badf5ea
|
||||
CIPHERTEXT = 1e22bebebeacd81d
|
||||
|
||||
COUNT = 8
|
||||
KEY = 64135e67c0ca1acef3360d930afcd726c5b04861a69c1b6a48bde1daf20f3b1f
|
||||
IV = 5377a154d5f948189f9aa57b466c16b2
|
||||
PLAINTEXT = a36ca5ea382a322eef
|
||||
CIPHERTEXT = 3105016567d3174aed
|
||||
|
||||
COUNT = 9
|
||||
KEY = ebbb4566b5e182e0f072466b0b311df38f9175bc0213a5530bce2ec4d74f400d
|
||||
IV = 0956a48e01002c9e16376d6e308dbad1
|
||||
PLAINTEXT = b0fe25ac8d3d28a2f471
|
||||
CIPHERTEXT = 638c6823e7256fb5626e
|
||||
|
||||
[DECRYPT]
|
||||
|
||||
COUNT = 0
|
||||
KEY = 1687831580cb764321a9d674dbd0a9640f668b0f58ef01b87a710b3095d5f855
|
||||
IV = 6cd5bec6d6e1fd23afc543b8f80d3f89
|
||||
CIPHERTEXT = 6f
|
||||
PLAINTEXT = 98
|
||||
|
||||
COUNT = 1
|
||||
KEY = b6b504e8b7065373ea31cd549e52eda7cb96fd1db14eddacbc420085ab48b747
|
||||
IV = 870ecd45b1241803ddaf8bad15a025d7
|
||||
CIPHERTEXT = 17d4
|
||||
PLAINTEXT = 3572
|
||||
|
||||
COUNT = 2
|
||||
KEY = 6ad3105e15fb5b742bf4fe1eb8e98c6c1ffea653107c84f6b42ed1232a0bbc21
|
||||
IV = 17534c89c4eae5dea6ea353dde7b1623
|
||||
CIPHERTEXT = a9841e
|
||||
PLAINTEXT = f9411a
|
||||
|
||||
COUNT = 3
|
||||
KEY = 758f3fa8b2b289f19fd59e7316be40b904eff7f565caac4570f972360e0da787
|
||||
IV = b21335ae980898fa92c4b3069e532973
|
||||
CIPHERTEXT = 84b35e25
|
||||
PLAINTEXT = 47887872
|
||||
|
||||
COUNT = 4
|
||||
KEY = 802e854eb799500975d960a67885820d195e02ab23d51f15e5cdbcee86a1580c
|
||||
IV = 94478c4e44e2fa8d2e6bc43d384597e6
|
||||
CIPHERTEXT = d1e96bf1e8
|
||||
PLAINTEXT = ed414b5689
|
||||
|
||||
COUNT = 5
|
||||
KEY = 3a0c03ca9d1e5d49bb37f9041f88d159c3f1d5ce26c798f59ed54a93f0a0e600
|
||||
IV = 9aae38ba832e4b093b50444074517d20
|
||||
CIPHERTEXT = 74410ccd12da
|
||||
PLAINTEXT = 8207eee2a7ab
|
||||
|
||||
COUNT = 6
|
||||
KEY = ee05462128fea75e919f6f436cb198f222847d698a283f5767df682d33d3ce77
|
||||
IV = d2ad55e41887075184635112a22fc093
|
||||
CIPHERTEXT = ff039e89877b44
|
||||
PLAINTEXT = aff3aa4c24e353
|
||||
|
||||
COUNT = 7
|
||||
KEY = 08abbdcc3eb9c1717db1faa38dcd0893afd5e16e2596747af58f8d61ebedf9cd
|
||||
IV = b925c8dc9a9b55a4372ea6d37d21c1eb
|
||||
CIPHERTEXT = e176ba99ea602fd9
|
||||
PLAINTEXT = b7370050288bf600
|
||||
|
||||
COUNT = 8
|
||||
KEY = 56d404a893fb3b3f594aab18939230b096646a37a781629fbd9270f3891a5cea
|
||||
IV = e5906b36f2d97e6f2db19b6c7a3ce319
|
||||
CIPHERTEXT = c55a9a917a809a784b
|
||||
PLAINTEXT = e44995bbb0fff40fee
|
||||
|
||||
COUNT = 9
|
||||
KEY = ec13062551e4d7291e320f565b749eea1809b663b26f2c4d53b52058b833e0ad
|
||||
IV = fbfa5a528e20863012790c2abafb5a0c
|
||||
CIPHERTEXT = 2bfc3f0209307140101a
|
||||
PLAINTEXT = 547bfd642cf6e12ed942
|
||||
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue