forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
this is a significantly smaller alternative to the PR at php#6358 , now blake3 "portable c" version is bundled (specifically version 0.3.7 plus a few patches that will be part of the 0.3.8 release..), and ./configure supports a new optional --with-blake3-upstream-c-source-dir=DIR argument for specifying the location of the upstream BLAKE3 C implementation, if invoked, the SSE2/SSE4.1/AVX2/AVX512 optimized versions of BLAKE3 will be compiled in when applicable (this has not been added to MSVC, i don't know how to do it on MSVC, and i don't have a MSVC system to figure it out out on, if someone think getting those optimizations available on MSVC is important, take it up with the windows php mailing list.. just getting the portable version to compile on MSVC was good enough for me.) also userland scripts can detect at runtime if the portable version or the upstream version, of BLAKE was compiled by consulting phpinfo(), it will either say "blake3 implementation: portable 0.3.7" or "blake3 implementation: upstream X.X.X"
- Loading branch information
1 parent
e12f7e3
commit 7b51423
Showing
16 changed files
with
247 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "php_hash.h" | ||
#include "php_hash_blake3.h" | ||
#include "blake3.h" | ||
|
||
|
||
#include <string.h> // memcpy | ||
|
||
PHP_HASH_API void PHP_BLAKE3Init(PHP_BLAKE3_CTX *context) | ||
{ | ||
blake3_hasher_init(context); | ||
} | ||
|
||
PHP_HASH_API void PHP_BLAKE3Update(PHP_BLAKE3_CTX *context, const unsigned char *input, size_t len) | ||
{ | ||
blake3_hasher_update(context, input, len); | ||
} | ||
|
||
PHP_HASH_API void PHP_BLAKE3Final(unsigned char digest[BLAKE3_OUT_LEN/*32*/], PHP_BLAKE3_CTX *context) | ||
{ | ||
blake3_hasher_finalize(context, digest, BLAKE3_OUT_LEN); | ||
} | ||
|
||
PHP_HASH_API int PHP_BLAKE3Copy(const php_hash_ops *ops, PHP_BLAKE3_CTX *orig_context, PHP_BLAKE3_CTX *copy_context) | ||
{ | ||
memcpy(copy_context, orig_context, sizeof(*orig_context)); | ||
return SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#ifndef PHP_HASH_BLAKE3_H | ||
#define PHP_HASH_BLAKE3_H | ||
|
||
#include "ext/standard/basic_functions.h" | ||
#include "php_hash.h" | ||
#include "blake3.h" | ||
|
||
|
||
// typedef struct blake3_hasher PHP_BLAKE3_CTX; | ||
#define PHP_BLAKE3_CTX blake3_hasher | ||
// help: is V correct? | ||
#define PHP_BLAKE3_SPEC "b8b8qb64bbbbb1760" | ||
|
||
PHP_HASH_API void PHP_BLAKE3Init(PHP_BLAKE3_CTX *context); | ||
PHP_HASH_API void PHP_BLAKE3Update(PHP_BLAKE3_CTX *context, const unsigned char *input, size_t len); | ||
PHP_HASH_API void PHP_BLAKE3Final(unsigned char digest[BLAKE3_OUT_LEN/*32*/], PHP_BLAKE3_CTX *context); | ||
PHP_HASH_API int PHP_BLAKE3Copy(const php_hash_ops *ops, PHP_BLAKE3_CTX *orig_context, PHP_BLAKE3_CTX *copy_context); | ||
|
||
const php_hash_ops php_hash_blake3_ops = { | ||
"blake3", | ||
(php_hash_init_func_t) PHP_BLAKE3Init, | ||
(php_hash_update_func_t) PHP_BLAKE3Update, | ||
(php_hash_final_func_t) PHP_BLAKE3Final, | ||
(php_hash_copy_func_t) PHP_BLAKE3Copy, | ||
php_hash_serialize, | ||
php_hash_unserialize, | ||
PHP_BLAKE3_SPEC, // << don't know what this should be, hopefully a dev that knows can remove this comment | ||
BLAKE3_OUT_LEN /*32*/, | ||
BLAKE3_CHUNK_LEN /*1024*/, | ||
sizeof(PHP_BLAKE3_CTX), | ||
1 | ||
}; | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.