mbed TLS v2.16.6
sha512.h
Go to the documentation of this file.
1 
8 /*
9  * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
10  * SPDX-License-Identifier: GPL-2.0
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License along
23  * with this program; if not, write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25  *
26  * This file is part of Mbed TLS (https://tls.mbed.org)
27  */
28 #ifndef MBEDTLS_SHA512_H
29 #define MBEDTLS_SHA512_H
30 
31 #if !defined(MBEDTLS_CONFIG_FILE)
32 #include "config.h"
33 #else
34 #include MBEDTLS_CONFIG_FILE
35 #endif
36 
37 #include <stddef.h>
38 #include <stdint.h>
39 
40 /* MBEDTLS_ERR_SHA512_HW_ACCEL_FAILED is deprecated and should not be used. */
41 #define MBEDTLS_ERR_SHA512_HW_ACCEL_FAILED -0x0039
42 #define MBEDTLS_ERR_SHA512_BAD_INPUT_DATA -0x0075
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 #if !defined(MBEDTLS_SHA512_ALT)
49 // Regular implementation
50 //
51 
59 typedef struct mbedtls_sha512_context
60 {
61  uint64_t total[2];
62  uint64_t state[8];
63  unsigned char buffer[128];
64  int is384;
66 }
68 
69 #else /* MBEDTLS_SHA512_ALT */
70 #include "sha512_alt.h"
71 #endif /* MBEDTLS_SHA512_ALT */
72 
80 
90 
98  const mbedtls_sha512_context *src );
99 
112 
127  const unsigned char *input,
128  size_t ilen );
129 
144  unsigned char output[64] );
145 
158  const unsigned char data[128] );
159 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
160 #if defined(MBEDTLS_DEPRECATED_WARNING)
161 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
162 #else
163 #define MBEDTLS_DEPRECATED
164 #endif
165 
176  int is384 );
177 
191  const unsigned char *input,
192  size_t ilen );
193 
206  unsigned char output[64] );
207 
221  const unsigned char data[128] );
222 
223 #undef MBEDTLS_DEPRECATED
224 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
225 
247 int mbedtls_sha512_ret( const unsigned char *input,
248  size_t ilen,
249  unsigned char output[64],
250  int is384 );
251 
252 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
253 #if defined(MBEDTLS_DEPRECATED_WARNING)
254 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
255 #else
256 #define MBEDTLS_DEPRECATED
257 #endif
258 
279 MBEDTLS_DEPRECATED void mbedtls_sha512( const unsigned char *input,
280  size_t ilen,
281  unsigned char output[64],
282  int is384 );
283 
284 #undef MBEDTLS_DEPRECATED
285 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
286 
287 #if defined(MBEDTLS_SELF_TEST)
288 
295 int mbedtls_sha512_self_test( int verbose );
296 #endif /* MBEDTLS_SELF_TEST */
297 
298 #ifdef __cplusplus
299 }
300 #endif
301 
302 #endif /* mbedtls_sha512.h */
#define MBEDTLS_DEPRECATED
Definition: sha512.h:256
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.
uint64_t total[2]
Definition: sha512.h:61
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...
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. ...
struct mbedtls_sha512_context mbedtls_sha512_context
The SHA-512 context structure.
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.
Configuration options (set of defines)
The SHA-512 context structure.
Definition: sha512.h:59
int mbedtls_sha512_starts_ret(mbedtls_sha512_context *ctx, int is384)
This function starts a SHA-384 or SHA-512 checksum calculation.
unsigned char buffer[128]
Definition: sha512.h:63
int mbedtls_sha512_self_test(int verbose)
The SHA-384 or SHA-512 checkup routine.
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...
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.
uint64_t state[8]
Definition: sha512.h:62
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.
MBEDTLS_DEPRECATED void mbedtls_sha512_starts(mbedtls_sha512_context *ctx, int is384)
This function starts a SHA-384 or SHA-512 checksum calculation.
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. ...
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.