blob: 5d6c6b7e93670920c11421f73fb91dae4722bbd5 [file] [log] [blame]
Manuel Pégourié-Gonnardcab4a882014-01-17 12:42:35 +01001/**
2 * \file rdm160.h
3 *
4 * \brief RIPE MD-160 message digest
5 *
6 * Copyright (C) 2014-2014, Brainspark B.V.
7 *
8 * This file is part of PolarSSL (http://www.polarssl.org)
9 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
10 *
11 * All rights reserved.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 */
27#ifndef POLARSSL_RMD160_H
28#define POLARSSL_RMD160_H
29
30#include "config.h"
31
32#include <string.h>
33
34#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
35#include <basetsd.h>
36typedef UINT32 uint32_t;
37#else
38#include <inttypes.h>
39#endif
40
41#define POLARSSL_ERR_RMD160_FILE_IO_ERROR -0x0074 /**< Read/write error in file. */
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
47/**
48 * \brief RMD160 context structure
49 */
50typedef struct
51{
52 uint32_t total[2]; /*!< number of bytes processed */
53 uint32_t state[5]; /*!< intermediate digest state */
54 unsigned char buffer[64]; /*!< data block being processed */
55}
56rmd160_context;
57
58/**
59 * \brief RMD160 context setup
60 *
61 * \param ctx context to be initialized
62 */
63void rmd160_starts( rmd160_context *ctx );
64
65/**
66 * \brief RMD160 process buffer
67 *
68 * \param ctx RMD160 context
69 * \param input buffer holding the data
70 * \param ilen length of the input data
71 */
72void rmd160_update( rmd160_context *ctx,
73 const unsigned char *input, size_t ilen );
74
75/**
76 * \brief RMD160 final digest
77 *
78 * \param ctx RMD160 context
79 * \param output RMD160 checksum result
80 */
81void rmd160_finish( rmd160_context *ctx, unsigned char output[16] );
82
83/**
84 * \brief Output = RMD160( input buffer )
85 *
86 * \param input buffer holding the data
87 * \param ilen length of the input data
88 * \param output RMD160 checksum result
89 */
90void rmd160( const unsigned char *input, size_t ilen,
91 unsigned char output[16] );
92
93#if defined(POLARSSL_FS_IO)
94/**
95 * \brief Output = RMD160( file contents )
96 *
97 * \param path input file name
98 * \param output RMD160 checksum result
99 *
100 * \return 0 if successful, or POLARSSL_ERR_RMD160_FILE_IO_ERROR
101 */
102int rmd160_file( const char *path, unsigned char output[16] );
103#endif /* POLARSSL_FS_IO */
104
105
106/**
107 * \brief Checkup routine
108 *
109 * \return 0 if successful, or 1 if the test failed
110 */
111int rmd160_self_test( int verbose );
112
113#ifdef __cplusplus
114}
115#endif
116
117#endif /* rmd160.h */