Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #15 from driehle/feature/php81
Browse files Browse the repository at this point in the history
Added support for PHP 8.1
  • Loading branch information
froschdesign authored Nov 28, 2021
2 parents a3147a4 + 9e817ba commit 1dbea86
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 135 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
"sort-packages": true
},
"require": {
"php": "^7.3 || ~8.0.0",
"php": "^7.3 || ~8.0.0 || ~8.1.0",
"ext-mbstring": "*",
"container-interop/container-interop": "^1.2",
"laminas/laminas-math": "^3.0",
"laminas/laminas-stdlib": "^2.7.7 || ^3.1",
"laminas/laminas-math": "^3.4",
"laminas/laminas-stdlib": "^3.6",
"laminas/laminas-zendframework-bridge": "^1.0"
},
"require-dev": {
Expand Down
256 changes: 130 additions & 126 deletions composer.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true">
colors="true"
convertDeprecationsToExceptions="true">
<testsuites>
<testsuite name="laminas-crypt Test Suite">
<directory>./test</directory>
Expand Down
2 changes: 1 addition & 1 deletion src/Hybrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function encrypt($plaintext, $keys = null)
* @return string
* @throws RuntimeException
*/
public function decrypt($msg, $privateKey = null, $passPhrase = null, $id = null)
public function decrypt($msg, $privateKey = null, $passPhrase = null, $id = "")
{
// get the session key
list($encKeys, $ciphertext) = explode(';', $msg, 2);
Expand Down
18 changes: 17 additions & 1 deletion src/Key/Derivation/SaltedS2k.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ public static function calc($hash, $password, $salt, $bytes)
if (mb_strlen($salt, '8bit') < 8) {
throw new Exception\InvalidArgumentException('The salt size must be at least of 8 bytes');
}
return mhash_keygen_s2k(static::$supportedMhashAlgos[$hash], $password, $salt, $bytes);

$result = '';

foreach (range(0, ceil($bytes / strlen(hash($hash, '', true))) - 1) as $i) {
$result .= hash(
$hash,
str_repeat("\0", $i) . str_pad(
substr($salt, 0, 8),
8,
"\0",
STR_PAD_RIGHT
) . $password,
true
);
}

return substr($result, 0, intval($bytes));
}
}
2 changes: 1 addition & 1 deletion src/Symmetric/Openssl.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class Openssl implements SymmetricInterface
*
* @var string
*/
protected $aad;
protected $aad = '';

/**
* Store the tag for authentication (only for PHP 7.1+)
Expand Down
4 changes: 2 additions & 2 deletions test/FileCipher/AbstractFileCipherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ abstract class AbstractFileCipherTest extends TestCase
/**
* @var string
*/
protected $fileIn;
protected $fileIn = '';

/**
* @var string
*/
protected $fileOut;
protected $fileOut = '';

public function setUp(): void
{
Expand Down

0 comments on commit 1dbea86

Please sign in to comment.