aboutsummaryrefslogtreecommitdiffstats
path: root/src/cryptography/x509/ocsp.py
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2018-08-15 18:04:28 -0500
committerAlex Gaynor <alex.gaynor@gmail.com>2018-08-15 19:04:28 -0400
commit732cf642141f57f26db84ec2a4f6122cf7918c9e (patch)
tree50902db869cba9ff9599491c76767bd2755e40ec /src/cryptography/x509/ocsp.py
parent962c963f75327f43592d7be31b156837f1f9eff1 (diff)
downloadcryptography-732cf642141f57f26db84ec2a4f6122cf7918c9e.tar.gz
cryptography-732cf642141f57f26db84ec2a4f6122cf7918c9e.tar.bz2
cryptography-732cf642141f57f26db84ec2a4f6122cf7918c9e.zip
OCSP request parsing (#4393)
* add public_bytes to OCSPRequest * review feedback * OCSP request parsing * change some prose * add __len__ as a required method
Diffstat (limited to 'src/cryptography/x509/ocsp.py')
-rw-r--r--src/cryptography/x509/ocsp.py79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/cryptography/x509/ocsp.py b/src/cryptography/x509/ocsp.py
new file mode 100644
index 00000000..22894dde
--- /dev/null
+++ b/src/cryptography/x509/ocsp.py
@@ -0,0 +1,79 @@
+# This file is dual licensed under the terms of the Apache License, Version
+# 2.0, and the BSD License. See the LICENSE file in the root of this repository
+# for complete details.
+
+from __future__ import absolute_import, division, print_function
+
+import abc
+
+import six
+
+from cryptography.hazmat.primitives import hashes
+
+
+_OIDS_TO_HASH = {
+ "1.3.14.3.2.26": hashes.SHA1(),
+ "2.16.840.1.101.3.4.2.4": hashes.SHA224(),
+ "2.16.840.1.101.3.4.2.1": hashes.SHA256(),
+ "2.16.840.1.101.3.4.2.2": hashes.SHA384(),
+ "2.16.840.1.101.3.4.2.3": hashes.SHA512(),
+}
+
+
+def load_der_ocsp_request(data):
+ from cryptography.hazmat.backends.openssl.backend import backend
+ return backend.load_der_ocsp_request(data)
+
+
+@six.add_metaclass(abc.ABCMeta)
+class OCSPRequest(object):
+ @abc.abstractmethod
+ def __iter__(self):
+ """
+ Iteration of Requests
+ """
+
+ @abc.abstractmethod
+ def __len__(self):
+ """
+ Number of Requests inside the OCSPRequest object
+ """
+
+ @abc.abstractmethod
+ def __getitem__(self, idx):
+ """
+ Returns a Request or range of Requests
+ """
+
+ @abc.abstractmethod
+ def public_bytes(self, encoding):
+ """
+ Serializes the request to DER
+ """
+
+
+@six.add_metaclass(abc.ABCMeta)
+class Request(object):
+ @abc.abstractproperty
+ def issuer_key_hash(self):
+ """
+ The hash of the issuer public key
+ """
+
+ @abc.abstractproperty
+ def issuer_name_hash(self):
+ """
+ The hash of the issuer name
+ """
+
+ @abc.abstractproperty
+ def hash_algorithm(self):
+ """
+ The hash algorithm used in the issuer name and key hashes
+ """
+
+ @abc.abstractproperty
+ def serial_number(self):
+ """
+ The serial number of the cert whose status is being checked
+ """