blob: 397ec841cc318afac2a6988ccc7d05e72c33a907 [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
Bence Szépkútic662b362021-05-27 11:25:03 +020026#include "mbedtls/build_info.h"
Paul Bakker61b699e2014-01-22 13:35:29 +010027
Rich Evans00ab4702015-02-06 13:43:58 +000028#include <stddef.h>
Manuel Pégourié-Gonnardab229102015-04-15 11:53:16 +020029#include <stdint.h>
Paul Bakker61b699e2014-01-22 13:35:29 +010030
Paul Bakker61b699e2014-01-22 13:35:29 +010031#ifdef __cplusplus
32extern "C" {
33#endif
34
Ron Eldorb2aacec2017-05-18 16:53:08 +030035#if !defined(MBEDTLS_RIPEMD160_ALT)
36// Regular implementation
37//
38
Paul Bakker61b699e2014-01-22 13:35:29 +010039/**
40 * \brief RIPEMD-160 context structure
41 */
Dawid Drozd428cc522018-07-24 10:02:47 +020042typedef struct mbedtls_ripemd160_context
Paul Bakker61b699e2014-01-22 13:35:29 +010043{
Mateusz Starzyk846f0212021-05-19 19:44:07 +020044 uint32_t MBEDTLS_PRIVATE(total)[2]; /*!< number of bytes processed */
45 uint32_t MBEDTLS_PRIVATE(state)[5]; /*!< intermediate digest state */
46 unsigned char MBEDTLS_PRIVATE(buffer)[64]; /*!< data block being processed */
Paul Bakker61b699e2014-01-22 13:35:29 +010047}
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020048mbedtls_ripemd160_context;
Paul Bakker61b699e2014-01-22 13:35:29 +010049
Ron Eldorb2aacec2017-05-18 16:53:08 +030050#else /* MBEDTLS_RIPEMD160_ALT */
Jaeden Amero8045cfb2019-07-04 20:26:59 +010051#include "ripemd160_alt.h"
Ron Eldorb2aacec2017-05-18 16:53:08 +030052#endif /* MBEDTLS_RIPEMD160_ALT */
53
Paul Bakker61b699e2014-01-22 13:35:29 +010054/**
Paul Bakker5b4af392014-06-26 12:09:34 +020055 * \brief Initialize RIPEMD-160 context
56 *
57 * \param ctx RIPEMD-160 context to be initialized
58 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020059void mbedtls_ripemd160_init( mbedtls_ripemd160_context *ctx );
Paul Bakker5b4af392014-06-26 12:09:34 +020060
61/**
62 * \brief Clear RIPEMD-160 context
63 *
64 * \param ctx RIPEMD-160 context to be cleared
65 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020066void mbedtls_ripemd160_free( mbedtls_ripemd160_context *ctx );
Paul Bakker5b4af392014-06-26 12:09:34 +020067
68/**
Tom Cosgrovece7f18c2022-07-28 05:50:56 +010069 * \brief Clone (the state of) a RIPEMD-160 context
Manuel Pégourié-Gonnard16d412f2015-07-06 15:26:26 +020070 *
71 * \param dst The destination context
72 * \param src The context to be cloned
73 */
74void mbedtls_ripemd160_clone( mbedtls_ripemd160_context *dst,
75 const mbedtls_ripemd160_context *src );
76
77/**
Paul Bakker61b699e2014-01-22 13:35:29 +010078 * \brief RIPEMD-160 context setup
79 *
80 * \param ctx context to be initialized
Andres Amaya Garciab1a8bf92017-05-02 10:59:46 +010081 *
82 * \return 0 if successful
Paul Bakker61b699e2014-01-22 13:35:29 +010083 */
TRodziewicz26371e42021-06-08 16:45:41 +020084int mbedtls_ripemd160_starts( mbedtls_ripemd160_context *ctx );
Paul Bakker61b699e2014-01-22 13:35:29 +010085
86/**
87 * \brief RIPEMD-160 process buffer
88 *
89 * \param ctx RIPEMD-160 context
Andres Amaya Garciaa21247e2017-07-20 14:01:08 +010090 * \param input buffer holding the data
Paul Bakker61b699e2014-01-22 13:35:29 +010091 * \param ilen length of the input data
Andres Amaya Garciab1a8bf92017-05-02 10:59:46 +010092 *
93 * \return 0 if successful
Paul Bakker61b699e2014-01-22 13:35:29 +010094 */
TRodziewicz26371e42021-06-08 16:45:41 +020095int mbedtls_ripemd160_update( mbedtls_ripemd160_context *ctx,
96 const unsigned char *input,
97 size_t ilen );
Paul Bakker61b699e2014-01-22 13:35:29 +010098
99/**
100 * \brief RIPEMD-160 final digest
101 *
102 * \param ctx RIPEMD-160 context
103 * \param output RIPEMD-160 checksum result
Andres Amaya Garciab1a8bf92017-05-02 10:59:46 +0100104 *
105 * \return 0 if successful
Paul Bakker61b699e2014-01-22 13:35:29 +0100106 */
TRodziewicz26371e42021-06-08 16:45:41 +0200107int mbedtls_ripemd160_finish( mbedtls_ripemd160_context *ctx,
108 unsigned char output[20] );
Paul Bakker61b699e2014-01-22 13:35:29 +0100109
Andres Amaya Garciab1a8bf92017-05-02 10:59:46 +0100110/**
111 * \brief RIPEMD-160 process data block (internal use only)
112 *
113 * \param ctx RIPEMD-160 context
114 * \param data buffer holding one block of data
115 *
116 * \return 0 if successful
117 */
Andres Amaya Garciacccfe082017-06-28 10:36:39 +0100118int mbedtls_internal_ripemd160_process( mbedtls_ripemd160_context *ctx,
119 const unsigned char data[64] );
Andres Amaya Garciab1a8bf92017-05-02 10:59:46 +0100120
Paul Bakker61b699e2014-01-22 13:35:29 +0100121/**
122 * \brief Output = RIPEMD-160( input buffer )
123 *
Andres Amaya Garciaa21247e2017-07-20 14:01:08 +0100124 * \param input buffer holding the data
Paul Bakker61b699e2014-01-22 13:35:29 +0100125 * \param ilen length of the input data
126 * \param output RIPEMD-160 checksum result
Andres Amaya Garciab1a8bf92017-05-02 10:59:46 +0100127 *
128 * \return 0 if successful
Paul Bakker61b699e2014-01-22 13:35:29 +0100129 */
TRodziewicz26371e42021-06-08 16:45:41 +0200130int mbedtls_ripemd160( const unsigned char *input,
131 size_t ilen,
132 unsigned char output[20] );
Andres Amaya Garciab1a8bf92017-05-02 10:59:46 +0100133
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500134#if defined(MBEDTLS_SELF_TEST)
135
Paul Bakker61b699e2014-01-22 13:35:29 +0100136/**
Paul Bakker61b699e2014-01-22 13:35:29 +0100137 * \brief Checkup routine
138 *
139 * \return 0 if successful, or 1 if the test failed
140 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200141int mbedtls_ripemd160_self_test( int verbose );
Paul Bakker61b699e2014-01-22 13:35:29 +0100142
Andrzej Kurekc470b6b2019-01-31 08:20:20 -0500143#endif /* MBEDTLS_SELF_TEST */
144
Paul Bakker61b699e2014-01-22 13:35:29 +0100145#ifdef __cplusplus
146}
147#endif
148
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200149#endif /* mbedtls_ripemd160.h */