Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 1 | /** |
Simon Butcher | 5b331b9 | 2016-01-03 16:14:14 +0000 | [diff] [blame] | 2 | * \file sha256.h |
Paul Bakker | e0ccd0a | 2009-01-04 16:27:10 +0000 | [diff] [blame] | 3 | * |
Rose Zadik | bde68b4 | 2018-03-27 12:59:13 +0100 | [diff] [blame] | 4 | * \brief This file contains SHA-224 and SHA-256 definitions and functions. |
| 5 | * |
| 6 | * The Secure Hash Algorithms 224 and 256 (SHA-224 and SHA-256) cryptographic |
| 7 | * hash functions are defined in <em>FIPS 180-4: Secure Hash Standard (SHS)</em>. |
Darryl Green | a40a101 | 2018-01-05 15:33:17 +0000 | [diff] [blame] | 8 | */ |
| 9 | /* |
Bence Szépkúti | 1e14827 | 2020-08-07 13:07:28 +0200 | [diff] [blame] | 10 | * Copyright The Mbed TLS Contributors |
Dave Rodgman | 7ff7965 | 2023-11-03 12:04:52 +0000 | [diff] [blame^] | 11 | * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 12 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 13 | #ifndef MBEDTLS_SHA256_H |
| 14 | #define MBEDTLS_SHA256_H |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 15 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 16 | #if !defined(MBEDTLS_CONFIG_FILE) |
Jaeden Amero | c49fbbf | 2019-07-04 20:01:14 +0100 | [diff] [blame] | 17 | #include "mbedtls/config.h" |
Manuel Pégourié-Gonnard | cef4ad2 | 2014-04-29 12:39:06 +0200 | [diff] [blame] | 18 | #else |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 19 | #include MBEDTLS_CONFIG_FILE |
Manuel Pégourié-Gonnard | cef4ad2 | 2014-04-29 12:39:06 +0200 | [diff] [blame] | 20 | #endif |
Paul Bakker | 90995b5 | 2013-06-24 19:20:35 +0200 | [diff] [blame] | 21 | |
Rich Evans | 00ab470 | 2015-02-06 13:43:58 +0000 | [diff] [blame] | 22 | #include <stddef.h> |
Manuel Pégourié-Gonnard | ab22910 | 2015-04-15 11:53:16 +0200 | [diff] [blame] | 23 | #include <stdint.h> |
Paul Bakker | 5c2364c | 2012-10-01 14:41:15 +0000 | [diff] [blame] | 24 | |
Manuel Pégourié-Gonnard | 93c0847 | 2021-04-15 12:23:55 +0200 | [diff] [blame] | 25 | /* MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED is deprecated and should not be used. */ |
Gilles Peskine | a397443 | 2021-07-26 18:48:10 +0200 | [diff] [blame] | 26 | /** SHA-256 hardware accelerator failed */ |
| 27 | #define MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED -0x0037 |
| 28 | /** SHA-256 input data was malformed. */ |
| 29 | #define MBEDTLS_ERR_SHA256_BAD_INPUT_DATA -0x0074 |
Gilles Peskine | a381fe8 | 2018-01-23 18:16:11 +0100 | [diff] [blame] | 30 | |
Paul Bakker | 407a0da | 2013-06-27 14:29:21 +0200 | [diff] [blame] | 31 | #ifdef __cplusplus |
| 32 | extern "C" { |
| 33 | #endif |
| 34 | |
Ron Eldor | b2aacec | 2017-05-18 16:53:08 +0300 | [diff] [blame] | 35 | #if !defined(MBEDTLS_SHA256_ALT) |
| 36 | // Regular implementation |
| 37 | // |
| 38 | |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 39 | /** |
Rose Zadik | 602285e | 2018-01-26 11:00:39 +0000 | [diff] [blame] | 40 | * \brief The SHA-256 context structure. |
| 41 | * |
| 42 | * The structure is used both for SHA-256 and for SHA-224 |
| 43 | * checksum calculations. The choice between these two is |
| 44 | * made in the call to mbedtls_sha256_starts_ret(). |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 45 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 46 | typedef struct mbedtls_sha256_context { |
Rose Zadik | 602285e | 2018-01-26 11:00:39 +0000 | [diff] [blame] | 47 | uint32_t total[2]; /*!< The number of Bytes processed. */ |
| 48 | uint32_t state[8]; /*!< The intermediate digest state. */ |
| 49 | unsigned char buffer[64]; /*!< The data block being processed. */ |
Rose Zadik | bde68b4 | 2018-03-27 12:59:13 +0100 | [diff] [blame] | 50 | int is224; /*!< Determines which function to use: |
| 51 | 0: Use SHA-256, or 1: Use SHA-224. */ |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 52 | } |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 53 | mbedtls_sha256_context; |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 54 | |
Ron Eldor | b2aacec | 2017-05-18 16:53:08 +0300 | [diff] [blame] | 55 | #else /* MBEDTLS_SHA256_ALT */ |
| 56 | #include "sha256_alt.h" |
| 57 | #endif /* MBEDTLS_SHA256_ALT */ |
| 58 | |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 59 | /** |
Rose Zadik | 602285e | 2018-01-26 11:00:39 +0000 | [diff] [blame] | 60 | * \brief This function initializes a SHA-256 context. |
Paul Bakker | 5b4af39 | 2014-06-26 12:09:34 +0200 | [diff] [blame] | 61 | * |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 62 | * \param ctx The SHA-256 context to initialize. This must not be \c NULL. |
Paul Bakker | 5b4af39 | 2014-06-26 12:09:34 +0200 | [diff] [blame] | 63 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 64 | void mbedtls_sha256_init(mbedtls_sha256_context *ctx); |
Paul Bakker | 5b4af39 | 2014-06-26 12:09:34 +0200 | [diff] [blame] | 65 | |
| 66 | /** |
Rose Zadik | 602285e | 2018-01-26 11:00:39 +0000 | [diff] [blame] | 67 | * \brief This function clears a SHA-256 context. |
Paul Bakker | 5b4af39 | 2014-06-26 12:09:34 +0200 | [diff] [blame] | 68 | * |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 69 | * \param ctx The SHA-256 context to clear. This may be \c NULL, in which |
| 70 | * case this function returns immediately. If it is not \c NULL, |
| 71 | * it must point to an initialized SHA-256 context. |
Paul Bakker | 5b4af39 | 2014-06-26 12:09:34 +0200 | [diff] [blame] | 72 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 73 | void mbedtls_sha256_free(mbedtls_sha256_context *ctx); |
Paul Bakker | 5b4af39 | 2014-06-26 12:09:34 +0200 | [diff] [blame] | 74 | |
| 75 | /** |
Rose Zadik | 602285e | 2018-01-26 11:00:39 +0000 | [diff] [blame] | 76 | * \brief This function clones the state of a SHA-256 context. |
Manuel Pégourié-Gonnard | 16d412f | 2015-07-06 15:26:26 +0200 | [diff] [blame] | 77 | * |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 78 | * \param dst The destination context. This must be initialized. |
| 79 | * \param src The context to clone. This must be initialized. |
Manuel Pégourié-Gonnard | 16d412f | 2015-07-06 15:26:26 +0200 | [diff] [blame] | 80 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 81 | void mbedtls_sha256_clone(mbedtls_sha256_context *dst, |
| 82 | const mbedtls_sha256_context *src); |
Manuel Pégourié-Gonnard | 16d412f | 2015-07-06 15:26:26 +0200 | [diff] [blame] | 83 | |
| 84 | /** |
Rose Zadik | 602285e | 2018-01-26 11:00:39 +0000 | [diff] [blame] | 85 | * \brief This function starts a SHA-224 or SHA-256 checksum |
| 86 | * calculation. |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 87 | * |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 88 | * \param ctx The context to use. This must be initialized. |
| 89 | * \param is224 This determines which function to use. This must be |
| 90 | * either \c 0 for SHA-256, or \c 1 for SHA-224. |
Andres Amaya Garcia | 72a7f53 | 2017-05-02 11:38:47 +0100 | [diff] [blame] | 91 | * |
Rose Zadik | 602285e | 2018-01-26 11:00:39 +0000 | [diff] [blame] | 92 | * \return \c 0 on success. |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 93 | * \return A negative error code on failure. |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 94 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 95 | int mbedtls_sha256_starts_ret(mbedtls_sha256_context *ctx, int is224); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 96 | |
| 97 | /** |
Rose Zadik | 602285e | 2018-01-26 11:00:39 +0000 | [diff] [blame] | 98 | * \brief This function feeds an input buffer into an ongoing |
| 99 | * SHA-256 checksum calculation. |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 100 | * |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 101 | * \param ctx The SHA-256 context. This must be initialized |
| 102 | * and have a hash operation started. |
| 103 | * \param input The buffer holding the data. This must be a readable |
| 104 | * buffer of length \p ilen Bytes. |
| 105 | * \param ilen The length of the input data in Bytes. |
Andres Amaya Garcia | 72a7f53 | 2017-05-02 11:38:47 +0100 | [diff] [blame] | 106 | * |
Rose Zadik | 602285e | 2018-01-26 11:00:39 +0000 | [diff] [blame] | 107 | * \return \c 0 on success. |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 108 | * \return A negative error code on failure. |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 109 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 110 | int mbedtls_sha256_update_ret(mbedtls_sha256_context *ctx, |
| 111 | const unsigned char *input, |
| 112 | size_t ilen); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 113 | |
| 114 | /** |
Rose Zadik | 602285e | 2018-01-26 11:00:39 +0000 | [diff] [blame] | 115 | * \brief This function finishes the SHA-256 operation, and writes |
| 116 | * the result to the output buffer. |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 117 | * |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 118 | * \param ctx The SHA-256 context. This must be initialized |
| 119 | * and have a hash operation started. |
Rose Zadik | 602285e | 2018-01-26 11:00:39 +0000 | [diff] [blame] | 120 | * \param output The SHA-224 or SHA-256 checksum result. |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 121 | * This must be a writable buffer of length \c 32 Bytes. |
Andres Amaya Garcia | 72a7f53 | 2017-05-02 11:38:47 +0100 | [diff] [blame] | 122 | * |
Rose Zadik | 602285e | 2018-01-26 11:00:39 +0000 | [diff] [blame] | 123 | * \return \c 0 on success. |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 124 | * \return A negative error code on failure. |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 125 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 126 | int mbedtls_sha256_finish_ret(mbedtls_sha256_context *ctx, |
| 127 | unsigned char output[32]); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 128 | |
Andres Amaya Garcia | 72a7f53 | 2017-05-02 11:38:47 +0100 | [diff] [blame] | 129 | /** |
Rose Zadik | 602285e | 2018-01-26 11:00:39 +0000 | [diff] [blame] | 130 | * \brief This function processes a single data block within |
| 131 | * the ongoing SHA-256 computation. This function is for |
| 132 | * internal use only. |
Andres Amaya Garcia | 72a7f53 | 2017-05-02 11:38:47 +0100 | [diff] [blame] | 133 | * |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 134 | * \param ctx The SHA-256 context. This must be initialized. |
| 135 | * \param data The buffer holding one block of data. This must |
| 136 | * be a readable buffer of length \c 64 Bytes. |
Andres Amaya Garcia | 72a7f53 | 2017-05-02 11:38:47 +0100 | [diff] [blame] | 137 | * |
Rose Zadik | 602285e | 2018-01-26 11:00:39 +0000 | [diff] [blame] | 138 | * \return \c 0 on success. |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 139 | * \return A negative error code on failure. |
Andres Amaya Garcia | 72a7f53 | 2017-05-02 11:38:47 +0100 | [diff] [blame] | 140 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 141 | int mbedtls_internal_sha256_process(mbedtls_sha256_context *ctx, |
| 142 | const unsigned char data[64]); |
Andres Amaya Garcia | 72a7f53 | 2017-05-02 11:38:47 +0100 | [diff] [blame] | 143 | |
Manuel Pégourié-Gonnard | 93c0847 | 2021-04-15 12:23:55 +0200 | [diff] [blame] | 144 | #if !defined(MBEDTLS_DEPRECATED_REMOVED) |
| 145 | #if defined(MBEDTLS_DEPRECATED_WARNING) |
| 146 | #define MBEDTLS_DEPRECATED __attribute__((deprecated)) |
| 147 | #else |
| 148 | #define MBEDTLS_DEPRECATED |
| 149 | #endif |
| 150 | /** |
| 151 | * \brief This function starts a SHA-224 or SHA-256 checksum |
| 152 | * calculation. |
| 153 | * |
| 154 | * \deprecated Superseded by mbedtls_sha256_starts_ret() in 2.7.0. |
| 155 | * |
| 156 | * \param ctx The context to use. This must be initialized. |
| 157 | * \param is224 Determines which function to use. This must be |
| 158 | * either \c 0 for SHA-256, or \c 1 for SHA-224. |
| 159 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 160 | MBEDTLS_DEPRECATED void mbedtls_sha256_starts(mbedtls_sha256_context *ctx, |
| 161 | int is224); |
Manuel Pégourié-Gonnard | 93c0847 | 2021-04-15 12:23:55 +0200 | [diff] [blame] | 162 | |
| 163 | /** |
| 164 | * \brief This function feeds an input buffer into an ongoing |
| 165 | * SHA-256 checksum calculation. |
| 166 | * |
| 167 | * \deprecated Superseded by mbedtls_sha256_update_ret() in 2.7.0. |
| 168 | * |
| 169 | * \param ctx The SHA-256 context to use. This must be |
| 170 | * initialized and have a hash operation started. |
| 171 | * \param input The buffer holding the data. This must be a readable |
| 172 | * buffer of length \p ilen Bytes. |
| 173 | * \param ilen The length of the input data in Bytes. |
| 174 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 175 | MBEDTLS_DEPRECATED void mbedtls_sha256_update(mbedtls_sha256_context *ctx, |
| 176 | const unsigned char *input, |
| 177 | size_t ilen); |
Manuel Pégourié-Gonnard | 93c0847 | 2021-04-15 12:23:55 +0200 | [diff] [blame] | 178 | |
| 179 | /** |
| 180 | * \brief This function finishes the SHA-256 operation, and writes |
| 181 | * the result to the output buffer. |
| 182 | * |
| 183 | * \deprecated Superseded by mbedtls_sha256_finish_ret() in 2.7.0. |
| 184 | * |
| 185 | * \param ctx The SHA-256 context. This must be initialized and |
| 186 | * have a hash operation started. |
| 187 | * \param output The SHA-224 or SHA-256 checksum result. This must be |
| 188 | * a writable buffer of length \c 32 Bytes. |
| 189 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 190 | MBEDTLS_DEPRECATED void mbedtls_sha256_finish(mbedtls_sha256_context *ctx, |
| 191 | unsigned char output[32]); |
Manuel Pégourié-Gonnard | 93c0847 | 2021-04-15 12:23:55 +0200 | [diff] [blame] | 192 | |
| 193 | /** |
| 194 | * \brief This function processes a single data block within |
| 195 | * the ongoing SHA-256 computation. This function is for |
| 196 | * internal use only. |
| 197 | * |
| 198 | * \deprecated Superseded by mbedtls_internal_sha256_process() in 2.7.0. |
| 199 | * |
| 200 | * \param ctx The SHA-256 context. This must be initialized. |
| 201 | * \param data The buffer holding one block of data. This must be |
| 202 | * a readable buffer of size \c 64 Bytes. |
| 203 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 204 | MBEDTLS_DEPRECATED void mbedtls_sha256_process(mbedtls_sha256_context *ctx, |
| 205 | const unsigned char data[64]); |
Manuel Pégourié-Gonnard | 93c0847 | 2021-04-15 12:23:55 +0200 | [diff] [blame] | 206 | |
| 207 | #undef MBEDTLS_DEPRECATED |
| 208 | #endif /* !MBEDTLS_DEPRECATED_REMOVED */ |
| 209 | |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 210 | /** |
Rose Zadik | 602285e | 2018-01-26 11:00:39 +0000 | [diff] [blame] | 211 | * \brief This function calculates the SHA-224 or SHA-256 |
| 212 | * checksum of a buffer. |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 213 | * |
Rose Zadik | 602285e | 2018-01-26 11:00:39 +0000 | [diff] [blame] | 214 | * The function allocates the context, performs the |
| 215 | * calculation, and frees the context. |
Andres Amaya Garcia | 72a7f53 | 2017-05-02 11:38:47 +0100 | [diff] [blame] | 216 | * |
Rose Zadik | 602285e | 2018-01-26 11:00:39 +0000 | [diff] [blame] | 217 | * The SHA-256 result is calculated as |
| 218 | * output = SHA-256(input buffer). |
| 219 | * |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 220 | * \param input The buffer holding the data. This must be a readable |
| 221 | * buffer of length \p ilen Bytes. |
| 222 | * \param ilen The length of the input data in Bytes. |
| 223 | * \param output The SHA-224 or SHA-256 checksum result. This must |
| 224 | * be a writable buffer of length \c 32 Bytes. |
| 225 | * \param is224 Determines which function to use. This must be |
| 226 | * either \c 0 for SHA-256, or \c 1 for SHA-224. |
Tom Cosgrove | 8100bf5 | 2021-11-22 15:35:58 +0000 | [diff] [blame] | 227 | * |
| 228 | * \return \c 0 on success. |
| 229 | * \return A negative error code on failure. |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 230 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 231 | int mbedtls_sha256_ret(const unsigned char *input, |
| 232 | size_t ilen, |
| 233 | unsigned char output[32], |
| 234 | int is224); |
Andres Amaya Garcia | 72a7f53 | 2017-05-02 11:38:47 +0100 | [diff] [blame] | 235 | |
Manuel Pégourié-Gonnard | 93c0847 | 2021-04-15 12:23:55 +0200 | [diff] [blame] | 236 | #if !defined(MBEDTLS_DEPRECATED_REMOVED) |
| 237 | #if defined(MBEDTLS_DEPRECATED_WARNING) |
| 238 | #define MBEDTLS_DEPRECATED __attribute__((deprecated)) |
| 239 | #else |
| 240 | #define MBEDTLS_DEPRECATED |
| 241 | #endif |
| 242 | |
| 243 | /** |
| 244 | * \brief This function calculates the SHA-224 or SHA-256 checksum |
| 245 | * of a buffer. |
| 246 | * |
| 247 | * The function allocates the context, performs the |
| 248 | * calculation, and frees the context. |
| 249 | * |
| 250 | * The SHA-256 result is calculated as |
| 251 | * output = SHA-256(input buffer). |
| 252 | * |
| 253 | * \deprecated Superseded by mbedtls_sha256_ret() in 2.7.0. |
| 254 | * |
| 255 | * \param input The buffer holding the data. This must be a readable |
| 256 | * buffer of length \p ilen Bytes. |
| 257 | * \param ilen The length of the input data in Bytes. |
| 258 | * \param output The SHA-224 or SHA-256 checksum result. This must be |
| 259 | * a writable buffer of length \c 32 Bytes. |
| 260 | * \param is224 Determines which function to use. This must be either |
| 261 | * \c 0 for SHA-256, or \c 1 for SHA-224. |
| 262 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 263 | MBEDTLS_DEPRECATED void mbedtls_sha256(const unsigned char *input, |
| 264 | size_t ilen, |
| 265 | unsigned char output[32], |
| 266 | int is224); |
Manuel Pégourié-Gonnard | 93c0847 | 2021-04-15 12:23:55 +0200 | [diff] [blame] | 267 | |
| 268 | #undef MBEDTLS_DEPRECATED |
| 269 | #endif /* !MBEDTLS_DEPRECATED_REMOVED */ |
| 270 | |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 271 | #if defined(MBEDTLS_SELF_TEST) |
| 272 | |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 273 | /** |
Rose Zadik | 602285e | 2018-01-26 11:00:39 +0000 | [diff] [blame] | 274 | * \brief The SHA-224 and SHA-256 checkup routine. |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 275 | * |
Rose Zadik | bde68b4 | 2018-03-27 12:59:13 +0100 | [diff] [blame] | 276 | * \return \c 0 on success. |
| 277 | * \return \c 1 on failure. |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 278 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 279 | int mbedtls_sha256_self_test(int verbose); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 280 | |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 281 | #endif /* MBEDTLS_SELF_TEST */ |
| 282 | |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 283 | #ifdef __cplusplus |
| 284 | } |
| 285 | #endif |
| 286 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 287 | #endif /* mbedtls_sha256.h */ |