Back to index

php5  5.3.10
php_hash_sha.h
Go to the documentation of this file.
00001 /*
00002    +----------------------------------------------------------------------+
00003    | PHP Version 5                                                        |
00004    +----------------------------------------------------------------------+
00005    | Copyright (c) 1997-2012 The PHP Group                                |
00006    +----------------------------------------------------------------------+
00007    | This source file is subject to version 3.01 of the PHP license,      |
00008    | that is bundled with this package in the file LICENSE, and is        |
00009    | available through the world-wide-web at the following url:           |
00010    | http://www.php.net/license/3_01.txt                                  |
00011    | If you did not receive a copy of the PHP license and are unable to   |
00012    | obtain it through the world-wide-web, please send a note to          |
00013    | license@php.net so we can mail you a copy immediately.               |
00014    +----------------------------------------------------------------------+
00015    | SHA1 Author: Stefan Esser <sesser@php.net>                           |
00016    | SHA256 Author: Sara Golemon <pollita@php.net>                        |
00017    +----------------------------------------------------------------------+
00018 */
00019 
00020 /* $Id: php_hash_sha.h 321634 2012-01-01 13:15:04Z felipe $ */
00021 
00022 #ifndef PHP_HASH_SHA_H
00023 #define PHP_HASH_SHA_H
00024 
00025 /* When SHA is removed from Core,
00026        the ext/standard/sha1.c file can be removed
00027        and the ext/standard/sha1.h file can be reduced to:
00028               #define PHP_HASH_SHA1_NOT_IN_CORE
00029               #include "ext/hash/php_hash_sha.h"
00030        Don't forget to remove sha1() and sha1_file() from basic_functions.c
00031  */
00032 #include "ext/standard/sha1.h"
00033 #include "ext/standard/basic_functions.h"
00034 
00035 #ifdef PHP_HASH_SHA1_NOT_IN_CORE
00036 
00037 /* SHA1 context. */
00038 typedef struct {
00039        php_hash_uint32 state[5];          /* state (ABCD) */
00040        php_hash_uint32 count[2];          /* number of bits, modulo 2^64 */
00041        unsigned char buffer[64];   /* input buffer */
00042 } PHP_SHA1_CTX;
00043 
00044 PHP_HASH_API void PHP_SHA1Init(PHP_SHA1_CTX *);
00045 PHP_HASH_API void PHP_SHA1Update(PHP_SHA1_CTX *, const unsigned char *, unsigned int);
00046 PHP_HASH_API void PHP_SHA1Final(unsigned char[20], PHP_SHA1_CTX *);
00047 
00048 PHP_FUNCTION(sha1);
00049 PHP_FUNCTION(sha1_file);
00050 
00051 #endif /* PHP_HASH_SHA1_NOT_IN_CORE */
00052 
00053 /* SHA224 context. */
00054 typedef struct {
00055        php_hash_uint32 state[8];          /* state */
00056        php_hash_uint32 count[2];          /* number of bits, modulo 2^64 */
00057        unsigned char buffer[64];   /* input buffer */
00058 } PHP_SHA224_CTX;
00059 
00060 PHP_HASH_API void PHP_SHA224Init(PHP_SHA224_CTX *);
00061 PHP_HASH_API void PHP_SHA224Update(PHP_SHA224_CTX *, const unsigned char *, unsigned int);
00062 PHP_HASH_API void PHP_SHA224Final(unsigned char[28], PHP_SHA224_CTX *);
00063 
00064 /* SHA256 context. */
00065 typedef struct {
00066        php_hash_uint32 state[8];          /* state */
00067        php_hash_uint32 count[2];          /* number of bits, modulo 2^64 */
00068        unsigned char buffer[64];   /* input buffer */
00069 } PHP_SHA256_CTX;
00070 
00071 PHP_HASH_API void PHP_SHA256Init(PHP_SHA256_CTX *);
00072 PHP_HASH_API void PHP_SHA256Update(PHP_SHA256_CTX *, const unsigned char *, unsigned int);
00073 PHP_HASH_API void PHP_SHA256Final(unsigned char[32], PHP_SHA256_CTX *);
00074 
00075 /* SHA384 context */
00076 typedef struct {
00077        php_hash_uint64 state[8];   /* state */
00078        php_hash_uint64 count[2];   /* number of bits, modulo 2^128 */
00079        unsigned char buffer[128];  /* input buffer */
00080 } PHP_SHA384_CTX;
00081 
00082 PHP_HASH_API void PHP_SHA384Init(PHP_SHA384_CTX *);
00083 PHP_HASH_API void PHP_SHA384Update(PHP_SHA384_CTX *, const unsigned char *, unsigned int);
00084 PHP_HASH_API void PHP_SHA384Final(unsigned char[48], PHP_SHA384_CTX *);
00085 
00086 /* SHA512 context */
00087 typedef struct {
00088        php_hash_uint64 state[8];   /* state */
00089        php_hash_uint64 count[2];   /* number of bits, modulo 2^128 */
00090        unsigned char buffer[128];  /* input buffer */
00091 } PHP_SHA512_CTX;
00092 
00093 PHP_HASH_API void PHP_SHA512Init(PHP_SHA512_CTX *);
00094 PHP_HASH_API void PHP_SHA512Update(PHP_SHA512_CTX *, const unsigned char *, unsigned int);
00095 PHP_HASH_API void PHP_SHA512Final(unsigned char[64], PHP_SHA512_CTX *);
00096 
00097 #endif /* PHP_HASH_SHA_H */