Mistake on this page?
Report an issue in GitHub or email us
TARGET_M480/sha/sha256_alt_sw.h
1 /**
2  * \file sha256.h
3  *
4  * \brief SHA-224 and SHA-256 cryptographic hash function
5  *
6  * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
7  * SPDX-License-Identifier: Apache-2.0
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License"); you may
10  * not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  * This file is part of mbed TLS (https://tls.mbed.org)
22  */
23 #ifndef MBEDTLS_SHA256_ALT_SW_H
24 #define MBEDTLS_SHA256_ALT_SW_H
25 
26 #if defined(MBEDTLS_SHA256_ALT)
27 
28 #include <stddef.h>
29 #include <stdint.h>
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /**
36  * \brief SHA-256 context structure
37  */
38 typedef struct {
39  uint32_t total[2]; /*!< number of bytes processed */
40  uint32_t state[8]; /*!< intermediate digest state */
41  unsigned char buffer[64]; /*!< data block being processed */
42  int is224; /*!< 0 => SHA-256, else SHA-224 */
43 }
44 mbedtls_sha256_sw_context;
45 
46 /**
47  * \brief Initialize SHA-256 context
48  *
49  * \param ctx SHA-256 context to be initialized
50  */
51 void mbedtls_sha256_sw_init( mbedtls_sha256_sw_context *ctx );
52 
53 /**
54  * \brief Clear SHA-256 context
55  *
56  * \param ctx SHA-256 context to be cleared
57  */
58 void mbedtls_sha256_sw_free( mbedtls_sha256_sw_context *ctx );
59 
60 /**
61  * \brief Clone (the state of) a SHA-256 context
62  *
63  * \param dst The destination context
64  * \param src The context to be cloned
65  */
66 void mbedtls_sha256_sw_clone( mbedtls_sha256_sw_context *dst,
67  const mbedtls_sha256_sw_context *src );
68 
69 /**
70  * \brief SHA-256 context setup
71  *
72  * \param ctx context to be initialized
73  * \param is224 0 = use SHA256, 1 = use SHA224
74  */
75 void mbedtls_sha256_sw_starts( mbedtls_sha256_sw_context *ctx, int is224 );
76 
77 /**
78  * \brief SHA-256 process buffer
79  *
80  * \param ctx SHA-256 context
81  * \param input buffer holding the data
82  * \param ilen length of the input data
83  */
84 void mbedtls_sha256_sw_update( mbedtls_sha256_sw_context *ctx, const unsigned char *input,
85  size_t ilen );
86 
87 /**
88  * \brief SHA-256 final digest
89  *
90  * \param ctx SHA-256 context
91  * \param output SHA-224/256 checksum result
92  */
93 void mbedtls_sha256_sw_finish( mbedtls_sha256_sw_context *ctx, unsigned char output[32] );
94 
95 /* Internal use */
96 void mbedtls_sha256_sw_process( mbedtls_sha256_sw_context *ctx, const unsigned char data[64] );
97 
98 #ifdef __cplusplus
99 }
100 #endif
101 
102 #endif /* MBEDTLS_SHA256_ALT */
103 
104 #endif /* sha256_alt_sw.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.