summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Matuska <martin@matuska.org>2020-11-02 13:35:03 +0100
committerMartin Matuska <martin@matuska.org>2020-11-02 13:35:03 +0100
commit0ae4ecd57576a330cf77cf28d6b632ec6e6bf113 (patch)
tree6cd650d17060dcaa96c29dd2b701db5d121989f2
parent12caafda8b6e1b1baa0aa492a37c73f02fee122b (diff)
downloadlibarchive-0ae4ecd57576a330cf77cf28d6b632ec6e6bf113.tar.gz
archive_cryptor: silence Nettle 3.5+ warnings
-rw-r--r--libarchive/archive_cryptor.c27
-rw-r--r--libarchive/archive_cryptor_private.h1
2 files changed, 28 insertions, 0 deletions
diff --git a/libarchive/archive_cryptor.c b/libarchive/archive_cryptor.c
index 8ab2b097..486e2999 100644
--- a/libarchive/archive_cryptor.c
+++ b/libarchive/archive_cryptor.c
@@ -347,8 +347,35 @@ aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
static int
aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
{
+#if NETTLE_VERSION_MAJOR < 3 || \
+ (NETTLE_VERSION_MAJOR == 3 && NETTLE_VERSION_MINOR < 5)
aes_set_encrypt_key(&ctx->ctx, ctx->key_len, ctx->key);
aes_encrypt(&ctx->ctx, AES_BLOCK_SIZE, ctx->encr_buf, ctx->nonce);
+#else
+ switch(ctx->key_len) {
+ case 16:
+ aes128_set_encrypt_key((struct aes128_ctx *)&ctx->ctx.u.ctx128,
+ ctx->key);
+ aes128_encrypt((struct aes128_ctx *)&ctx->ctx.u.ctx128,
+ AES_BLOCK_SIZE, ctx->encr_buf, ctx->nonce);
+ break;
+ case 24:
+ aes192_set_encrypt_key((struct aes192_ctx *)&ctx->ctx.u.ctx192,
+ ctx->key);
+ aes192_encrypt((struct aes192_ctx *)&ctx->ctx.u.ctx192,
+ AES_BLOCK_SIZE, ctx->encr_buf, ctx->nonce);
+ break;
+ case 32:
+ aes256_set_encrypt_key((struct aes256_ctx *)&ctx->ctx.u.ctx256,
+ ctx->key);
+ aes256_encrypt((struct aes256_ctx *)&ctx->ctx.u.ctx256,
+ AES_BLOCK_SIZE, ctx->encr_buf, ctx->nonce);
+ break;
+ default:
+ return -1;
+ break;
+ }
+#endif
return 0;
}
diff --git a/libarchive/archive_cryptor_private.h b/libarchive/archive_cryptor_private.h
index 64a20556..bcd6c583 100644
--- a/libarchive/archive_cryptor_private.h
+++ b/libarchive/archive_cryptor_private.h
@@ -104,6 +104,7 @@ typedef struct {
#include <nettle/pbkdf2.h>
#endif
#include <nettle/aes.h>
+#include <nettle/version.h>
typedef struct {
struct aes_ctx ctx;