From 91d6334c7d5ce0c595dc82cfbd9f47adf3d3fb21 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 15 Dec 2016 12:00:50 +0100 Subject: php-pecl-crypto: 0.3.0 --- REFLECTION | 371 ++++++++++++++++++++++++++++++++++++++++++-------- crypto-pr20.patch | 66 +++++++++ crypto-upstream.patch | 91 ------------- php-pecl-crypto.spec | 15 +- 4 files changed, 388 insertions(+), 155 deletions(-) create mode 100644 crypto-pr20.patch delete mode 100644 crypto-upstream.patch diff --git a/REFLECTION b/REFLECTION index b1b52b6..3d092b6 100644 --- a/REFLECTION +++ b/REFLECTION @@ -1,7 +1,7 @@ -Extension [ extension #84 crypto version 0.2.2 ] { +Extension [ extension #78 crypto version 0.3.0 ] { - - Classes [13] { - Class [ class Crypto\CryptoException extends Exception ] { + - Classes [17] { + Class [ class Crypto\CryptoException extends Exception implements Throwable ] { - Constants [0] { } @@ -32,33 +32,33 @@ Extension [ extension #84 crypto version 0.2.2 ] { Method [ public method __wakeup ] { } - Method [ final public method getMessage ] { + Method [ final public method getMessage ] { } - Method [ final public method getCode ] { + Method [ final public method getCode ] { } - Method [ final public method getFile ] { + Method [ final public method getFile ] { } - Method [ final public method getLine ] { + Method [ final public method getLine ] { } - Method [ final public method getTrace ] { + Method [ final public method getTrace ] { } - Method [ final public method getPrevious ] { + Method [ final public method getPrevious ] { } - Method [ final public method getTraceAsString ] { + Method [ final public method getTraceAsString ] { } - Method [ public method __toString ] { + Method [ public method __toString ] { } } } - Class [ class Crypto\CipherException extends Crypto\CryptoException ] { + Class [ class Crypto\CipherException extends Crypto\CryptoException implements Throwable ] { - Constants [30] { Constant [ integer ALGORITHM_NOT_FOUND ] { 1 } @@ -119,28 +119,28 @@ Extension [ extension #84 crypto version 0.2.2 ] { Method [ public method __wakeup ] { } - Method [ final public method getMessage ] { + Method [ final public method getMessage ] { } - Method [ final public method getCode ] { + Method [ final public method getCode ] { } - Method [ final public method getFile ] { + Method [ final public method getFile ] { } - Method [ final public method getLine ] { + Method [ final public method getLine ] { } - Method [ final public method getTrace ] { + Method [ final public method getTrace ] { } - Method [ final public method getPrevious ] { + Method [ final public method getPrevious ] { } - Method [ final public method getTraceAsString ] { + Method [ final public method getTraceAsString ] { } - Method [ public method __toString ] { + Method [ public method __toString ] { } } } @@ -371,10 +371,10 @@ Extension [ extension #84 crypto version 0.2.2 ] { } } - Class [ class Crypto\HashException extends Crypto\CryptoException ] { + Class [ class Crypto\HashException extends Crypto\CryptoException implements Throwable ] { - Constants [7] { - Constant [ integer ALGORITHM_NOT_FOUND ] { 1 } + Constant [ integer HASH_ALGORITHM_NOT_FOUND ] { 1 } Constant [ integer STATIC_METHOD_NOT_FOUND ] { 2 } Constant [ integer STATIC_METHOD_TOO_MANY_ARGS ] { 3 } Constant [ integer INIT_FAILED ] { 4 } @@ -409,28 +409,28 @@ Extension [ extension #84 crypto version 0.2.2 ] { Method [ public method __wakeup ] { } - Method [ final public method getMessage ] { + Method [ final public method getMessage ] { } - Method [ final public method getCode ] { + Method [ final public method getCode ] { } - Method [ final public method getFile ] { + Method [ final public method getFile ] { } - Method [ final public method getLine ] { + Method [ final public method getLine ] { } - Method [ final public method getTrace ] { + Method [ final public method getTrace ] { } - Method [ final public method getPrevious ] { + Method [ final public method getPrevious ] { } - Method [ final public method getTraceAsString ] { + Method [ final public method getTraceAsString ] { } - Method [ public method __toString ] { + Method [ public method __toString ] { } } } @@ -505,16 +505,17 @@ Extension [ extension #84 crypto version 0.2.2 ] { } } - Class [ class Crypto\MACException extends Crypto\HashException ] { + Class [ class Crypto\MACException extends Crypto\HashException implements Throwable ] { - - Constants [8] { - Constant [ integer ALGORITHM_NOT_FOUND ] { 1 } + - Constants [9] { + Constant [ integer HASH_ALGORITHM_NOT_FOUND ] { 1 } Constant [ integer STATIC_METHOD_NOT_FOUND ] { 2 } Constant [ integer STATIC_METHOD_TOO_MANY_ARGS ] { 3 } Constant [ integer INIT_FAILED ] { 4 } Constant [ integer UPDATE_FAILED ] { 5 } Constant [ integer DIGEST_FAILED ] { 6 } Constant [ integer INPUT_DATA_LENGTH_HIGH ] { 7 } + Constant [ integer MAC_ALGORITHM_NOT_FOUND ] { 1 } Constant [ integer KEY_LENGTH_INVALID ] { 2 } } @@ -544,28 +545,28 @@ Extension [ extension #84 crypto version 0.2.2 ] { Method [ public method __wakeup ] { } - Method [ final public method getMessage ] { + Method [ final public method getMessage ] { } - Method [ final public method getCode ] { + Method [ final public method getCode ] { } - Method [ final public method getFile ] { + Method [ final public method getFile ] { } - Method [ final public method getLine ] { + Method [ final public method getLine ] { } - Method [ final public method getTrace ] { + Method [ final public method getTrace ] { } - Method [ final public method getPrevious ] { + Method [ final public method getPrevious ] { } - Method [ final public method getTraceAsString ] { + Method [ final public method getTraceAsString ] { } - Method [ public method __toString ] { + Method [ public method __toString ] { } } } @@ -763,7 +764,7 @@ Extension [ extension #84 crypto version 0.2.2 ] { } } - Class [ class Crypto\Base64Exception extends Crypto\CryptoException ] { + Class [ class Crypto\Base64Exception extends Crypto\CryptoException implements Throwable ] { - Constants [6] { Constant [ integer ENCODE_UPDATE_FORBIDDEN ] { 1 } @@ -800,28 +801,28 @@ Extension [ extension #84 crypto version 0.2.2 ] { Method [ public method __wakeup ] { } - Method [ final public method getMessage ] { + Method [ final public method getMessage ] { } - Method [ final public method getCode ] { + Method [ final public method getCode ] { } - Method [ final public method getFile ] { + Method [ final public method getFile ] { } - Method [ final public method getLine ] { + Method [ final public method getLine ] { } - Method [ final public method getTrace ] { + Method [ final public method getTrace ] { } - Method [ final public method getPrevious ] { + Method [ final public method getPrevious ] { } - Method [ final public method getTraceAsString ] { + Method [ final public method getTraceAsString ] { } - Method [ public method __toString ] { + Method [ public method __toString ] { } } } @@ -878,7 +879,7 @@ Extension [ extension #84 crypto version 0.2.2 ] { } } - Class [ class Crypto\RandException extends Crypto\CryptoException ] { + Class [ class Crypto\RandException extends Crypto\CryptoException implements Throwable ] { - Constants [4] { Constant [ integer GENERATE_PREDICTABLE ] { 1 } @@ -913,28 +914,280 @@ Extension [ extension #84 crypto version 0.2.2 ] { Method [ public method __wakeup ] { } - Method [ final public method getMessage ] { + Method [ final public method getMessage ] { + } + + Method [ final public method getCode ] { + } + + Method [ final public method getFile ] { + } + + Method [ final public method getLine ] { + } + + Method [ final public method getTrace ] { + } + + Method [ final public method getPrevious ] { + } + + Method [ final public method getTraceAsString ] { + } + + Method [ public method __toString ] { + } + } + } + + Class [ abstract class Crypto\KDF ] { + + - Constants [0] { + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [0] { + } + + - Methods [6] { + Method [ public method __construct ] { + + - Parameters [2] { + Parameter #0 [ $length ] + Parameter #1 [ $salt ] + } + } + + Method [ abstract public method derive ] { + + - Parameters [1] { + Parameter #0 [ $password ] + } + } + + Method [ public method getLength ] { + } + + Method [ public method setLength ] { + + - Parameters [1] { + Parameter #0 [ $length ] + } + } + + Method [ public method getSalt ] { + } + + Method [ public method setSalt ] { + + - Parameters [1] { + Parameter #0 [ $salt ] + } + } + } + } + + Class [ class Crypto\KDFException extends Crypto\CryptoException implements Throwable ] { + + - Constants [5] { + Constant [ integer KEY_LENGTH_LOW ] { 1 } + Constant [ integer KEY_LENGTH_HIGH ] { 2 } + Constant [ integer SALT_LENGTH_HIGH ] { 3 } + Constant [ integer PASSWORD_LENGTH_INVALID ] { 4 } + Constant [ integer DERIVATION_FAILED ] { 5 } + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [4] { + Property [ protected $message ] + Property [ protected $code ] + Property [ protected $file ] + Property [ protected $line ] + } + + - Methods [10] { + Method [ public method __construct ] { + + - Parameters [3] { + Parameter #0 [ $message ] + Parameter #1 [ $code ] + Parameter #2 [ $previous ] + } + } + + Method [ public method __wakeup ] { + } + + Method [ final public method getMessage ] { + } + + Method [ final public method getCode ] { + } + + Method [ final public method getFile ] { + } + + Method [ final public method getLine ] { + } + + Method [ final public method getTrace ] { + } + + Method [ final public method getPrevious ] { + } + + Method [ final public method getTraceAsString ] { + } + + Method [ public method __toString ] { + } + } + } + + Class [ class Crypto\PBKDF2 extends Crypto\KDF ] { + + - Constants [0] { + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [0] { + } + + - Methods [10] { + Method [ public method __construct ] { + + - Parameters [4] { + Parameter #0 [ $hashAlgorithm ] + Parameter #1 [ $length ] + Parameter #2 [ $salt ] + Parameter #3 [ $iterations ] + } + } + + Method [ public method derive ] { + + - Parameters [1] { + Parameter #0 [ $password ] + } + } + + Method [ public method getIterations ] { + } + + Method [ public method setIterations ] { + + - Parameters [1] { + Parameter #0 [ $iterations ] + } + } + + Method [ public method getHashAlgorithm ] { + } + + Method [ public method setHashAlgorithm ] { + + - Parameters [1] { + Parameter #0 [ $hashAlgorithm ] + } + } + + Method [ public method getLength ] { + } + + Method [ public method setLength ] { + + - Parameters [1] { + Parameter #0 [ $length ] + } + } + + Method [ public method getSalt ] { + } + + Method [ public method setSalt ] { + + - Parameters [1] { + Parameter #0 [ $salt ] + } + } + } + } + + Class [ class Crypto\PBKDF2Exception extends Crypto\KDFException implements Throwable ] { + + - Constants [7] { + Constant [ integer KEY_LENGTH_LOW ] { 1 } + Constant [ integer KEY_LENGTH_HIGH ] { 2 } + Constant [ integer SALT_LENGTH_HIGH ] { 3 } + Constant [ integer PASSWORD_LENGTH_INVALID ] { 4 } + Constant [ integer DERIVATION_FAILED ] { 5 } + Constant [ integer HASH_ALGORITHM_NOT_FOUND ] { 1 } + Constant [ integer ITERATIONS_HIGH ] { 2 } + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [4] { + Property [ protected $message ] + Property [ protected $code ] + Property [ protected $file ] + Property [ protected $line ] + } + + - Methods [10] { + Method [ public method __construct ] { + + - Parameters [3] { + Parameter #0 [ $message ] + Parameter #1 [ $code ] + Parameter #2 [ $previous ] + } + } + + Method [ public method __wakeup ] { + } + + Method [ final public method getMessage ] { } - Method [ final public method getCode ] { + Method [ final public method getCode ] { } - Method [ final public method getFile ] { + Method [ final public method getFile ] { } - Method [ final public method getLine ] { + Method [ final public method getLine ] { } - Method [ final public method getTrace ] { + Method [ final public method getTrace ] { } - Method [ final public method getPrevious ] { + Method [ final public method getPrevious ] { } - Method [ final public method getTraceAsString ] { + Method [ final public method getTraceAsString ] { } - Method [ public method __toString ] { + Method [ public method __toString ] { } } } diff --git a/crypto-pr20.patch b/crypto-pr20.patch new file mode 100644 index 0000000..69ba38b --- /dev/null +++ b/crypto-pr20.patch @@ -0,0 +1,66 @@ +From 536aae8e608a0f6977816eb4a1e6ab085e82e32c Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Thu, 15 Dec 2016 11:19:12 +0100 +Subject: [PATCH 1/2] fix #19 segfault in KDF::setLength and PHP 5 + +--- + crypto_kdf.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/crypto_kdf.c b/crypto_kdf.c +index dca4a1b..8018324 100644 +--- a/crypto_kdf.c ++++ b/crypto_kdf.c +@@ -356,7 +356,7 @@ PHP_CRYPTO_METHOD(KDF, getLength) + PHP_CRYPTO_METHOD(KDF, setLength) + { + PHPC_THIS_DECLARE(crypto_kdf); +- phpc_str_size_t key_len; ++ phpc_long_t key_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", + &key_len) == FAILURE) { + +From 932bb0c65be0c389449400bfc21ca8d4860b3723 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Thu, 15 Dec 2016 11:35:45 +0100 +Subject: [PATCH 2/2] fix more zpp calls + +--- + crypto_kdf.c | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/crypto_kdf.c b/crypto_kdf.c +index 8018324..3fda8dc 100644 +--- a/crypto_kdf.c ++++ b/crypto_kdf.c +@@ -321,7 +321,8 @@ PHP_CRYPTO_METHOD(KDF, __construct) + { + PHPC_THIS_DECLARE(crypto_kdf); + char *salt = NULL; +- phpc_str_size_t key_len, salt_len; ++ phpc_str_size_t salt_len; ++ phpc_long_t key_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|s", + &key_len, &salt, &salt_len) == FAILURE) { +@@ -447,8 +448,8 @@ PHP_CRYPTO_METHOD(PBKDF2, __construct) + { + PHPC_THIS_DECLARE(crypto_kdf); + char *hash_alg, *salt = NULL; +- phpc_str_size_t key_len, hash_alg_len, salt_len; +- phpc_long_t iterations = PHP_CRYPTO_PBKDF2_ITER_DEFAULT; ++ phpc_str_size_t hash_alg_len, salt_len; ++ phpc_long_t key_len, iterations = PHP_CRYPTO_PBKDF2_ITER_DEFAULT; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|sl", + &hash_alg, &hash_alg_len, &key_len, &salt, &salt_len, &iterations) == FAILURE) { +@@ -560,7 +561,7 @@ PHP_CRYPTO_METHOD(PBKDF2, setHashAlgorithm) + char *hash_alg; + phpc_str_size_t hash_alg_len; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|sl", ++ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", + &hash_alg, &hash_alg_len) == FAILURE) { + return; + } diff --git a/crypto-upstream.patch b/crypto-upstream.patch deleted file mode 100644 index b7b010b..0000000 --- a/crypto-upstream.patch +++ /dev/null @@ -1,91 +0,0 @@ -From ee493a2737fd29a8ff8c8e3dec7c6fa46822ef05 Mon Sep 17 00:00:00 2001 -From: Jakub Zelenka -Date: Wed, 6 Jan 2016 14:40:54 +0000 -Subject: [PATCH] Split name codes for Hash and MAC alg not found - -It prevents constant redefinition error ---- - crypto_hash.c | 8 ++++---- - tests/CMAC___construct_basic.phpt | 2 +- - tests/HMAC___construct_basic.phpt | 2 +- - tests/Hash___construct_basic.phpt | 2 +- - 4 files changed, 7 insertions(+), 7 deletions(-) - -diff --git a/crypto_hash.c b/crypto_hash.c -index 7fc0ded..2ce172a 100644 ---- a/crypto_hash.c -+++ b/crypto_hash.c -@@ -29,7 +29,7 @@ - PHP_CRYPTO_EXCEPTION_DEFINE(Hash) - PHP_CRYPTO_ERROR_INFO_BEGIN(Hash) - PHP_CRYPTO_ERROR_INFO_ENTRY( -- ALGORITHM_NOT_FOUND, -+ HASH_ALGORITHM_NOT_FOUND, - "Hash algorithm '%s' not found" - ) - PHP_CRYPTO_ERROR_INFO_ENTRY( -@@ -134,7 +134,7 @@ static const zend_function_entry php_crypto_hash_object_methods[] = { - PHP_CRYPTO_EXCEPTION_DEFINE(MAC) - PHP_CRYPTO_ERROR_INFO_BEGIN(MAC) - PHP_CRYPTO_ERROR_INFO_ENTRY( -- ALGORITHM_NOT_FOUND, -+ MAC_ALGORITHM_NOT_FOUND, - "MAC algorithm '%s' not found" - ) - PHP_CRYPTO_ERROR_INFO_ENTRY( -@@ -609,7 +609,7 @@ PHP_CRYPTO_METHOD(Hash, __construct) - - digest = EVP_get_digestbyname(algorithm); - if (!digest) { -- php_crypto_error_ex(PHP_CRYPTO_ERROR_ARGS(Hash, ALGORITHM_NOT_FOUND), algorithm); -+ php_crypto_error_ex(PHP_CRYPTO_ERROR_ARGS(Hash, HASH_ALGORITHM_NOT_FOUND), algorithm); - } else { - PHP_CRYPTO_HASH_ALG(PHPC_THIS) = digest; - } -@@ -787,6 +787,6 @@ PHP_CRYPTO_METHOD(MAC, __construct) - return; - - php_crypto_mac_alg_not_found: -- php_crypto_error_ex(PHP_CRYPTO_ERROR_ARGS(MAC, ALGORITHM_NOT_FOUND), algorithm); -+ php_crypto_error_ex(PHP_CRYPTO_ERROR_ARGS(MAC, MAC_ALGORITHM_NOT_FOUND), algorithm); - efree(algorithm_uc); - } -diff --git a/tests/CMAC___construct_basic.phpt b/tests/CMAC___construct_basic.phpt -index abd58a3..77a66c6 100644 ---- a/tests/CMAC___construct_basic.phpt -+++ b/tests/CMAC___construct_basic.phpt -@@ -28,7 +28,7 @@ try { - $cmac = new Crypto\CMAC($key, 'nnn'); - } - catch (Crypto\MACException $e) { -- if ($e->getCode() === Crypto\MACException::ALGORITHM_NOT_FOUND) { -+ if ($e->getCode() === Crypto\MACException::MAC_ALGORITHM_NOT_FOUND) { - echo "NOT FOUND\n"; - } - } -diff --git a/tests/HMAC___construct_basic.phpt b/tests/HMAC___construct_basic.phpt -index 09a4d11..0200091 100644 ---- a/tests/HMAC___construct_basic.phpt -+++ b/tests/HMAC___construct_basic.phpt -@@ -11,7 +11,7 @@ try { - $hmac = new Crypto\HMAC('key', 'nnn'); - } - catch (Crypto\MACException $e) { -- if ($e->getCode() === Crypto\MACException::ALGORITHM_NOT_FOUND) { -+ if ($e->getCode() === Crypto\MACException::MAC_ALGORITHM_NOT_FOUND) { - echo "NOT FOUND\n"; - } - } -diff --git a/tests/Hash___construct_basic.phpt b/tests/Hash___construct_basic.phpt -index 0755703..ac8b0f5 100644 ---- a/tests/Hash___construct_basic.phpt -+++ b/tests/Hash___construct_basic.phpt -@@ -11,7 +11,7 @@ try { - $hash = new Crypto\Hash('nnn'); - } - catch (Crypto\HashException $e) { -- if ($e->getCode() === Crypto\HashException::ALGORITHM_NOT_FOUND) { -+ if ($e->getCode() === Crypto\HashException::HASH_ALGORITHM_NOT_FOUND) { - echo "NOT FOUND\n"; - } - } diff --git a/php-pecl-crypto.spec b/php-pecl-crypto.spec index 452b13e..cf3e51d 100644 --- a/php-pecl-crypto.spec +++ b/php-pecl-crypto.spec @@ -14,7 +14,7 @@ %global with_zts 0%{!?_without_zts:%{?__ztsphp:1}} %global pecl_name crypto -%global with_tests %{!?_without_tests:1}%{?_without_tests:0} +%global with_tests 0%{!?_without_tests:1} %if "%{php_version}" < "5.6" %global ini_name %{pecl_name}.ini %else @@ -23,14 +23,14 @@ Summary: Wrapper for OpenSSL Crypto Library Name: %{?sub_prefix}php-pecl-%{pecl_name} -Version: 0.2.2 -Release: 5%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} +Version: 0.3.0 +Release: 1%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} License: BSD Group: Development/Languages URL: http://pecl.php.net/package/%{pecl_name} Source0: http://pecl.php.net/get/%{pecl_name}-%{version}.tgz -Patch0: %{pecl_name}-upstream.patch +Patch0: %{pecl_name}-pr20.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: %{?scl_prefix}php-devel > 5.3 @@ -101,7 +101,7 @@ sed -e 's/role="test"/role="src"/' \ -i package.xml cd NTS -%patch0 -p1 -b .upstream +%patch0 -p1 -b .pr20 # Sanity check, really often broken extver=$(sed -n '/#define PHP_CRYPTO_VERSION/{s/.* "//;s/".*$//;p}' php_crypto.h) @@ -238,6 +238,11 @@ rm -rf %{buildroot} %changelog +* Thu Dec 15 2016 Remi Collet - 0.3.0-1 +- Update to 0.3.0 +- open https://github.com/bukka/php-crypto/issues/19 segfault +- open https://github.com/bukka/php-crypto/pull/20 fix for PHP 5 + * Thu Dec 1 2016 Remi Collet - 0.2.2-5 - rebuild with PHP 7.1.0 GA -- cgit