[MBEDTLS]
[reactos.git] / reactos / sdk / include / reactos / libs / mbedtls / sha512.h
1 /**
2 * \file sha512.h
3 *
4 * \brief SHA-384 and SHA-512 cryptographic hash function
5 *
6 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
7 * SPDX-License-Identifier: GPL-2.0
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 *
23 * This file is part of mbed TLS (https://tls.mbed.org)
24 */
25 #ifndef MBEDTLS_SHA512_H
26 #define MBEDTLS_SHA512_H
27
28 #if !defined(MBEDTLS_CONFIG_FILE)
29 #include "config.h"
30 #else
31 #include MBEDTLS_CONFIG_FILE
32 #endif
33
34 #include <stddef.h>
35 #include <stdint.h>
36
37 #if !defined(MBEDTLS_SHA512_ALT)
38 // Regular implementation
39 //
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
45 /**
46 * \brief SHA-512 context structure
47 */
48 typedef struct
49 {
50 uint64_t total[2]; /*!< number of bytes processed */
51 uint64_t state[8]; /*!< intermediate digest state */
52 unsigned char buffer[128]; /*!< data block being processed */
53 int is384; /*!< 0 => SHA-512, else SHA-384 */
54 }
55 mbedtls_sha512_context;
56
57 /**
58 * \brief Initialize SHA-512 context
59 *
60 * \param ctx SHA-512 context to be initialized
61 */
62 void mbedtls_sha512_init( mbedtls_sha512_context *ctx );
63
64 /**
65 * \brief Clear SHA-512 context
66 *
67 * \param ctx SHA-512 context to be cleared
68 */
69 void mbedtls_sha512_free( mbedtls_sha512_context *ctx );
70
71 /**
72 * \brief Clone (the state of) a SHA-512 context
73 *
74 * \param dst The destination context
75 * \param src The context to be cloned
76 */
77 void mbedtls_sha512_clone( mbedtls_sha512_context *dst,
78 const mbedtls_sha512_context *src );
79
80 /**
81 * \brief SHA-512 context setup
82 *
83 * \param ctx context to be initialized
84 * \param is384 0 = use SHA512, 1 = use SHA384
85 */
86 void mbedtls_sha512_starts( mbedtls_sha512_context *ctx, int is384 );
87
88 /**
89 * \brief SHA-512 process buffer
90 *
91 * \param ctx SHA-512 context
92 * \param input buffer holding the data
93 * \param ilen length of the input data
94 */
95 void mbedtls_sha512_update( mbedtls_sha512_context *ctx, const unsigned char *input,
96 size_t ilen );
97
98 /**
99 * \brief SHA-512 final digest
100 *
101 * \param ctx SHA-512 context
102 * \param output SHA-384/512 checksum result
103 */
104 void mbedtls_sha512_finish( mbedtls_sha512_context *ctx, unsigned char output[64] );
105
106 #ifdef __cplusplus
107 }
108 #endif
109
110 #else /* MBEDTLS_SHA512_ALT */
111 #include "sha512_alt.h"
112 #endif /* MBEDTLS_SHA512_ALT */
113
114 #ifdef __cplusplus
115 extern "C" {
116 #endif
117
118 /**
119 * \brief Output = SHA-512( input buffer )
120 *
121 * \param input buffer holding the data
122 * \param ilen length of the input data
123 * \param output SHA-384/512 checksum result
124 * \param is384 0 = use SHA512, 1 = use SHA384
125 */
126 void mbedtls_sha512( const unsigned char *input, size_t ilen,
127 unsigned char output[64], int is384 );
128
129 /**
130 * \brief Checkup routine
131 *
132 * \return 0 if successful, or 1 if the test failed
133 */
134 int mbedtls_sha512_self_test( int verbose );
135
136 /* Internal use */
137 void mbedtls_sha512_process( mbedtls_sha512_context *ctx, const unsigned char data[128] );
138
139 #ifdef __cplusplus
140 }
141 #endif
142
143 #endif /* mbedtls_sha512.h */