blob: e69db8a15a0ba4cef5ce80ef6cdd08f003ffacc6 [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/**
Simon Butcher5b331b92016-01-03 16:14:14 +00002 * \file sha1.h
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00003 *
Rose Zadik82741422018-03-27 12:49:48 +01004 * \brief This file contains SHA-1 definitions and functions.
5 *
Darryl Green11999bb2018-03-13 15:22:58 +00006 * The Secure Hash Algorithm 1 (SHA-1) cryptographic hash function is defined in
Rose Zadik82741422018-03-27 12:49:48 +01007 * <em>FIPS 180-4: Secure Hash Standard (SHS)</em>.
Hanno Beckerbbca8c52017-09-25 14:53:51 +01008 *
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 Greena40a1012018-01-05 15:33:17 +000012 */
13/*
Rose Zadik44833d92018-01-26 08:41:09 +000014 * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
Bence Szépkútif744bd72020-06-05 13:02:18 +020015 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
16 *
17 * This file is provided under the Apache License 2.0, or the
18 * GNU General Public License v2.0 or later.
19 *
20 * **********
21 * Apache License 2.0:
Manuel Pégourié-Gonnard37ff1402015-09-04 14:21:07 +020022 *
23 * Licensed under the Apache License, Version 2.0 (the "License"); you may
24 * not use this file except in compliance with the License.
25 * You may obtain a copy of the License at
26 *
27 * http://www.apache.org/licenses/LICENSE-2.0
28 *
29 * Unless required by applicable law or agreed to in writing, software
30 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
31 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32 * See the License for the specific language governing permissions and
33 * limitations under the License.
Paul Bakkerb96f1542010-07-18 20:36:00 +000034 *
Bence Szépkútif744bd72020-06-05 13:02:18 +020035 * **********
36 *
37 * **********
38 * GNU General Public License v2.0 or later:
39 *
40 * This program is free software; you can redistribute it and/or modify
41 * it under the terms of the GNU General Public License as published by
42 * the Free Software Foundation; either version 2 of the License, or
43 * (at your option) any later version.
44 *
45 * This program is distributed in the hope that it will be useful,
46 * but WITHOUT ANY WARRANTY; without even the implied warranty of
47 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48 * GNU General Public License for more details.
49 *
50 * You should have received a copy of the GNU General Public License along
51 * with this program; if not, write to the Free Software Foundation, Inc.,
52 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
53 *
54 * **********
55 *
Rose Zadik44833d92018-01-26 08:41:09 +000056 * This file is part of Mbed TLS (https://tls.mbed.org)
Paul Bakker5121ce52009-01-03 21:22:43 +000057 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020058#ifndef MBEDTLS_SHA1_H
59#define MBEDTLS_SHA1_H
Paul Bakker5121ce52009-01-03 21:22:43 +000060
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020061#if !defined(MBEDTLS_CONFIG_FILE)
Paul Bakker90995b52013-06-24 19:20:35 +020062#include "config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020063#else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020064#include MBEDTLS_CONFIG_FILE
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020065#endif
Paul Bakker90995b52013-06-24 19:20:35 +020066
Rich Evans00ab4702015-02-06 13:43:58 +000067#include <stddef.h>
Manuel Pégourié-Gonnardab229102015-04-15 11:53:16 +020068#include <stdint.h>
Paul Bakker5c2364c2012-10-01 14:41:15 +000069
Ron Eldor9924bdc2018-10-04 10:59:13 +030070/* MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED is deprecated and should not be used. */
Gilles Peskinea381fe82018-01-23 18:16:11 +010071#define MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED -0x0035 /**< SHA-1 hardware accelerator failed */
Andres Amaya Garciac523e012018-12-10 10:11:47 +000072#define MBEDTLS_ERR_SHA1_BAD_INPUT_DATA -0x0073 /**< SHA-1 input data was malformed. */
Gilles Peskinea381fe82018-01-23 18:16:11 +010073
Paul Bakker407a0da2013-06-27 14:29:21 +020074#ifdef __cplusplus
75extern "C" {
76#endif
77
Ron Eldorb2aacec2017-05-18 16:53:08 +030078#if !defined(MBEDTLS_SHA1_ALT)
79// Regular implementation
80//
81
Paul Bakker5121ce52009-01-03 21:22:43 +000082/**
Rose Zadik44833d92018-01-26 08:41:09 +000083 * \brief The SHA-1 context structure.
Hanno Beckerbbca8c52017-09-25 14:53:51 +010084 *
85 * \warning SHA-1 is considered a weak message digest and its use
86 * constitutes a security risk. We recommend considering
87 * stronger message digests instead.
88 *
Paul Bakker5121ce52009-01-03 21:22:43 +000089 */
Dawid Drozd428cc522018-07-24 10:02:47 +020090typedef struct mbedtls_sha1_context
Paul Bakker5121ce52009-01-03 21:22:43 +000091{
Rose Zadik44833d92018-01-26 08:41:09 +000092 uint32_t total[2]; /*!< The number of Bytes processed. */
93 uint32_t state[5]; /*!< The intermediate digest state. */
94 unsigned char buffer[64]; /*!< The data block being processed. */
Paul Bakker5121ce52009-01-03 21:22:43 +000095}
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020096mbedtls_sha1_context;
Paul Bakker5121ce52009-01-03 21:22:43 +000097
Ron Eldorb2aacec2017-05-18 16:53:08 +030098#else /* MBEDTLS_SHA1_ALT */
99#include "sha1_alt.h"
100#endif /* MBEDTLS_SHA1_ALT */
101
Paul Bakker5121ce52009-01-03 21:22:43 +0000102/**
Rose Zadik44833d92018-01-26 08:41:09 +0000103 * \brief This function initializes a SHA-1 context.
Paul Bakker5b4af392014-06-26 12:09:34 +0200104 *
Hanno Beckerbbca8c52017-09-25 14:53:51 +0100105 * \warning SHA-1 is considered a weak message digest and its use
106 * constitutes a security risk. We recommend considering
107 * stronger message digests instead.
108 *
Rose Zadik82741422018-03-27 12:49:48 +0100109 * \param ctx The SHA-1 context to initialize.
Hanno Becker5359ca82018-12-18 11:11:18 +0000110 * This must not be \c NULL.
Rose Zadik82741422018-03-27 12:49:48 +0100111 *
Paul Bakker5b4af392014-06-26 12:09:34 +0200112 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200113void mbedtls_sha1_init( mbedtls_sha1_context *ctx );
Paul Bakker5b4af392014-06-26 12:09:34 +0200114
115/**
Rose Zadik44833d92018-01-26 08:41:09 +0000116 * \brief This function clears a SHA-1 context.
Paul Bakker5b4af392014-06-26 12:09:34 +0200117 *
Hanno Beckerbbca8c52017-09-25 14:53:51 +0100118 * \warning SHA-1 is considered a weak message digest and its use
119 * constitutes a security risk. We recommend considering
120 * stronger message digests instead.
121 *
Hanno Becker5359ca82018-12-18 11:11:18 +0000122 * \param ctx The SHA-1 context to clear. This may be \c NULL,
123 * in which case this function does nothing. If it is
124 * not \c NULL, it must point to an initialized
125 * SHA-1 context.
Rose Zadik82741422018-03-27 12:49:48 +0100126 *
Paul Bakker5b4af392014-06-26 12:09:34 +0200127 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200128void mbedtls_sha1_free( mbedtls_sha1_context *ctx );
Paul Bakker5b4af392014-06-26 12:09:34 +0200129
130/**
Rose Zadik44833d92018-01-26 08:41:09 +0000131 * \brief This function clones the state of a SHA-1 context.
Manuel Pégourié-Gonnard16d412f2015-07-06 15:26:26 +0200132 *
Hanno Beckerbbca8c52017-09-25 14:53:51 +0100133 * \warning SHA-1 is considered a weak message digest and its use
134 * constitutes a security risk. We recommend considering
135 * stronger message digests instead.
136 *
Hanno Becker5359ca82018-12-18 11:11:18 +0000137 * \param dst The SHA-1 context to clone to. This must be initialized.
138 * \param src The SHA-1 context to clone from. This must be initialized.
Rose Zadik82741422018-03-27 12:49:48 +0100139 *
Manuel Pégourié-Gonnard16d412f2015-07-06 15:26:26 +0200140 */
141void mbedtls_sha1_clone( mbedtls_sha1_context *dst,
142 const mbedtls_sha1_context *src );
143
144/**
Rose Zadik44833d92018-01-26 08:41:09 +0000145 * \brief This function starts a SHA-1 checksum calculation.
Paul Bakker5121ce52009-01-03 21:22:43 +0000146 *
Hanno Beckerbbca8c52017-09-25 14:53:51 +0100147 * \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 *
Hanno Becker5359ca82018-12-18 11:11:18 +0000151 * \param ctx The SHA-1 context to initialize. This must be initialized.
Rose Zadik82741422018-03-27 12:49:48 +0100152 *
153 * \return \c 0 on success.
Hanno Becker5359ca82018-12-18 11:11:18 +0000154 * \return A negative error code on failure.
Rose Zadik82741422018-03-27 12:49:48 +0100155 *
Paul Bakker5121ce52009-01-03 21:22:43 +0000156 */
Gilles Peskine9e4f77c2018-01-22 11:48:08 +0100157int mbedtls_sha1_starts_ret( mbedtls_sha1_context *ctx );
Paul Bakker5121ce52009-01-03 21:22:43 +0000158
159/**
Rose Zadik44833d92018-01-26 08:41:09 +0000160 * \brief This function feeds an input buffer into an ongoing SHA-1
161 * checksum calculation.
Paul Bakker5121ce52009-01-03 21:22:43 +0000162 *
Hanno Beckerbbca8c52017-09-25 14:53:51 +0100163 * \warning SHA-1 is considered a weak message digest and its use
164 * constitutes a security risk. We recommend considering
165 * stronger message digests instead.
166 *
Hanno Becker5359ca82018-12-18 11:11:18 +0000167 * \param ctx The SHA-1 context. This must be initialized
168 * and have a hash operation started.
Rose Zadik82741422018-03-27 12:49:48 +0100169 * \param input The buffer holding the input data.
Hanno Becker5359ca82018-12-18 11:11:18 +0000170 * This must be a readable buffer of length \p ilen Bytes.
Hanno Becker5359ca82018-12-18 11:11:18 +0000171 * \param ilen The length of the input data \p input in Bytes.
Rose Zadik82741422018-03-27 12:49:48 +0100172 *
173 * \return \c 0 on success.
Hanno Becker5359ca82018-12-18 11:11:18 +0000174 * \return A negative error code on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000175 */
Gilles Peskine9e4f77c2018-01-22 11:48:08 +0100176int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx,
Andres Amaya Garcia034ea7e2017-04-28 15:14:50 +0100177 const unsigned char *input,
178 size_t ilen );
Paul Bakker5121ce52009-01-03 21:22:43 +0000179
180/**
Rose Zadik44833d92018-01-26 08:41:09 +0000181 * \brief This function finishes the SHA-1 operation, and writes
182 * the result to the output buffer.
Paul Bakker5121ce52009-01-03 21:22:43 +0000183 *
Hanno Beckerbbca8c52017-09-25 14:53:51 +0100184 * \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 *
Hanno Becker5359ca82018-12-18 11:11:18 +0000188 * \param ctx The SHA-1 context to use. This must be initialized and
189 * have a hash operation started.
Hanno Becker5359ca82018-12-18 11:11:18 +0000190 * \param output The SHA-1 checksum result. This must be a writable
191 * buffer of length \c 20 Bytes.
Rose Zadik82741422018-03-27 12:49:48 +0100192 *
193 * \return \c 0 on success.
Hanno Becker5359ca82018-12-18 11:11:18 +0000194 * \return A negative error code on failure.
Paul Bakker5121ce52009-01-03 21:22:43 +0000195 */
Gilles Peskine9e4f77c2018-01-22 11:48:08 +0100196int mbedtls_sha1_finish_ret( mbedtls_sha1_context *ctx,
Andres Amaya Garcia034ea7e2017-04-28 15:14:50 +0100197 unsigned char output[20] );
Paul Bakker5121ce52009-01-03 21:22:43 +0000198
Andres Amaya Garcia034ea7e2017-04-28 15:14:50 +0100199/**
Rose Zadik82741422018-03-27 12:49:48 +0100200 * \brief SHA-1 process data block (internal use only).
Hanno Beckerbbca8c52017-09-25 14:53:51 +0100201 *
202 * \warning SHA-1 is considered a weak message digest and its use
203 * constitutes a security risk. We recommend considering
204 * stronger message digests instead.
205 *
Hanno Becker79b9e392018-12-18 23:17:49 +0000206 * \param ctx The SHA-1 context to use. This must be initialized.
Hanno Becker5359ca82018-12-18 11:11:18 +0000207 * \param data The data block being processed. This must be a
208 * readable buffer of length \c 64 Bytes.
Rose Zadik82741422018-03-27 12:49:48 +0100209 *
210 * \return \c 0 on success.
Hanno Becker5359ca82018-12-18 11:11:18 +0000211 * \return A negative error code on failure.
Rose Zadik82741422018-03-27 12:49:48 +0100212 *
Andres Amaya Garcia034ea7e2017-04-28 15:14:50 +0100213 */
Andres Amaya Garciacccfe082017-06-28 10:36:39 +0100214int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx,
215 const unsigned char data[64] );
Andres Amaya Garcia034ea7e2017-04-28 15:14:50 +0100216
217#if !defined(MBEDTLS_DEPRECATED_REMOVED)
218#if defined(MBEDTLS_DEPRECATED_WARNING)
219#define MBEDTLS_DEPRECATED __attribute__((deprecated))
220#else
221#define MBEDTLS_DEPRECATED
222#endif
223/**
Rose Zadik82741422018-03-27 12:49:48 +0100224 * \brief This function starts a SHA-1 checksum calculation.
Hanno Beckerbbca8c52017-09-25 14:53:51 +0100225 *
226 * \warning SHA-1 is considered a weak message digest and its use
227 * constitutes a security risk. We recommend considering
228 * stronger message digests instead.
229 *
Rose Zadik82741422018-03-27 12:49:48 +0100230 * \deprecated Superseded by mbedtls_sha1_starts_ret() in 2.7.0.
231 *
Hanno Becker5359ca82018-12-18 11:11:18 +0000232 * \param ctx The SHA-1 context to initialize. This must be initialized.
Rose Zadik82741422018-03-27 12:49:48 +0100233 *
Andres Amaya Garcia034ea7e2017-04-28 15:14:50 +0100234 */
Jaeden Amero041039f2018-02-19 15:28:08 +0000235MBEDTLS_DEPRECATED void mbedtls_sha1_starts( mbedtls_sha1_context *ctx );
Andres Amaya Garcia034ea7e2017-04-28 15:14:50 +0100236
237/**
Rose Zadik82741422018-03-27 12:49:48 +0100238 * \brief This function feeds an input buffer into an ongoing SHA-1
239 * checksum calculation.
Hanno Beckerbbca8c52017-09-25 14:53:51 +0100240 *
241 * \warning SHA-1 is considered a weak message digest and its use
242 * constitutes a security risk. We recommend considering
243 * stronger message digests instead.
244 *
Rose Zadik82741422018-03-27 12:49:48 +0100245 * \deprecated Superseded by mbedtls_sha1_update_ret() in 2.7.0.
246 *
Hanno Becker42f783d2018-12-18 18:39:32 +0000247 * \param ctx The SHA-1 context. This must be initialized and
Hanno Becker5359ca82018-12-18 11:11:18 +0000248 * have a hash operation started.
Rose Zadik82741422018-03-27 12:49:48 +0100249 * \param input The buffer holding the input data.
Hanno Becker5359ca82018-12-18 11:11:18 +0000250 * This must be a readable buffer of length \p ilen Bytes.
Hanno Becker5359ca82018-12-18 11:11:18 +0000251 * \param ilen The length of the input data \p input in Bytes.
Rose Zadik82741422018-03-27 12:49:48 +0100252 *
Andres Amaya Garcia034ea7e2017-04-28 15:14:50 +0100253 */
Jaeden Amero041039f2018-02-19 15:28:08 +0000254MBEDTLS_DEPRECATED void mbedtls_sha1_update( mbedtls_sha1_context *ctx,
255 const unsigned char *input,
256 size_t ilen );
Andres Amaya Garcia034ea7e2017-04-28 15:14:50 +0100257
258/**
Rose Zadik82741422018-03-27 12:49:48 +0100259 * \brief This function finishes the SHA-1 operation, and writes
260 * the result to the output buffer.
Hanno Beckerbbca8c52017-09-25 14:53:51 +0100261 *
262 * \warning SHA-1 is considered a weak message digest and its use
263 * constitutes a security risk. We recommend considering
264 * stronger message digests instead.
265 *
Rose Zadik82741422018-03-27 12:49:48 +0100266 * \deprecated Superseded by mbedtls_sha1_finish_ret() in 2.7.0.
267 *
Hanno Becker5359ca82018-12-18 11:11:18 +0000268 * \param ctx The SHA-1 context. This must be initialized and
269 * have a hash operation started.
Rose Zadik82741422018-03-27 12:49:48 +0100270 * \param output The SHA-1 checksum result.
Hanno Becker5359ca82018-12-18 11:11:18 +0000271 * This must be a writable buffer of length \c 20 Bytes.
Andres Amaya Garcia034ea7e2017-04-28 15:14:50 +0100272 */
Jaeden Amero041039f2018-02-19 15:28:08 +0000273MBEDTLS_DEPRECATED void mbedtls_sha1_finish( mbedtls_sha1_context *ctx,
274 unsigned char output[20] );
Andres Amaya Garcia034ea7e2017-04-28 15:14:50 +0100275
276/**
Rose Zadik82741422018-03-27 12:49:48 +0100277 * \brief SHA-1 process data block (internal use only).
Hanno Beckerbbca8c52017-09-25 14:53:51 +0100278 *
279 * \warning SHA-1 is considered a weak message digest and its use
280 * constitutes a security risk. We recommend considering
281 * stronger message digests instead.
282 *
Rose Zadik82741422018-03-27 12:49:48 +0100283 * \deprecated Superseded by mbedtls_internal_sha1_process() in 2.7.0.
284 *
Hanno Becker79b9e392018-12-18 23:17:49 +0000285 * \param ctx The SHA-1 context. This must be initialized.
Rose Zadik82741422018-03-27 12:49:48 +0100286 * \param data The data block being processed.
Hanno Becker5359ca82018-12-18 11:11:18 +0000287 * This must be a readable buffer of length \c 64 bytes.
Rose Zadik82741422018-03-27 12:49:48 +0100288 *
Andres Amaya Garcia034ea7e2017-04-28 15:14:50 +0100289 */
Jaeden Amero041039f2018-02-19 15:28:08 +0000290MBEDTLS_DEPRECATED void mbedtls_sha1_process( mbedtls_sha1_context *ctx,
291 const unsigned char data[64] );
Andres Amaya Garcia034ea7e2017-04-28 15:14:50 +0100292
293#undef MBEDTLS_DEPRECATED
294#endif /* !MBEDTLS_DEPRECATED_REMOVED */
Paul Bakker90995b52013-06-24 19:20:35 +0200295
Paul Bakker5121ce52009-01-03 21:22:43 +0000296/**
Rose Zadik44833d92018-01-26 08:41:09 +0000297 * \brief This function calculates the SHA-1 checksum of a buffer.
Paul Bakker5121ce52009-01-03 21:22:43 +0000298 *
Rose Zadik44833d92018-01-26 08:41:09 +0000299 * The function allocates the context, performs the
300 * calculation, and frees the context.
Andres Amaya Garcia034ea7e2017-04-28 15:14:50 +0100301 *
Rose Zadik44833d92018-01-26 08:41:09 +0000302 * The SHA-1 result is calculated as
303 * output = SHA-1(input buffer).
304 *
Rose Zadik82741422018-03-27 12:49:48 +0100305 * \warning SHA-1 is considered a weak message digest and its use
306 * constitutes a security risk. We recommend considering
307 * stronger message digests instead.
308 *
Rose Zadik44833d92018-01-26 08:41:09 +0000309 * \param input The buffer holding the input data.
Hanno Becker5359ca82018-12-18 11:11:18 +0000310 * This must be a readable buffer of length \p ilen Bytes.
Hanno Becker5359ca82018-12-18 11:11:18 +0000311 * \param ilen The length of the input data \p input in Bytes.
Rose Zadik44833d92018-01-26 08:41:09 +0000312 * \param output The SHA-1 checksum result.
Hanno Becker5359ca82018-12-18 11:11:18 +0000313 * This must be a writable buffer of length \c 20 Bytes.
Rose Zadik44833d92018-01-26 08:41:09 +0000314 *
Rose Zadik82741422018-03-27 12:49:48 +0100315 * \return \c 0 on success.
Hanno Becker5359ca82018-12-18 11:11:18 +0000316 * \return A negative error code on failure.
Hanno Beckerbbca8c52017-09-25 14:53:51 +0100317 *
Paul Bakker5121ce52009-01-03 21:22:43 +0000318 */
Gilles Peskine9e4f77c2018-01-22 11:48:08 +0100319int mbedtls_sha1_ret( const unsigned char *input,
Andres Amaya Garcia034ea7e2017-04-28 15:14:50 +0100320 size_t ilen,
321 unsigned char output[20] );
322
323#if !defined(MBEDTLS_DEPRECATED_REMOVED)
324#if defined(MBEDTLS_DEPRECATED_WARNING)
325#define MBEDTLS_DEPRECATED __attribute__((deprecated))
326#else
327#define MBEDTLS_DEPRECATED
328#endif
329/**
Gilles Peskine2e1934a2018-04-18 16:05:29 +0200330 * \brief This function calculates the SHA-1 checksum of a buffer.
Rose Zadik82741422018-03-27 12:49:48 +0100331 *
332 * The function allocates the context, performs the
333 * calculation, and frees the context.
334 *
335 * The SHA-1 result is calculated as
336 * output = SHA-1(input buffer).
337 *
338 * \warning SHA-1 is considered a weak message digest and its use
339 * constitutes a security risk. We recommend considering
340 * stronger message digests instead.
Andres Amaya Garcia034ea7e2017-04-28 15:14:50 +0100341 *
Gilles Peskine3e28d702018-01-22 12:18:59 +0100342 * \deprecated Superseded by mbedtls_sha1_ret() in 2.7.0
Andres Amaya Garcia034ea7e2017-04-28 15:14:50 +0100343 *
Rose Zadik44833d92018-01-26 08:41:09 +0000344 * \param input The buffer holding the input data.
Hanno Becker5359ca82018-12-18 11:11:18 +0000345 * This must be a readable buffer of length \p ilen Bytes.
Hanno Becker5359ca82018-12-18 11:11:18 +0000346 * \param ilen The length of the input data \p input in Bytes.
347 * \param output The SHA-1 checksum result. This must be a writable
348 * buffer of size \c 20 Bytes.
Hanno Beckerbbca8c52017-09-25 14:53:51 +0100349 *
Paul Bakker5121ce52009-01-03 21:22:43 +0000350 */
Jaeden Amero041039f2018-02-19 15:28:08 +0000351MBEDTLS_DEPRECATED void mbedtls_sha1( const unsigned char *input,
352 size_t ilen,
353 unsigned char output[20] );
Andres Amaya Garcia034ea7e2017-04-28 15:14:50 +0100354
355#undef MBEDTLS_DEPRECATED
356#endif /* !MBEDTLS_DEPRECATED_REMOVED */
Paul Bakker5121ce52009-01-03 21:22:43 +0000357
Ron Eldorfa8f6352017-06-20 15:48:46 +0300358#if defined(MBEDTLS_SELF_TEST)
359
Paul Bakker5121ce52009-01-03 21:22:43 +0000360/**
Rose Zadik44833d92018-01-26 08:41:09 +0000361 * \brief The SHA-1 checkup routine.
Paul Bakker5121ce52009-01-03 21:22:43 +0000362 *
Hanno Beckerbbca8c52017-09-25 14:53:51 +0100363 * \warning SHA-1 is considered a weak message digest and its use
364 * constitutes a security risk. We recommend considering
365 * stronger message digests instead.
366 *
Rose Zadik82741422018-03-27 12:49:48 +0100367 * \return \c 0 on success.
368 * \return \c 1 on failure.
369 *
Paul Bakker5121ce52009-01-03 21:22:43 +0000370 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200371int mbedtls_sha1_self_test( int verbose );
Paul Bakker5121ce52009-01-03 21:22:43 +0000372
Ron Eldorfa8f6352017-06-20 15:48:46 +0300373#endif /* MBEDTLS_SELF_TEST */
374
Paul Bakker5121ce52009-01-03 21:22:43 +0000375#ifdef __cplusplus
376}
377#endif
378
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200379#endif /* mbedtls_sha1.h */