4 * \brief RIPE MD-160 message digest
7 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
8 * SPDX-License-Identifier: Apache-2.0
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
14 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 * This file is part of mbed TLS (https://tls.mbed.org)
24 #ifndef MBEDTLS_RIPEMD160_H
25 #define MBEDTLS_RIPEMD160_H
27 #if !defined(MBEDTLS_CONFIG_FILE)
30 #include MBEDTLS_CONFIG_FILE
36 /* MBEDTLS_ERR_RIPEMD160_HW_ACCEL_FAILED is deprecated and should not be used.
38 #define MBEDTLS_ERR_RIPEMD160_HW_ACCEL_FAILED -0x0031 /**< RIPEMD160 hardware accelerator failed */
44 #if !defined(MBEDTLS_RIPEMD160_ALT)
45 // Regular implementation
49 * \brief RIPEMD-160 context structure
51 typedef struct mbedtls_ripemd160_context
53 uint32_t total[2]; /*!< number of bytes processed */
54 uint32_t state[5]; /*!< intermediate digest state */
55 unsigned char buffer[64]; /*!< data block being processed */
57 mbedtls_ripemd160_context;
59 #else /* MBEDTLS_RIPEMD160_ALT */
60 #include "ripemd160.h"
61 #endif /* MBEDTLS_RIPEMD160_ALT */
64 * \brief Initialize RIPEMD-160 context
66 * \param ctx RIPEMD-160 context to be initialized
68 void mbedtls_ripemd160_init( mbedtls_ripemd160_context *ctx );
71 * \brief Clear RIPEMD-160 context
73 * \param ctx RIPEMD-160 context to be cleared
75 void mbedtls_ripemd160_free( mbedtls_ripemd160_context *ctx );
78 * \brief Clone (the state of) an RIPEMD-160 context
80 * \param dst The destination context
81 * \param src The context to be cloned
83 void mbedtls_ripemd160_clone( mbedtls_ripemd160_context *dst,
84 const mbedtls_ripemd160_context *src );
87 * \brief RIPEMD-160 context setup
89 * \param ctx context to be initialized
91 * \return 0 if successful
93 int mbedtls_ripemd160_starts_ret( mbedtls_ripemd160_context *ctx );
96 * \brief RIPEMD-160 process buffer
98 * \param ctx RIPEMD-160 context
99 * \param input buffer holding the data
100 * \param ilen length of the input data
102 * \return 0 if successful
104 int mbedtls_ripemd160_update_ret( mbedtls_ripemd160_context *ctx,
105 const unsigned char *input,
109 * \brief RIPEMD-160 final digest
111 * \param ctx RIPEMD-160 context
112 * \param output RIPEMD-160 checksum result
114 * \return 0 if successful
116 int mbedtls_ripemd160_finish_ret( mbedtls_ripemd160_context *ctx,
117 unsigned char output[20] );
120 * \brief RIPEMD-160 process data block (internal use only)
122 * \param ctx RIPEMD-160 context
123 * \param data buffer holding one block of data
125 * \return 0 if successful
127 int mbedtls_internal_ripemd160_process( mbedtls_ripemd160_context *ctx,
128 const unsigned char data[64] );
130 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
131 #if defined(MBEDTLS_DEPRECATED_WARNING)
132 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
134 #define MBEDTLS_DEPRECATED
137 * \brief RIPEMD-160 context setup
139 * \deprecated Superseded by mbedtls_ripemd160_starts_ret() in 2.7.0
141 * \param ctx context to be initialized
143 MBEDTLS_DEPRECATED void mbedtls_ripemd160_starts(
144 mbedtls_ripemd160_context *ctx );
147 * \brief RIPEMD-160 process buffer
149 * \deprecated Superseded by mbedtls_ripemd160_update_ret() in 2.7.0
151 * \param ctx RIPEMD-160 context
152 * \param input buffer holding the data
153 * \param ilen length of the input data
155 MBEDTLS_DEPRECATED void mbedtls_ripemd160_update(
156 mbedtls_ripemd160_context *ctx,
157 const unsigned char *input,
161 * \brief RIPEMD-160 final digest
163 * \deprecated Superseded by mbedtls_ripemd160_finish_ret() in 2.7.0
165 * \param ctx RIPEMD-160 context
166 * \param output RIPEMD-160 checksum result
168 MBEDTLS_DEPRECATED void mbedtls_ripemd160_finish(
169 mbedtls_ripemd160_context *ctx,
170 unsigned char output[20] );
173 * \brief RIPEMD-160 process data block (internal use only)
175 * \deprecated Superseded by mbedtls_internal_ripemd160_process() in 2.7.0
177 * \param ctx RIPEMD-160 context
178 * \param data buffer holding one block of data
180 MBEDTLS_DEPRECATED void mbedtls_ripemd160_process(
181 mbedtls_ripemd160_context *ctx,
182 const unsigned char data[64] );
184 #undef MBEDTLS_DEPRECATED
185 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
188 * \brief Output = RIPEMD-160( input buffer )
190 * \param input buffer holding the data
191 * \param ilen length of the input data
192 * \param output RIPEMD-160 checksum result
194 * \return 0 if successful
196 int mbedtls_ripemd160_ret( const unsigned char *input,
198 unsigned char output[20] );
200 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
201 #if defined(MBEDTLS_DEPRECATED_WARNING)
202 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
204 #define MBEDTLS_DEPRECATED
207 * \brief Output = RIPEMD-160( input buffer )
209 * \deprecated Superseded by mbedtls_ripemd160_ret() in 2.7.0
211 * \param input buffer holding the data
212 * \param ilen length of the input data
213 * \param output RIPEMD-160 checksum result
215 MBEDTLS_DEPRECATED void mbedtls_ripemd160( const unsigned char *input,
217 unsigned char output[20] );
219 #undef MBEDTLS_DEPRECATED
220 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
222 #if defined(MBEDTLS_SELF_TEST)
225 * \brief Checkup routine
227 * \return 0 if successful, or 1 if the test failed
229 int mbedtls_ripemd160_self_test( int verbose );
231 #endif /* MBEDTLS_SELF_TEST */
237 #endif /* mbedtls_ripemd160.h */