xref: /PHP-5.3/ext/hash/php_hash_md.h (revision a2045ff3)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 5                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1997-2013 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 /* $Id$ */
21 
22 #ifndef PHP_HASH_MD_H
23 #define PHP_HASH_MD_H
24 
25 /* When SHA is removed from Core,
26     the ext/standard/sha1.c file can be removed
27     and the ext/standard/sha1.h file can be reduced to:
28         #define PHP_HASH_SHA1_NOT_IN_CORE
29         #include "ext/hash/php_hash_sha.h"
30 	Don't forget to remove md5() and md5_file() entries from basic_functions.c
31  */
32 
33 #include "ext/standard/md5.h"
34 
35 #ifdef PHP_HASH_MD5_NOT_IN_CORE
36 /* MD5.H - header file for MD5C.C
37  */
38 
39 /* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
40    rights reserved.
41 
42    License to copy and use this software is granted provided that it
43    is identified as the "RSA Data Security, Inc. MD5 Message-Digest
44    Algorithm" in all material mentioning or referencing this software
45    or this function.
46 
47    License is also granted to make and use derivative works provided
48    that such works are identified as "derived from the RSA Data
49    Security, Inc. MD5 Message-Digest Algorithm" in all material
50    mentioning or referencing the derived work.
51 
52    RSA Data Security, Inc. makes no representations concerning either
53    the merchantability of this software or the suitability of this
54    software for any particular purpose. It is provided "as is"
55    without express or implied warranty of any kind.
56 
57    These notices must be retained in any copies of any part of this
58    documentation and/or software.
59  */
60 
61 /* MD5 context. */
62 typedef struct {
63 	php_hash_uint32 state[4];				/* state (ABCD) */
64 	php_hash_uint32 count[2];				/* number of bits, modulo 2^64 (lsb first) */
65 	unsigned char buffer[64];	/* input buffer */
66 } PHP_MD5_CTX;
67 
68 PHP_HASH_API void make_digest(char *md5str, unsigned char *digest);
69 PHP_HASH_API void PHP_MD5Init(PHP_MD5_CTX *);
70 PHP_HASH_API void PHP_MD5Update(PHP_MD5_CTX *, const unsigned char *, unsigned int);
71 PHP_HASH_API void PHP_MD5Final(unsigned char[16], PHP_MD5_CTX *);
72 
73 PHP_NAMED_FUNCTION(php_if_md5);
74 PHP_NAMED_FUNCTION(php_if_md5_file);
75 #endif /* PHP_HASH_MD5_NOT_IN_CORE */
76 
77 /* MD4 context */
78 typedef struct {
79 	php_hash_uint32 state[4];
80 	php_hash_uint32 count[2];
81 	unsigned char buffer[64];
82 } PHP_MD4_CTX;
83 
84 PHP_HASH_API void PHP_MD4Init(PHP_MD4_CTX *);
85 PHP_HASH_API void PHP_MD4Update(PHP_MD4_CTX *context, const unsigned char *, unsigned int);
86 PHP_HASH_API void PHP_MD4Final(unsigned char[16], PHP_MD4_CTX *);
87 
88 /* MD2 context */
89 typedef struct {
90 	unsigned char state[48];
91 	unsigned char checksum[16];
92 	unsigned char buffer[16];
93 	char in_buffer;
94 } PHP_MD2_CTX;
95 
96 PHP_HASH_API void PHP_MD2Init(PHP_MD2_CTX *context);
97 PHP_HASH_API void PHP_MD2Update(PHP_MD2_CTX *context, const unsigned char *, unsigned int);
98 PHP_HASH_API void PHP_MD2Final(unsigned char[16], PHP_MD2_CTX *);
99 
100 #endif
101