Mbed OS Reference
Loading...
Searching...
No Matches
TARGET_Samsung/sha/sha256_alt.h
1/* mbed Microcontroller Library
2 * Copyright (c) 2006-2020 ARM Limited
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16/****************************************************************************
17 *
18 * Copyright 2020 Samsung Electronics All Rights Reserved.
19 * SPDX-License-Identifier: Apache-2.0
20 *
21 * Licensed under the Apache License, Version 2.0 (the "License");
22 * you may not use this file except in compliance with the License.
23 * You may obtain a copy of the License at
24 *
25 * http://www.apache.org/licenses/LICENSE-2.0
26 *
27 * Unless required by applicable law or agreed to in writing,
28 * software distributed under the License is distributed on an
29 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
30 * either express or implied. See the License for the specific
31 * language governing permissions and limitations under the License.
32 *
33 ****************************************************************************/
34
35#ifndef MBEDTLS_SHA256_ALT_H
36#define MBEDTLS_SHA256_ALT_H
37
38#include "mbedtls/sha256.h"
39
40#if defined(MBEDTLS_SHA256_ALT)
41
42#include "sss_common.h"
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48#define ST_SHA256_BUF_SIZE ((size_t) 256)
49struct mbedtls_sha256_context_s;
50
51/**
52 * \brief SHA-256 context structure
53 */
54typedef struct mbedtls_sha256_context_s {
55 /* for S/W SHA-224 */
56 uint32_t total[2]; /*!< The number of Bytes processed. */
57 uint32_t state[8]; /*!< The intermediate digest state. */
58 unsigned char buffer[64]; /*!< The data block being processed. */
59 int is224; /*!< Determines which function to use:
60 0: Use SHA-256, or 1: Use SHA-224. */
61
62 /* for H/W SHA-256 */
63 uint32_t totals;
64 uint32_t hw;
65 unsigned char sbuf[ST_SHA256_BUF_SIZE]; /*!< ST_SHA256_BLOCK_SIZE buffer to store values so that algorithm is called once the buffer is filled */
66 stOCTET_STRING pstMessage;
67 stOCTET_STRING pstDigest;
68
69}
71
72/**
73 * \brief Initialize SHA-256 context
74 *
75 * \param ctx SHA-256 context to be initialized
76 */
78
79/**
80 * \brief Clear SHA-256 context
81 *
82 * \param ctx SHA-256 context to be cleared
83 */
85
86/**
87 * \brief Clone (the state of) a SHA-256 context
88 *
89 * \param dst The destination context
90 * \param src The context to be cloned
91 */
93 const mbedtls_sha256_context *src);
94
95/**
96 * \brief SHA-256 context setup
97 *
98 * \param ctx context to be initialized
99 * \param is224 0 = use SHA256, 1 = use SHA224
100 *
101 * \returns error code
102 */
104
105/**
106 * \brief SHA-256 process buffer
107 *
108 * \param ctx SHA-256 context
109 * \param input buffer holding the data
110 * \param ilen length of the input data
111 *
112 * \returns error code
113 */
114int mbedtls_sha256_update_ret(mbedtls_sha256_context *ctx, const unsigned char *input,
115 size_t ilen);
116
117/**
118 * \brief SHA-256 final digest
119 *
120 * \param ctx SHA-256 context
121 * \param output SHA-224/256 checksum result
122 *
123 * \returns error code
124 */
125int mbedtls_sha256_finish_ret(mbedtls_sha256_context *ctx, unsigned char output[32]);
126
127/* Internal use */
128int mbedtls_internal_sha256_process(mbedtls_sha256_context *ctx, const unsigned char data[64]);
129
130#if !defined(MBEDTLS_DEPRECATED_REMOVED)
131#if defined(MBEDTLS_DEPRECATED_WARNING)
132#define MBEDTLS_DEPRECATED __attribute__((deprecated))
133#else
134#define MBEDTLS_DEPRECATED
135#endif
136/**
137 * \brief This function starts a SHA-256 checksum calculation.
138 *
139 * \deprecated Superseded by mbedtls_sha256_starts_ret() in 2.7.0.
140 *
141 * \param ctx The SHA-256 context to initialize.
142 * \param is224 Determines which function to use.
143 * <ul><li>0: Use SHA-256.</li>
144 * <li>1: Use SHA-224.</li></ul>
145 */
146MBEDTLS_DEPRECATED void mbedtls_sha256_starts(mbedtls_sha256_context *ctx,
147 int is224);
148
149/**
150 * \brief This function feeds an input buffer into an ongoing
151 * SHA-256 checksum calculation.
152 *
153 * \deprecated Superseded by mbedtls_sha256_update_ret() in 2.7.0.
154 *
155 * \param ctx The SHA-256 context to initialize.
156 * \param input The buffer holding the data.
157 * \param ilen The length of the input data.
158 */
159MBEDTLS_DEPRECATED void mbedtls_sha256_update(mbedtls_sha256_context *ctx,
160 const unsigned char *input,
161 size_t ilen);
162
163/**
164 * \brief This function finishes the SHA-256 operation, and writes
165 * the result to the output buffer.
166 *
167 * \deprecated Superseded by mbedtls_sha256_finish_ret() in 2.7.0.
168 *
169 * \param ctx The SHA-256 context.
170 * \param output The SHA-224or SHA-256 checksum result.
171 */
172MBEDTLS_DEPRECATED void mbedtls_sha256_finish(mbedtls_sha256_context *ctx,
173 unsigned char output[32]);
174
175/**
176 * \brief This function processes a single data block within
177 * the ongoing SHA-256 computation. This function is for
178 * internal use only.
179 *
180 * \deprecated Superseded by mbedtls_internal_sha256_process() in 2.7.0.
181 *
182 * \param ctx The SHA-256 context.
183 * \param data The buffer holding one block of data.
184 */
185MBEDTLS_DEPRECATED void mbedtls_sha256_process(mbedtls_sha256_context *ctx,
186 const unsigned char data[64]);
187
188#undef MBEDTLS_DEPRECATED
189#endif /* !MBEDTLS_DEPRECATED_REMOVED */
190
191#ifdef __cplusplus
192}
193#endif
194
195#endif /* MBEDTLS_SHA256_ALT */
196
197#endif /* sha256_alt.h */
void mbedtls_sha256_process(mbedtls_sha256_context *ctx, const unsigned char data[64])
This function processes a single data block within the ongoing SHA-256 computation.
void mbedtls_sha256_finish(mbedtls_sha256_context *ctx, unsigned char output[32])
This function finishes the SHA-256 operation, and writes the result to the output buffer.
void mbedtls_sha256_update(mbedtls_sha256_context *ctx, const unsigned char *input, size_t ilen)
This function feeds an input buffer into an ongoing SHA-256 checksum calculation.
void mbedtls_sha256_free(mbedtls_sha256_context *ctx)
This function clears a SHA-256 context.
void mbedtls_sha256_init(mbedtls_sha256_context *ctx)
This function initializes a SHA-256 context.
int mbedtls_internal_sha256_process(mbedtls_sha256_context *ctx, const unsigned char data[64])
This function processes a single data block within the ongoing SHA-256 computation.
void mbedtls_sha256_clone(mbedtls_sha256_context *dst, const mbedtls_sha256_context *src)
This function clones the state of a SHA-256 context.
int mbedtls_sha256_finish_ret(mbedtls_sha256_context *ctx, unsigned char output[32])
This function finishes the SHA-256 operation, and writes the result to the output buffer.
void mbedtls_sha256_starts(mbedtls_sha256_context *ctx, int is224)
This function starts a SHA-224 or SHA-256 checksum calculation.
int mbedtls_sha256_starts_ret(mbedtls_sha256_context *ctx, int is224)
This function starts a SHA-224 or SHA-256 checksum calculation.
int mbedtls_sha256_update_ret(mbedtls_sha256_context *ctx, const unsigned char *input, size_t ilen)
This function feeds an input buffer into an ongoing SHA-256 checksum calculation.
This file contains SHA-224 and SHA-256 definitions and functions.
The SHA-256 context structure.
Definition: sha256.h:65