Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set sensitive param #70

Merged
merged 1 commit into from
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion php_scrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "crypto/crypto_scrypt.h"
#include "crypto/params.h"
#if PHP_MAJOR_VERSION >= 8
#include "zend_attributes.h"
#include "php_scrypt_arginfo.h"
#else
#include "php_scrypt_legacy_arginfo.h"
Expand All @@ -59,13 +60,22 @@ static const zend_module_dep scrypt_deps[] = {
ZEND_MOD_END
};

static PHP_MINIT_FUNCTION(scrypt)
{
#if PHP_VERSION_ID >= 80200
register_php_scrypt_symbols(module_number);
#endif

return SUCCESS;
}

zend_module_entry scrypt_module_entry = {
STANDARD_MODULE_HEADER_EX,
NULL,
scrypt_deps,
PHP_SCRYPT_EXTNAME,
ext_functions,
NULL,
PHP_MINIT(scrypt),
NULL,
NULL,
NULL,
Expand Down
4 changes: 2 additions & 2 deletions php_scrypt.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

/**
* @generate-class-entries
* @generate-legacy-arginfo 7.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops :O

* @generate-legacy-arginfo 70000
*/

function scrypt(string $password, string $salt, int $N, int $r, int $p, int $key_length, bool $raw_output = false): string|false {}
function scrypt(#[\SensitiveParameter] string $password, #[\SensitiveParameter] string $salt, int $N, int $r, int $p, int $key_length, bool $raw_output = false): string|false {}

function scrypt_pickparams(int $max_memory, float $memory_fraction, float $max_time): array|false {}
12 changes: 11 additions & 1 deletion php_scrypt_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: ea5f25cdf40271f96836b23cdda89954e4c2a479 */
* Stub hash: 8b564912a6ddca2a4134bbff80f81e82ba20805e */

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_scrypt, 0, 6, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, password, IS_STRING, 0)
Expand Down Expand Up @@ -27,3 +27,13 @@ static const zend_function_entry ext_functions[] = {
ZEND_FE(scrypt_pickparams, arginfo_scrypt_pickparams)
ZEND_FE_END
};

static void register_php_scrypt_symbols(int module_number)
{

#if (PHP_VERSION_ID >= 80200)
zend_add_parameter_attribute(zend_hash_str_find_ptr(CG(function_table), "scrypt", sizeof("scrypt") - 1), 0, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0);

zend_add_parameter_attribute(zend_hash_str_find_ptr(CG(function_table), "scrypt", sizeof("scrypt") - 1), 1, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0);
#endif
}
2 changes: 1 addition & 1 deletion php_scrypt_legacy_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: ea5f25cdf40271f96836b23cdda89954e4c2a479 */
* Stub hash: 8b564912a6ddca2a4134bbff80f81e82ba20805e */

ZEND_BEGIN_ARG_INFO_EX(arginfo_scrypt, 0, 0, 6)
ZEND_ARG_INFO(0, password)
Expand Down