aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2016-06-19 01:22:07 -0400
committerPaul Kehrer <paul.l.kehrer@gmail.com>2016-06-19 00:22:07 -0500
commit741b2316b0bfaa107c009659dd4731602471f442 (patch)
tree1fe547e5659ef57b948983d2f920cc52bf2ca4e7
parent8db7ef57d78b666139fe64c62ddc7e6552290b9f (diff)
downloadcryptography-741b2316b0bfaa107c009659dd4731602471f442.tar.gz
cryptography-741b2316b0bfaa107c009659dd4731602471f442.tar.bz2
cryptography-741b2316b0bfaa107c009659dd4731602471f442.zip
Removed 0.9.8 specific hmac code (#2995)
-rw-r--r--src/_cffi_src/openssl/hmac.py65
-rw-r--r--src/cryptography/hazmat/backends/openssl/hmac.py14
2 files changed, 9 insertions, 70 deletions
diff --git a/src/_cffi_src/openssl/hmac.py b/src/_cffi_src/openssl/hmac.py
index bcc8a861..8b853042 100644
--- a/src/_cffi_src/openssl/hmac.py
+++ b/src/_cffi_src/openssl/hmac.py
@@ -13,11 +13,11 @@ typedef ... HMAC_CTX;
"""
FUNCTIONS = """
-int Cryptography_HMAC_Init_ex(HMAC_CTX *, const void *, int, const EVP_MD *,
- ENGINE *);
-int Cryptography_HMAC_Update(HMAC_CTX *, const unsigned char *, size_t);
-int Cryptography_HMAC_Final(HMAC_CTX *, unsigned char *, unsigned int *);
-int Cryptography_HMAC_CTX_copy(HMAC_CTX *, HMAC_CTX *);
+int HMAC_Init_ex(HMAC_CTX *, const void *, int, const EVP_MD *, ENGINE *);
+int HMAC_Update(HMAC_CTX *, const unsigned char *, size_t);
+int HMAC_Final(HMAC_CTX *, unsigned char *, unsigned int *);
+int HMAC_CTX_copy(HMAC_CTX *, HMAC_CTX *);
+
HMAC_CTX *Cryptography_HMAC_CTX_new(void);
void Cryptography_HMAC_CTX_free(HMAC_CTX *ctx);
"""
@@ -26,60 +26,6 @@ MACROS = """
"""
CUSTOMIZATIONS = """
-int Cryptography_HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int key_len,
- const EVP_MD *md, ENGINE *impl) {
-#if OPENSSL_VERSION_NUMBER >= 0x010000000
- return HMAC_Init_ex(ctx, key, key_len, md, impl);
-#else
- HMAC_Init_ex(ctx, key, key_len, md, impl);
- return 1;
-#endif
-}
-
-int Cryptography_HMAC_Update(HMAC_CTX *ctx, const unsigned char *data,
- size_t data_len) {
-#if OPENSSL_VERSION_NUMBER >= 0x010000000
- return HMAC_Update(ctx, data, data_len);
-#else
- HMAC_Update(ctx, data, data_len);
- return 1;
-#endif
-}
-
-int Cryptography_HMAC_Final(HMAC_CTX *ctx, unsigned char *digest,
- unsigned int *outlen) {
-#if OPENSSL_VERSION_NUMBER >= 0x010000000
- return HMAC_Final(ctx, digest, outlen);
-#else
- HMAC_Final(ctx, digest, outlen);
- return 1;
-#endif
-}
-
-int Cryptography_HMAC_CTX_copy(HMAC_CTX *dst_ctx, HMAC_CTX *src_ctx) {
-#if OPENSSL_VERSION_NUMBER >= 0x010000000
- return HMAC_CTX_copy(dst_ctx, src_ctx);
-#else
- HMAC_CTX_init(dst_ctx);
- if (!EVP_MD_CTX_copy_ex(&dst_ctx->i_ctx, &src_ctx->i_ctx)) {
- goto err;
- }
- if (!EVP_MD_CTX_copy_ex(&dst_ctx->o_ctx, &src_ctx->o_ctx)) {
- goto err;
- }
- if (!EVP_MD_CTX_copy_ex(&dst_ctx->md_ctx, &src_ctx->md_ctx)) {
- goto err;
- }
- memcpy(dst_ctx->key, src_ctx->key, HMAC_MAX_MD_CBLOCK);
- dst_ctx->key_length = src_ctx->key_length;
- dst_ctx->md = src_ctx->md;
- return 1;
-
- err:
- return 0;
-#endif
-}
-
HMAC_CTX *Cryptography_HMAC_CTX_new(void) {
#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
return HMAC_CTX_new();
@@ -92,7 +38,6 @@ HMAC_CTX *Cryptography_HMAC_CTX_new(void) {
}
-
void Cryptography_HMAC_CTX_free(HMAC_CTX *ctx) {
#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
return HMAC_CTX_free(ctx);
diff --git a/src/cryptography/hazmat/backends/openssl/hmac.py b/src/cryptography/hazmat/backends/openssl/hmac.py
index ab1ad46f..dff3742d 100644
--- a/src/cryptography/hazmat/backends/openssl/hmac.py
+++ b/src/cryptography/hazmat/backends/openssl/hmac.py
@@ -33,7 +33,7 @@ class _HMACContext(object):
algorithm.name),
_Reasons.UNSUPPORTED_HASH
)
- res = self._backend._lib.Cryptography_HMAC_Init_ex(
+ res = self._backend._lib.HMAC_Init_ex(
ctx, key, len(key), evp_md, self._backend._ffi.NULL
)
self._backend.openssl_assert(res != 0)
@@ -49,27 +49,21 @@ class _HMACContext(object):
copied_ctx = self._backend._ffi.gc(
copied_ctx, self._backend._lib.Cryptography_HMAC_CTX_free
)
- res = self._backend._lib.Cryptography_HMAC_CTX_copy(
- copied_ctx, self._ctx
- )
+ res = self._backend._lib.HMAC_CTX_copy(copied_ctx, self._ctx)
self._backend.openssl_assert(res != 0)
return _HMACContext(
self._backend, self._key, self.algorithm, ctx=copied_ctx
)
def update(self, data):
- res = self._backend._lib.Cryptography_HMAC_Update(
- self._ctx, data, len(data)
- )
+ res = self._backend._lib.HMAC_Update(self._ctx, data, len(data))
self._backend.openssl_assert(res != 0)
def finalize(self):
buf = self._backend._ffi.new("unsigned char[]",
self._backend._lib.EVP_MAX_MD_SIZE)
outlen = self._backend._ffi.new("unsigned int *")
- res = self._backend._lib.Cryptography_HMAC_Final(
- self._ctx, buf, outlen
- )
+ res = self._backend._lib.HMAC_Final(self._ctx, buf, outlen)
self._backend.openssl_assert(res != 0)
self._backend.openssl_assert(outlen[0] == self.algorithm.digest_size)
return self._backend._ffi.buffer(buf)[:outlen[0]]