php_hash_sha.h 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. | SHA1 Author: Stefan Esser <sesser@php.net> |
  16. | SHA256 Author: Sara Golemon <pollita@php.net> |
  17. +----------------------------------------------------------------------+
  18. */
  19. /* $Id$ */
  20. #ifndef PHP_HASH_SHA_H
  21. #define PHP_HASH_SHA_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 sha1() and sha1_file() from basic_functions.c
  28. */
  29. #include "ext/standard/sha1.h"
  30. #include "ext/standard/basic_functions.h"
  31. #ifdef PHP_HASH_SHA1_NOT_IN_CORE
  32. /* SHA1 context. */
  33. typedef struct {
  34. php_hash_uint32 state[5]; /* state (ABCD) */
  35. php_hash_uint32 count[2]; /* number of bits, modulo 2^64 */
  36. unsigned char buffer[64]; /* input buffer */
  37. } PHP_SHA1_CTX;
  38. PHP_HASH_API void PHP_SHA1Init(PHP_SHA1_CTX *);
  39. PHP_HASH_API void PHP_SHA1Update(PHP_SHA1_CTX *, const unsigned char *, unsigned int);
  40. PHP_HASH_API void PHP_SHA1Final(unsigned char[20], PHP_SHA1_CTX *);
  41. PHP_FUNCTION(sha1);
  42. PHP_FUNCTION(sha1_file);
  43. #endif /* PHP_HASH_SHA1_NOT_IN_CORE */
  44. /* SHA224 context. */
  45. typedef struct {
  46. php_hash_uint32 state[8]; /* state */
  47. php_hash_uint32 count[2]; /* number of bits, modulo 2^64 */
  48. unsigned char buffer[64]; /* input buffer */
  49. } PHP_SHA224_CTX;
  50. PHP_HASH_API void PHP_SHA224Init(PHP_SHA224_CTX *);
  51. PHP_HASH_API void PHP_SHA224Update(PHP_SHA224_CTX *, const unsigned char *, unsigned int);
  52. PHP_HASH_API void PHP_SHA224Final(unsigned char[28], PHP_SHA224_CTX *);
  53. /* SHA256 context. */
  54. typedef struct {
  55. php_hash_uint32 state[8]; /* state */
  56. php_hash_uint32 count[2]; /* number of bits, modulo 2^64 */
  57. unsigned char buffer[64]; /* input buffer */
  58. } PHP_SHA256_CTX;
  59. PHP_HASH_API void PHP_SHA256Init(PHP_SHA256_CTX *);
  60. PHP_HASH_API void PHP_SHA256Update(PHP_SHA256_CTX *, const unsigned char *, unsigned int);
  61. PHP_HASH_API void PHP_SHA256Final(unsigned char[32], PHP_SHA256_CTX *);
  62. /* SHA384 context */
  63. typedef struct {
  64. php_hash_uint64 state[8]; /* state */
  65. php_hash_uint64 count[2]; /* number of bits, modulo 2^128 */
  66. unsigned char buffer[128]; /* input buffer */
  67. } PHP_SHA384_CTX;
  68. PHP_HASH_API void PHP_SHA384Init(PHP_SHA384_CTX *);
  69. PHP_HASH_API void PHP_SHA384Update(PHP_SHA384_CTX *, const unsigned char *, unsigned int);
  70. PHP_HASH_API void PHP_SHA384Final(unsigned char[48], PHP_SHA384_CTX *);
  71. /* SHA512 context */
  72. typedef struct {
  73. php_hash_uint64 state[8]; /* state */
  74. php_hash_uint64 count[2]; /* number of bits, modulo 2^128 */
  75. unsigned char buffer[128]; /* input buffer */
  76. } PHP_SHA512_CTX;
  77. PHP_HASH_API void PHP_SHA512Init(PHP_SHA512_CTX *);
  78. PHP_HASH_API void PHP_SHA512Update(PHP_SHA512_CTX *, const unsigned char *, unsigned int);
  79. PHP_HASH_API void PHP_SHA512Final(unsigned char[64], PHP_SHA512_CTX *);
  80. #endif /* PHP_HASH_SHA_H */