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;
}