Mistake on this page?
Report an issue in GitHub or email us
TARGET_NUVOTON/TARGET_M480/sha/sha512_alt.h
1 /*
2  * Copyright (c) 2015-2016, Nuvoton Technology Corporation
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #ifndef MBEDTLS_SHA512_ALT_H
20 #define MBEDTLS_SHA512_ALT_H
21 
22 #include "mbedtls/sha512.h"
23 
24 #if defined(MBEDTLS_SHA512_ALT)
25 
26 #include "sha_alt_hw.h"
27 #include "sha512_alt_sw.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 struct mbedtls_sha512_context_s;
34 
35 /**
36  * \brief SHA-512 context structure
37  */
38 typedef struct mbedtls_sha512_context_s {
39  void *active_ctx;
40  crypto_sha_context hw_ctx;
41  mbedtls_sha512_sw_context sw_ctx;
42 }
43 mbedtls_sha512_context;
44 
45 /**
46  * \brief Initialize SHA-512 context
47  *
48  * \param ctx SHA-512 context to be initialized
49  */
50 void mbedtls_sha512_init( mbedtls_sha512_context *ctx );
51 
52 /**
53  * \brief Clear SHA-512 context
54  *
55  * \param ctx SHA-512 context to be cleared
56  */
57 void mbedtls_sha512_free( mbedtls_sha512_context *ctx );
58 
59 /**
60  * \brief Clone (the state of) a SHA-512 context
61  *
62  * \param dst The destination context
63  * \param src The context to be cloned
64  */
65 void mbedtls_sha512_clone( mbedtls_sha512_context *dst,
66  const mbedtls_sha512_context *src );
67 
68 /**
69  * \brief SHA-512 context setup
70  *
71  * \param ctx context to be initialized
72  * \param is384 0 = use SHA512, 1 = use SHA384
73  *
74  * \returns error code
75  */
76 int mbedtls_sha512_starts_ret( mbedtls_sha512_context *ctx, int is384 );
77 
78 /**
79  * \brief SHA-512 process buffer
80  *
81  * \param ctx SHA-512 context
82  * \param input buffer holding the data
83  * \param ilen length of the input data
84  *
85  * \returns error code
86  */
87 int mbedtls_sha512_update_ret( mbedtls_sha512_context *ctx, const unsigned char *input,
88  size_t ilen );
89 
90 /**
91  * \brief SHA-512 final digest
92  *
93  * \param ctx SHA-512 context
94  * \param output SHA-384/512 checksum result
95  *
96  * \returns error code
97  */
98 int mbedtls_sha512_finish_ret( mbedtls_sha512_context *ctx, unsigned char output[64] );
99 
100 /* Internal use */
101 int mbedtls_internal_sha512_process( mbedtls_sha512_context *ctx, const unsigned char data[128] );
102 
103 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
104 #if defined(MBEDTLS_DEPRECATED_WARNING)
105 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
106 #else
107 #define MBEDTLS_DEPRECATED
108 #endif
109 /**
110  * \brief This function starts a SHA-384 or SHA-512 checksum
111  * calculation.
112  *
113  * \deprecated Superseded by mbedtls_sha512_starts_ret() in 2.7.0
114  *
115  * \param ctx The SHA-512 context to initialize.
116  * \param is384 Determines which function to use.
117  * <ul><li>0: Use SHA-512.</li>
118  * <li>1: Use SHA-384.</li></ul>
119  */
120 MBEDTLS_DEPRECATED void mbedtls_sha512_starts( mbedtls_sha512_context *ctx,
121  int is384 );
122 
123 /**
124  * \brief This function feeds an input buffer into an ongoing
125  * SHA-512 checksum calculation.
126  *
127  * \deprecated Superseded by mbedtls_sha512_update_ret() in 2.7.0
128  *
129  * \param ctx The SHA-512 context.
130  * \param input The buffer holding the data.
131  * \param ilen The length of the input data.
132  */
133 MBEDTLS_DEPRECATED void mbedtls_sha512_update( mbedtls_sha512_context *ctx,
134  const unsigned char *input,
135  size_t ilen );
136 
137 /**
138  * \brief This function finishes the SHA-512 operation, and writes
139  * the result to the output buffer.
140  *
141  * \deprecated Superseded by mbedtls_sha512_finish_ret() in 2.7.0
142  *
143  * \param ctx The SHA-512 context.
144  * \param output The SHA-384 or SHA-512 checksum result.
145  */
146 MBEDTLS_DEPRECATED void mbedtls_sha512_finish( mbedtls_sha512_context *ctx,
147  unsigned char output[64] );
148 
149 /**
150  * \brief This function processes a single data block within
151  * the ongoing SHA-512 computation. This function is for
152  * internal use only.
153  *
154  * \deprecated Superseded by mbedtls_internal_sha512_process() in 2.7.0
155  *
156  * \param ctx The SHA-512 context.
157  * \param data The buffer holding one block of data.
158  */
159 MBEDTLS_DEPRECATED void mbedtls_sha512_process( mbedtls_sha512_context *ctx,
160  const unsigned char data[128] );
161 
162 #undef MBEDTLS_DEPRECATED
163 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
164 #ifdef __cplusplus
165 }
166 #endif
167 
168 #endif /* MBEDTLS_SHA512_ALT */
169 
170 #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.