diff --git a/nettle-internal.h b/nettle-internal.h index c5b1b532b252db69b60f4a39876850337b59dbb0..bead0513b942bb4c94713f9e5cc09b59e2544a03 100644 --- a/nettle-internal.h +++ b/nettle-internal.h @@ -74,4 +74,54 @@ extern const struct nettle_cipher nettle_openssl_cast128; extern const struct nettle_hash nettle_openssl_md5; extern const struct nettle_hash nettle_openssl_sha1; +/* Tentative interface for "authenticated encryption with associated + data" algorithms. Should be moved to nettle-meta.h when stable. */ +struct nettle_aead +{ + const char *name; + + unsigned context_size; + /* Block size of the input, and the size of the output digest */ + unsigned block_size; + + /* Suggested key size; other sizes are sometimes possible. */ + unsigned key_size; + + nettle_set_key_func *set_key; + nettle_set_key_func *set_iv; + nettle_hash_update_func *update; + nettle_crypt_func *encrypt; + nettle_crypt_func *decrypt; + nettle_hash_digest_func *digest; +}; + +#define _NETTLE_AEAD(type, TYPE, name, key_size) { \ + #type "-" #name #key_size, \ + sizeof(struct type##_##name##_ctx), \ + TYPE##_BLOCK_SIZE, \ + key_size / 8, \ + (nettle_set_key_func *) type##_##name##_set_key, \ + (nettle_set_key_func *) type##_##name##_set_iv, \ + (nettle_hash_update_func *) type##_##name##_update, \ + (nettle_crypt_func *) type##_##name##_encrypt, \ + (nettle_crypt_func *) type##_##name##_decrypt, \ + (nettle_hash_digest_func *) type##_##name##_digest, \ +} + +const struct nettle_aead nettle_gcm_aes128; +const struct nettle_aead nettle_gcm_aes192; +const struct nettle_aead nettle_gcm_aes256; + +const struct nettle_aead nettle_gcm_camellia128; +const struct nettle_aead nettle_gcm_camellia192; +const struct nettle_aead nettle_gcm_camellia256; + +const struct nettle_aead nettle_gcm_serpent128; +const struct nettle_aead nettle_gcm_serpent192; +const struct nettle_aead nettle_gcm_serpent256; + +const struct nettle_aead nettle_gcm_twofish128; +const struct nettle_aead nettle_gcm_twofish192; +const struct nettle_aead nettle_gcm_twofish256; + #endif /* NETTLE_INTERNAL_H_INCLUDED */