Mistake on this page?
Report an issue in GitHub or email us
TARGET_NUC472/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 #include "mbedtls/sha256.h"
27 
28 #if defined(MBEDTLS_SHA256_ALT)
29 
30 #include <stddef.h>
31 #include <stdint.h>
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 /**
38  * \brief SHA-256 context structure
39  */
40 typedef struct {
41  uint32_t total[2]; /*!< number of bytes processed */
42  uint32_t state[8]; /*!< intermediate digest state */
43  unsigned char buffer[64]; /*!< data block being processed */
44  int is224; /*!< 0 => SHA-256, else SHA-224 */
45 }
46 mbedtls_sha256_sw_context;
47 
48 /**
49  * \brief Initialize SHA-256 context
50  *
51  * \param ctx SHA-256 context to be initialized
52  */
53 void mbedtls_sha256_sw_init( mbedtls_sha256_sw_context *ctx );
54 
55 /**
56  * \brief Clear SHA-256 context
57  *
58  * \param ctx SHA-256 context to be cleared
59  */
60 void mbedtls_sha256_sw_free( mbedtls_sha256_sw_context *ctx );
61 
62 /**
63  * \brief Clone (the state of) a SHA-256 context
64  *
65  * \param dst The destination context
66  * \param src The context to be cloned
67  */
68 void mbedtls_sha256_sw_clone( mbedtls_sha256_sw_context *dst,
69  const mbedtls_sha256_sw_context *src );
70 
71 /**
72  * \brief SHA-256 context setup
73  *
74  * \param ctx context to be initialized
75  * \param is224 0 = use SHA256, 1 = use SHA224
76  */
77 void mbedtls_sha256_sw_starts( mbedtls_sha256_sw_context *ctx, int is224 );
78 
79 /**
80  * \brief SHA-256 process buffer
81  *
82  * \param ctx SHA-256 context
83  * \param input buffer holding the data
84  * \param ilen length of the input data
85  */
86 void mbedtls_sha256_sw_update( mbedtls_sha256_sw_context *ctx, const unsigned char *input,
87  size_t ilen );
88 
89 /**
90  * \brief SHA-256 final digest
91  *
92  * \param ctx SHA-256 context
93  * \param output SHA-224/256 checksum result
94  */
95 void mbedtls_sha256_sw_finish( mbedtls_sha256_sw_context *ctx, unsigned char output[32] );
96 
97 /* Internal use */
98 void mbedtls_sha256_sw_process( mbedtls_sha256_sw_context *ctx, const unsigned char data[64] );
99 
100 #ifdef __cplusplus
101 }
102 #endif
103 
104 #endif /* MBEDTLS_SHA256_ALT */
105 
106 #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.