Allow chaining of key set functions for encryption
This commit is contained in:
@@ -262,7 +262,7 @@ class AsymmetricAnonymousEncryption
|
|||||||
public function setKeyPair(
|
public function setKeyPair(
|
||||||
#[\SensitiveParameter]
|
#[\SensitiveParameter]
|
||||||
string $key_pair
|
string $key_pair
|
||||||
) {
|
): AsymmetricAnonymousEncryption {
|
||||||
if (empty($key_pair)) {
|
if (empty($key_pair)) {
|
||||||
throw new \UnexpectedValueException('Key pair cannot be empty');
|
throw new \UnexpectedValueException('Key pair cannot be empty');
|
||||||
}
|
}
|
||||||
@@ -277,6 +277,7 @@ class AsymmetricAnonymousEncryption
|
|||||||
// check if valid
|
// check if valid
|
||||||
$this->createPublicKey($this->public_key);
|
$this->createPublicKey($this->public_key);
|
||||||
}
|
}
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -311,7 +312,7 @@ class AsymmetricAnonymousEncryption
|
|||||||
* @return void
|
* @return void
|
||||||
* @throws \UnexpectedValueException public key empty
|
* @throws \UnexpectedValueException public key empty
|
||||||
*/
|
*/
|
||||||
public function setPublicKey(string $public_key)
|
public function setPublicKey(string $public_key): AsymmetricAnonymousEncryption
|
||||||
{
|
{
|
||||||
if (empty($public_key)) {
|
if (empty($public_key)) {
|
||||||
throw new \UnexpectedValueException('Public key cannot be empty');
|
throw new \UnexpectedValueException('Public key cannot be empty');
|
||||||
@@ -320,6 +321,7 @@ class AsymmetricAnonymousEncryption
|
|||||||
$this->createPublicKey($public_key);
|
$this->createPublicKey($public_key);
|
||||||
$this->public_key = $public_key;
|
$this->public_key = $public_key;
|
||||||
sodium_memzero($public_key);
|
sodium_memzero($public_key);
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ class SymmetricEncryption
|
|||||||
public function setKey(
|
public function setKey(
|
||||||
#[\SensitiveParameter]
|
#[\SensitiveParameter]
|
||||||
string $key
|
string $key
|
||||||
) {
|
): SymmetricEncryption {
|
||||||
if (empty($key)) {
|
if (empty($key)) {
|
||||||
throw new \UnexpectedValueException('Key cannot be empty');
|
throw new \UnexpectedValueException('Key cannot be empty');
|
||||||
}
|
}
|
||||||
@@ -224,6 +224,7 @@ class SymmetricEncryption
|
|||||||
// set key
|
// set key
|
||||||
$this->key = $key;
|
$this->key = $key;
|
||||||
sodium_memzero($key);
|
sodium_memzero($key);
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user