Skip to content

Dev/fix 22 #26

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

Merged
merged 2 commits into from
Jun 1, 2025
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
11 changes: 8 additions & 3 deletions src/AESCryptoServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
$this->key,
OPENSSL_RAW_DATA,
$this->iv,
$this->tag

Check failure on line 116 in src/AESCryptoServiceProvider.php

View workflow job for this annotation

GitHub Actions / stan

Property MayMeow\Cryptography\AESCryptoServiceProvider::$tag (string) does not accept string|null.
);

return base64_encode($this->iv . $this->tag . $encryptedBytes);
Expand Down Expand Up @@ -168,7 +168,11 @@
* @param bool $humanReadableData whether to return base64 encoded data
* @return array Sealed data
*/
public function seal(string $plain_text, RSAParameters $rSAParameters, bool $humanReadableData = false): array
public function seal(

Check failure on line 171 in src/AESCryptoServiceProvider.php

View workflow job for this annotation

GitHub Actions / stan

Method MayMeow\Cryptography\AESCryptoServiceProvider::seal() return type has no value type specified in iterable type array.
string $plain_text,
RSAParameters $rSAParameters,
bool $humanReadableData = false
): array
{
$this->generateIV('aes-256-cbc');

Expand Down Expand Up @@ -197,7 +201,8 @@
* @param RSAParameters $rSAParameters
* @return string Opened data
*/
public function open(string $sealed_data, string $ekeys, RSAParameters $rSAParameters): string
public function open(string $sealed_data, string $ekeys, RSAParameters $rSAParameters, string $privateKeyPass,
string $salt): string
{
if (preg_match('/^[a-zA-Z0-9\/\r\n+]*={0,2}$/', $sealed_data)) {
$sealed_data = base64_decode($sealed_data);
Expand All @@ -216,7 +221,7 @@
$iv = substr($sealed_data, 0, $iv_len);
$encryptedData = substr($sealed_data, $iv_len);

openssl_open($encryptedData, $open_data, $ekeys, $rSAParameters->getPrivateKey(), 'aes-256-cbc', $iv);
openssl_open($encryptedData, $open_data, $ekeys, $rSAParameters->getPrivateKey(passphrase: $privateKeyPass, salt: $salt), 'aes-256-cbc', $iv);

Check failure on line 224 in src/AESCryptoServiceProvider.php

View workflow job for this annotation

GitHub Actions / stan

Unknown parameter $passphrase in call to method MayMeow\Cryptography\RSAParameters::getPrivateKey().

return $open_data;
}
Expand Down
12 changes: 6 additions & 6 deletions src/RSACryptoServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
/**
* decrypt with private key
*/
public function decrypt(string $encryptedText): string
public function decrypt(string $encryptedText, string $privateKeyPass, string $salt): string
{
$plainText = '';
$privKey = $this->parameters->getPrivateKey();
$privKey = $this->parameters->getPrivateKey(passphrase: $privateKeyPass, salt: $salt);

Check failure on line 38 in src/RSACryptoServiceProvider.php

View workflow job for this annotation

GitHub Actions / stan

Unknown parameter $passphrase in call to method MayMeow\Cryptography\RSAParameters::getPrivateKey().

openssl_private_decrypt(base64_decode($encryptedText), $plainText, $privKey);

Expand All @@ -48,10 +48,10 @@
* @param string $plainText
* @return string
*/
public function privateEncrypt(string $plainText): string
public function privateEncrypt(string $plainText, string $privateKeyPass, string $salt): string
{
$encrypted = '';
$privKey = $this->parameters->getPrivateKey();
$privKey = $this->parameters->getPrivateKey(passphrase: $privateKeyPass, salt: $salt);

openssl_private_encrypt($plainText, $encrypted, $privKey);

Expand All @@ -78,9 +78,9 @@
* @param string $data
* @return string
*/
public function sign(string $data): string
public function sign(string $data, string $privateKeyPass, string $salt): string
{
$privKey = $this->getPrivateKey();
$privKey = $this->parameters->getPrivateKey(passphrase: $privateKeyPass, salt: $salt);

$result = openssl_sign($data, $signature, $privKey, OPENSSL_ALGO_SHA512);

Expand Down
Loading