Python cryptography.hazmat.primitives.hashes.SHA224 Examples
The following are 16
code examples of cryptography.hazmat.primitives.hashes.SHA224().
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
cryptography.hazmat.primitives.hashes
, or try the search function
.
Example #1
Source File: signature_handler.py From ontology-python-sdk with GNU Lesser General Public License v3.0 | 6 votes |
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
Example #2
Source File: backend.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
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)
Example #3
Source File: backend.py From teleport with Apache License 2.0 | 5 votes |
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)
Example #4
Source File: ocsp.py From teleport with Apache License 2.0 | 5 votes |
def _verify_algorithm(algorithm): if not isinstance(algorithm, _ALLOWED_HASHES): raise ValueError( "Algorithm must be SHA1, SHA224, SHA256, SHA384, or SHA512" )
Example #5
Source File: backend.py From teleport with Apache License 2.0 | 5 votes |
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)
Example #6
Source File: ocsp.py From teleport with Apache License 2.0 | 5 votes |
def _verify_algorithm(algorithm): if not isinstance(algorithm, _ALLOWED_HASHES): raise ValueError( "Algorithm must be SHA1, SHA224, SHA256, SHA384, or SHA512" )
Example #7
Source File: backend.py From teleport with Apache License 2.0 | 5 votes |
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)
Example #8
Source File: ocsp.py From learn_python3_spider with MIT License | 5 votes |
def _verify_algorithm(algorithm): if not isinstance(algorithm, _ALLOWED_HASHES): raise ValueError( "Algorithm must be SHA1, SHA224, SHA256, SHA384, or SHA512" )
Example #9
Source File: backend.py From learn_python3_spider with MIT License | 5 votes |
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)
Example #10
Source File: test_engine.py From PyKMIP with Apache License 2.0 | 5 votes |
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
Example #11
Source File: crypto.py From spid-testenv2 with GNU Affero General Public License v3.0 | 5 votes |
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
Example #12
Source File: backend.py From quickstart-git2s3 with Apache License 2.0 | 5 votes |
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)
Example #13
Source File: ocsp.py From quickstart-redhat-openshift with Apache License 2.0 | 5 votes |
def _verify_algorithm(algorithm): if not isinstance(algorithm, _ALLOWED_HASHES): raise ValueError( "Algorithm must be SHA1, SHA224, SHA256, SHA384, or SHA512" )
Example #14
Source File: backend.py From quickstart-redhat-openshift with Apache License 2.0 | 5 votes |
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)
Example #15
Source File: ocsp.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _verify_algorithm(algorithm): if not isinstance(algorithm, _ALLOWED_HASHES): raise ValueError( "Algorithm must be SHA1, SHA224, SHA256, SHA384, or SHA512" )
Example #16
Source File: backend.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)