diff options
author | Martin Matuska <martin@matuska.org> | 2020-01-03 00:24:39 +0100 |
---|---|---|
committer | Martin Matuska <martin@matuska.org> | 2020-01-03 03:10:32 +0100 |
commit | f96a71144b7725ca4a94d84bd27d7dca8c2f58d2 (patch) | |
tree | 44e5f4496eb19dcb943b47e8cf716e17b54964a8 /libarchive/archive_cryptor_private.h | |
parent | ded60625ca7cbd87a8aab6c23cb674373ea139f1 (diff) | |
download | libarchive-f96a71144b7725ca4a94d84bd27d7dca8c2f58d2.tar.gz |
Add mbed TLS as optional crypto provider
Make Nettle optional and OpenSSL default
Fixes #1301
Diffstat (limited to 'libarchive/archive_cryptor_private.h')
-rw-r--r-- | libarchive/archive_cryptor_private.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libarchive/archive_cryptor_private.h b/libarchive/archive_cryptor_private.h index b9759220..0063f3e0 100644 --- a/libarchive/archive_cryptor_private.h +++ b/libarchive/archive_cryptor_private.h @@ -83,6 +83,23 @@ typedef struct { unsigned encr_pos; } archive_crypto_ctx; +#elif defined(HAVE_LIBMBEDCRYPTO) && defined(HAVE_MBEDTLS_AES_H) +#include <mbedtls/aes.h> +#include <mbedtls/md.h> +#include <mbedtls/pkcs5.h> + +#define AES_MAX_KEY_SIZE 32 +#define AES_BLOCK_SIZE 16 + +typedef struct { + mbedtls_aes_context ctx; + uint8_t key[AES_MAX_KEY_SIZE]; + unsigned key_len; + uint8_t nonce[AES_BLOCK_SIZE]; + uint8_t encr_buf[AES_BLOCK_SIZE]; + unsigned encr_pos; +} archive_crypto_ctx; + #elif defined(HAVE_LIBNETTLE) && defined(HAVE_NETTLE_AES_H) #if defined(HAVE_NETTLE_PBKDF2_H) #include <nettle/pbkdf2.h> |