| 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 sha1.h | 
| Paul Bakker | e0ccd0a | 2009-01-04 16:27:10 +0000 | [diff] [blame] | 3 | * | 
| Rose Zadik | 8274142 | 2018-03-27 12:49:48 +0100 | [diff] [blame] | 4 | * \brief This file contains SHA-1 definitions and functions. | 
|  | 5 | * | 
| Darryl Green | 11999bb | 2018-03-13 15:22:58 +0000 | [diff] [blame] | 6 | * The Secure Hash Algorithm 1 (SHA-1) cryptographic hash function is defined in | 
| Rose Zadik | 8274142 | 2018-03-27 12:49:48 +0100 | [diff] [blame] | 7 | * <em>FIPS 180-4: Secure Hash Standard (SHS)</em>. | 
| Hanno Becker | bbca8c5 | 2017-09-25 14:53:51 +0100 | [diff] [blame] | 8 | * | 
|  | 9 | * \warning   SHA-1 is considered a weak message digest and its use constitutes | 
|  | 10 | *            a security risk. We recommend considering stronger message | 
|  | 11 | *            digests instead. | 
| Darryl Green | a40a101 | 2018-01-05 15:33:17 +0000 | [diff] [blame] | 12 | */ | 
|  | 13 | /* | 
| Rose Zadik | 44833d9 | 2018-01-26 08:41:09 +0000 | [diff] [blame] | 14 | *  Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved | 
| Manuel Pégourié-Gonnard | 37ff140 | 2015-09-04 14:21:07 +0200 | [diff] [blame] | 15 | *  SPDX-License-Identifier: Apache-2.0 | 
|  | 16 | * | 
|  | 17 | *  Licensed under the Apache License, Version 2.0 (the "License"); you may | 
|  | 18 | *  not use this file except in compliance with the License. | 
|  | 19 | *  You may obtain a copy of the License at | 
|  | 20 | * | 
|  | 21 | *  http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 22 | * | 
|  | 23 | *  Unless required by applicable law or agreed to in writing, software | 
|  | 24 | *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | 
|  | 25 | *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 26 | *  See the License for the specific language governing permissions and | 
|  | 27 | *  limitations under the License. | 
| Paul Bakker | b96f154 | 2010-07-18 20:36:00 +0000 | [diff] [blame] | 28 | * | 
| Rose Zadik | 44833d9 | 2018-01-26 08:41:09 +0000 | [diff] [blame] | 29 | *  This file is part of Mbed TLS (https://tls.mbed.org) | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 30 | */ | 
| Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 31 | #ifndef MBEDTLS_SHA1_H | 
|  | 32 | #define MBEDTLS_SHA1_H | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 33 |  | 
| Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 34 | #if !defined(MBEDTLS_CONFIG_FILE) | 
| Paul Bakker | 90995b5 | 2013-06-24 19:20:35 +0200 | [diff] [blame] | 35 | #include "config.h" | 
| Manuel Pégourié-Gonnard | cef4ad2 | 2014-04-29 12:39:06 +0200 | [diff] [blame] | 36 | #else | 
| Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 37 | #include MBEDTLS_CONFIG_FILE | 
| Manuel Pégourié-Gonnard | cef4ad2 | 2014-04-29 12:39:06 +0200 | [diff] [blame] | 38 | #endif | 
| Paul Bakker | 90995b5 | 2013-06-24 19:20:35 +0200 | [diff] [blame] | 39 |  | 
| Rich Evans | 00ab470 | 2015-02-06 13:43:58 +0000 | [diff] [blame] | 40 | #include <stddef.h> | 
| Manuel Pégourié-Gonnard | ab22910 | 2015-04-15 11:53:16 +0200 | [diff] [blame] | 41 | #include <stdint.h> | 
| Paul Bakker | 5c2364c | 2012-10-01 14:41:15 +0000 | [diff] [blame] | 42 |  | 
| Gilles Peskine | a381fe8 | 2018-01-23 18:16:11 +0100 | [diff] [blame] | 43 | #define MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED                  -0x0035  /**< SHA-1 hardware accelerator failed */ | 
|  | 44 |  | 
| Paul Bakker | 407a0da | 2013-06-27 14:29:21 +0200 | [diff] [blame] | 45 | #ifdef __cplusplus | 
|  | 46 | extern "C" { | 
|  | 47 | #endif | 
|  | 48 |  | 
| Ron Eldor | b2aacec | 2017-05-18 16:53:08 +0300 | [diff] [blame] | 49 | #if !defined(MBEDTLS_SHA1_ALT) | 
|  | 50 | // Regular implementation | 
|  | 51 | // | 
|  | 52 |  | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 53 | /** | 
| Rose Zadik | 44833d9 | 2018-01-26 08:41:09 +0000 | [diff] [blame] | 54 | * \brief          The SHA-1 context structure. | 
| Hanno Becker | bbca8c5 | 2017-09-25 14:53:51 +0100 | [diff] [blame] | 55 | * | 
|  | 56 | * \warning        SHA-1 is considered a weak message digest and its use | 
|  | 57 | *                 constitutes a security risk. We recommend considering | 
|  | 58 | *                 stronger message digests instead. | 
|  | 59 | * | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 60 | */ | 
| Dawid Drozd | 428cc52 | 2018-07-24 10:02:47 +0200 | [diff] [blame] | 61 | typedef struct mbedtls_sha1_context | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 62 | { | 
| Rose Zadik | 44833d9 | 2018-01-26 08:41:09 +0000 | [diff] [blame] | 63 | uint32_t total[2];          /*!< The number of Bytes processed.  */ | 
|  | 64 | uint32_t state[5];          /*!< The intermediate digest state.  */ | 
|  | 65 | unsigned char buffer[64];   /*!< The data block being processed. */ | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 66 | } | 
| Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 67 | mbedtls_sha1_context; | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 68 |  | 
| Ron Eldor | b2aacec | 2017-05-18 16:53:08 +0300 | [diff] [blame] | 69 | #else  /* MBEDTLS_SHA1_ALT */ | 
|  | 70 | #include "sha1_alt.h" | 
|  | 71 | #endif /* MBEDTLS_SHA1_ALT */ | 
|  | 72 |  | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 73 | /** | 
| Rose Zadik | 44833d9 | 2018-01-26 08:41:09 +0000 | [diff] [blame] | 74 | * \brief          This function initializes a SHA-1 context. | 
| Paul Bakker | 5b4af39 | 2014-06-26 12:09:34 +0200 | [diff] [blame] | 75 | * | 
| Hanno Becker | bbca8c5 | 2017-09-25 14:53:51 +0100 | [diff] [blame] | 76 | * \warning        SHA-1 is considered a weak message digest and its use | 
|  | 77 | *                 constitutes a security risk. We recommend considering | 
|  | 78 | *                 stronger message digests instead. | 
|  | 79 | * | 
| Rose Zadik | 8274142 | 2018-03-27 12:49:48 +0100 | [diff] [blame] | 80 | * \param ctx      The SHA-1 context to initialize. | 
|  | 81 | * | 
| Paul Bakker | 5b4af39 | 2014-06-26 12:09:34 +0200 | [diff] [blame] | 82 | */ | 
| Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 83 | void mbedtls_sha1_init( mbedtls_sha1_context *ctx ); | 
| Paul Bakker | 5b4af39 | 2014-06-26 12:09:34 +0200 | [diff] [blame] | 84 |  | 
|  | 85 | /** | 
| Rose Zadik | 44833d9 | 2018-01-26 08:41:09 +0000 | [diff] [blame] | 86 | * \brief          This function clears a SHA-1 context. | 
| Paul Bakker | 5b4af39 | 2014-06-26 12:09:34 +0200 | [diff] [blame] | 87 | * | 
| Hanno Becker | bbca8c5 | 2017-09-25 14:53:51 +0100 | [diff] [blame] | 88 | * \warning        SHA-1 is considered a weak message digest and its use | 
|  | 89 | *                 constitutes a security risk. We recommend considering | 
|  | 90 | *                 stronger message digests instead. | 
|  | 91 | * | 
| Rose Zadik | 8274142 | 2018-03-27 12:49:48 +0100 | [diff] [blame] | 92 | * \param ctx      The SHA-1 context to clear. | 
|  | 93 | * | 
| Paul Bakker | 5b4af39 | 2014-06-26 12:09:34 +0200 | [diff] [blame] | 94 | */ | 
| Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 95 | void mbedtls_sha1_free( mbedtls_sha1_context *ctx ); | 
| Paul Bakker | 5b4af39 | 2014-06-26 12:09:34 +0200 | [diff] [blame] | 96 |  | 
|  | 97 | /** | 
| Rose Zadik | 44833d9 | 2018-01-26 08:41:09 +0000 | [diff] [blame] | 98 | * \brief          This function clones the state of a SHA-1 context. | 
| Manuel Pégourié-Gonnard | 16d412f | 2015-07-06 15:26:26 +0200 | [diff] [blame] | 99 | * | 
| Hanno Becker | bbca8c5 | 2017-09-25 14:53:51 +0100 | [diff] [blame] | 100 | * \warning        SHA-1 is considered a weak message digest and its use | 
|  | 101 | *                 constitutes a security risk. We recommend considering | 
|  | 102 | *                 stronger message digests instead. | 
|  | 103 | * | 
| Rose Zadik | 92d66b8 | 2018-04-17 10:36:56 +0100 | [diff] [blame] | 104 | * \param dst      The SHA-1 context to clone to. | 
|  | 105 | * \param src      The SHA-1 context to clone from. | 
| Rose Zadik | 8274142 | 2018-03-27 12:49:48 +0100 | [diff] [blame] | 106 | * | 
| Manuel Pégourié-Gonnard | 16d412f | 2015-07-06 15:26:26 +0200 | [diff] [blame] | 107 | */ | 
|  | 108 | void mbedtls_sha1_clone( mbedtls_sha1_context *dst, | 
|  | 109 | const mbedtls_sha1_context *src ); | 
|  | 110 |  | 
|  | 111 | /** | 
| Rose Zadik | 44833d9 | 2018-01-26 08:41:09 +0000 | [diff] [blame] | 112 | * \brief          This function starts a SHA-1 checksum calculation. | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 113 | * | 
| Hanno Becker | bbca8c5 | 2017-09-25 14:53:51 +0100 | [diff] [blame] | 114 | * \warning        SHA-1 is considered a weak message digest and its use | 
|  | 115 | *                 constitutes a security risk. We recommend considering | 
|  | 116 | *                 stronger message digests instead. | 
|  | 117 | * | 
| Rose Zadik | 92d66b8 | 2018-04-17 10:36:56 +0100 | [diff] [blame] | 118 | * \param ctx      The SHA-1 context to initialize. | 
| Rose Zadik | 8274142 | 2018-03-27 12:49:48 +0100 | [diff] [blame] | 119 | * | 
|  | 120 | * \return         \c 0 on success. | 
|  | 121 | * | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 122 | */ | 
| Gilles Peskine | 9e4f77c | 2018-01-22 11:48:08 +0100 | [diff] [blame] | 123 | int mbedtls_sha1_starts_ret( mbedtls_sha1_context *ctx ); | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 124 |  | 
|  | 125 | /** | 
| Rose Zadik | 44833d9 | 2018-01-26 08:41:09 +0000 | [diff] [blame] | 126 | * \brief          This function feeds an input buffer into an ongoing SHA-1 | 
|  | 127 | *                 checksum calculation. | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 128 | * | 
| Hanno Becker | bbca8c5 | 2017-09-25 14:53:51 +0100 | [diff] [blame] | 129 | * \warning        SHA-1 is considered a weak message digest and its use | 
|  | 130 | *                 constitutes a security risk. We recommend considering | 
|  | 131 | *                 stronger message digests instead. | 
|  | 132 | * | 
| Rose Zadik | 8274142 | 2018-03-27 12:49:48 +0100 | [diff] [blame] | 133 | * \param ctx      The SHA-1 context. | 
|  | 134 | * \param input    The buffer holding the input data. | 
|  | 135 | * \param ilen     The length of the input data. | 
|  | 136 | * | 
|  | 137 | * \return         \c 0 on success. | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 138 | */ | 
| Gilles Peskine | 9e4f77c | 2018-01-22 11:48:08 +0100 | [diff] [blame] | 139 | int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx, | 
| Andres Amaya Garcia | 034ea7e | 2017-04-28 15:14:50 +0100 | [diff] [blame] | 140 | const unsigned char *input, | 
|  | 141 | size_t ilen ); | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 142 |  | 
|  | 143 | /** | 
| Rose Zadik | 44833d9 | 2018-01-26 08:41:09 +0000 | [diff] [blame] | 144 | * \brief          This function finishes the SHA-1 operation, and writes | 
|  | 145 | *                 the result to the output buffer. | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 146 | * | 
| Hanno Becker | bbca8c5 | 2017-09-25 14:53:51 +0100 | [diff] [blame] | 147 | * \warning        SHA-1 is considered a weak message digest and its use | 
|  | 148 | *                 constitutes a security risk. We recommend considering | 
|  | 149 | *                 stronger message digests instead. | 
|  | 150 | * | 
| Rose Zadik | 8274142 | 2018-03-27 12:49:48 +0100 | [diff] [blame] | 151 | * \param ctx      The SHA-1 context. | 
|  | 152 | * \param output   The SHA-1 checksum result. | 
|  | 153 | * | 
|  | 154 | * \return         \c 0 on success. | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 155 | */ | 
| Gilles Peskine | 9e4f77c | 2018-01-22 11:48:08 +0100 | [diff] [blame] | 156 | int mbedtls_sha1_finish_ret( mbedtls_sha1_context *ctx, | 
| Andres Amaya Garcia | 034ea7e | 2017-04-28 15:14:50 +0100 | [diff] [blame] | 157 | unsigned char output[20] ); | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 158 |  | 
| Andres Amaya Garcia | 034ea7e | 2017-04-28 15:14:50 +0100 | [diff] [blame] | 159 | /** | 
| Rose Zadik | 8274142 | 2018-03-27 12:49:48 +0100 | [diff] [blame] | 160 | * \brief          SHA-1 process data block (internal use only). | 
| Hanno Becker | bbca8c5 | 2017-09-25 14:53:51 +0100 | [diff] [blame] | 161 | * | 
|  | 162 | * \warning        SHA-1 is considered a weak message digest and its use | 
|  | 163 | *                 constitutes a security risk. We recommend considering | 
|  | 164 | *                 stronger message digests instead. | 
|  | 165 | * | 
| Rose Zadik | 8274142 | 2018-03-27 12:49:48 +0100 | [diff] [blame] | 166 | * \param ctx      The SHA-1 context. | 
|  | 167 | * \param data     The data block being processed. | 
|  | 168 | * | 
|  | 169 | * \return         \c 0 on success. | 
|  | 170 | * | 
| Andres Amaya Garcia | 034ea7e | 2017-04-28 15:14:50 +0100 | [diff] [blame] | 171 | */ | 
| Andres Amaya Garcia | cccfe08 | 2017-06-28 10:36:39 +0100 | [diff] [blame] | 172 | int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx, | 
|  | 173 | const unsigned char data[64] ); | 
| Andres Amaya Garcia | 034ea7e | 2017-04-28 15:14:50 +0100 | [diff] [blame] | 174 |  | 
|  | 175 | #if !defined(MBEDTLS_DEPRECATED_REMOVED) | 
|  | 176 | #if defined(MBEDTLS_DEPRECATED_WARNING) | 
|  | 177 | #define MBEDTLS_DEPRECATED      __attribute__((deprecated)) | 
|  | 178 | #else | 
|  | 179 | #define MBEDTLS_DEPRECATED | 
|  | 180 | #endif | 
|  | 181 | /** | 
| Rose Zadik | 8274142 | 2018-03-27 12:49:48 +0100 | [diff] [blame] | 182 | * \brief          This function starts a SHA-1 checksum calculation. | 
| Hanno Becker | bbca8c5 | 2017-09-25 14:53:51 +0100 | [diff] [blame] | 183 | * | 
|  | 184 | * \warning        SHA-1 is considered a weak message digest and its use | 
|  | 185 | *                 constitutes a security risk. We recommend considering | 
|  | 186 | *                 stronger message digests instead. | 
|  | 187 | * | 
| Rose Zadik | 8274142 | 2018-03-27 12:49:48 +0100 | [diff] [blame] | 188 | * \deprecated     Superseded by mbedtls_sha1_starts_ret() in 2.7.0. | 
|  | 189 | * | 
| Rose Zadik | 92d66b8 | 2018-04-17 10:36:56 +0100 | [diff] [blame] | 190 | * \param ctx      The SHA-1 context to initialize. | 
| Rose Zadik | 8274142 | 2018-03-27 12:49:48 +0100 | [diff] [blame] | 191 | * | 
| Andres Amaya Garcia | 034ea7e | 2017-04-28 15:14:50 +0100 | [diff] [blame] | 192 | */ | 
| Jaeden Amero | 041039f | 2018-02-19 15:28:08 +0000 | [diff] [blame] | 193 | MBEDTLS_DEPRECATED void mbedtls_sha1_starts( mbedtls_sha1_context *ctx ); | 
| Andres Amaya Garcia | 034ea7e | 2017-04-28 15:14:50 +0100 | [diff] [blame] | 194 |  | 
|  | 195 | /** | 
| Rose Zadik | 8274142 | 2018-03-27 12:49:48 +0100 | [diff] [blame] | 196 | * \brief          This function feeds an input buffer into an ongoing SHA-1 | 
|  | 197 | *                 checksum calculation. | 
| Hanno Becker | bbca8c5 | 2017-09-25 14:53:51 +0100 | [diff] [blame] | 198 | * | 
|  | 199 | * \warning        SHA-1 is considered a weak message digest and its use | 
|  | 200 | *                 constitutes a security risk. We recommend considering | 
|  | 201 | *                 stronger message digests instead. | 
|  | 202 | * | 
| Rose Zadik | 8274142 | 2018-03-27 12:49:48 +0100 | [diff] [blame] | 203 | * \deprecated     Superseded by mbedtls_sha1_update_ret() in 2.7.0. | 
|  | 204 | * | 
|  | 205 | * \param ctx      The SHA-1 context. | 
|  | 206 | * \param input    The buffer holding the input data. | 
|  | 207 | * \param ilen     The length of the input data. | 
|  | 208 | * | 
| Andres Amaya Garcia | 034ea7e | 2017-04-28 15:14:50 +0100 | [diff] [blame] | 209 | */ | 
| Jaeden Amero | 041039f | 2018-02-19 15:28:08 +0000 | [diff] [blame] | 210 | MBEDTLS_DEPRECATED void mbedtls_sha1_update( mbedtls_sha1_context *ctx, | 
|  | 211 | const unsigned char *input, | 
|  | 212 | size_t ilen ); | 
| Andres Amaya Garcia | 034ea7e | 2017-04-28 15:14:50 +0100 | [diff] [blame] | 213 |  | 
|  | 214 | /** | 
| Rose Zadik | 8274142 | 2018-03-27 12:49:48 +0100 | [diff] [blame] | 215 | * \brief          This function finishes the SHA-1 operation, and writes | 
|  | 216 | *                 the result to the output buffer. | 
| Hanno Becker | bbca8c5 | 2017-09-25 14:53:51 +0100 | [diff] [blame] | 217 | * | 
|  | 218 | * \warning        SHA-1 is considered a weak message digest and its use | 
|  | 219 | *                 constitutes a security risk. We recommend considering | 
|  | 220 | *                 stronger message digests instead. | 
|  | 221 | * | 
| Rose Zadik | 8274142 | 2018-03-27 12:49:48 +0100 | [diff] [blame] | 222 | * \deprecated     Superseded by mbedtls_sha1_finish_ret() in 2.7.0. | 
|  | 223 | * | 
|  | 224 | * \param ctx      The SHA-1 context. | 
|  | 225 | * \param output   The SHA-1 checksum result. | 
|  | 226 | * | 
| Andres Amaya Garcia | 034ea7e | 2017-04-28 15:14:50 +0100 | [diff] [blame] | 227 | */ | 
| Jaeden Amero | 041039f | 2018-02-19 15:28:08 +0000 | [diff] [blame] | 228 | MBEDTLS_DEPRECATED void mbedtls_sha1_finish( mbedtls_sha1_context *ctx, | 
|  | 229 | unsigned char output[20] ); | 
| Andres Amaya Garcia | 034ea7e | 2017-04-28 15:14:50 +0100 | [diff] [blame] | 230 |  | 
|  | 231 | /** | 
| Rose Zadik | 8274142 | 2018-03-27 12:49:48 +0100 | [diff] [blame] | 232 | * \brief          SHA-1 process data block (internal use only). | 
| Hanno Becker | bbca8c5 | 2017-09-25 14:53:51 +0100 | [diff] [blame] | 233 | * | 
|  | 234 | * \warning        SHA-1 is considered a weak message digest and its use | 
|  | 235 | *                 constitutes a security risk. We recommend considering | 
|  | 236 | *                 stronger message digests instead. | 
|  | 237 | * | 
| Rose Zadik | 8274142 | 2018-03-27 12:49:48 +0100 | [diff] [blame] | 238 | * \deprecated     Superseded by mbedtls_internal_sha1_process() in 2.7.0. | 
|  | 239 | * | 
|  | 240 | * \param ctx      The SHA-1 context. | 
|  | 241 | * \param data     The data block being processed. | 
|  | 242 | * | 
| Andres Amaya Garcia | 034ea7e | 2017-04-28 15:14:50 +0100 | [diff] [blame] | 243 | */ | 
| Jaeden Amero | 041039f | 2018-02-19 15:28:08 +0000 | [diff] [blame] | 244 | MBEDTLS_DEPRECATED void mbedtls_sha1_process( mbedtls_sha1_context *ctx, | 
|  | 245 | const unsigned char data[64] ); | 
| Andres Amaya Garcia | 034ea7e | 2017-04-28 15:14:50 +0100 | [diff] [blame] | 246 |  | 
|  | 247 | #undef MBEDTLS_DEPRECATED | 
|  | 248 | #endif /* !MBEDTLS_DEPRECATED_REMOVED */ | 
| Paul Bakker | 90995b5 | 2013-06-24 19:20:35 +0200 | [diff] [blame] | 249 |  | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 250 | /** | 
| Rose Zadik | 44833d9 | 2018-01-26 08:41:09 +0000 | [diff] [blame] | 251 | * \brief          This function calculates the SHA-1 checksum of a buffer. | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 252 | * | 
| Rose Zadik | 44833d9 | 2018-01-26 08:41:09 +0000 | [diff] [blame] | 253 | *                 The function allocates the context, performs the | 
|  | 254 | *                 calculation, and frees the context. | 
| Andres Amaya Garcia | 034ea7e | 2017-04-28 15:14:50 +0100 | [diff] [blame] | 255 | * | 
| Rose Zadik | 44833d9 | 2018-01-26 08:41:09 +0000 | [diff] [blame] | 256 | *                 The SHA-1 result is calculated as | 
|  | 257 | *                 output = SHA-1(input buffer). | 
|  | 258 | * | 
| Rose Zadik | 8274142 | 2018-03-27 12:49:48 +0100 | [diff] [blame] | 259 | * \warning        SHA-1 is considered a weak message digest and its use | 
|  | 260 | *                 constitutes a security risk. We recommend considering | 
|  | 261 | *                 stronger message digests instead. | 
|  | 262 | * | 
| Rose Zadik | 44833d9 | 2018-01-26 08:41:09 +0000 | [diff] [blame] | 263 | * \param input    The buffer holding the input data. | 
|  | 264 | * \param ilen     The length of the input data. | 
|  | 265 | * \param output   The SHA-1 checksum result. | 
|  | 266 | * | 
| Rose Zadik | 8274142 | 2018-03-27 12:49:48 +0100 | [diff] [blame] | 267 | * \return         \c 0 on success. | 
| Hanno Becker | bbca8c5 | 2017-09-25 14:53:51 +0100 | [diff] [blame] | 268 | * | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 269 | */ | 
| Gilles Peskine | 9e4f77c | 2018-01-22 11:48:08 +0100 | [diff] [blame] | 270 | int mbedtls_sha1_ret( const unsigned char *input, | 
| Andres Amaya Garcia | 034ea7e | 2017-04-28 15:14:50 +0100 | [diff] [blame] | 271 | size_t ilen, | 
|  | 272 | unsigned char output[20] ); | 
|  | 273 |  | 
|  | 274 | #if !defined(MBEDTLS_DEPRECATED_REMOVED) | 
|  | 275 | #if defined(MBEDTLS_DEPRECATED_WARNING) | 
|  | 276 | #define MBEDTLS_DEPRECATED      __attribute__((deprecated)) | 
|  | 277 | #else | 
|  | 278 | #define MBEDTLS_DEPRECATED | 
|  | 279 | #endif | 
|  | 280 | /** | 
| Gilles Peskine | 2e1934a | 2018-04-18 16:05:29 +0200 | [diff] [blame] | 281 | * \brief          This function calculates the SHA-1 checksum of a buffer. | 
| Rose Zadik | 8274142 | 2018-03-27 12:49:48 +0100 | [diff] [blame] | 282 | * | 
|  | 283 | *                 The function allocates the context, performs the | 
|  | 284 | *                 calculation, and frees the context. | 
|  | 285 | * | 
|  | 286 | *                 The SHA-1 result is calculated as | 
|  | 287 | *                 output = SHA-1(input buffer). | 
|  | 288 | * | 
|  | 289 | * \warning        SHA-1 is considered a weak message digest and its use | 
|  | 290 | *                 constitutes a security risk. We recommend considering | 
|  | 291 | *                 stronger message digests instead. | 
| Andres Amaya Garcia | 034ea7e | 2017-04-28 15:14:50 +0100 | [diff] [blame] | 292 | * | 
| Gilles Peskine | 3e28d70 | 2018-01-22 12:18:59 +0100 | [diff] [blame] | 293 | * \deprecated     Superseded by mbedtls_sha1_ret() in 2.7.0 | 
| Andres Amaya Garcia | 034ea7e | 2017-04-28 15:14:50 +0100 | [diff] [blame] | 294 | * | 
| Rose Zadik | 44833d9 | 2018-01-26 08:41:09 +0000 | [diff] [blame] | 295 | * \param input    The buffer holding the input data. | 
|  | 296 | * \param ilen     The length of the input data. | 
|  | 297 | * \param output   The SHA-1 checksum result. | 
| Hanno Becker | bbca8c5 | 2017-09-25 14:53:51 +0100 | [diff] [blame] | 298 | * | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 299 | */ | 
| Jaeden Amero | 041039f | 2018-02-19 15:28:08 +0000 | [diff] [blame] | 300 | MBEDTLS_DEPRECATED void mbedtls_sha1( const unsigned char *input, | 
|  | 301 | size_t ilen, | 
|  | 302 | unsigned char output[20] ); | 
| Andres Amaya Garcia | 034ea7e | 2017-04-28 15:14:50 +0100 | [diff] [blame] | 303 |  | 
|  | 304 | #undef MBEDTLS_DEPRECATED | 
|  | 305 | #endif /* !MBEDTLS_DEPRECATED_REMOVED */ | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 306 |  | 
|  | 307 | /** | 
| Rose Zadik | 44833d9 | 2018-01-26 08:41:09 +0000 | [diff] [blame] | 308 | * \brief          The SHA-1 checkup routine. | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 309 | * | 
| Hanno Becker | bbca8c5 | 2017-09-25 14:53:51 +0100 | [diff] [blame] | 310 | * \warning        SHA-1 is considered a weak message digest and its use | 
|  | 311 | *                 constitutes a security risk. We recommend considering | 
|  | 312 | *                 stronger message digests instead. | 
|  | 313 | * | 
| Rose Zadik | 8274142 | 2018-03-27 12:49:48 +0100 | [diff] [blame] | 314 | * \return         \c 0 on success. | 
|  | 315 | * \return         \c 1 on failure. | 
|  | 316 | * | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 317 | */ | 
| Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 318 | int mbedtls_sha1_self_test( int verbose ); | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 319 |  | 
| Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 320 | #ifdef __cplusplus | 
|  | 321 | } | 
|  | 322 | #endif | 
|  | 323 |  | 
| Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 324 | #endif /* mbedtls_sha1.h */ |