Made message signing in Cryptography use SHA512 as the message content for... #1

Closed
netkas wants to merge 421 commits from master into dev
Showing only changes of commit cebfa72ec0 - Show all commits

View file

@ -1,6 +1,6 @@
<?php <?php
namespace Socialbox\Objects; namespace Socialbox\Objects\Client;
use Socialbox\Interfaces\SerializableInterface; use Socialbox\Interfaces\SerializableInterface;
@ -24,6 +24,11 @@
private string $privateSharedSecret; private string $privateSharedSecret;
private string $clientTransportEncryptionKey; private string $clientTransportEncryptionKey;
private string $serverTransportEncryptionKey; private string $serverTransportEncryptionKey;
private ?string $defaultSigningKey;
/**
* @var SignatureKeyPair[]
*/
private array $signingKeys;
/** /**
* Constructor method to initialize class properties from the provided data array. * Constructor method to initialize class properties from the provided data array.
@ -55,6 +60,8 @@
$this->privateSharedSecret = $data['private_shared_secret']; $this->privateSharedSecret = $data['private_shared_secret'];
$this->clientTransportEncryptionKey = $data['client_transport_encryption_key']; $this->clientTransportEncryptionKey = $data['client_transport_encryption_key'];
$this->serverTransportEncryptionKey = $data['server_transport_encryption_key']; $this->serverTransportEncryptionKey = $data['server_transport_encryption_key'];
$this->defaultSigningKey = $data['default_signing_key'] ?? null;
$this->signingKeys = array_map(fn($key) => SignatureKeyPair::fromArray($key), $data['signing_keys']);
} }
/** /**
@ -207,6 +214,26 @@
return $this->serverTransportEncryptionKey; return $this->serverTransportEncryptionKey;
} }
/**
* Retrieves the default signing key associated with the current instance.
*
* @return string|null The default signing key.
*/
public function getDefaultSigningKey(): ?string
{
return $this->defaultSigningKey;
}
/**
* Retrieves the signing keys associated with the current instance.
*
* @return SignatureKeyPair[] The signing keys.
*/
public function getSigningKeys(): array
{
return $this->signingKeys;
}
/** /**
* @inheritDoc * @inheritDoc
*/ */
@ -228,6 +255,8 @@
'private_shared_secret' => $this->privateSharedSecret, 'private_shared_secret' => $this->privateSharedSecret,
'client_transport_encryption_key' => $this->clientTransportEncryptionKey, 'client_transport_encryption_key' => $this->clientTransportEncryptionKey,
'server_transport_encryption_key' => $this->serverTransportEncryptionKey, 'server_transport_encryption_key' => $this->serverTransportEncryptionKey,
'default_signing_key' => $this->defaultSigningKey,
'signing_keys' => array_map(fn($key) => $key->toArray(), $this->signingKeys)
]; ];
} }