php_hash_md.h 3.8 KB

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