blob: f12f4346d5105e98a84bc913c402b83b514603eb [file] [log] [blame]
Paul Bakker61b699e2014-01-22 13:35:29 +01001/**
Simon Butcher5b331b92016-01-03 16:14:14 +00002 * \file ripemd160.h
Paul Bakker61b699e2014-01-22 13:35:29 +01003 *
4 * \brief RIPE MD-160 message digest
Darryl Greena40a1012018-01-05 15:33:17 +00005 */
6/*
Bence Szépkúti1e148272020-08-07 13:07:28 +02007 * Copyright The Mbed TLS Contributors
Manuel Pégourié-Gonnard37ff1402015-09-04 14:21:07 +02008 * SPDX-License-Identifier: Apache-2.0
9 *
10 * Licensed under the Apache License, Version 2.0 (the "License"); you may
11 * not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
13 *
14 * http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
Paul Bakker61b699e2014-01-22 13:35:29 +010021 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020022#ifndef MBEDTLS_RIPEMD160_H
23#define MBEDTLS_RIPEMD160_H
Mateusz Starzyk846f0212021-05-19 19:44:07 +020024#include "mbedtls/private_access.h"
Paul Bakker61b699e2014-01-22 13:35:29 +010025
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020026#if !defined(MBEDTLS_CONFIG_FILE)
Jaeden Ameroc49fbbf2019-07-04 20:01:14 +010027#include "mbedtls/config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020028#else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020029#include MBEDTLS_CONFIG_FILE
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020030#endif
Paul Bakker61b699e2014-01-22 13:35:29 +010031
Rich Evans00ab4702015-02-06 13:43:58 +000032#include <stddef.h>
Manuel Pégourié-Gonnardab229102015-04-15 11:53:16 +020033#include <stdint.h>
Paul Bakker61b699e2014-01-22 13:35:29 +010034
Paul Bakker61b699e2014-01-22 13:35:29 +010035#ifdef __cplusplus
36extern "C" {
37#endif
38
Ron Eldorb2aacec2017-05-18 16:53:08 +030039#if !defined(MBEDTLS_RIPEMD160_ALT)
40// Regular implementation
41//
42
Paul Bakker61b699e2014-01-22 13:35:29 +010043/**
44 * \brief RIPEMD-160 context structure
45 */
Dawid Drozd428cc522018-07-24 10:02:47 +020046typedef struct mbedtls_ripemd160_context
Paul Bakker61b699e2014-01-22 13:35:29 +010047{
Mateusz Starzyk846f0212021-05-19 19:44:07 +020048 uint32_t MBEDTLS_PRIVATE(total)[2]; /*!< number of bytes processed */
49 uint32_t MBEDTLS_PRIVATE(state)[5]; /*!< intermediate digest state */
50 unsigned char MBEDTLS_PRIVATE(buffer)[64]; /*!< data block being processed */
Paul Bakker61b699e2014-01-22 13:35:29 +010051}
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020052mbedtls_ripemd160_context;
Paul Bakker61b699e2014-01-22 13:35:29 +010053
Ron Eldorb2aacec2017-05-18 16:53:08 +030054#else /* MBEDTLS_RIPEMD160_ALT */
Jaeden Amero8045cfb2019-07-04 20:26:59 +010055#include "ripemd160_alt.h"
Ron Eldorb2aacec2017-05-18 16:53:08 +030056#endif /* MBEDTLS_RIPEMD160_ALT */
57
Paul Bakker61b699e2014-01-22 13:35:29 +010058/**
Paul Bakker5b4af392014-06-26 12:09:34 +020059 * \brief Initialize RIPEMD-160 context
60 *
61 * \param ctx RIPEMD-160 context to be initialized
62 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020063void mbedtls_ripemd160_init( mbedtls_ripemd160_context *ctx );
Paul Bakker5b4af392014-06-26 12:09:34 +020064
65/**
66 * \brief Clear RIPEMD-160 context
67 *
68 * \param ctx RIPEMD-160 context to be cleared
69 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020070void mbedtls_ripemd160_free( mbedtls_ripemd160_context *ctx );
Paul Bakker5b4af392014-06-26 12:09:34 +020071
72/**
Manuel Pégourié-Gonnard16d412f2015-07-06 15:26:26 +020073 * \brief Clone (the state of) an RIPEMD-160 context
74 *
75 * \param dst The destination context
76 * \param src The context to be cloned
77 */
78void mbedtls_ripemd160_clone( mbedtls_ripemd160_context *dst,
79 const mbedtls_ripemd160_context *src );
80
81/**
Paul Bakker61b699e2014-01-22 13:35:29 +010082 * \brief RIPEMD-160 context setup
83 *
84 * \param ctx context to be initialized
Andres Amaya Garciab1a8bf92017-05-02 10:59:46 +010085 *
86 * \return 0 if successful
Paul Bakker61b699e2014-01-22 13:35:29 +010087 */
TRodziewicz26371e42021-06-08 16:45:41 +020088int mbedtls_ripemd160_starts( mbedtls_ripemd160_context *ctx );
Paul Bakker61b699e2014-01-22 13:35:29 +010089
90/**
91 * \brief RIPEMD-160 process buffer
92 *
93 * \param ctx RIPEMD-160 context
Andres Amaya Garciaa21247e2017-07-20 14:01:08 +010094 * \param input buffer holding the data
Paul Bakker61b699e2014-01-22 13:35:29 +010095 * \param ilen length of the input data
Andres Amaya Garciab1a8bf92017-05-02 10:59:46 +010096 *
97 * \return 0 if successful
Paul Bakker61b699e2014-01-22 13:35:29 +010098 */
TRodziewicz26371e42021-06-08 16:45:41 +020099int mbedtls_ripemd160_update( mbedtls_ripemd160_context *ctx,
100 const unsigned char *input,
101 size_t ilen );
Paul Bakker61b699e2014-01-22 13:35:29 +0100102
103/**
104 * \brief RIPEMD-160 final digest
105 *
106 * \param ctx RIPEMD-160 context
107 * \param output RIPEMD-160 checksum result
Andres Amaya Garciab1a8bf92017-05-02 10:59:46 +0100108 *
109 * \return 0 if successful
Paul Bakker61b699e2014-01-22 13:35:29 +0100110 */
TRodziewicz26371e42021-06-08 16:45:41 +0200111int mbedtls_ripemd160_finish( mbedtls_ripemd160_context *ctx,
112 unsigned char output[20] );
Paul Bakker61b699e2014-01-22 13:35:29 +0100113
Andres Amaya Garciab1a8bf92017-05-02 10:59:46 +0100114/**
115 * \brief RIPEMD-160 process data block (internal use only)
116 *
117 * \param ctx RIPEMD-160 context
118 * \param data buffer holding one block of data
119 *
120 * \return 0 if successful
121 */
Andres Amaya Garciacccfe082017-06-28 10:36:39 +0100122int mbedtls_internal_ripemd160_process( mbedtls_ripemd160_context *ctx,
123 const unsigned char data[64] );
Andres Amaya Garciab1a8bf92017-05-02 10:59:46 +0100124
Paul Bakker61b699e2014-01-22 13:35:29 +0100125/**
126 * \brief Output = RIPEMD-160( input buffer )
127 *
Andres Amaya Garciaa21247e2017-07-20 14:01:08 +0100128 * \param input buffer holding the data
Paul Bakker61b699e2014-01-22 13:35:29 +0100129 * \param ilen length of the input data
130 * \param output RIPEMD-160 checksum result
Andres Amaya Garciab1a8bf92017-05-02 10:59:46 +0100131 *
132 * \return 0 if successful
Paul Bakker61b699e2014-01-22 13:35:29 +0100133 */
TRodziewicz26371e42021-06-08 16:45:41 +0200134int mbedtls_ripemd160( const unsigned char *input,
135 size_t ilen,
136 unsigned char output[20] );
Andres Amaya Garciab1a8bf92017-05-02 10:59:46 +0100137
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500138#if defined(MBEDTLS_SELF_TEST)
139
Paul Bakker61b699e2014-01-22 13:35:29 +0100140/**
Paul Bakker61b699e2014-01-22 13:35:29 +0100141 * \brief Checkup routine
142 *
143 * \return 0 if successful, or 1 if the test failed
144 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200145int mbedtls_ripemd160_self_test( int verbose );
Paul Bakker61b699e2014-01-22 13:35:29 +0100146
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500147#endif /* MBEDTLS_SELF_TEST */
148
Paul Bakker61b699e2014-01-22 13:35:29 +0100149#ifdef __cplusplus
150}
151#endif
152
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200153#endif /* mbedtls_ripemd160.h */