Python Crypto.Hash.SHA384 Examples
The following are 14
code examples of Crypto.Hash.SHA384().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
Crypto.Hash
, or try the search function
.
Example #1
Source File: test_pss.py From FODI with GNU General Public License v3.0 | 6 votes |
def runTest(self): key = RSA.generate(1280) signer = pss.new(key) hash_names = ("MD2", "MD4", "MD5", "RIPEMD160", "SHA1", "SHA224", "SHA256", "SHA384", "SHA512", "SHA3_224", "SHA3_256", "SHA3_384", "SHA3_512") for name in hash_names: hashed = load_hash_by_name(name).new(b("Test")) signer.sign(hashed) from Crypto.Hash import BLAKE2b, BLAKE2s for hash_size in (20, 32, 48, 64): hashed_b = BLAKE2b.new(digest_bytes=hash_size, data=b("Test")) signer.sign(hashed_b) for hash_size in (16, 20, 28, 32): hashed_s = BLAKE2s.new(digest_bytes=hash_size, data=b("Test")) signer.sign(hashed_s)
Example #2
Source File: test_pss.py From FODI with GNU General Public License v3.0 | 6 votes |
def get_hash_module(hash_name): if hash_name == "SHA-512": hash_module = SHA512 elif hash_name == "SHA-512/224": hash_module = SHA512.new(truncate="224") elif hash_name == "SHA-512/256": hash_module = SHA512.new(truncate="256") elif hash_name == "SHA-384": hash_module = SHA384 elif hash_name == "SHA-256": hash_module = SHA256 elif hash_name == "SHA-224": hash_module = SHA224 elif hash_name == "SHA-1": hash_module = SHA1 else: raise ValueError("Unknown hash algorithm: " + hash_name) return hash_module
Example #3
Source File: test_pkcs1_15.py From android_universal with MIT License | 6 votes |
def runTest(self): key = RSA.generate(1024) signer = pkcs1_15.new(key) hash_names = ("MD2", "MD4", "MD5", "RIPEMD160", "SHA1", "SHA224", "SHA256", "SHA384", "SHA512", "SHA3_224", "SHA3_256", "SHA3_384", "SHA3_512") for name in hash_names: hashed = load_hash_by_name(name).new(b"Test") signer.sign(hashed) from Crypto.Hash import BLAKE2b, BLAKE2s for hash_size in (20, 32, 48, 64): hashed_b = BLAKE2b.new(digest_bytes=hash_size, data=b"Test") signer.sign(hashed_b) for hash_size in (16, 20, 28, 32): hashed_s = BLAKE2s.new(digest_bytes=hash_size, data=b"Test") signer.sign(hashed_s)
Example #4
Source File: test_pss.py From android_universal with MIT License | 6 votes |
def runTest(self): key = RSA.generate(1280) signer = pss.new(key) hash_names = ("MD2", "MD4", "MD5", "RIPEMD160", "SHA1", "SHA224", "SHA256", "SHA384", "SHA512", "SHA3_224", "SHA3_256", "SHA3_384", "SHA3_512") for name in hash_names: hashed = load_hash_by_name(name).new(b("Test")) signer.sign(hashed) from Crypto.Hash import BLAKE2b, BLAKE2s for hash_size in (20, 32, 48, 64): hashed_b = BLAKE2b.new(digest_bytes=hash_size, data=b("Test")) signer.sign(hashed_b) for hash_size in (16, 20, 28, 32): hashed_s = BLAKE2s.new(digest_bytes=hash_size, data=b("Test")) signer.sign(hashed_s)
Example #5
Source File: test_SHA384.py From earthengine with MIT License | 5 votes |
def get_tests(config={}): from Crypto.Hash import SHA384 from common import make_hash_tests return make_hash_tests(SHA384, "SHA384", test_data, digest_size=48, oid='\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x02')
Example #6
Source File: test_HMAC.py From earthengine with MIT License | 5 votes |
def get_tests(config={}): global test_data from Crypto.Hash import HMAC, MD5, SHA as SHA1, SHA256 from common import make_mac_tests hashmods = dict(MD5=MD5, SHA1=SHA1, SHA256=SHA256, default=None) try: from Crypto.Hash import SHA224, SHA384, SHA512 hashmods.update(dict(SHA224=SHA224, SHA384=SHA384, SHA512=SHA512)) test_data += hashlib_test_data except ImportError: import sys sys.stderr.write("SelfTest: warning: not testing HMAC-SHA224/384/512 (not available)\n") return make_mac_tests(HMAC, "HMAC", test_data, hashmods)
Example #7
Source File: test_SHA384.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def get_tests(config={}): from Crypto.Hash import SHA384 from common import make_hash_tests return make_hash_tests(SHA384, "SHA384", test_data, digest_size=48, oid='\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x02')
Example #8
Source File: test_HMAC.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def get_tests(config={}): global test_data from Crypto.Hash import HMAC, MD5, SHA as SHA1, SHA256 from common import make_mac_tests hashmods = dict(MD5=MD5, SHA1=SHA1, SHA256=SHA256, default=None) try: from Crypto.Hash import SHA224, SHA384, SHA512 hashmods.update(dict(SHA224=SHA224, SHA384=SHA384, SHA512=SHA512)) test_data += hashlib_test_data except ImportError: import sys sys.stderr.write("SelfTest: warning: not testing HMAC-SHA224/384/512 (not available)\n") return make_mac_tests(HMAC, "HMAC", test_data, hashmods)
Example #9
Source File: test_SHA384.py From FODI with GNU General Public License v3.0 | 5 votes |
def get_tests(config={}): from Crypto.Hash import SHA384 from .common import make_hash_tests return make_hash_tests(SHA384, "SHA384", test_data, digest_size=48, oid='2.16.840.1.101.3.4.2.2')
Example #10
Source File: test_KDF.py From FODI with GNU General Public License v3.0 | 5 votes |
def test3(self): # Verify that hmac_hash_module works like prf password = b("xxx") salt = b("yyy") for hashmod in (MD5, SHA1, SHA224, SHA256, SHA384, SHA512): pr1 = PBKDF2(password, salt, 16, 100, prf=lambda p, s: HMAC.new(p,s,hashmod).digest()) pr2 = PBKDF2(password, salt, 16, 100, hmac_hash_module=hashmod) self.assertEqual(pr1, pr2)
Example #11
Source File: test_KDF.py From FODI with GNU General Public License v3.0 | 5 votes |
def add_tests(self, filename): comps = "Crypto.SelfTest.Protocol.test_vectors.wycheproof".split(".") with open(pycryptodome_filename(comps, filename), "rt") as file_in: tv_tree = json.load(file_in) algo_name = tv_tree['algorithm'] if algo_name == "HKDF-SHA-1": hash_module = SHA1 elif algo_name == "HKDF-SHA-256": hash_module = SHA256 elif algo_name == "HKDF-SHA-384": hash_module = SHA384 elif algo_name == "HKDF-SHA-512": hash_module = SHA512 else: raise ValueError("Unknown algorithm " + algo_name) for group in tv_tree['testGroups']: from collections import namedtuple TestVector = namedtuple('TestVector', 'id comment ikm salt info size okm hash_module valid warning filename') for test in group['tests']: tv = TestVector( test['tcId'], test['comment'], unhexlify(test['ikm']), unhexlify(test['salt']), unhexlify(test['info']), int(test['size']), unhexlify(test['okm']), hash_module, test['result'] != "invalid", test['result'] == "acceptable", filename ) self.tv.append(tv)
Example #12
Source File: test_SHA384.py From android_universal with MIT License | 5 votes |
def get_tests(config={}): from Crypto.Hash import SHA384 from .common import make_hash_tests return make_hash_tests(SHA384, "SHA384", test_data, digest_size=48, oid='2.16.840.1.101.3.4.2.2')
Example #13
Source File: test_KDF.py From android_universal with MIT License | 5 votes |
def test3(self): # Verify that hmac_hash_module works like prf password = b("xxx") salt = b("yyy") for hashmod in (MD5, SHA1, SHA224, SHA256, SHA384, SHA512): pr1 = PBKDF2(password, salt, 16, 100, prf=lambda p, s: HMAC.new(p,s,hashmod).digest()) pr2 = PBKDF2(password, salt, 16, 100, hmac_hash_module=hashmod) self.assertEqual(pr1, pr2)
Example #14
Source File: test_pkcs1_15.py From android_universal with MIT License | 5 votes |
def add_tests(self, filename): comps = "Crypto.SelfTest.Signature.test_vectors.wycheproof".split(".") with open(pycryptodome_filename(comps, filename), "rt") as file_in: tv_tree = json.load(file_in) class TestVector(object): pass self.tv = [] for group in tv_tree['testGroups']: key = RSA.import_key(group['keyPem']) hash_name = group['sha'] if hash_name == "SHA-512": hash_module = SHA512 elif hash_name == "SHA-384": hash_module = SHA384 elif hash_name == "SHA-256": hash_module = SHA256 elif hash_name == "SHA-224": hash_module = SHA224 elif hash_name == "SHA-1": hash_module = SHA1 else: raise ValueError("Unknown hash algorithm: " + hash_name) assert group['type'] == "RSASigVer" for test in group['tests']: tv = TestVector() tv.id = test['tcId'] tv.comment = test['comment'] for attr in 'msg', 'sig': setattr(tv, attr, unhexlify(test[attr])) tv.key = key tv.hash_module = hash_module tv.valid = test['result'] != "invalid" tv.warning = test['result'] == "acceptable" self.tv.append(tv)