• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * \file ripemd160.h
3  *
4  * \brief RIPE MD-160 message digest
5  */
6 /*
7  *  Copyright The Mbed TLS Contributors
8  *  SPDX-License-Identifier: Apache-2.0
9  *
10  *  Licensed under the Apache License, Version 2.0 (the "License"); you may
11  *  not use this file except in compliance with the License.
12  *  You may obtain a copy of the License at
13  *
14  *  http://www.apache.org/licenses/LICENSE-2.0
15  *
16  *  Unless required by applicable law or agreed to in writing, software
17  *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18  *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  *  See the License for the specific language governing permissions and
20  *  limitations under the License.
21  */
22 #ifndef MBEDTLS_RIPEMD160_H
23 #define MBEDTLS_RIPEMD160_H
24 #include "mbedtls/private_access.h"
25 
26 #include "mbedtls/build_info.h"
27 
28 #include <stddef.h>
29 #include <stdint.h>
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 #if !defined(MBEDTLS_RIPEMD160_ALT)
36 // Regular implementation
37 //
38 
39 /**
40  * \brief          RIPEMD-160 context structure
41  */
42 typedef struct mbedtls_ripemd160_context
43 {
44     uint32_t MBEDTLS_PRIVATE(total)[2];          /*!< number of bytes processed  */
45     uint32_t MBEDTLS_PRIVATE(state)[5];          /*!< intermediate digest state  */
46     unsigned char MBEDTLS_PRIVATE(buffer)[64];   /*!< data block being processed */
47 }
48 mbedtls_ripemd160_context;
49 
50 #else  /* MBEDTLS_RIPEMD160_ALT */
51 #include "ripemd160_alt.h"
52 #endif /* MBEDTLS_RIPEMD160_ALT */
53 
54 /**
55  * \brief          Initialize RIPEMD-160 context
56  *
57  * \param ctx      RIPEMD-160 context to be initialized
58  */
59 void mbedtls_ripemd160_init( mbedtls_ripemd160_context *ctx );
60 
61 /**
62  * \brief          Clear RIPEMD-160 context
63  *
64  * \param ctx      RIPEMD-160 context to be cleared
65  */
66 void mbedtls_ripemd160_free( mbedtls_ripemd160_context *ctx );
67 
68 /**
69  * \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  */
74 void mbedtls_ripemd160_clone( mbedtls_ripemd160_context *dst,
75                         const mbedtls_ripemd160_context *src );
76 
77 /**
78  * \brief          RIPEMD-160 context setup
79  *
80  * \param ctx      context to be initialized
81  *
82  * \return         0 if successful
83  */
84 int mbedtls_ripemd160_starts( mbedtls_ripemd160_context *ctx );
85 
86 /**
87  * \brief          RIPEMD-160 process buffer
88  *
89  * \param ctx      RIPEMD-160 context
90  * \param input    buffer holding the data
91  * \param ilen     length of the input data
92  *
93  * \return         0 if successful
94  */
95 int mbedtls_ripemd160_update( mbedtls_ripemd160_context *ctx,
96                               const unsigned char *input,
97                               size_t ilen );
98 
99 /**
100  * \brief          RIPEMD-160 final digest
101  *
102  * \param ctx      RIPEMD-160 context
103  * \param output   RIPEMD-160 checksum result
104  *
105  * \return         0 if successful
106  */
107 int mbedtls_ripemd160_finish( mbedtls_ripemd160_context *ctx,
108                               unsigned char output[20] );
109 
110 /**
111  * \brief          RIPEMD-160 process data block (internal use only)
112  *
113  * \param ctx      RIPEMD-160 context
114  * \param data     buffer holding one block of data
115  *
116  * \return         0 if successful
117  */
118 int mbedtls_internal_ripemd160_process( mbedtls_ripemd160_context *ctx,
119                                         const unsigned char data[64] );
120 
121 /**
122  * \brief          Output = RIPEMD-160( input buffer )
123  *
124  * \param input    buffer holding the data
125  * \param ilen     length of the input data
126  * \param output   RIPEMD-160 checksum result
127  *
128  * \return         0 if successful
129  */
130 int mbedtls_ripemd160( const unsigned char *input,
131                        size_t ilen,
132                        unsigned char output[20] );
133 
134 #if defined(MBEDTLS_SELF_TEST)
135 
136 /**
137  * \brief          Checkup routine
138  *
139  * \return         0 if successful, or 1 if the test failed
140  */
141 int mbedtls_ripemd160_self_test( int verbose );
142 
143 #endif /* MBEDTLS_SELF_TEST */
144 
145 #ifdef __cplusplus
146 }
147 #endif
148 
149 #endif /* mbedtls_ripemd160.h */
150