Skip to content

Commit d2dd2a1

Browse files
committed
fix blake3 serialization
1 parent 9e5e9ef commit d2dd2a1

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

ext/hash/php_hash_blake3.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
// typedef struct blake3_hasher PHP_BLAKE3_CTX;
1010
#define PHP_BLAKE3_CTX blake3_hasher
11-
// help: what is V supposed to be?
12-
#define PHP_BLAKE3_SPEC "l.I_HAVE_NO_IDEA_WHAT_THIS_IS_SUPPOSED_TO_BE"
11+
// help: is V correct?
12+
#define PHP_BLAKE3_SPEC "b8b8qb64bbbbb1760"
1313

1414
PHP_HASH_API void PHP_BLAKE3Init(PHP_BLAKE3_CTX *context);
1515
PHP_HASH_API void PHP_BLAKE3Update(PHP_BLAKE3_CTX *context, const unsigned char *input, size_t len);
@@ -27,7 +27,7 @@ const php_hash_ops php_hash_blake3_ops = {
2727
PHP_BLAKE3_SPEC, // << don't know what this should be, hopefully a dev that knows can remove this comment
2828
BLAKE3_OUT_LEN /*32*/,
2929
BLAKE3_CHUNK_LEN /*1024*/,
30-
sizeof(*((PHP_BLAKE3_CTX*)NULL)), // << bet there's a better way to write that
30+
sizeof(PHP_BLAKE3_CTX),
3131
1
3232
};
3333

ext/hash/tests/hash_serialize_001.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ string(16) "bebc746a33b6ab62"
154154
string(5) "joaat"
155155
string(8) "aaebf370"
156156
string(8) "aaebf370"
157+
string(6) "blake3"
158+
string(64) "e232493e3d416e24ffc588b24a1772ccc6f80290f1920cf15f21313bc3543a51"
159+
string(64) "e232493e3d416e24ffc588b24a1772ccc6f80290f1920cf15f21313bc3543a51"
157160
string(10) "haval128,3"
158161
string(32) "86362472c8895e68e223ef8b3711d8d9"
159162
string(32) "86362472c8895e68e223ef8b3711d8d9"
@@ -313,6 +316,9 @@ string(16) "893899e4415a920f"
313316
string(5) "joaat"
314317
string(8) "836fb0e5"
315318
string(8) "836fb0e5"
319+
string(6) "blake3"
320+
string(64) "dbdea45e5a6c3bad18a4f96d9d4b9105e4cceaa4fc06568f69829435c47587fb"
321+
string(64) "dbdea45e5a6c3bad18a4f96d9d4b9105e4cceaa4fc06568f69829435c47587fb"
316322
string(10) "haval128,3"
317323
string(32) "ebeeeb05c18af1e53d2d127b561d5e0d"
318324
string(32) "ebeeeb05c18af1e53d2d127b561d5e0d"

ext/hash/tests/hash_serialize_002.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ string(4) "gost"
8383
HashContext with HASH_HMAC option cannot be serialized
8484
string(11) "gost-crypto"
8585
HashContext with HASH_HMAC option cannot be serialized
86+
string(6) "blake3"
87+
HashContext with HASH_HMAC option cannot be serialized
8688
string(10) "haval128,3"
8789
HashContext with HASH_HMAC option cannot be serialized
8890
string(10) "haval160,3"

0 commit comments

Comments
 (0)