0729218626ee08d1327763ded6c0c49692eef755
[bertos.git] / algos / md2.h
1 /**
2  * \file
3  * <!--
4  * Copyright 2007 Develer S.r.l. (http://www.develer.com/)
5  * This file is part of DevLib - See README.devlib for information.
6  * -->
7  *
8  * \brief MD2 Message-Digest algorithm.
9  *
10  * The algorithm takes as input a message of arbitrary length and produces
11  * as output a 128-bit message digest of the input.
12  * It is conjectured that it is computationally infeasible to produce
13  * two messages having the same message digest, or to produce any
14  * message having a given prespecified target message digest.
15  *
16  *
17  *
18  * \version $Id$
19  * \author Daniele Basile <asterix@develer.com>
20  */
21
22 /*#*
23  *#* $Log$
24  *#* Revision 1.7  2007/02/15 13:29:49  asterix
25  *#* Add MD2_DIGEST_LEN macro.
26  *#*
27  *#* Revision 1.6  2007/02/02 18:15:31  asterix
28  *#* Add function MD2_test. Fix bug in md2_update function.
29  *#*
30  *#* Revision 1.5  2007/02/02 15:37:45  asterix
31  *#* Change md2_end prototype. Remove a unneeded memcpy in md2_end. Add comments.
32  *#*
33  *#* Revision 1.4  2007/01/31 13:53:36  asterix
34  *#* Define COMPUTE_ARRAY_LEN.
35  *#*
36  *#* Revision 1.3  2007/01/31 11:16:48  asterix
37  *#* Defined constants for algorithm compute
38  *#*
39  *#* Revision 1.2  2007/01/30 17:31:44  asterix
40  *#* Add function prototypes.
41  *#*
42  *#* Revision 1.1  2007/01/30 15:53:26  batt
43  *#* Add first md2 skel.
44  *#*
45  *#*/
46
47 #ifndef ALGOS_MD2_H
48 #define ALGOS_MD2_H
49
50 #include <cfg/compiler.h>
51 #include <appconfig.h>
52
53 #define NUM_COMPUTE_ROUNDS 18                        ///< Number of compute rounds.
54 #define COMPUTE_ARRAY_LEN  CONFIG_MD2_BLOCK_LEN * 3     ///< Lenght of compute array.
55 #define MD2_DIGEST_LEN CONFIG_MD2_BLOCK_LEN
56 /**
57  * Context for MD2 computation.
58  */
59 typedef struct Md2Context
60 {
61         uint8_t buffer[CONFIG_MD2_BLOCK_LEN];   ///< Input buffer.
62         uint8_t state[CONFIG_MD2_BLOCK_LEN];    ///< Current state buffer.
63         uint8_t checksum[CONFIG_MD2_BLOCK_LEN]; ///< Checksum.
64         size_t counter;                         ///< Counter of remaining bytes.
65
66 } Md2Context;
67
68 void md2_init(Md2Context *context);
69 void md2_update(Md2Context *context, const void *block_in, size_t block_len);
70 uint8_t *md2_end(Md2Context *context);
71 bool md2_test(void);
72
73 #endif /* ALGOS_MD2_H */