Fix various memory management issues
[project/libubox.git] / md5.h
1 /*
2  * Copyright (C) 2014 Felix Fietkau <nbd@openwrt.org>
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 /*
17  * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc.
18  * MD5 Message-Digest Algorithm (RFC 1321).
19  *
20  * Homepage:
21  * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5
22  *
23  * Author:
24  * Alexander Peslyak, better known as Solar Designer <solar at openwall.com>
25  *
26  * This software was written by Alexander Peslyak in 2001.  No copyright is
27  * claimed, and the software is hereby placed in the public domain.
28  * In case this attempt to disclaim copyright and place the software in the
29  * public domain is deemed null and void, then the software is
30  * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the
31  * general public under the following terms:
32  *
33  * Redistribution and use in source and binary forms, with or without
34  * modification, are permitted.
35  *
36  * There's ABSOLUTELY NO WARRANTY, express or implied.
37  *
38  * See md5.c for more information.
39  */
40
41 #ifndef _LIBUBOX_MD5_H
42 #define _LIBUBOX_MD5_H
43
44 #include <stdint.h>
45 #include <stddef.h>
46
47 typedef struct md5_ctx {
48         uint32_t lo, hi;
49         uint32_t a, b, c, d;
50         unsigned char buffer[64];
51 } md5_ctx_t;
52
53 extern void md5_begin(md5_ctx_t *ctx);
54 extern void md5_hash(const void *data, size_t length, md5_ctx_t *ctx);
55 extern void md5_end(void *resbuf, md5_ctx_t *ctx);
56 int md5sum(char *file, void *md5_buf);
57
58 #endif