blob: ae365f3d62a3054ee91f0819d8cf64930f0c6ddb [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/*
Manuel Pégourié-Gonnard6fb81872015-07-27 11:11:48 +02007 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
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é-Gonnardfe446432015-03-06 13:17:10 +000022 * This file is part of mbed TLS (https://tls.mbed.org)
Paul Bakker61b699e2014-01-22 13:35:29 +010023 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020024#ifndef MBEDTLS_RIPEMD160_H
25#define MBEDTLS_RIPEMD160_H
Paul Bakker61b699e2014-01-22 13:35:29 +010026
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020027#if !defined(MBEDTLS_CONFIG_FILE)
Paul Bakker61b699e2014-01-22 13:35:29 +010028#include "config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020029#else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020030#include MBEDTLS_CONFIG_FILE
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020031#endif
Paul Bakker61b699e2014-01-22 13:35:29 +010032
Rich Evans00ab4702015-02-06 13:43:58 +000033#include <stddef.h>
Manuel Pégourié-Gonnardab229102015-04-15 11:53:16 +020034#include <stdint.h>
Paul Bakker61b699e2014-01-22 13:35:29 +010035
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020036#if !defined(MBEDTLS_RIPEMD160_ALT)
Paul Bakker9f4c1622014-01-22 14:14:26 +010037// Regular implementation
38//
39
Paul Bakker61b699e2014-01-22 13:35:29 +010040#ifdef __cplusplus
41extern "C" {
42#endif
43
44/**
45 * \brief RIPEMD-160 context structure
46 */
47typedef struct
48{
49 uint32_t total[2]; /*!< number of bytes processed */
50 uint32_t state[5]; /*!< intermediate digest state */
51 unsigned char buffer[64]; /*!< data block being processed */
Paul Bakker61b699e2014-01-22 13:35:29 +010052}
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020053mbedtls_ripemd160_context;
Paul Bakker61b699e2014-01-22 13:35:29 +010054
55/**
Paul Bakker5b4af392014-06-26 12:09:34 +020056 * \brief Initialize RIPEMD-160 context
57 *
58 * \param ctx RIPEMD-160 context to be initialized
59 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020060void mbedtls_ripemd160_init( mbedtls_ripemd160_context *ctx );
Paul Bakker5b4af392014-06-26 12:09:34 +020061
62/**
63 * \brief Clear RIPEMD-160 context
64 *
65 * \param ctx RIPEMD-160 context to be cleared
66 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020067void mbedtls_ripemd160_free( mbedtls_ripemd160_context *ctx );
Paul Bakker5b4af392014-06-26 12:09:34 +020068
69/**
Manuel Pégourié-Gonnard16d412f2015-07-06 15:26:26 +020070 * \brief Clone (the state of) an RIPEMD-160 context
71 *
72 * \param dst The destination context
73 * \param src The context to be cloned
74 */
75void mbedtls_ripemd160_clone( mbedtls_ripemd160_context *dst,
76 const mbedtls_ripemd160_context *src );
77
78/**
Paul Bakker61b699e2014-01-22 13:35:29 +010079 * \brief RIPEMD-160 context setup
80 *
81 * \param ctx context to be initialized
82 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020083void mbedtls_ripemd160_starts( mbedtls_ripemd160_context *ctx );
Paul Bakker61b699e2014-01-22 13:35:29 +010084
85/**
86 * \brief RIPEMD-160 process buffer
87 *
88 * \param ctx RIPEMD-160 context
89 * \param input buffer holding the data
90 * \param ilen length of the input data
91 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020092void mbedtls_ripemd160_update( mbedtls_ripemd160_context *ctx,
Paul Bakker61b699e2014-01-22 13:35:29 +010093 const unsigned char *input, size_t ilen );
94
95/**
96 * \brief RIPEMD-160 final digest
97 *
98 * \param ctx RIPEMD-160 context
99 * \param output RIPEMD-160 checksum result
100 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200101void mbedtls_ripemd160_finish( mbedtls_ripemd160_context *ctx, unsigned char output[20] );
Paul Bakker61b699e2014-01-22 13:35:29 +0100102
Paul Bakker9f4c1622014-01-22 14:14:26 +0100103/* Internal use */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200104void mbedtls_ripemd160_process( mbedtls_ripemd160_context *ctx, const unsigned char data[64] );
Paul Bakker9f4c1622014-01-22 14:14:26 +0100105
106#ifdef __cplusplus
107}
108#endif
109
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200110#else /* MBEDTLS_RIPEMD160_ALT */
Paul Bakker9f4c1622014-01-22 14:14:26 +0100111#include "ripemd160.h"
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200112#endif /* MBEDTLS_RIPEMD160_ALT */
Paul Bakker9f4c1622014-01-22 14:14:26 +0100113
114#ifdef __cplusplus
115extern "C" {
116#endif
117
Paul Bakker61b699e2014-01-22 13:35:29 +0100118/**
119 * \brief Output = RIPEMD-160( input buffer )
120 *
121 * \param input buffer holding the data
122 * \param ilen length of the input data
123 * \param output RIPEMD-160 checksum result
124 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200125void mbedtls_ripemd160( const unsigned char *input, size_t ilen,
Paul Bakker61b699e2014-01-22 13:35:29 +0100126 unsigned char output[20] );
127
Paul Bakker61b699e2014-01-22 13:35:29 +0100128/**
Paul Bakker61b699e2014-01-22 13:35:29 +0100129 * \brief Checkup routine
130 *
131 * \return 0 if successful, or 1 if the test failed
132 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200133int mbedtls_ripemd160_self_test( int verbose );
Paul Bakker61b699e2014-01-22 13:35:29 +0100134
Paul Bakker61b699e2014-01-22 13:35:29 +0100135#ifdef __cplusplus
136}
137#endif
138
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200139#endif /* mbedtls_ripemd160.h */