diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2019-01-10 15:37:03 -0800 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2019-01-10 18:37:03 -0500 |
commit | 60f264b0f293bfded7a0b4395715669d355a6185 (patch) | |
tree | a8fdf4f17f20115063e557eebf36b0f9dd1b7a63 /src | |
parent | 90a557764542f2d939a8b0a61c74b299870fca6c (diff) | |
download | cryptography-60f264b0f293bfded7a0b4395715669d355a6185.tar.gz cryptography-60f264b0f293bfded7a0b4395715669d355a6185.tar.bz2 cryptography-60f264b0f293bfded7a0b4395715669d355a6185.zip |
add signature_hash_algorithm to OCSPResponse (#4681)
* add signature_hash_algorithm to OCSPResponse
* fix pointless asserts
Diffstat (limited to 'src')
-rw-r--r-- | src/cryptography/hazmat/backends/openssl/ocsp.py | 11 | ||||
-rw-r--r-- | src/cryptography/x509/ocsp.py | 6 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/cryptography/hazmat/backends/openssl/ocsp.py b/src/cryptography/hazmat/backends/openssl/ocsp.py index 32e26a0a..16dbbc2a 100644 --- a/src/cryptography/hazmat/backends/openssl/ocsp.py +++ b/src/cryptography/hazmat/backends/openssl/ocsp.py @@ -128,6 +128,17 @@ class _OCSPResponse(object): @property @_requires_successful_response + def signature_hash_algorithm(self): + oid = self.signature_algorithm_oid + try: + return x509._SIG_OIDS_TO_HASH[oid] + except KeyError: + raise UnsupportedAlgorithm( + "Signature algorithm OID:{0} not recognized".format(oid) + ) + + @property + @_requires_successful_response def signature(self): sig = self._backend._lib.OCSP_resp_get0_signature(self._basic) self._backend.openssl_assert(sig != self._backend._ffi.NULL) diff --git a/src/cryptography/x509/ocsp.py b/src/cryptography/x509/ocsp.py index 2b0b1dc3..97933b1f 100644 --- a/src/cryptography/x509/ocsp.py +++ b/src/cryptography/x509/ocsp.py @@ -315,6 +315,12 @@ class OCSPResponse(object): """ @abc.abstractproperty + def signature_hash_algorithm(self): + """ + Returns a HashAlgorithm corresponding to the type of the digest signed + """ + + @abc.abstractproperty def signature(self): """ The signature bytes |