Skip to content
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
3 changes: 3 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ http://pear.php.net/dtd/package-2.0.xsd">
<file name="LICENSE" role="doc" />
<file name="php_scrypt.c" role="src" />
<file name="php_scrypt.h" role="src" />
<file name="php_scrypt_arginfo.h" role="src" />
<file name="php_scrypt_legacy_arginfo.h" role="src" />
<file name="php_scrypt.stub.php" role="src" />
<file name="php_scrypt_utils.c" role="src" />
<file name="php_scrypt_utils.h" role="src" />
<file name="README.md" role="doc" />
Expand Down
39 changes: 6 additions & 33 deletions php_scrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,53 +40,26 @@
#include "php_scrypt.h"
#include "crypto/crypto_scrypt.h"
#include "crypto/params.h"

#if PHP_MAJOR_VERSION >= 8
#include "php_scrypt_arginfo.h"
#else
#include "php_scrypt_legacy_arginfo.h"
#endif
#include "math.h"

typedef size_t strsize_t;

/* {{{ arginfo */
ZEND_BEGIN_ARG_INFO_EX(scrypt_arginfo, 0, 0, 6)
ZEND_ARG_INFO(0, password)
ZEND_ARG_INFO(0, salt)
ZEND_ARG_INFO(0, N)
ZEND_ARG_INFO(0, r)
ZEND_ARG_INFO(0, p)
ZEND_ARG_INFO(0, keyLength)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the $raw_output param was missing from here

ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(scrypt_pickparams_arginfo, 0, 0, 3)
ZEND_ARG_INFO(0, maxMemory)
ZEND_ARG_INFO(0, memFraction)
ZEND_ARG_INFO(0, maxTime)
ZEND_END_ARG_INFO()
/* }}} */

static zend_function_entry scrypt_functions[] = {
PHP_FE(scrypt, scrypt_arginfo)
PHP_FE(scrypt_pickparams, scrypt_pickparams_arginfo)
#ifdef PHP_FE_END
PHP_FE_END
#else
{NULL, NULL, NULL}
#endif
};

static const zend_module_dep scrypt_deps[] = {
ZEND_MOD_REQUIRED("hash")
#ifdef ZEND_MOD_END
ZEND_MOD_END
#else
{NULL, NULL, NULL}
#endif
};

zend_module_entry scrypt_module_entry = {
STANDARD_MODULE_HEADER_EX,
NULL,
scrypt_deps,
PHP_SCRYPT_EXTNAME,
scrypt_functions,
ext_functions,
NULL,
NULL,
NULL,
Expand Down
3 changes: 0 additions & 3 deletions php_scrypt.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
#define PHP_SCRYPT_VERSION "2.0.0-dev"
#define PHP_SCRYPT_EXTNAME "scrypt"

PHP_FUNCTION(scrypt);
PHP_FUNCTION(scrypt_pickparams);

extern zend_module_entry scrypt_module_entry;
#define phpext_scrypt_ptr &scrypt_module_entry

Expand Down
10 changes: 10 additions & 0 deletions php_scrypt.stub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

/**
* @generate-class-entries
* @generate-legacy-arginfo 7.0
*/

function scrypt(string $password, 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 {}
29 changes: 29 additions & 0 deletions php_scrypt_arginfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: ea5f25cdf40271f96836b23cdda89954e4c2a479 */

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)
ZEND_ARG_TYPE_INFO(0, salt, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, N, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, r, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, p, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, key_length, IS_LONG, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, raw_output, _IS_BOOL, 0, "false")
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_scrypt_pickparams, 0, 3, MAY_BE_ARRAY|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, max_memory, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, memory_fraction, IS_DOUBLE, 0)
ZEND_ARG_TYPE_INFO(0, max_time, IS_DOUBLE, 0)
ZEND_END_ARG_INFO()


ZEND_FUNCTION(scrypt);
ZEND_FUNCTION(scrypt_pickparams);


static const zend_function_entry ext_functions[] = {
ZEND_FE(scrypt, arginfo_scrypt)
ZEND_FE(scrypt_pickparams, arginfo_scrypt_pickparams)
ZEND_FE_END
};
29 changes: 29 additions & 0 deletions php_scrypt_legacy_arginfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: ea5f25cdf40271f96836b23cdda89954e4c2a479 */

ZEND_BEGIN_ARG_INFO_EX(arginfo_scrypt, 0, 0, 6)
ZEND_ARG_INFO(0, password)
ZEND_ARG_INFO(0, salt)
ZEND_ARG_INFO(0, N)
ZEND_ARG_INFO(0, r)
ZEND_ARG_INFO(0, p)
ZEND_ARG_INFO(0, key_length)
ZEND_ARG_INFO(0, raw_output)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_scrypt_pickparams, 0, 0, 3)
ZEND_ARG_INFO(0, max_memory)
ZEND_ARG_INFO(0, memory_fraction)
ZEND_ARG_INFO(0, max_time)
ZEND_END_ARG_INFO()


ZEND_FUNCTION(scrypt);
ZEND_FUNCTION(scrypt_pickparams);


static const zend_function_entry ext_functions[] = {
ZEND_FE(scrypt, arginfo_scrypt)
ZEND_FE(scrypt_pickparams, arginfo_scrypt_pickparams)
ZEND_FE_END
};