Paul Bakker | 61b699e | 2014-01-22 13:35:29 +0100 | [diff] [blame] | 1 | /** |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 2 | * \file mbedtls_ripemd160.h |
Paul Bakker | 61b699e | 2014-01-22 13:35:29 +0100 | [diff] [blame] | 3 | * |
| 4 | * \brief RIPE MD-160 message digest |
| 5 | * |
Manuel Pégourié-Gonnard | a658a40 | 2015-01-23 09:45:19 +0000 | [diff] [blame] | 6 | * Copyright (C) 2014-2014, ARM Limited, All Rights Reserved |
Paul Bakker | 61b699e | 2014-01-22 13:35:29 +0100 | [diff] [blame] | 7 | * |
Manuel Pégourié-Gonnard | fe44643 | 2015-03-06 13:17:10 +0000 | [diff] [blame] | 8 | * This file is part of mbed TLS (https://tls.mbed.org) |
Paul Bakker | 61b699e | 2014-01-22 13:35:29 +0100 | [diff] [blame] | 9 | * |
Paul Bakker | 61b699e | 2014-01-22 13:35:29 +0100 | [diff] [blame] | 10 | * 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é-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 24 | #ifndef MBEDTLS_RIPEMD160_H |
| 25 | #define MBEDTLS_RIPEMD160_H |
Paul Bakker | 61b699e | 2014-01-22 13:35:29 +0100 | [diff] [blame] | 26 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 27 | #if !defined(MBEDTLS_CONFIG_FILE) |
Paul Bakker | 61b699e | 2014-01-22 13:35:29 +0100 | [diff] [blame] | 28 | #include "config.h" |
Manuel Pégourié-Gonnard | cef4ad2 | 2014-04-29 12:39:06 +0200 | [diff] [blame] | 29 | #else |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 30 | #include MBEDTLS_CONFIG_FILE |
Manuel Pégourié-Gonnard | cef4ad2 | 2014-04-29 12:39:06 +0200 | [diff] [blame] | 31 | #endif |
Paul Bakker | 61b699e | 2014-01-22 13:35:29 +0100 | [diff] [blame] | 32 | |
Rich Evans | 00ab470 | 2015-02-06 13:43:58 +0000 | [diff] [blame] | 33 | #include <stddef.h> |
Manuel Pégourié-Gonnard | ab22910 | 2015-04-15 11:53:16 +0200 | [diff] [blame] | 34 | #include <stdint.h> |
Paul Bakker | 61b699e | 2014-01-22 13:35:29 +0100 | [diff] [blame] | 35 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 36 | #if !defined(MBEDTLS_RIPEMD160_ALT) |
Paul Bakker | 9f4c162 | 2014-01-22 14:14:26 +0100 | [diff] [blame] | 37 | // Regular implementation |
| 38 | // |
| 39 | |
Paul Bakker | 61b699e | 2014-01-22 13:35:29 +0100 | [diff] [blame] | 40 | #ifdef __cplusplus |
| 41 | extern "C" { |
| 42 | #endif |
| 43 | |
| 44 | /** |
| 45 | * \brief RIPEMD-160 context structure |
| 46 | */ |
| 47 | typedef 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 Bakker | 61b699e | 2014-01-22 13:35:29 +0100 | [diff] [blame] | 52 | } |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 53 | mbedtls_ripemd160_context; |
Paul Bakker | 61b699e | 2014-01-22 13:35:29 +0100 | [diff] [blame] | 54 | |
| 55 | /** |
Paul Bakker | 5b4af39 | 2014-06-26 12:09:34 +0200 | [diff] [blame] | 56 | * \brief Initialize RIPEMD-160 context |
| 57 | * |
| 58 | * \param ctx RIPEMD-160 context to be initialized |
| 59 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 60 | void mbedtls_ripemd160_init( mbedtls_ripemd160_context *ctx ); |
Paul Bakker | 5b4af39 | 2014-06-26 12:09:34 +0200 | [diff] [blame] | 61 | |
| 62 | /** |
| 63 | * \brief Clear RIPEMD-160 context |
| 64 | * |
| 65 | * \param ctx RIPEMD-160 context to be cleared |
| 66 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 67 | void mbedtls_ripemd160_free( mbedtls_ripemd160_context *ctx ); |
Paul Bakker | 5b4af39 | 2014-06-26 12:09:34 +0200 | [diff] [blame] | 68 | |
| 69 | /** |
Manuel Pégourié-Gonnard | 16d412f | 2015-07-06 15:26:26 +0200 | [diff] [blame] | 70 | * \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 | */ |
| 75 | void mbedtls_ripemd160_clone( mbedtls_ripemd160_context *dst, |
| 76 | const mbedtls_ripemd160_context *src ); |
| 77 | |
| 78 | /** |
Paul Bakker | 61b699e | 2014-01-22 13:35:29 +0100 | [diff] [blame] | 79 | * \brief RIPEMD-160 context setup |
| 80 | * |
| 81 | * \param ctx context to be initialized |
| 82 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 83 | void mbedtls_ripemd160_starts( mbedtls_ripemd160_context *ctx ); |
Paul Bakker | 61b699e | 2014-01-22 13:35:29 +0100 | [diff] [blame] | 84 | |
| 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é-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 92 | void mbedtls_ripemd160_update( mbedtls_ripemd160_context *ctx, |
Paul Bakker | 61b699e | 2014-01-22 13:35:29 +0100 | [diff] [blame] | 93 | 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é-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 101 | void mbedtls_ripemd160_finish( mbedtls_ripemd160_context *ctx, unsigned char output[20] ); |
Paul Bakker | 61b699e | 2014-01-22 13:35:29 +0100 | [diff] [blame] | 102 | |
Paul Bakker | 9f4c162 | 2014-01-22 14:14:26 +0100 | [diff] [blame] | 103 | /* Internal use */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 104 | void mbedtls_ripemd160_process( mbedtls_ripemd160_context *ctx, const unsigned char data[64] ); |
Paul Bakker | 9f4c162 | 2014-01-22 14:14:26 +0100 | [diff] [blame] | 105 | |
| 106 | #ifdef __cplusplus |
| 107 | } |
| 108 | #endif |
| 109 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 110 | #else /* MBEDTLS_RIPEMD160_ALT */ |
Paul Bakker | 9f4c162 | 2014-01-22 14:14:26 +0100 | [diff] [blame] | 111 | #include "ripemd160.h" |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 112 | #endif /* MBEDTLS_RIPEMD160_ALT */ |
Paul Bakker | 9f4c162 | 2014-01-22 14:14:26 +0100 | [diff] [blame] | 113 | |
| 114 | #ifdef __cplusplus |
| 115 | extern "C" { |
| 116 | #endif |
| 117 | |
Paul Bakker | 61b699e | 2014-01-22 13:35:29 +0100 | [diff] [blame] | 118 | /** |
| 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é-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 125 | void mbedtls_ripemd160( const unsigned char *input, size_t ilen, |
Paul Bakker | 61b699e | 2014-01-22 13:35:29 +0100 | [diff] [blame] | 126 | unsigned char output[20] ); |
| 127 | |
Paul Bakker | 61b699e | 2014-01-22 13:35:29 +0100 | [diff] [blame] | 128 | /** |
Paul Bakker | 61b699e | 2014-01-22 13:35:29 +0100 | [diff] [blame] | 129 | * \brief Checkup routine |
| 130 | * |
| 131 | * \return 0 if successful, or 1 if the test failed |
| 132 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 133 | int mbedtls_ripemd160_self_test( int verbose ); |
Paul Bakker | 61b699e | 2014-01-22 13:35:29 +0100 | [diff] [blame] | 134 | |
Paul Bakker | 61b699e | 2014-01-22 13:35:29 +0100 | [diff] [blame] | 135 | #ifdef __cplusplus |
| 136 | } |
| 137 | #endif |
| 138 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 139 | #endif /* mbedtls_ripemd160.h */ |