/*-1* SPDX-License-Identifier: BSD-2-Clause-FreeBSD2*3* Copyright (c) 2023 Stormshield4*5* Redistribution and use in source and binary forms, with or without6* modification, are permitted provided that the following conditions7* are met:8* 1. Redistributions of source code must retain the above copyright9* notice, this list of conditions and the following disclaimer.10* 2. Redistributions in binary form must reproduce the above copyright11* notice, this list of conditions and the following disclaimer in the12* documentation and/or other materials provided with the distribution.13*14* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR15* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES16* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.17* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,18* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT19* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,20* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY21* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT22* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF23* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.24*/2526#ifndef _OSSL_AES_GCM_H_27#define _OSSL_AES_GCM_H_2829#include <crypto/openssl/ossl_cipher.h>3031struct ossl_gcm_context;3233struct ossl_aes_gcm_ops {34void (*init)(struct ossl_gcm_context *ctx, const void *key,35size_t keylen);36void (*setiv)(struct ossl_gcm_context *ctx, const unsigned char *iv,37size_t ivlen);38int (*aad)(struct ossl_gcm_context *ctx, const unsigned char *aad,39size_t len);40int (*encrypt)(struct ossl_gcm_context *ctx, const unsigned char *in,41unsigned char *out, size_t len);42int (*decrypt)(struct ossl_gcm_context *ctx, const unsigned char *in,43unsigned char *out, size_t len);44int (*finish)(struct ossl_gcm_context *ctx, const unsigned char *tag,45size_t len);46void (*tag)(struct ossl_gcm_context *ctx, unsigned char *tag,47size_t len);48};4950#ifndef __SIZEOF_INT128__51typedef struct { uint64_t v[2]; } __uint128_t;52#endif5354struct ossl_gcm_context {55struct {56union {57uint64_t u[2];58uint32_t d[4];59uint8_t c[16];60} Yi, EKi, EK0, len, Xi, H;61__uint128_t Htable[16];62unsigned int mres, ares;63} gcm;6465struct ossl_aes_keysched aes_ks;6667const struct ossl_aes_gcm_ops *ops;68};6970#endif /* !_OSSL_AES_GCM_H_ */717273