md2.h
Go to the documentation of this file.
1 /**
2  * @file md2.h
3  * @brief MD2 (Message-Digest Algorithm)
4  *
5  * @section License
6  *
7  * Copyright (C) 2010-2018 Oryx Embedded SARL. All rights reserved.
8  *
9  * This file is part of CycloneCrypto Open.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24  *
25  * @author Oryx Embedded SARL (www.oryx-embedded.com)
26  * @version 1.9.0
27  **/
28 
29 #ifndef _MD2_H
30 #define _MD2_H
31 
32 //Dependencies
33 #include "core/crypto.h"
34 
35 //MD2 block size
36 #define MD2_BLOCK_SIZE 16
37 //MD2 digest size
38 #define MD2_DIGEST_SIZE 16
39 //MD2 algorithm object identifier
40 #define MD2_OID md2Oid
41 //Common interface for hash algorithms
42 #define MD2_HASH_ALGO (&md2HashAlgo)
43 
44 //C++ guard
45 #ifdef __cplusplus
46  extern "C" {
47 #endif
48 
49 
50 /**
51  * @brief MD2 algorithm context
52  **/
53 
54 typedef struct
55 {
56 
57  union
58  {
59  uint8_t x[48];
60  uint8_t digest[16];
61  };
62  uint8_t m[16];
63  uint8_t c[16];
64  size_t size;
65 } Md2Context;
66 
67 
68 //MD2 related constants
69 extern const uint8_t md2Oid[8];
70 extern const HashAlgo md2HashAlgo;
71 
72 //MD2 related functions
73 error_t md2Compute(const void *data, size_t length, uint8_t *digest);
74 void md2Init(Md2Context *context);
75 void md2Update(Md2Context *context, const void *data, size_t length);
76 void md2Final(Md2Context *context, uint8_t *digest);
77 void md2ProcessBlock(const uint8_t *m, uint8_t *x, uint8_t *c);
78 
79 //C++ guard
80 #ifdef __cplusplus
81  }
82 #endif
83 
84 #endif
const HashAlgo md2HashAlgo
Definition: md2.c:69
void md2Init(Md2Context *context)
Initialize MD2 message digest context.
Definition: md2.c:119
uint8_t c
Definition: ndp.h:510
void md2Final(Md2Context *context, uint8_t *digest)
Finish the MD2 message digest.
Definition: md2.c:175
General definitions for cryptographic algorithms.
uint8_t m
Definition: ndp.h:299
void md2ProcessBlock(const uint8_t *m, uint8_t *x, uint8_t *c)
Process message in 16-word blocks.
Definition: md2.c:205
const uint8_t md2Oid[8]
Definition: md2.c:66
MD2 algorithm context.
Definition: md2.h:54
error_t md2Compute(const void *data, size_t length, uint8_t *digest)
Digest a message using MD2.
Definition: md2.c:92
error_t
Error codes.
Definition: error.h:40
uint8_t data[]
Definition: dtls_misc.h:167
size_t size
Definition: md2.h:64
void md2Update(Md2Context *context, const void *data, size_t length)
Update the MD2 context with a portion of the message being hashed.
Definition: md2.c:137
Common interface for hash algorithms.
Definition: crypto.h:1054
uint8_t length
Definition: dtls_misc.h:140