summaryrefslogtreecommitdiff
path: root/libarchive/archive_hmac.c
diff options
context:
space:
mode:
authorTomas Mraz <tmraz@redhat.com>2016-11-17 15:44:44 -0500
committerBrad King <brad.king@kitware.com>2016-11-21 13:56:54 -0500
commit89a6ed13be1c8813764c40ea2c42c472ec3aabf9 (patch)
tree320f3fc8021a9ca6f4021e3dc44307d30f93a545 /libarchive/archive_hmac.c
parentaa8f77083954fe0f41327ab856be59c370d4c13b (diff)
downloadlibarchive-89a6ed13be1c8813764c40ea2c42c472ec3aabf9.tar.gz
Add support for building with OpenSSL 1.1
OpenSSL 1.1 made some CTX structures opaque. Port our code to use the structures only through pointers via OpenSSL 1.1 APIs. Use our adaption layer to make this work with OpenSSL 1.0 and below. Closes: #810 Patch-from: https://bugzilla.redhat.com/1383744
Diffstat (limited to 'libarchive/archive_hmac.c')
-rw-r--r--libarchive/archive_hmac.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/libarchive/archive_hmac.c b/libarchive/archive_hmac.c
index 7857c0ff..1e0ae283 100644
--- a/libarchive/archive_hmac.c
+++ b/libarchive/archive_hmac.c
@@ -176,8 +176,10 @@ __hmac_sha1_cleanup(archive_hmac_sha1_ctx *ctx)
static int
__hmac_sha1_init(archive_hmac_sha1_ctx *ctx, const uint8_t *key, size_t key_len)
{
- HMAC_CTX_init(ctx);
- HMAC_Init(ctx, key, key_len, EVP_sha1());
+ *ctx = HMAC_CTX_new();
+ if (*ctx == NULL)
+ return -1;
+ HMAC_Init_ex(*ctx, key, key_len, EVP_sha1(), NULL);
return 0;
}
@@ -185,22 +187,22 @@ static void
__hmac_sha1_update(archive_hmac_sha1_ctx *ctx, const uint8_t *data,
size_t data_len)
{
- HMAC_Update(ctx, data, data_len);
+ HMAC_Update(*ctx, data, data_len);
}
static void
__hmac_sha1_final(archive_hmac_sha1_ctx *ctx, uint8_t *out, size_t *out_len)
{
unsigned int len = (unsigned int)*out_len;
- HMAC_Final(ctx, out, &len);
+ HMAC_Final(*ctx, out, &len);
*out_len = len;
}
static void
__hmac_sha1_cleanup(archive_hmac_sha1_ctx *ctx)
{
- HMAC_CTX_cleanup(ctx);
- memset(ctx, 0, sizeof(*ctx));
+ HMAC_CTX_free(*ctx);
+ *ctx = NULL;
}
#else