aboutsummaryrefslogtreecommitdiffstats
path: root/ext/openssl/openssl_missing.c
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-05-05 15:53:08 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-05-05 18:43:52 +0900
commit0defff925a85f675b17c7c6d6d8c9d2d20f6c56c (patch)
tree3898589cdbc9e3fde69c9aa1ccfc8c4efa414d62 /ext/openssl/openssl_missing.c
parent3889a0d192d484e2d0a27ebdda3311a2d7073c1c (diff)
downloadruby-0defff925a85f675b17c7c6d6d8c9d2d20f6c56c.tar.gz
ext/openssl: use HMAC_CTX_{new,free,reset} to allocate HMAC_CTX
HMAC_CTX is made opaque in OpenSSL 1.1.0
Diffstat (limited to 'ext/openssl/openssl_missing.c')
-rw-r--r--ext/openssl/openssl_missing.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/ext/openssl/openssl_missing.c b/ext/openssl/openssl_missing.c
index 4222ce65bf..735ec8cfd5 100644
--- a/ext/openssl/openssl_missing.c
+++ b/ext/openssl/openssl_missing.c
@@ -65,15 +65,19 @@ EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in)
#endif
#if !defined(HAVE_HMAC_CTX_COPY)
-void
+int
HMAC_CTX_copy(HMAC_CTX *out, HMAC_CTX *in)
{
- if (!out || !in) return;
+ if (!out || !in)
+ return 0;
+
memcpy(out, in, sizeof(HMAC_CTX));
EVP_MD_CTX_copy(&out->md_ctx, &in->md_ctx);
EVP_MD_CTX_copy(&out->i_ctx, &in->i_ctx);
EVP_MD_CTX_copy(&out->o_ctx, &in->o_ctx);
+
+ return 1;
}
#endif /* HAVE_HMAC_CTX_COPY */
@@ -95,3 +99,34 @@ CRYPTO_memcmp(const volatile void * volatile in_a,
return x;
}
#endif
+
+/*** added in 1.1.0 ***/
+#if !defined(HAVE_HMAC_CTX_NEW)
+HMAC_CTX *
+HMAC_CTX_new(void)
+{
+ HMAC_CTX *ctx = OPENSSL_malloc(sizeof(HMAC_CTX));
+ HMAC_CTX_reset(ctx);
+ if (!ctx)
+ return NULL;
+ return ctx;
+}
+#endif
+
+#if !defined(HAVE_HMAC_CTX_FREE)
+void
+HMAC_CTX_free(HMAC_CTX *ctx)
+{
+ HMAC_CTX_cleanup(ctx);
+ OPENSSL_free(ctx);
+}
+#endif
+
+#if !defined(HAVE_HMAC_CTX_RESET)
+int
+HMAC_CTX_reset(HMAC_CTX *ctx)
+{
+ HMAC_CTX_init(ctx);
+ return 0;
+}
+#endif