php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
hash_sha3.c File Reference
#include "php_hash.h"
#include "php_hash_sha3.h"
#include "KeccakHash.h"

Go to the source code of this file.

Macros

#define SUCCESS   SHA3_SUCCESS /* Avoid conflict between KeccacHash.h and zend_types.h */
 
#define PHP_KECCAK_SPEC   "b200IiIIB"
 
#define DECLARE_SHA3_OPS(bits)
 

Functions

 DECLARE_SHA3_OPS (224)
 
 DECLARE_SHA3_OPS (256)
 
 DECLARE_SHA3_OPS (384)
 
 DECLARE_SHA3_OPS (512)
 

Macro Definition Documentation

◆ DECLARE_SHA3_OPS

#define DECLARE_SHA3_OPS ( bits)
Value:
void PHP_SHA3##bits##Init(PHP_SHA3_##bits##_CTX* ctx, ZEND_ATTRIBUTE_UNUSED HashTable *args) { \
ZEND_ASSERT(sizeof(Keccak_HashInstance) <= sizeof(PHP_SHA3_##bits##_CTX)); \
Keccak_HashInitialize_SHA3_##bits((Keccak_HashInstance *)ctx); \
} \
void PHP_SHA3##bits##Update(PHP_SHA3_##bits##_CTX* ctx, \
const unsigned char* input, \
size_t inputLen) { \
Keccak_HashUpdate((Keccak_HashInstance *)ctx, input, inputLen * 8); \
} \
void PHP_SHA3##bits##Final(unsigned char* digest, \
PHP_SHA3_##bits##_CTX* ctx) { \
Keccak_HashFinal((Keccak_HashInstance *)ctx, digest); \
} \
const php_hash_ops php_hash_sha3_##bits##_ops = { \
"sha3-" #bits, \
(php_hash_init_func_t) PHP_SHA3##bits##Init, \
(php_hash_update_func_t) PHP_SHA3##bits##Update, \
(php_hash_final_func_t) PHP_SHA3##bits##Final, \
php_keccak_serialize, \
php_keccak_unserialize, \
bits >> 3, \
(1600 - (2 * bits)) >> 3, \
sizeof(PHP_SHA3_CTX), \
1 \
}
PHP_HASH_API zend_result php_hash_copy(const void *ops, const void *orig_context, void *dest_context)
Definition hash.c:124
#define PHP_KECCAK_SPEC
Definition hash_sha3.c:293
void(* php_hash_final_func_t)(unsigned char *digest, void *context)
Definition php_hash.h:36
void(* php_hash_init_func_t)(void *context, HashTable *args)
Definition php_hash.h:34
void(* php_hash_update_func_t)(void *context, const unsigned char *buf, size_t count)
Definition php_hash.h:35
struct _php_hash_ops php_hash_ops
zval * args
#define ZEND_ATTRIBUTE_UNUSED
struct _zend_array HashTable
Definition zend_types.h:386

Definition at line 316 of file hash_sha3.c.

◆ PHP_KECCAK_SPEC

#define PHP_KECCAK_SPEC   "b200IiIIB"

Definition at line 293 of file hash_sha3.c.

◆ SUCCESS

return SUCCESS   SHA3_SUCCESS /* Avoid conflict between KeccacHash.h and zend_types.h */

Definition at line 261 of file hash_sha3.c.

Function Documentation

◆ DECLARE_SHA3_OPS() [1/4]

DECLARE_SHA3_OPS ( 224 )

◆ DECLARE_SHA3_OPS() [2/4]

DECLARE_SHA3_OPS ( 256 )

◆ DECLARE_SHA3_OPS() [3/4]

DECLARE_SHA3_OPS ( 384 )

◆ DECLARE_SHA3_OPS() [4/4]

DECLARE_SHA3_OPS ( 512 )