Skip to content

Commit 3f42dfd

Browse files
committed
STM32 MBEDTLS: AES/CCM/GCM/MD5/SHA1/SHA256 ALT implementation
1 parent f62e384 commit 3f42dfd

File tree

12 files changed

+2944
-853
lines changed

12 files changed

+2944
-853
lines changed

features/mbedtls/targets/TARGET_STM/aes_alt.c

Lines changed: 914 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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+
/*
24+
* Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved.
25+
* Copyright (C) 2019-2020 STMicroelectronics, All Rights Reserved
26+
* SPDX-License-Identifier: Apache-2.0
27+
*
28+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
29+
* not use this file except in compliance with the License.
30+
* You may obtain a copy of the License at
31+
*
32+
* http://www.apache.org/licenses/LICENSE-2.0
33+
*
34+
* Unless required by applicable law or agreed to in writing, software
35+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
36+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37+
* See the License for the specific language governing permissions and
38+
* limitations under the License.
39+
*
40+
* This file implements ST AES HW services based on API from mbed TLS
41+
*/
42+
43+
/* Define to prevent recursive inclusion -------------------------------------*/
44+
#ifndef MBEDTLS_AES_ALT_H
45+
#define MBEDTLS_AES_ALT_H
46+
47+
#if (TARGET_STM32L4)
48+
#include "aes_alt_stm32l4.h"
49+
#else
50+
#if defined(MBEDTLS_AES_ALT)
51+
/* Includes ------------------------------------------------------------------*/
52+
#include "cryp_stm32.h"
53+
54+
#ifdef __cplusplus
55+
extern "C" {
56+
#endif
57+
58+
/* Exported types ------------------------------------------------------------*/
59+
/**
60+
* \brief AES context structure
61+
*/
62+
typedef struct {
63+
/* Encryption/Decryption key */
64+
uint32_t aes_key[8];
65+
66+
CRYP_HandleTypeDef hcryp_aes; /* AES context */
67+
uint32_t ctx_save_cr; /* save context for multi-context */
68+
}
69+
mbedtls_aes_context;
70+
71+
#if defined(MBEDTLS_CIPHER_MODE_XTS)
72+
/**
73+
* \brief The AES XTS context-type definition.
74+
*/
75+
typedef struct mbedtls_aes_xts_context {
76+
mbedtls_aes_context crypt; /*!< The AES context to use for AES block
77+
encryption or decryption. */
78+
mbedtls_aes_context tweak; /*!< The AES context used for tweak
79+
computation. */
80+
} mbedtls_aes_xts_context;
81+
#endif /* MBEDTLS_CIPHER_MODE_XTS */
82+
83+
/* Exported constants --------------------------------------------------------*/
84+
/* Exported macro ------------------------------------------------------------*/
85+
/* Exported functions --------------------------------------------------------*/
86+
87+
88+
#ifdef __cplusplus
89+
}
90+
#endif
91+
92+
#endif /* MBEDTLS_AES_ALT */
93+
94+
#endif /* MBEDTLS_AES_ALT_H */
95+
96+
#endif /* ! TARGET_STM32L4 */

0 commit comments

Comments
 (0)