• 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     uint32_t MBEDTLS_PRIVATE(total)[2];          /*!< number of bytes processed  */
44     uint32_t MBEDTLS_PRIVATE(state)[5];          /*!< intermediate digest state  */
45     unsigned char MBEDTLS_PRIVATE(buffer)[64];   /*!< data block being processed */
46 }
47 mbedtls_ripemd160_context;
48 
49 #else  /* MBEDTLS_RIPEMD160_ALT */
50 #include "ripemd160_alt.h"
51 #endif /* MBEDTLS_RIPEMD160_ALT */
52 
53 /**
54  * \brief          Initialize RIPEMD-160 context
55  *
56  * \param ctx      RIPEMD-160 context to be initialized
57  */
58 void mbedtls_ripemd160_init(mbedtls_ripemd160_context *ctx);
59 
60 /**
61  * \brief          Clear RIPEMD-160 context
62  *
63  * \param ctx      RIPEMD-160 context to be cleared
64  */
65 void mbedtls_ripemd160_free(mbedtls_ripemd160_context *ctx);
66 
67 /**
68  * \brief          Clone (the state of) a RIPEMD-160 context
69  *
70  * \param dst      The destination context
71  * \param src      The context to be cloned
72  */
73 void mbedtls_ripemd160_clone(mbedtls_ripemd160_context *dst,
74                              const mbedtls_ripemd160_context *src);
75 
76 /**
77  * \brief          RIPEMD-160 context setup
78  *
79  * \param ctx      context to be initialized
80  *
81  * \return         0 if successful
82  */
83 int mbedtls_ripemd160_starts(mbedtls_ripemd160_context *ctx);
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  *
92  * \return         0 if successful
93  */
94 int mbedtls_ripemd160_update(mbedtls_ripemd160_context *ctx,
95                              const unsigned char *input,
96                              size_t ilen);
97 
98 /**
99  * \brief          RIPEMD-160 final digest
100  *
101  * \param ctx      RIPEMD-160 context
102  * \param output   RIPEMD-160 checksum result
103  *
104  * \return         0 if successful
105  */
106 int mbedtls_ripemd160_finish(mbedtls_ripemd160_context *ctx,
107                              unsigned char output[20]);
108 
109 /**
110  * \brief          RIPEMD-160 process data block (internal use only)
111  *
112  * \param ctx      RIPEMD-160 context
113  * \param data     buffer holding one block of data
114  *
115  * \return         0 if successful
116  */
117 int mbedtls_internal_ripemd160_process(mbedtls_ripemd160_context *ctx,
118                                        const unsigned char data[64]);
119 
120 /**
121  * \brief          Output = RIPEMD-160( input buffer )
122  *
123  * \param input    buffer holding the data
124  * \param ilen     length of the input data
125  * \param output   RIPEMD-160 checksum result
126  *
127  * \return         0 if successful
128  */
129 int mbedtls_ripemd160(const unsigned char *input,
130                       size_t ilen,
131                       unsigned char output[20]);
132 
133 #if defined(MBEDTLS_SELF_TEST)
134 
135 /**
136  * \brief          Checkup routine
137  *
138  * \return         0 if successful, or 1 if the test failed
139  */
140 int mbedtls_ripemd160_self_test(int verbose);
141 
142 #endif /* MBEDTLS_SELF_TEST */
143 
144 #ifdef __cplusplus
145 }
146 #endif
147 
148 #endif /* mbedtls_ripemd160.h */
149