Mistake on this page?
Report an issue in GitHub or email us
TARGET_Samsung/sha/sha512_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 #ifndef MBEDTLS_SHA512_ALT_H
35 #define MBEDTLS_SHA512_ALT_H
36 
37 #include "mbedtls/sha512.h"
38 
39 #if defined(MBEDTLS_SHA512_ALT)
40 
41 #include "sss_common.h"
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 #define ST_SHA512_BUF_SIZE ((size_t) 512)
48 struct mbedtls_sha512_context_s;
49 
50 /**
51  * \brief SHA-512 context structure
52  */
53 typedef struct mbedtls_sha512_context_s {
54  /* for S/W SHA-384 */
55  uint64_t total[2]; /*!< The number of Bytes processed. */
56  uint64_t state[8]; /*!< The intermediate digest state. */
57  unsigned char buffer[128]; /*!< The data block being processed. */
58  int is384; /*!< Determines which function to use:
59  0: Use SHA-512, or 1: Use SHA-384. */
60  /* for H/W SHA-512 */
61  uint32_t totals;
62  uint32_t hw;
63  unsigned char sbuf[ST_SHA512_BUF_SIZE]; /*!< ST_SHA512_BLOCK_SIZE buffer to store values so that algorithm is called once the buffer is filled */
64  stOCTET_STRING pstMessage;
65  stOCTET_STRING pstDigest;
66 
67 }
68 mbedtls_sha512_context;
69 
70 /**
71  * \brief Initialize SHA-512 context
72  *
73  * \param ctx SHA-512 context to be initialized
74  */
75 void mbedtls_sha512_init(mbedtls_sha512_context *ctx);
76 
77 /**
78  * \brief Clear SHA-512 context
79  *
80  * \param ctx SHA-512 context to be cleared
81  */
82 void mbedtls_sha512_free(mbedtls_sha512_context *ctx);
83 
84 /**
85  * \brief Clone (the state of) a SHA-512 context
86  *
87  * \param dst The destination context
88  * \param src The context to be cloned
89  */
90 void mbedtls_sha512_clone(mbedtls_sha512_context *dst,
91  const mbedtls_sha512_context *src);
92 
93 /**
94  * \brief SHA-512 context setup
95  *
96  * \param ctx context to be initialized
97  * \param is224 0 = use SHA256, 1 = use SHA224
98  *
99  * \returns error code
100  */
101 int mbedtls_sha512_starts_ret(mbedtls_sha512_context *ctx, int is224);
102 
103 /**
104  * \brief SHA-512 process buffer
105  *
106  * \param ctx SHA-512 context
107  * \param input buffer holding the data
108  * \param ilen length of the input data
109  *
110  * \returns error code
111  */
112 int mbedtls_sha512_update_ret(mbedtls_sha512_context *ctx, const unsigned char *input,
113  size_t ilen);
114 
115 /**
116  * \brief SHA-512 final digest
117  *
118  * \param ctx SHA-512 context
119  * \param output SHA-224/256 checksum result
120  *
121  * \returns error code
122  */
123 int mbedtls_sha512_finish_ret(mbedtls_sha512_context *ctx, unsigned char output[64]);
124 
125 /* Internal use */
126 int mbedtls_internal_sha512_process(mbedtls_sha512_context *ctx, const unsigned char data[128]);
127 
128 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
129 #if defined(MBEDTLS_DEPRECATED_WARNING)
130 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
131 #else
132 #define MBEDTLS_DEPRECATED
133 #endif
134 /**
135  * \brief This function starts a SHA-512 checksum calculation.
136  *
137  * \deprecated Superseded by mbedtls_sha512_starts_ret() in 2.7.0.
138  *
139  * \param ctx The SHA-512 context to initialize.
140  * \param is224 Determines which function to use.
141  * <ul><li>0: Use SHA-512.</li>
142  * <li>1: Use SHA-224.</li></ul>
143  */
144 MBEDTLS_DEPRECATED void mbedtls_sha512_starts(mbedtls_sha512_context *ctx,
145  int is224);
146 
147 /**
148  * \brief This function feeds an input buffer into an ongoing
149  * SHA-512 checksum calculation.
150  *
151  * \deprecated Superseded by mbedtls_sha512_update_ret() in 2.7.0.
152  *
153  * \param ctx The SHA-512 context to initialize.
154  * \param input The buffer holding the data.
155  * \param ilen The length of the input data.
156  */
157 MBEDTLS_DEPRECATED void mbedtls_sha512_update(mbedtls_sha512_context *ctx,
158  const unsigned char *input,
159  size_t ilen);
160 
161 /**
162  * \brief This function finishes the SHA-512 operation, and writes
163  * the result to the output buffer.
164  *
165  * \deprecated Superseded by mbedtls_sha512_finish_ret() in 2.7.0.
166  *
167  * \param ctx The SHA-512 context.
168  * \param output The SHA-224or SHA-512 checksum result.
169  */
170 MBEDTLS_DEPRECATED void mbedtls_sha512_finish(mbedtls_sha512_context *ctx,
171  unsigned char output[64]);
172 
173 /**
174  * \brief This function processes a single data block within
175  * the ongoing SHA-512 computation. This function is for
176  * internal use only.
177  *
178  * \deprecated Superseded by mbedtls_internal_sha512_process() in 2.7.0.
179  *
180  * \param ctx The SHA-512 context.
181  * \param data The buffer holding one block of data.
182  */
183 MBEDTLS_DEPRECATED void mbedtls_sha512_process(mbedtls_sha512_context *ctx,
184  const unsigned char data[128]);
185 
186 #undef MBEDTLS_DEPRECATED
187 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
188 
189 #ifdef __cplusplus
190 }
191 #endif
192 
193 #endif /* MBEDTLS_SHA512_ALT */
194 
195 #endif /* sha512_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.