Made message signing in Cryptography use SHA512 as the message content for... #1
5 changed files with 19 additions and 19 deletions
|
@ -20,7 +20,7 @@
|
||||||
use Socialbox\Objects\ClientRequest;
|
use Socialbox\Objects\ClientRequest;
|
||||||
use Socialbox\Objects\PeerAddress;
|
use Socialbox\Objects\PeerAddress;
|
||||||
use Socialbox\Objects\RpcRequest;
|
use Socialbox\Objects\RpcRequest;
|
||||||
use Socialbox\Objects\Standard\SigningKey;
|
use Socialbox\Objects\Standard\Signature;
|
||||||
use Socialbox\Socialbox;
|
use Socialbox\Socialbox;
|
||||||
|
|
||||||
class EncryptionCreateChannel extends Method
|
class EncryptionCreateChannel extends Method
|
||||||
|
@ -150,12 +150,12 @@
|
||||||
*
|
*
|
||||||
* @param PeerAddress $callingPeer The calling peer
|
* @param PeerAddress $callingPeer The calling peer
|
||||||
* @param RpcRequest $rpcRequest The focused RPC request
|
* @param RpcRequest $rpcRequest The focused RPC request
|
||||||
* @return SigningKey The resolved signing key
|
* @return Signature The resolved signing key
|
||||||
* @throws InvalidRpcArgumentException If one or more RPC parameters are invalid
|
* @throws InvalidRpcArgumentException If one or more RPC parameters are invalid
|
||||||
* @throws MissingRpcArgumentException If one or more RPC parameters are missing
|
* @throws MissingRpcArgumentException If one or more RPC parameters are missing
|
||||||
* @throws StandardRpcException If the calling signature cannot be resolved
|
* @throws StandardRpcException If the calling signature cannot be resolved
|
||||||
*/
|
*/
|
||||||
private static function getCallingSignature(PeerAddress $callingPeer, RpcRequest $rpcRequest): SigningKey
|
private static function getCallingSignature(PeerAddress $callingPeer, RpcRequest $rpcRequest): Signature
|
||||||
{
|
{
|
||||||
// Caller signature verification
|
// Caller signature verification
|
||||||
if(!$rpcRequest->containsParameter('calling_signature_uuid'))
|
if(!$rpcRequest->containsParameter('calling_signature_uuid'))
|
||||||
|
@ -238,12 +238,12 @@
|
||||||
/**
|
/**
|
||||||
* @param PeerAddress $receivingPeer
|
* @param PeerAddress $receivingPeer
|
||||||
* @param RpcRequest $rpcRequest
|
* @param RpcRequest $rpcRequest
|
||||||
* @return SigningKey
|
* @return Signature
|
||||||
* @throws InvalidRpcArgumentException
|
* @throws InvalidRpcArgumentException
|
||||||
* @throws MissingRpcArgumentException
|
* @throws MissingRpcArgumentException
|
||||||
* @throws StandardRpcException
|
* @throws StandardRpcException
|
||||||
*/
|
*/
|
||||||
private static function getReceivingSignature(PeerAddress $receivingPeer, RpcRequest $rpcRequest): SigningKey
|
private static function getReceivingSignature(PeerAddress $receivingPeer, RpcRequest $rpcRequest): Signature
|
||||||
{
|
{
|
||||||
// Receiving signature verification
|
// Receiving signature verification
|
||||||
if(!$rpcRequest->containsParameter('receiving_signature_uuid'))
|
if(!$rpcRequest->containsParameter('receiving_signature_uuid'))
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
use Socialbox\Objects\Database\ContactKnownKeyRecord;
|
use Socialbox\Objects\Database\ContactKnownKeyRecord;
|
||||||
use Socialbox\Objects\PeerAddress;
|
use Socialbox\Objects\PeerAddress;
|
||||||
use Socialbox\Objects\Standard\Contact;
|
use Socialbox\Objects\Standard\Contact;
|
||||||
use Socialbox\Objects\Standard\SigningKey;
|
use Socialbox\Objects\Standard\Signature;
|
||||||
|
|
||||||
class ContactManager
|
class ContactManager
|
||||||
{
|
{
|
||||||
|
@ -334,11 +334,11 @@
|
||||||
* Adds a signing key to a contact in the database.
|
* Adds a signing key to a contact in the database.
|
||||||
*
|
*
|
||||||
* @param string|ContactDatabaseRecord $contactUuid The unique identifier of the contact to add the signing key to.
|
* @param string|ContactDatabaseRecord $contactUuid The unique identifier of the contact to add the signing key to.
|
||||||
* @param SigningKey $signingKey The signing key to add to the contact.
|
* @param Signature $signingKey The signing key to add to the contact.
|
||||||
* @return void
|
* @return void
|
||||||
* @throws DatabaseOperationException If the database query fails.
|
* @throws DatabaseOperationException If the database query fails.
|
||||||
*/
|
*/
|
||||||
public static function addContactSigningKey(string|ContactDatabaseRecord $contactUuid, SigningKey $signingKey): void
|
public static function addContactSigningKey(string|ContactDatabaseRecord $contactUuid, Signature $signingKey): void
|
||||||
{
|
{
|
||||||
if($contactUuid instanceof ContactDatabaseRecord)
|
if($contactUuid instanceof ContactDatabaseRecord)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Socialbox\Enums\SigningKeyState;
|
use Socialbox\Enums\SigningKeyState;
|
||||||
use Socialbox\Interfaces\SerializableInterface;
|
use Socialbox\Interfaces\SerializableInterface;
|
||||||
use Socialbox\Objects\Standard\SigningKey;
|
use Socialbox\Objects\Standard\Signature;
|
||||||
|
|
||||||
class SigningKeyRecord implements SerializableInterface
|
class SigningKeyRecord implements SerializableInterface
|
||||||
{
|
{
|
||||||
|
@ -188,10 +188,10 @@
|
||||||
/**
|
/**
|
||||||
* Converts the current signing key record to its standard format.
|
* Converts the current signing key record to its standard format.
|
||||||
*
|
*
|
||||||
* @return SigningKey The signing key in its standard format.
|
* @return Signature The signing key in its standard format.
|
||||||
*/
|
*/
|
||||||
public function toStandard(): SigningKey
|
public function toStandard(): Signature
|
||||||
{
|
{
|
||||||
return SigningKey::fromSigningKeyRecord($this);
|
return Signature::fromSigningKeyRecord($this);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,7 +8,7 @@
|
||||||
use Socialbox\Interfaces\SerializableInterface;
|
use Socialbox\Interfaces\SerializableInterface;
|
||||||
use Socialbox\Objects\Database\SigningKeyRecord;
|
use Socialbox\Objects\Database\SigningKeyRecord;
|
||||||
|
|
||||||
class SigningKey implements SerializableInterface
|
class Signature implements SerializableInterface
|
||||||
{
|
{
|
||||||
private string $uuid;
|
private string $uuid;
|
||||||
private string $name;
|
private string $name;
|
||||||
|
@ -135,9 +135,9 @@
|
||||||
* Creates a new SigningKey instance from a SigningKeyRecord.
|
* Creates a new SigningKey instance from a SigningKeyRecord.
|
||||||
*
|
*
|
||||||
* @param SigningKeyRecord $record The record containing the signing key data.
|
* @param SigningKeyRecord $record The record containing the signing key data.
|
||||||
* @return SigningKey An instance of SigningKey populated with data from the provided record.
|
* @return Signature An instance of SigningKey populated with data from the provided record.
|
||||||
*/
|
*/
|
||||||
public static function fromSigningKeyRecord(SigningKeyRecord $record): SigningKey
|
public static function fromSigningKeyRecord(SigningKeyRecord $record): Signature
|
||||||
{
|
{
|
||||||
return new self([
|
return new self([
|
||||||
'uuid' => $record->getUuid(),
|
'uuid' => $record->getUuid(),
|
||||||
|
@ -152,7 +152,7 @@
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public static function fromArray(array $data): SigningKey
|
public static function fromArray(array $data): Signature
|
||||||
{
|
{
|
||||||
return new self($data);
|
return new self($data);
|
||||||
}
|
}
|
|
@ -39,7 +39,7 @@
|
||||||
use Socialbox\Objects\Standard\InformationField;
|
use Socialbox\Objects\Standard\InformationField;
|
||||||
use Socialbox\Objects\Standard\Peer;
|
use Socialbox\Objects\Standard\Peer;
|
||||||
use Socialbox\Objects\Standard\ServerInformation;
|
use Socialbox\Objects\Standard\ServerInformation;
|
||||||
use Socialbox\Objects\Standard\SigningKey;
|
use Socialbox\Objects\Standard\Signature;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
class Socialbox
|
class Socialbox
|
||||||
|
@ -903,10 +903,10 @@
|
||||||
*
|
*
|
||||||
* @param PeerAddress|string $peerAddress The peer address or string identifier to be resolved.
|
* @param PeerAddress|string $peerAddress The peer address or string identifier to be resolved.
|
||||||
* @param string $signatureUuid The UUID of the signature key to be resolved.
|
* @param string $signatureUuid The UUID of the signature key to be resolved.
|
||||||
* @return SigningKey|null The resolved signing key for the peer. Null if not found
|
* @return Signature|null The resolved signing key for the peer. Null if not found
|
||||||
* @throws StandardRpcException If there was an error while resolving the peer signature key.
|
* @throws StandardRpcException If there was an error while resolving the peer signature key.
|
||||||
*/
|
*/
|
||||||
public static function resolvePeerSignature(PeerAddress|string $peerAddress, string $signatureUuid): ?SigningKey
|
public static function resolvePeerSignature(PeerAddress|string $peerAddress, string $signatureUuid): ?Signature
|
||||||
{
|
{
|
||||||
// Convert string peer address to object PeerAddress
|
// Convert string peer address to object PeerAddress
|
||||||
if(is_string($peerAddress))
|
if(is_string($peerAddress))
|
||||||
|
|
Loading…
Add table
Reference in a new issue