Merge pull request #2585 from reaperhulk/san-iterable
support indexing on GeneralNames and SubjectAlternativeName
diff --git a/src/_cffi_src/openssl/asn1.py b/src/_cffi_src/openssl/asn1.py
index ddf4b9c..30bd245 100644
--- a/src/_cffi_src/openssl/asn1.py
+++ b/src/_cffi_src/openssl/asn1.py
@@ -95,13 +95,16 @@
/* ASN1 GENERALIZEDTIME */
int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *, const char *);
+ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *, time_t);
void ASN1_GENERALIZEDTIME_free(ASN1_GENERALIZEDTIME *);
+int i2d_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME *, unsigned char **);
/* ASN1 ENUMERATED */
ASN1_ENUMERATED *ASN1_ENUMERATED_new(void);
void ASN1_ENUMERATED_free(ASN1_ENUMERATED *);
int ASN1_ENUMERATED_set(ASN1_ENUMERATED *, long);
long ASN1_ENUMERATED_get(ASN1_ENUMERATED *);
+int i2d_ASN1_ENUMERATED(ASN1_ENUMERATED *, unsigned char **);
ASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **, const unsigned char **, long,
const ASN1_ITEM *);
diff --git a/src/cryptography/x509/extensions.py b/src/cryptography/x509/extensions.py
index f5fb134..10b8da4 100644
--- a/src/cryptography/x509/extensions.py
+++ b/src/cryptography/x509/extensions.py
@@ -235,6 +235,9 @@
def __ne__(self, other):
return not self == other
+ def __hash__(self):
+ return hash(self.digest)
+
@utils.register_interface(ExtensionType)
class AuthorityInformationAccess(object):
diff --git a/tests/test_x509_ext.py b/tests/test_x509_ext.py
index e725262..bfa94ec 100644
--- a/tests/test_x509_ext.py
+++ b/tests/test_x509_ext.py
@@ -687,6 +687,20 @@
assert ski != ski2
assert ski != object()
+ def test_hash(self):
+ ski1 = x509.SubjectKeyIdentifier(
+ binascii.unhexlify(b"092384932230498bc980aa8098456f6ff7ff3ac9")
+ )
+ ski2 = x509.SubjectKeyIdentifier(
+ binascii.unhexlify(b"092384932230498bc980aa8098456f6ff7ff3ac9")
+ )
+ ski3 = x509.SubjectKeyIdentifier(
+ binascii.unhexlify(b"aa8098456f6ff7ff3ac9092384932230498bc980")
+ )
+
+ assert hash(ski1) == hash(ski2)
+ assert hash(ski1) != hash(ski3)
+
class TestAuthorityKeyIdentifier(object):
def test_authority_cert_issuer_not_generalname(self):