1 /** 2 * \file gcm_alt.h.h 3 * 4 * \brief This file contains GCM definitions and functions. 5 * 6 * The Galois/Counter Mode (GCM) for 128-bit block ciphers is defined 7 * in <em>D. McGrew, J. Viega, The Galois/Counter Mode of Operation 8 * (GCM), Natl. Inst. Stand. Technol.</em> 9 * 10 * For more information on GCM, see <em>NIST SP 800-38D: Recommendation for 11 * Block Cipher Modes of Operation: Galois/Counter Mode (GCM) and GMAC</em>. 12 * 13 */ 14 /* 15 * Copyright The Mbed TLS Contributors 16 * Copyright (C) 2021, STMicroelectronics, All Rights Reserved 17 * SPDX-License-Identifier: Apache-2.0 18 * 19 * Licensed under the Apache License, Version 2.0 (the "License"); you may 20 * not use this file except in compliance with the License. 21 * You may obtain a copy of the License at 22 * 23 * http://www.apache.org/licenses/LICENSE-2.0 24 * 25 * Unless required by applicable law or agreed to in writing, software 26 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 27 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 28 * See the License for the specific language governing permissions and 29 * limitations under the License. 30 * 31 * This file implements ST GCM HW services based on API from mbed TLS 32 */ 33 #ifndef MBEDTLS_GCM_ALT_H 34 #define MBEDTLS_GCM_ALT_H 35 36 #if defined(MBEDTLS_GCM_ALT) 37 #include "stm32hal.h" 38 39 #ifdef __cplusplus 40 extern "C" { 41 #endif 42 43 /** 44 * \brief AES context structure 45 * 46 */ 47 typedef struct mbedtls_gcm_context 48 { 49 uint32_t gcm_key[8]; /* Encryption/Decryption key */ 50 CRYP_HandleTypeDef hcryp_gcm; /* HW driver handle */ 51 uint32_t ctx_save_cr; /* Saved HW context for multi-instance */ 52 uint64_t len; /* total length of the encrypted data. */ 53 54 uint64_t HL[16]; /*!< Precalculated HTable low. */ 55 uint64_t HH[16]; /*!< Precalculated HTable high. */ 56 uint64_t add_len; /*!< The total length of the additional data. */ 57 unsigned char base_ectr[16]; /*!< The first ECTR for tag. */ 58 unsigned char y[16]; /*!< The Y working value. */ 59 unsigned char buf[16]; /*!< The buf working value. */ 60 61 int mode; /* The operation to perform: 62 #MBEDTLS_GCM_ENCRYPT or 63 #MBEDTLS_GCM_DECRYPT. */ 64 } 65 mbedtls_gcm_context; 66 67 #ifdef __cplusplus 68 } 69 #endif 70 71 #endif /* MBEDTLS_GCM_ALT */ 72 73 #endif /* MBEDTLS_GCM_ALT_H */ 74