ssl_tls: fix format warning in ssl_parse_certificate() on x86_64
[tropicssl.git] / include / tropicssl / md2.h
blob867c9768d5d9826ee157a8b3219301b9c6e90f22
1 /**
2 * \file md2.h
4 * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
6 * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
8 * All rights reserved.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * * Neither the names of PolarSSL or XySSL nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #ifndef TROPICSSL_MD2_H
36 #define TROPICSSL_MD2_H
38 /**
39 * \brief MD2 context structure
41 typedef struct {
42 unsigned char cksum[16]; /*!< checksum of the data block */
43 unsigned char state[48]; /*!< intermediate digest state */
44 unsigned char buffer[16]; /*!< data block being processed */
46 unsigned char ipad[64]; /*!< HMAC: inner padding */
47 unsigned char opad[64]; /*!< HMAC: outer padding */
48 int left; /*!< amount of data in buffer */
49 } md2_context;
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
55 /**
56 * \brief MD2 context setup
58 * \param ctx context to be initialized
60 void md2_starts(md2_context * ctx);
62 /**
63 * \brief MD2 process buffer
65 * \param ctx MD2 context
66 * \param input buffer holding the data
67 * \param ilen length of the input data
69 void md2_update(md2_context * ctx, const unsigned char *input, int ilen);
71 /**
72 * \brief MD2 final digest
74 * \param ctx MD2 context
75 * \param output MD2 checksum result
77 void md2_finish(md2_context * ctx, unsigned char output[16]);
79 /**
80 * \brief Output = MD2( input buffer )
82 * \param input buffer holding the data
83 * \param ilen length of the input data
84 * \param output MD2 checksum result
86 void md2(const unsigned char *input, int ilen, unsigned char output[16]);
88 /**
89 * \brief Output = MD2( file contents )
91 * \param path input file name
92 * \param output MD2 checksum result
94 * \return 0 if successful, 1 if fopen failed,
95 * or 2 if fread failed
97 int md2_file(const char *path, unsigned char output[16]);
99 /**
100 * \brief MD2 HMAC context setup
102 * \param ctx HMAC context to be initialized
103 * \param key HMAC secret key
104 * \param keylen length of the HMAC key
106 void md2_hmac_starts(md2_context * ctx, const unsigned char *key, int keylen);
109 * \brief MD2 HMAC process buffer
111 * \param ctx HMAC context
112 * \param input buffer holding the data
113 * \param ilen length of the input data
115 void md2_hmac_update(md2_context * ctx, const unsigned char *input, int ilen);
118 * \brief MD2 HMAC final digest
120 * \param ctx HMAC context
121 * \param output MD2 HMAC checksum result
123 void md2_hmac_finish(md2_context * ctx, unsigned char output[16]);
126 * \brief Output = HMAC-MD2( hmac key, input buffer )
128 * \param key HMAC secret key
129 * \param keylen length of the HMAC key
130 * \param input buffer holding the data
131 * \param ilen length of the input data
132 * \param output HMAC-MD2 result
134 void md2_hmac(const unsigned char *key, int keylen,
135 const unsigned char *input, int ilen, unsigned char output[16]);
138 * \brief Checkup routine
140 * \return 0 if successful, or 1 if the test failed
142 int md2_self_test(int verbose);
144 #ifdef __cplusplus
146 #endif
147 #endif /* md2.h */