xref: /PHP-7.4/ext/hash/php_hash_md.h (revision 0cf7de1c)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 7                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) The PHP Group                                          |
6    +----------------------------------------------------------------------+
7    | This source file is subject to version 3.01 of the PHP license,      |
8    | that is bundled with this package in the file LICENSE, and is        |
9    | available through the world-wide-web at the following url:           |
10    | http://www.php.net/license/3_01.txt                                  |
11    | If you did not receive a copy of the PHP license and are unable to   |
12    | obtain it through the world-wide-web, please send a note to          |
13    | license@php.net so we can mail you a copy immediately.               |
14    +----------------------------------------------------------------------+
15    | Original Author: Rasmus Lerdorf <rasmus@lerdorf.on.ca>               |
16    | Modified for pHASH by: Sara Golemon <pollita@php.net>
17    +----------------------------------------------------------------------+
18 */
19 
20 #ifndef PHP_HASH_MD_H
21 #define PHP_HASH_MD_H
22 
23 /* When SHA is removed from Core,
24     the ext/standard/sha1.c file can be removed
25     and the ext/standard/sha1.h file can be reduced to:
26         #define PHP_HASH_SHA1_NOT_IN_CORE
27         #include "ext/hash/php_hash_sha.h"
28 	Don't forget to remove md5() and md5_file() entries from basic_functions.c
29  */
30 
31 #include "ext/standard/md5.h"
32 
33 #ifdef PHP_HASH_MD5_NOT_IN_CORE
34 /* MD5.H - header file for MD5C.C
35  */
36 
37 /* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
38    rights reserved.
39 
40    License to copy and use this software is granted provided that it
41    is identified as the "RSA Data Security, Inc. MD5 Message-Digest
42    Algorithm" in all material mentioning or referencing this software
43    or this function.
44 
45    License is also granted to make and use derivative works provided
46    that such works are identified as "derived from the RSA Data
47    Security, Inc. MD5 Message-Digest Algorithm" in all material
48    mentioning or referencing the derived work.
49 
50    RSA Data Security, Inc. makes no representations concerning either
51    the merchantability of this software or the suitability of this
52    software for any particular purpose. It is provided "as is"
53    without express or implied warranty of any kind.
54 
55    These notices must be retained in any copies of any part of this
56    documentation and/or software.
57  */
58 
59 /* MD5 context. */
60 typedef struct {
61 	uint32_t state[4];				/* state (ABCD) */
62 	uint32_t count[2];				/* number of bits, modulo 2^64 (lsb first) */
63 	unsigned char buffer[64];	/* input buffer */
64 } PHP_MD5_CTX;
65 
66 PHP_HASH_API void make_digest(char *md5str, unsigned char *digest);
67 PHP_HASH_API void PHP_MD5Init(PHP_MD5_CTX *);
68 PHP_HASH_API void PHP_MD5Update(PHP_MD5_CTX *, const unsigned char *, size_t);
69 PHP_HASH_API void PHP_MD5Final(unsigned char[16], PHP_MD5_CTX *);
70 
71 PHP_NAMED_FUNCTION(php_if_md5);
72 PHP_NAMED_FUNCTION(php_if_md5_file);
73 #endif /* PHP_HASH_MD5_NOT_IN_CORE */
74 
75 /* MD4 context */
76 typedef struct {
77 	uint32_t state[4];
78 	uint32_t count[2];
79 	unsigned char buffer[64];
80 } PHP_MD4_CTX;
81 
82 PHP_HASH_API void PHP_MD4Init(PHP_MD4_CTX *);
83 PHP_HASH_API void PHP_MD4Update(PHP_MD4_CTX *context, const unsigned char *, size_t);
84 PHP_HASH_API void PHP_MD4Final(unsigned char[16], PHP_MD4_CTX *);
85 
86 /* MD2 context */
87 typedef struct {
88 	unsigned char state[48];
89 	unsigned char checksum[16];
90 	unsigned char buffer[16];
91 	char in_buffer;
92 } PHP_MD2_CTX;
93 
94 PHP_HASH_API void PHP_MD2Init(PHP_MD2_CTX *context);
95 PHP_HASH_API void PHP_MD2Update(PHP_MD2_CTX *context, const unsigned char *, size_t);
96 PHP_HASH_API void PHP_MD2Final(unsigned char[16], PHP_MD2_CTX *);
97 
98 #endif
99