1 /** 2 * \file aes_alt.h 3 * 4 * \brief This file contains AES definitions and functions. 5 * 6 * The Advanced Encryption Standard (AES) specifies a FIPS-approved 7 * cryptographic algorithm that can be used to protect electronic 8 * data. 9 * 10 * The AES algorithm is a symmetric block cipher that can 11 * encrypt and decrypt information. For more information, see 12 * <em>FIPS Publication 197: Advanced Encryption Standard</em> and 13 * <em>ISO/IEC 18033-2:2006: Information technology -- Security 14 * techniques -- Encryption algorithms -- Part 2: Asymmetric 15 * ciphers</em>. 16 * 17 * The AES-XTS block mode is standardized by NIST SP 800-38E 18 * <https://nvlpubs.nist.gov/nistpubs/legacy/sp/nistspecialpublication800-38e.pdf> 19 * and described in detail by IEEE P1619 20 * <https://ieeexplore.ieee.org/servlet/opac?punumber=4375278>. 21 */ 22 23 /* Copyright The Mbed TLS Contributors 24 * Copyright (C) 2021, STMicroelectronics, All Rights Reserved 25 * SPDX-License-Identifier: Apache-2.0 26 * 27 * Licensed under the Apache License, Version 2.0 (the "License"); you may 28 * not use this file except in compliance with the License. 29 * You may obtain a copy of the License at 30 * 31 * http://www.apache.org/licenses/LICENSE-2.0 32 * 33 * Unless required by applicable law or agreed to in writing, software 34 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 35 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 36 * See the License for the specific language governing permissions and 37 * limitations under the License. 38 * 39 * This file implements ST AES HW services based on API from mbed TLS 40 */ 41 42 #ifndef MBEDTLS_AES_ALT_H 43 #define MBEDTLS_AES_ALT_H 44 45 #if defined(MBEDTLS_AES_ALT) 46 #include "stm32hal.h" 47 48 #ifdef __cplusplus 49 extern "C" { 50 #endif 51 52 /** 53 * \brief AES context structure 54 */ 55 typedef struct { 56 uint32_t aes_key[8]; /* Decryption key */ 57 CRYP_HandleTypeDef hcryp_aes; /* HW driver handle */ 58 uint32_t ctx_save_cr; /* Saved HW context for multi-instance */ 59 } 60 mbedtls_aes_context; 61 62 #if defined(MBEDTLS_CIPHER_MODE_XTS) 63 /** 64 * \brief The AES XTS context-type definition. 65 */ 66 typedef struct mbedtls_aes_xts_context 67 { 68 mbedtls_aes_context crypt; /*!< The AES context to use for AES block 69 encryption or decryption. */ 70 mbedtls_aes_context tweak; /*!< The AES context used for tweak 71 computation. */ 72 } mbedtls_aes_xts_context; 73 #endif /* MBEDTLS_CIPHER_MODE_XTS */ 74 75 #ifdef __cplusplus 76 } 77 #endif 78 79 #endif /* MBEDTLS_AES_ALT */ 80 81 #endif /* MBEDTLS_AES_ALT_H */ 82 83