blob: a92d3844940187410a5541c120b7a358ef6b0f13 [file] [log] [blame]
Paul Bakker61b699e2014-01-22 13:35:29 +01001/**
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002 * \file mbedtls_ripemd160.h
Paul Bakker61b699e2014-01-22 13:35:29 +01003 *
4 * \brief RIPE MD-160 message digest
5 *
Manuel Pégourié-Gonnard6fb81872015-07-27 11:11:48 +02006 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
Manuel Pégourié-Gonnard37ff1402015-09-04 14:21:07 +02007 * SPDX-License-Identifier: Apache-2.0
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License"); you may
10 * not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
Paul Bakker61b699e2014-01-22 13:35:29 +010020 *
Manuel Pégourié-Gonnardfe446432015-03-06 13:17:10 +000021 * This file is part of mbed TLS (https://tls.mbed.org)
Paul Bakker61b699e2014-01-22 13:35:29 +010022 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020023#ifndef MBEDTLS_RIPEMD160_H
24#define MBEDTLS_RIPEMD160_H
Paul Bakker61b699e2014-01-22 13:35:29 +010025
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020026#if !defined(MBEDTLS_CONFIG_FILE)
Paul Bakker61b699e2014-01-22 13:35:29 +010027#include "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
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020035#if !defined(MBEDTLS_RIPEMD160_ALT)
Paul Bakker9f4c1622014-01-22 14:14:26 +010036// Regular implementation
37//
38
Paul Bakker61b699e2014-01-22 13:35:29 +010039#ifdef __cplusplus
40extern "C" {
41#endif
42
43/**
44 * \brief RIPEMD-160 context structure
45 */
46typedef struct
47{
48 uint32_t total[2]; /*!< number of bytes processed */
49 uint32_t state[5]; /*!< intermediate digest state */
50 unsigned char 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
54/**
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/**
Manuel Pégourié-Gonnard16d412f2015-07-06 15:26:26 +020069 * \brief Clone (the state of) an RIPEMD-160 context
70 *
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
81 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020082void mbedtls_ripemd160_starts( mbedtls_ripemd160_context *ctx );
Paul Bakker61b699e2014-01-22 13:35:29 +010083
84/**
85 * \brief RIPEMD-160 process buffer
86 *
87 * \param ctx RIPEMD-160 context
88 * \param input buffer holding the data
89 * \param ilen length of the input data
90 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020091void mbedtls_ripemd160_update( mbedtls_ripemd160_context *ctx,
Paul Bakker61b699e2014-01-22 13:35:29 +010092 const unsigned char *input, size_t ilen );
93
94/**
95 * \brief RIPEMD-160 final digest
96 *
97 * \param ctx RIPEMD-160 context
98 * \param output RIPEMD-160 checksum result
99 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200100void mbedtls_ripemd160_finish( mbedtls_ripemd160_context *ctx, unsigned char output[20] );
Paul Bakker61b699e2014-01-22 13:35:29 +0100101
Paul Bakker9f4c1622014-01-22 14:14:26 +0100102/* Internal use */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200103void mbedtls_ripemd160_process( mbedtls_ripemd160_context *ctx, const unsigned char data[64] );
Paul Bakker9f4c1622014-01-22 14:14:26 +0100104
105#ifdef __cplusplus
106}
107#endif
108
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200109#else /* MBEDTLS_RIPEMD160_ALT */
Paul Bakker9f4c1622014-01-22 14:14:26 +0100110#include "ripemd160.h"
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200111#endif /* MBEDTLS_RIPEMD160_ALT */
Paul Bakker9f4c1622014-01-22 14:14:26 +0100112
113#ifdef __cplusplus
114extern "C" {
115#endif
116
Paul Bakker61b699e2014-01-22 13:35:29 +0100117/**
118 * \brief Output = RIPEMD-160( input buffer )
119 *
120 * \param input buffer holding the data
121 * \param ilen length of the input data
122 * \param output RIPEMD-160 checksum result
123 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200124void mbedtls_ripemd160( const unsigned char *input, size_t ilen,
Paul Bakker61b699e2014-01-22 13:35:29 +0100125 unsigned char output[20] );
126
Paul Bakker61b699e2014-01-22 13:35:29 +0100127/**
Paul Bakker61b699e2014-01-22 13:35:29 +0100128 * \brief Checkup routine
129 *
130 * \return 0 if successful, or 1 if the test failed
131 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200132int mbedtls_ripemd160_self_test( int verbose );
Paul Bakker61b699e2014-01-22 13:35:29 +0100133
Paul Bakker61b699e2014-01-22 13:35:29 +0100134#ifdef __cplusplus
135}
136#endif
137
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200138#endif /* mbedtls_ripemd160.h */