aboutsummaryrefslogtreecommitdiffstats
path: root/cryptography
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2013-10-18 20:53:04 -0500
committerPaul Kehrer <paul.l.kehrer@gmail.com>2013-10-18 20:53:04 -0500
commitba3b471e4b0f56e65acdb9d5daf64eb726d9c371 (patch)
tree7b9a2189fbf2c0f409ea43035ddb9bd29323addc /cryptography
parentbb069c2fee6460185ee435ea848d80bab2ccec6c (diff)
downloadcryptography-ba3b471e4b0f56e65acdb9d5daf64eb726d9c371.tar.gz
cryptography-ba3b471e4b0f56e65acdb9d5daf64eb726d9c371.tar.bz2
cryptography-ba3b471e4b0f56e65acdb9d5daf64eb726d9c371.zip
change api.supports_hash to take a hash class rather than a str
* This change means hash class names will be byte strings and we no longer need to encode to ascii on hashobject.name in create_hash_context
Diffstat (limited to 'cryptography')
-rw-r--r--cryptography/bindings/openssl/api.py6
-rw-r--r--cryptography/primitives/hashes.py2
2 files changed, 4 insertions, 4 deletions
diff --git a/cryptography/bindings/openssl/api.py b/cryptography/bindings/openssl/api.py
index 548a9e66..84458367 100644
--- a/cryptography/bindings/openssl/api.py
+++ b/cryptography/bindings/openssl/api.py
@@ -139,14 +139,14 @@ class API(object):
assert res != 0
return self.ffi.buffer(buf)[:outlen[0]]
- def supports_hash(self, hashname):
+ def supports_hash(self, hash_cls):
return (self.ffi.NULL !=
- self.lib.EVP_get_digestbyname(hashname.encode("ascii")))
+ self.lib.EVP_get_digestbyname(hash_cls.name))
def create_hash_context(self, hashobject):
ctx = self.lib.EVP_MD_CTX_create()
ctx = self.ffi.gc(ctx, self.lib.EVP_MD_CTX_destroy)
- evp_md = self.lib.EVP_get_digestbyname(hashobject.name.encode("ascii"))
+ evp_md = self.lib.EVP_get_digestbyname(hashobject.name)
assert evp_md != self.ffi.NULL
res = self.lib.EVP_DigestInit_ex(ctx, evp_md, self.ffi.NULL)
assert res != 0
diff --git a/cryptography/primitives/hashes.py b/cryptography/primitives/hashes.py
index d74287f9..f5cf135a 100644
--- a/cryptography/primitives/hashes.py
+++ b/cryptography/primitives/hashes.py
@@ -43,6 +43,6 @@ class BaseHash(object):
class SHA1(BaseHash):
- name = "sha1"
+ name = b"sha1"
digest_size = 20
block_size = 64