]> git.ipfire.org Git - thirdparty/openssl.git/blame - providers/implementations/ciphers/cipher_aes_gcm.c
PROV: Move AES_GCM specialisation away from common cipher header
[thirdparty/openssl.git] / providers / implementations / ciphers / cipher_aes_gcm.c
CommitLineData
e1178600
SL
1/*
2 * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10/* Dispatch functions for AES GCM mode */
11
dc7aa029 12#include "cipher_aes_gcm.h"
af3e7e1b 13#include "prov/implementations.h"
e1178600
SL
14
15static void *aes_gcm_newctx(void *provctx, size_t keybits)
16{
17 PROV_AES_GCM_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
18
19 if (ctx != NULL)
20 gcm_initctx(provctx, &ctx->base, keybits, PROV_AES_HW_gcm(keybits), 8);
21 return ctx;
22}
23
24static OSSL_OP_cipher_freectx_fn aes_gcm_freectx;
25static void aes_gcm_freectx(void *vctx)
26{
27 PROV_AES_GCM_CTX *ctx = (PROV_AES_GCM_CTX *)vctx;
28
e1178600
SL
29 OPENSSL_clear_free(ctx, sizeof(*ctx));
30}
31
32/* aes128gcm_functions */
33IMPLEMENT_aead_cipher(aes, gcm, GCM, AEAD_FLAGS, 128, 8, 96);
34/* aes192gcm_functions */
35IMPLEMENT_aead_cipher(aes, gcm, GCM, AEAD_FLAGS, 192, 8, 96);
36/* aes256gcm_functions */
37IMPLEMENT_aead_cipher(aes, gcm, GCM, AEAD_FLAGS, 256, 8, 96);