From b36e3af1f715eaebefc4a3b97c7ec5a7e0b8990c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Mon, 6 Feb 2023 20:36:45 +0100 Subject: Move ocb_aes128_ctx and nettle_ocb_aes128 to nettle-internal.{c,h} for now. --- nettle-internal.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'nettle-internal.c') diff --git a/nettle-internal.c b/nettle-internal.c index dd293227..5f0f0086 100644 --- a/nettle-internal.c +++ b/nettle-internal.c @@ -248,3 +248,62 @@ nettle_cbc_aes256 = { NULL, NULL, }; + +static void +set_encrypt_key_wrapper (struct ocb_aes128_ctx *ctx, const uint8_t *key) +{ + ocb_aes128_set_encrypt_key(&ctx->key, key); +} + +static void +set_decrypt_key_wrapper (struct ocb_aes128_ctx *ctx, const uint8_t *key) +{ + ocb_aes128_set_decrypt_key(&ctx->key, &ctx->decrypt, key); +} + +static void +set_nonce_wrapper (struct ocb_aes128_ctx *ctx, const uint8_t *nonce) +{ + ocb_aes128_set_nonce (&ctx->ocb, &ctx->key, + OCB_DIGEST_SIZE, OCB_NONCE_SIZE, nonce); +} + +static void +update_wrapper (struct ocb_aes128_ctx *ctx, size_t length, const uint8_t *data) +{ + ocb_aes128_update (&ctx->ocb, &ctx->key, length, data); +} + +static void +encrypt_wrapper (struct ocb_aes128_ctx *ctx, + size_t length, uint8_t *dst, const uint8_t *src) +{ + ocb_aes128_encrypt (&ctx->ocb, &ctx->key, length, dst, src); +} + +static void +decrypt_wrapper (struct ocb_aes128_ctx *ctx, + size_t length, uint8_t *dst, const uint8_t *src) +{ + ocb_aes128_decrypt (&ctx->ocb, &ctx->key, &ctx->decrypt, length, dst, src); +} + +static void +digest_wrapper (struct ocb_aes128_ctx *ctx, size_t length, uint8_t *digest) +{ + ocb_aes128_digest (&ctx->ocb, &ctx->key, length, digest); +} + +const struct nettle_aead +nettle_ocb_aes128 = + { "ocb_aes128", sizeof(struct ocb_aes128_ctx), + OCB_BLOCK_SIZE, AES128_KEY_SIZE, + OCB_NONCE_SIZE, OCB_DIGEST_SIZE, + (nettle_set_key_func *) set_encrypt_key_wrapper, + (nettle_set_key_func *) set_decrypt_key_wrapper, + (nettle_set_key_func *) set_nonce_wrapper, + (nettle_hash_update_func *) update_wrapper, + (nettle_crypt_func *) encrypt_wrapper, + (nettle_crypt_func *) decrypt_wrapper, + (nettle_hash_digest_func *) digest_wrapper + }; -- cgit v1.2.1