xref: /php-src/ext/hash/php_hash_ripemd.h (revision 3813ad10)
1 /*
2    +----------------------------------------------------------------------+
3    | Copyright (c) The PHP Group                                          |
4    +----------------------------------------------------------------------+
5    | This source file is subject to version 3.01 of the PHP license,      |
6    | that is bundled with this package in the file LICENSE, and is        |
7    | available through the world-wide-web at the following url:           |
8    | https://www.php.net/license/3_01.txt                                 |
9    | If you did not receive a copy of the PHP license and are unable to   |
10    | obtain it through the world-wide-web, please send a note to          |
11    | license@php.net so we can mail you a copy immediately.               |
12    +----------------------------------------------------------------------+
13    | Author: Sara Golemon <pollita@php.net>                               |
14    +----------------------------------------------------------------------+
15 */
16 
17 #ifndef PHP_HASH_RIPEMD_H
18 #define PHP_HASH_RIPEMD_H
19 
20 /* RIPEMD context. */
21 typedef struct {
22 	uint32_t state[4];		/* state (ABCD) */
23 	uint32_t count[2];		/* number of bits, modulo 2^64 (lsb first) */
24 	unsigned char buffer[64];	/* input buffer */
25 } PHP_RIPEMD128_CTX;
26 #define PHP_RIPEMD128_SPEC "l4l2b64."
27 
28 typedef struct {
29 	uint32_t state[5];		/* state (ABCD) */
30 	uint32_t count[2];		/* number of bits, modulo 2^64 (lsb first) */
31 	unsigned char buffer[64];	/* input buffer */
32 } PHP_RIPEMD160_CTX;
33 #define PHP_RIPEMD160_SPEC "l5l2b64."
34 
35 typedef struct {
36 	uint32_t state[8];		/* state (ABCD) */
37 	uint32_t count[2];		/* number of bits, modulo 2^64 (lsb first) */
38 	unsigned char buffer[64];	/* input buffer */
39 } PHP_RIPEMD256_CTX;
40 #define PHP_RIPEMD256_SPEC "l8l2b64."
41 
42 typedef struct {
43 	uint32_t state[10];		/* state (ABCD) */
44 	uint32_t count[2];		/* number of bits, modulo 2^64 (lsb first) */
45 	unsigned char buffer[64];	/* input buffer */
46 } PHP_RIPEMD320_CTX;
47 #define PHP_RIPEMD320_SPEC "l10l2b64."
48 
49 PHP_HASH_API void PHP_RIPEMD128Init(PHP_RIPEMD128_CTX *, ZEND_ATTRIBUTE_UNUSED HashTable *);
50 PHP_HASH_API void PHP_RIPEMD128Update(PHP_RIPEMD128_CTX *, const unsigned char *, size_t);
51 PHP_HASH_API void PHP_RIPEMD128Final(unsigned char[16], PHP_RIPEMD128_CTX *);
52 
53 PHP_HASH_API void PHP_RIPEMD160Init(PHP_RIPEMD160_CTX *, ZEND_ATTRIBUTE_UNUSED HashTable *);
54 PHP_HASH_API void PHP_RIPEMD160Update(PHP_RIPEMD160_CTX *, const unsigned char *, size_t);
55 PHP_HASH_API void PHP_RIPEMD160Final(unsigned char[20], PHP_RIPEMD160_CTX *);
56 
57 PHP_HASH_API void PHP_RIPEMD256Init(PHP_RIPEMD256_CTX *, ZEND_ATTRIBUTE_UNUSED HashTable *);
58 PHP_HASH_API void PHP_RIPEMD256Update(PHP_RIPEMD256_CTX *, const unsigned char *, size_t);
59 PHP_HASH_API void PHP_RIPEMD256Final(unsigned char[32], PHP_RIPEMD256_CTX *);
60 
61 PHP_HASH_API void PHP_RIPEMD320Init(PHP_RIPEMD320_CTX *, ZEND_ATTRIBUTE_UNUSED HashTable *);
62 PHP_HASH_API void PHP_RIPEMD320Update(PHP_RIPEMD320_CTX *, const unsigned char *, size_t);
63 PHP_HASH_API void PHP_RIPEMD320Final(unsigned char[40], PHP_RIPEMD320_CTX *);
64 
65 #endif /* PHP_HASH_RIPEMD_H */
66