本文整理匯總了Python中cryptography.hazmat.primitives.hashes.SHA224屬性的典型用法代碼示例。如果您正苦於以下問題:Python hashes.SHA224屬性的具體用法?Python hashes.SHA224怎麽用?Python hashes.SHA224使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類cryptography.hazmat.primitives.hashes
的用法示例。
在下文中一共展示了hashes.SHA224屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: generate_signature
# 需要導入模塊: from cryptography.hazmat.primitives import hashes [as 別名]
# 或者: from cryptography.hazmat.primitives.hashes import SHA224 [as 別名]
def generate_signature(self, pri_key: str, msg: bytes) -> str:
if self.__scheme == SignatureScheme.SHA224withECDSA:
private_key = ec.derive_private_key(int(pri_key, 16), ec.SECP224R1(), default_backend())
signature = private_key.sign(
msg,
ec.ECDSA(hashes.SHA224())
)
elif self.__scheme == SignatureScheme.SHA256withECDSA:
private_key = ec.derive_private_key(int(pri_key, 16), ec.SECP256R1(), default_backend())
signature = private_key.sign(
msg,
ec.ECDSA(hashes.SHA256())
)
elif self.__scheme == SignatureScheme.SHA384withECDSA:
private_key = ec.derive_private_key(int(pri_key, 16), ec.SECP384R1(), default_backend())
signature = private_key.sign(
msg,
ec.ECDSA(hashes.SHA384())
)
else:
raise SDKException(ErrorCode.other_error('Invalid signature scheme.'))
sign = SignatureHandler.dsa_der_to_plain(signature)
return sign
示例2: _oaep_hash_supported
# 需要導入模塊: from cryptography.hazmat.primitives import hashes [as 別名]
# 或者: from cryptography.hazmat.primitives.hashes import SHA224 [as 別名]
def _oaep_hash_supported(self, algorithm):
if self._lib.Cryptography_HAS_RSA_OAEP_MD:
return isinstance(
algorithm, (
hashes.SHA1,
hashes.SHA224,
hashes.SHA256,
hashes.SHA384,
hashes.SHA512,
)
)
else:
return isinstance(algorithm, hashes.SHA1)
示例3: _verify_algorithm
# 需要導入模塊: from cryptography.hazmat.primitives import hashes [as 別名]
# 或者: from cryptography.hazmat.primitives.hashes import SHA224 [as 別名]
def _verify_algorithm(algorithm):
if not isinstance(algorithm, _ALLOWED_HASHES):
raise ValueError(
"Algorithm must be SHA1, SHA224, SHA256, SHA384, or SHA512"
)
示例4: test_handle_symmetric_padding_undo
# 需要導入模塊: from cryptography.hazmat.primitives import hashes [as 別名]
# 或者: from cryptography.hazmat.primitives.hashes import SHA224 [as 別名]
def test_handle_symmetric_padding_undo(symmetric_padding_parameters):
"""
Test that data of various lengths can be unpadded correctly using
different padding schemes.
"""
engine = crypto.CryptographyEngine()
result = engine._handle_symmetric_padding(
symmetric_padding_parameters.get('algorithm'),
symmetric_padding_parameters.get('padded_text'),
symmetric_padding_parameters.get('padding_method'),
undo_padding=True
)
assert result == symmetric_padding_parameters.get('plain_text')
# PBKDF2 test vectors were obtained from IETF RFC 6070:
#
# https://www.ietf.org/rfc/rfc6070.txt
#
# HMAC test vectors were obtained from IETF RFC 5869:
#
# https://tools.ietf.org/html/rfc5869
#
# HASH test vectors for SHA1/SHA224/SHA256/SHA384/SHA512
# were obtained from the NIST CAVP test suite. Test vectors for MD5 were
# obtained from NIST NSRL:
#
# http://csrc.nist.gov/groups/STM/cavp/documents/shs/shabytetestvectors.zip
# https://www.nsrl.nist.gov/testdata/
#
# NIST 800-108 Counter Mode test vectors were obtained from the NIST CAVP
# test suite:
#
# http://csrc.nist.gov/groups/STM/cavp/documents/KBKDF800-108/kbkdfvs.pdf
# http://csrc.nist.gov/groups/STM/cavp/documents/KBKDF800-108/CounterMode.zip
示例5: verify_certificate_algorithm
# 需要導入模塊: from cryptography.hazmat.primitives import hashes [as 別名]
# 或者: from cryptography.hazmat.primitives.hashes import SHA224 [as 別名]
def verify_certificate_algorithm(cert):
valid_algorithm = False
for alg in [SHA224, SHA256, SHA256, SHA384, SHA512]:
if isinstance(cert.signature_hash_algorithm, alg):
valid_algorithm = True
break
return valid_algorithm