4 * \brief RIPE MD-160 message digest
6 * Copyright (C) 2014-2014, Brainspark B.V.
8 * This file is part of PolarSSL (http://www.polarssl.org)
9 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
11 * All rights reserved.
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.
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.
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.
27 #ifndef POLARSSL_RIPEMD160_H
28 #define POLARSSL_RIPEMD160_H
30 #if !defined(POLARSSL_CONFIG_FILE)
33 #include POLARSSL_CONFIG_FILE
38 #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
40 typedef UINT32
uint32_t;
45 #define POLARSSL_ERR_RIPEMD160_FILE_IO_ERROR -0x007E /**< Read/write error in file. */
47 #if !defined(POLARSSL_RIPEMD160_ALT)
48 // Regular implementation
56 * \brief RIPEMD-160 context structure
60 uint32_t total
[2]; /*!< number of bytes processed */
61 uint32_t state
[5]; /*!< intermediate digest state */
62 unsigned char buffer
[64]; /*!< data block being processed */
64 unsigned char ipad
[64]; /*!< HMAC: inner padding */
65 unsigned char opad
[64]; /*!< HMAC: outer padding */
70 * \brief RIPEMD-160 context setup
72 * \param ctx context to be initialized
74 void ripemd160_starts( ripemd160_context
*ctx
);
77 * \brief RIPEMD-160 process buffer
79 * \param ctx RIPEMD-160 context
80 * \param input buffer holding the data
81 * \param ilen length of the input data
83 void ripemd160_update( ripemd160_context
*ctx
,
84 const unsigned char *input
, size_t ilen
);
87 * \brief RIPEMD-160 final digest
89 * \param ctx RIPEMD-160 context
90 * \param output RIPEMD-160 checksum result
92 void ripemd160_finish( ripemd160_context
*ctx
, unsigned char output
[20] );
95 void ripemd160_process( ripemd160_context
*ctx
, const unsigned char data
[64] );
101 #else /* POLARSSL_RIPEMD160_ALT */
102 #include "ripemd160.h"
103 #endif /* POLARSSL_RIPEMD160_ALT */
110 * \brief Output = RIPEMD-160( input buffer )
112 * \param input buffer holding the data
113 * \param ilen length of the input data
114 * \param output RIPEMD-160 checksum result
116 void ripemd160( const unsigned char *input
, size_t ilen
,
117 unsigned char output
[20] );
119 #if defined(POLARSSL_FS_IO)
121 * \brief Output = RIPEMD-160( file contents )
123 * \param path input file name
124 * \param output RIPEMD-160 checksum result
126 * \return 0 if successful, or POLARSSL_ERR_RIPEMD160_FILE_IO_ERROR
128 int ripemd160_file( const char *path
, unsigned char output
[20] );
129 #endif /* POLARSSL_FS_IO */
132 * \brief RIPEMD-160 HMAC context setup
134 * \param ctx HMAC context to be initialized
135 * \param key HMAC secret key
136 * \param keylen length of the HMAC key
138 void ripemd160_hmac_starts( ripemd160_context
*ctx
,
139 const unsigned char *key
, size_t keylen
);
142 * \brief RIPEMD-160 HMAC process buffer
144 * \param ctx HMAC context
145 * \param input buffer holding the data
146 * \param ilen length of the input data
148 void ripemd160_hmac_update( ripemd160_context
*ctx
,
149 const unsigned char *input
, size_t ilen
);
152 * \brief RIPEMD-160 HMAC final digest
154 * \param ctx HMAC context
155 * \param output RIPEMD-160 HMAC checksum result
157 void ripemd160_hmac_finish( ripemd160_context
*ctx
, unsigned char output
[20] );
160 * \brief RIPEMD-160 HMAC context reset
162 * \param ctx HMAC context to be reset
164 void ripemd160_hmac_reset( ripemd160_context
*ctx
);
167 * \brief Output = HMAC-RIPEMD-160( hmac key, input buffer )
169 * \param key HMAC secret key
170 * \param keylen length of the HMAC key
171 * \param input buffer holding the data
172 * \param ilen length of the input data
173 * \param output HMAC-RIPEMD-160 result
175 void ripemd160_hmac( const unsigned char *key
, size_t keylen
,
176 const unsigned char *input
, size_t ilen
,
177 unsigned char output
[20] );
180 * \brief Checkup routine
182 * \return 0 if successful, or 1 if the test failed
184 int ripemd160_self_test( int verbose
);
190 #endif /* ripemd160.h */