blob: 390584b6c94c022be32026591e9cee36db4ab442 [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é-Gonnarda658a402015-01-23 09:45:19 +00006 * Copyright (C) 2014-2014, ARM Limited, All Rights Reserved
Paul Bakker61b699e2014-01-22 13:35:29 +01007 *
Manuel Pégourié-Gonnardfe446432015-03-06 13:17:10 +00008 * This file is part of mbed TLS (https://tls.mbed.org)
Paul Bakker61b699e2014-01-22 13:35:29 +01009 *
Paul Bakker61b699e2014-01-22 13:35:29 +010010 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 */
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#define MBEDTLS_ERR_RIPEMD160_FILE_IO_ERROR -0x007E /**< Read/write error in file. */
Paul Bakker61b699e2014-01-22 13:35:29 +010037
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020038#if !defined(MBEDTLS_RIPEMD160_ALT)
Paul Bakker9f4c1622014-01-22 14:14:26 +010039// Regular implementation
40//
41
Paul Bakker61b699e2014-01-22 13:35:29 +010042#ifdef __cplusplus
43extern "C" {
44#endif
45
46/**
47 * \brief RIPEMD-160 context structure
48 */
49typedef struct
50{
51 uint32_t total[2]; /*!< number of bytes processed */
52 uint32_t state[5]; /*!< intermediate digest state */
53 unsigned char buffer[64]; /*!< data block being processed */
Paul Bakker61b699e2014-01-22 13:35:29 +010054}
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020055mbedtls_ripemd160_context;
Paul Bakker61b699e2014-01-22 13:35:29 +010056
57/**
Paul Bakker5b4af392014-06-26 12:09:34 +020058 * \brief Initialize RIPEMD-160 context
59 *
60 * \param ctx RIPEMD-160 context to be initialized
61 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020062void mbedtls_ripemd160_init( mbedtls_ripemd160_context *ctx );
Paul Bakker5b4af392014-06-26 12:09:34 +020063
64/**
65 * \brief Clear RIPEMD-160 context
66 *
67 * \param ctx RIPEMD-160 context to be cleared
68 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020069void mbedtls_ripemd160_free( mbedtls_ripemd160_context *ctx );
Paul Bakker5b4af392014-06-26 12:09:34 +020070
71/**
Paul Bakker61b699e2014-01-22 13:35:29 +010072 * \brief RIPEMD-160 context setup
73 *
74 * \param ctx context to be initialized
75 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020076void mbedtls_ripemd160_starts( mbedtls_ripemd160_context *ctx );
Paul Bakker61b699e2014-01-22 13:35:29 +010077
78/**
79 * \brief RIPEMD-160 process buffer
80 *
81 * \param ctx RIPEMD-160 context
82 * \param input buffer holding the data
83 * \param ilen length of the input data
84 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020085void mbedtls_ripemd160_update( mbedtls_ripemd160_context *ctx,
Paul Bakker61b699e2014-01-22 13:35:29 +010086 const unsigned char *input, size_t ilen );
87
88/**
89 * \brief RIPEMD-160 final digest
90 *
91 * \param ctx RIPEMD-160 context
92 * \param output RIPEMD-160 checksum result
93 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020094void mbedtls_ripemd160_finish( mbedtls_ripemd160_context *ctx, unsigned char output[20] );
Paul Bakker61b699e2014-01-22 13:35:29 +010095
Paul Bakker9f4c1622014-01-22 14:14:26 +010096/* Internal use */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020097void mbedtls_ripemd160_process( mbedtls_ripemd160_context *ctx, const unsigned char data[64] );
Paul Bakker9f4c1622014-01-22 14:14:26 +010098
99#ifdef __cplusplus
100}
101#endif
102
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200103#else /* MBEDTLS_RIPEMD160_ALT */
Paul Bakker9f4c1622014-01-22 14:14:26 +0100104#include "ripemd160.h"
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200105#endif /* MBEDTLS_RIPEMD160_ALT */
Paul Bakker9f4c1622014-01-22 14:14:26 +0100106
107#ifdef __cplusplus
108extern "C" {
109#endif
110
Paul Bakker61b699e2014-01-22 13:35:29 +0100111/**
112 * \brief Output = RIPEMD-160( input buffer )
113 *
114 * \param input buffer holding the data
115 * \param ilen length of the input data
116 * \param output RIPEMD-160 checksum result
117 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200118void mbedtls_ripemd160( const unsigned char *input, size_t ilen,
Paul Bakker61b699e2014-01-22 13:35:29 +0100119 unsigned char output[20] );
120
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200121#if defined(MBEDTLS_FS_IO)
Paul Bakker61b699e2014-01-22 13:35:29 +0100122/**
123 * \brief Output = RIPEMD-160( file contents )
124 *
125 * \param path input file name
126 * \param output RIPEMD-160 checksum result
127 *
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200128 * \return 0 if successful, or MBEDTLS_ERR_RIPEMD160_FILE_IO_ERROR
Paul Bakker61b699e2014-01-22 13:35:29 +0100129 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200130int mbedtls_ripemd160_file( const char *path, unsigned char output[20] );
131#endif /* MBEDTLS_FS_IO */
Paul Bakker61b699e2014-01-22 13:35:29 +0100132
133/**
Paul Bakker61b699e2014-01-22 13:35:29 +0100134 * \brief Checkup routine
135 *
136 * \return 0 if successful, or 1 if the test failed
137 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200138int mbedtls_ripemd160_self_test( int verbose );
Paul Bakker61b699e2014-01-22 13:35:29 +0100139
Paul Bakker61b699e2014-01-22 13:35:29 +0100140#ifdef __cplusplus
141}
142#endif
143
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200144#endif /* mbedtls_ripemd160.h */