mbed TLS v2.7.0
sha512.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
8  * SPDX-License-Identifier: Apache-2.0
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License"); you may
11  * not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  * This file is part of Mbed TLS (https://tls.mbed.org)
23  */
24 #ifndef MBEDTLS_SHA512_H
25 #define MBEDTLS_SHA512_H
26 
27 #if !defined(MBEDTLS_CONFIG_FILE)
28 #include "config.h"
29 #else
30 #include MBEDTLS_CONFIG_FILE
31 #endif
32 
33 #include <stddef.h>
34 #include <stdint.h>
35 
36 #define MBEDTLS_ERR_SHA512_HW_ACCEL_FAILED -0x0039
38 #if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
39  !defined(inline) && !defined(__cplusplus)
40 #define inline __inline
41 #endif
42 #if !defined(MBEDTLS_SHA512_ALT)
43 // Regular implementation
44 //
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
57 typedef struct
58 {
59  uint64_t total[2];
60  uint64_t state[8];
61  unsigned char buffer[128];
62  int is384;
65 }
67 
74 
81 
89  const mbedtls_sha512_context *src );
90 
103 
115  const unsigned char *input,
116  size_t ilen );
117 
129  unsigned char output[64] );
130 
141  const unsigned char data[128] );
142 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
143 #if defined(MBEDTLS_DEPRECATED_WARNING)
144 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
145 #else
146 #define MBEDTLS_DEPRECATED
147 #endif
148 
161  int is384 )
162 {
163  mbedtls_sha512_starts_ret( ctx, is384 );
164 }
165 
178  const unsigned char *input,
179  size_t ilen )
180 {
181  mbedtls_sha512_update_ret( ctx, input, ilen );
182 }
183 
195  unsigned char output[64] )
196 {
197  mbedtls_sha512_finish_ret( ctx, output );
198 }
199 
212  const unsigned char data[128] )
213 {
214  mbedtls_internal_sha512_process( ctx, data );
215 }
216 
217 #undef MBEDTLS_DEPRECATED
218 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
219 
220 #ifdef __cplusplus
221 }
222 #endif
223 
224 #else /* MBEDTLS_SHA512_ALT */
225 #include "sha512_alt.h"
226 #endif /* MBEDTLS_SHA512_ALT */
227 
228 #ifdef __cplusplus
229 extern "C" {
230 #endif
231 
251 int mbedtls_sha512_ret( const unsigned char *input,
252  size_t ilen,
253  unsigned char output[64],
254  int is384 );
255 
256 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
257 #if defined(MBEDTLS_DEPRECATED_WARNING)
258 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
259 #else
260 #define MBEDTLS_DEPRECATED
261 #endif
262 
282  const unsigned char *input,
283  size_t ilen,
284  unsigned char output[64],
285  int is384 )
286 {
287  mbedtls_sha512_ret( input, ilen, output, is384 );
288 }
289 
290 #undef MBEDTLS_DEPRECATED
291 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
292 
297 int mbedtls_sha512_self_test( int verbose );
298 
299 #ifdef __cplusplus
300 }
301 #endif
302 
303 #endif /* mbedtls_sha512.h */
#define MBEDTLS_DEPRECATED
Definition: sha512.h:258
void mbedtls_sha512_clone(mbedtls_sha512_context *dst, const mbedtls_sha512_context *src)
This function clones the state of a SHA-512 context.
void mbedtls_sha512_init(mbedtls_sha512_context *ctx)
This function initializes a SHA-512 context.
int mbedtls_sha512_finish_ret(mbedtls_sha512_context *ctx, unsigned char output[64])
This function finishes the SHA-512 operation, and writes the result to the output buffer...
static MBEDTLS_DEPRECATED void mbedtls_sha512(const unsigned char *input, size_t ilen, unsigned char output[64], int is384)
This function calculates the SHA-512 or SHA-384 checksum of a buffer.
Definition: sha512.h:281
Configuration options (set of defines)
static MBEDTLS_DEPRECATED void mbedtls_sha512_process(mbedtls_sha512_context *ctx, const unsigned char data[128])
This function processes a single data block within the ongoing SHA-512 computation. This function is for internal use only.
Definition: sha512.h:210
The SHA-512 context structure.
Definition: sha512.h:57
int mbedtls_sha512_starts_ret(mbedtls_sha512_context *ctx, int is384)
This function starts a SHA-384 or SHA-512 checksum calculation.
int mbedtls_sha512_self_test(int verbose)
The SHA-384 or SHA-512 checkup routine.
static MBEDTLS_DEPRECATED void mbedtls_sha512_starts(mbedtls_sha512_context *ctx, int is384)
This function starts a SHA-384 or SHA-512 checksum calculation.
Definition: sha512.h:159
int mbedtls_internal_sha512_process(mbedtls_sha512_context *ctx, const unsigned char data[128])
This function processes a single data block within the ongoing SHA-512 computation.
void mbedtls_sha512_free(mbedtls_sha512_context *ctx)
This function clears a SHA-512 context.
int mbedtls_sha512_ret(const unsigned char *input, size_t ilen, unsigned char output[64], int is384)
This function calculates the SHA-512 or SHA-384 checksum of a buffer.
static MBEDTLS_DEPRECATED void mbedtls_sha512_update(mbedtls_sha512_context *ctx, const unsigned char *input, size_t ilen)
This function feeds an input buffer into an ongoing SHA-512 checksum calculation. ...
Definition: sha512.h:176
int mbedtls_sha512_update_ret(mbedtls_sha512_context *ctx, const unsigned char *input, size_t ilen)
This function feeds an input buffer into an ongoing SHA-512 checksum calculation. ...
static MBEDTLS_DEPRECATED void mbedtls_sha512_finish(mbedtls_sha512_context *ctx, unsigned char output[64])
This function finishes the SHA-512 operation, and writes the result to the output buffer...
Definition: sha512.h:193