1e1051a39Sopenharmony_ci/* 2e1051a39Sopenharmony_ci * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved. 3e1051a39Sopenharmony_ci * 4e1051a39Sopenharmony_ci * Licensed under the Apache License 2.0 (the "License"). You may not use 5e1051a39Sopenharmony_ci * this file except in compliance with the License. You can obtain a copy 6e1051a39Sopenharmony_ci * in the file LICENSE in the source distribution or at 7e1051a39Sopenharmony_ci * https://www.openssl.org/source/license.html 8e1051a39Sopenharmony_ci */ 9e1051a39Sopenharmony_ci 10e1051a39Sopenharmony_ci/* 11e1051a39Sopenharmony_ci * AES low level APIs are deprecated for public use, but still ok for internal 12e1051a39Sopenharmony_ci * use where we're using them to implement the higher level EVP interface, as is 13e1051a39Sopenharmony_ci * the case here. 14e1051a39Sopenharmony_ci */ 15e1051a39Sopenharmony_ci#include "internal/deprecated.h" 16e1051a39Sopenharmony_ci 17e1051a39Sopenharmony_ci/* Dispatch functions for AES GCM mode */ 18e1051a39Sopenharmony_ci 19e1051a39Sopenharmony_ci#include "cipher_aes_gcm.h" 20e1051a39Sopenharmony_ci#include "prov/implementations.h" 21e1051a39Sopenharmony_ci#include "prov/providercommon.h" 22e1051a39Sopenharmony_ci 23e1051a39Sopenharmony_cistatic void *aes_gcm_newctx(void *provctx, size_t keybits) 24e1051a39Sopenharmony_ci{ 25e1051a39Sopenharmony_ci PROV_AES_GCM_CTX *ctx; 26e1051a39Sopenharmony_ci 27e1051a39Sopenharmony_ci if (!ossl_prov_is_running()) 28e1051a39Sopenharmony_ci return NULL; 29e1051a39Sopenharmony_ci 30e1051a39Sopenharmony_ci ctx = OPENSSL_zalloc(sizeof(*ctx)); 31e1051a39Sopenharmony_ci if (ctx != NULL) 32e1051a39Sopenharmony_ci ossl_gcm_initctx(provctx, &ctx->base, keybits, 33e1051a39Sopenharmony_ci ossl_prov_aes_hw_gcm(keybits)); 34e1051a39Sopenharmony_ci return ctx; 35e1051a39Sopenharmony_ci} 36e1051a39Sopenharmony_ci 37e1051a39Sopenharmony_cistatic OSSL_FUNC_cipher_freectx_fn aes_gcm_freectx; 38e1051a39Sopenharmony_cistatic void aes_gcm_freectx(void *vctx) 39e1051a39Sopenharmony_ci{ 40e1051a39Sopenharmony_ci PROV_AES_GCM_CTX *ctx = (PROV_AES_GCM_CTX *)vctx; 41e1051a39Sopenharmony_ci 42e1051a39Sopenharmony_ci OPENSSL_clear_free(ctx, sizeof(*ctx)); 43e1051a39Sopenharmony_ci} 44e1051a39Sopenharmony_ci 45e1051a39Sopenharmony_ci/* ossl_aes128gcm_functions */ 46e1051a39Sopenharmony_ciIMPLEMENT_aead_cipher(aes, gcm, GCM, AEAD_FLAGS, 128, 8, 96); 47e1051a39Sopenharmony_ci/* ossl_aes192gcm_functions */ 48e1051a39Sopenharmony_ciIMPLEMENT_aead_cipher(aes, gcm, GCM, AEAD_FLAGS, 192, 8, 96); 49e1051a39Sopenharmony_ci/* ossl_aes256gcm_functions */ 50e1051a39Sopenharmony_ciIMPLEMENT_aead_cipher(aes, gcm, GCM, AEAD_FLAGS, 256, 8, 96); 51