summaryrefslogtreecommitdiff
path: root/nettle-internal.c
diff options
context:
space:
mode:
Diffstat (limited to 'nettle-internal.c')
-rw-r--r--nettle-internal.c59
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
+ };