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