md5.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2003-2005 by Christopher R. Hertel
3  * 2015 Freie Universität Berlin
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19 
20 #pragma once
21 
56 #include <stdint.h>
57 #include <string.h>
58 
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62 
66 #define MD5_DIGEST_LENGTH (16U)
67 
71 typedef struct {
72  uint32_t len;
73  uint32_t abcd[4];
74  int b_used;
75  uint8_t block[64];
76 } md5_ctx_t;
77 
94 void md5_init(md5_ctx_t *ctx);
95 
103 void md5_update(md5_ctx_t *ctx, const void *data, size_t len);
104 
111 void md5_final(md5_ctx_t *ctx, void *digest);
112 
120 void md5(void *digest, const void *data, size_t len);
121 
122 #ifdef __cplusplus
123 }
124 #endif
125 
void md5(void *digest, const void *data, size_t len)
Calculate a MD5 hash from the given data.
void md5_init(md5_ctx_t *ctx)
Initialize the MD5 calculation context.
void md5_update(md5_ctx_t *ctx, const void *data, size_t len)
Build an MD5 Message Digest within the given context.
void md5_final(md5_ctx_t *ctx, void *digest)
Finish up the current MD5 hash calculation generate the final hash.
MD5 calculation context.
Definition: md5.h:71
uint32_t len
overall number of bytes processed
Definition: md5.h:72
int b_used
number of bytes used in the current block
Definition: md5.h:74