Made message signing in Cryptography use SHA512 as the message content for... #1
1 changed files with 18 additions and 0 deletions
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Socialbox\Objects\Client;
|
||||
|
||||
use Socialbox\Classes\Cryptography;
|
||||
use Socialbox\Exceptions\CryptographyException;
|
||||
use Socialbox\Interfaces\SerializableInterface;
|
||||
use Socialbox\Objects\PeerAddress;
|
||||
|
||||
|
@ -87,6 +89,22 @@
|
|||
$this->receivingPublicEncryptionKey = $receivingPublicEncryptionKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Preform a Diffie-Hellman Exchange to get the shared secret between the two peers
|
||||
*
|
||||
* @return string The shared secret
|
||||
* @throws CryptographyException If the receiving public encryption key is not set
|
||||
*/
|
||||
public function getSharedSecret(): string
|
||||
{
|
||||
if($this->receivingPublicEncryptionKey === null)
|
||||
{
|
||||
throw new CryptographyException('The receiving public encryption key is not set');
|
||||
}
|
||||
|
||||
return Cryptography::performDHE($this->receivingPublicEncryptionKey, $this->localPrivateEncryptionKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue