]> www.wagner.pp.ru Git - oss/ctypescrypto.git/commitdiff
Added X509Name.__hash__
authorVictor Wagner <wagner@atlas-card.ru>
Wed, 4 Feb 2015 13:11:31 +0000 (16:11 +0300)
committerVictor Wagner <wagner@atlas-card.ru>
Wed, 4 Feb 2015 13:11:31 +0000 (16:11 +0300)
MANIFEST.in
ctypescrypto/x509.py
tests/testx509.py

index 16b52e44c2815353b0fae9b6620de4761a7d259d..62a0e2c47cff349a923367e106d4e07195314baa 100644 (file)
@@ -1 +1,5 @@
 include tests/*.py
+include LICENSE
+include README.md
+include MANIFEST
+include MANIFEST.in
index dd4cba2b1c13b403359e98c4e1ca02b36158e7f0..e2ddea88f508f336f822f43ea9ad5c640e6751e7 100644 (file)
@@ -177,6 +177,8 @@ class X509Name(object):
                        raise ValueError("Attempt to modify constant X509 object")
                else:
                        raise NotImplementedError
+       def __hash__(self):
+               return libcrypto.X509_NAME_hash(self.ptr)
 
 class _x509_ext(Structure):
        """ Represens C structure X509_EXTENSION """
@@ -568,3 +570,5 @@ libcrypto.sk_value.restype=c_void_p
 libcrypto.X509_dup.restype=c_void_p
 libcrypto.sk_new_null.restype=c_void_p
 libcrypto.X509_dup.argtypes=(c_void_p,)
+libcrypto.X509_NAME_hash.restype=c_long
+libcrypto.X509_NAME_hash.argtypes=(c_void_p,)
index 060cc0967623b86bc87c637d3d314db9fec71416..060d8117111e96f80fc1e57940b86ab0ddadf66c 100644 (file)
@@ -158,6 +158,12 @@ zVMSW4SOwg/H7ZMZ2cn6j1g0djIvruFQFGHUqFijyDATI+/GJYw2jxyA
        def test_notAfter(self):
                c=X509(self.cert1)
                self.assertEqual(c.endDate,datetime.datetime(2024,10,23,19,7,17,0,utc))
+       def test_subjectHash(self):
+               c=X509(self.cert1)
+               self.assertEqual(hash(c.subject),0x1f3ed722)
+       def test_issuerHash(self):
+               c=X509(self.cert1)
+               self.assertEqual(hash(c.issuer),0x7d3ea8c3)
        def test_namecomp(self):
                c=X509(self.cert1)
                ca=X509(self.ca_cert)