Mistake on this page?
Report an issue in GitHub or email us
TARGET_STM/sha256_alt.h
1 /**
2  * \file sha256.h
3  *
4  * \brief This file contains SHA-224 and SHA-256 definitions and functions.
5  *
6  * The Secure Hash Algorithms 224 and 256 (SHA-224 and SHA-256) cryptographic
7  * hash functions are defined in <em>FIPS 180-4: Secure Hash Standard (SHS)</em>.
8  */
9 /*
10  * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
11  * Copyright (C) 2019-2020, STMicroelectronics, All Rights Reserved
12  * SPDX-License-Identifier: Apache-2.0
13  *
14  * Licensed under the Apache License, Version 2.0 (the "License"); you may
15  * not use this file except in compliance with the License.
16  * You may obtain a copy of the License at
17  *
18  * http://www.apache.org/licenses/LICENSE-2.0
19  *
20  * Unless required by applicable law or agreed to in writing, software
21  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
22  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23  * See the License for the specific language governing permissions and
24  * limitations under the License.
25  *
26  * This file implements STMicroelectronics SHA256 API with HW services based
27  * on mbed TLS API
28  */
29 
30 #ifndef MBEDTLS_SHA256_ALT_H
31 #define MBEDTLS_SHA256_ALT_H
32 
33 #if defined (MBEDTLS_SHA256_ALT)
34 /* Includes ------------------------------------------------------------------*/
35 #include "hash_stm32.h"
36 
37 #define ST_SHA256_BLOCK_SIZE ((size_t) 64) /*!< HW handles 512 bits, ie 64 bytes */
38 #define ST_SHA256_NB_HASH_REG ((uint32_t)57) /*!< Number of HASH HW context Registers:
39  CR + STR + IMR + CSR[54] */
40 
41 /**
42  * \brief SHA-256 context structure
43  *
44  * The structure is used both for SHA-256 and for SHA-224
45  * checksum calculations. The choice between these two is
46  * made in the call to mbedtls_sha256_starts_ret().
47  */
48 typedef struct mbedtls_sha256_context {
49  int is224; /*!< 0 = use SHA256, 1 = use SHA224 */
50  HASH_HandleTypeDef hhash; /*!< Handle of HASH HAL */
51  uint8_t sbuf[ST_SHA256_BLOCK_SIZE]; /*!< Buffer to store input data until ST_SHA256_BLOCK_SIZE
52  is reached, or until last input data is reached */
53  uint8_t sbuf_len; /*!< Number of bytes stored in sbuf */
54  uint32_t ctx_save_regs[ST_SHA256_NB_HASH_REG];
55 }
56 mbedtls_sha256_context;
57 
58 
59 #endif /* MBEDTLS_SHA256_ALT */
60 #endif /* MBEDTLS_SHA256_ALT_H */
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.