diff options
author | Niels Möller <nisse@lysator.liu.se> | 2023-02-06 20:36:45 +0100 |
---|---|---|
committer | Niels Möller <nisse@lysator.liu.se> | 2023-02-06 20:36:45 +0100 |
commit | b36e3af1f715eaebefc4a3b97c7ec5a7e0b8990c (patch) | |
tree | b2e44550c0083127d85f08c9ea4ada60f8bd953c /nettle-internal.c | |
parent | fbad65a2d94860e3a3be0769f5a92f51f203604e (diff) | |
download | nettle-ocb-mode.tar.gz |
Move ocb_aes128_ctx and nettle_ocb_aes128 to nettle-internal.{c,h} for now.ocb-mode
Diffstat (limited to 'nettle-internal.c')
-rw-r--r-- | nettle-internal.c | 59 |
1 files changed, 59 insertions, 0 deletions
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 + }; |