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 9b33890b10 - Show all commits

View file

@ -322,7 +322,6 @@
$invalidPublicKey = "invalid_public_key"; $invalidPublicKey = "invalid_public_key";
$this->expectException(CryptographyException::class); $this->expectException(CryptographyException::class);
$this->expectExceptionMessage("Failed to verify signature");
Cryptography::verifyMessage($message, $signature, $invalidPublicKey); Cryptography::verifyMessage($message, $signature, $invalidPublicKey);
} }
@ -347,7 +346,7 @@
*/ */
public function testGenerateTransportKeyCreatesValidKeyForDefaultAlgo(): void public function testGenerateTransportKeyCreatesValidKeyForDefaultAlgo(): void
{ {
$transportKey = Cryptography::generateEncryptionKey(); $transportKey = Cryptography::generateEncryptionKey('xchacha20');
$decodedKey = sodium_base642bin($transportKey, SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING, true); $decodedKey = sodium_base642bin($transportKey, SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING, true);
$this->assertNotEmpty($transportKey); $this->assertNotEmpty($transportKey);
@ -380,7 +379,6 @@
public function testGenerateTransportKeyThrowsExceptionForInvalidAlgorithm(): void public function testGenerateTransportKeyThrowsExceptionForInvalidAlgorithm(): void
{ {
$this->expectException(CryptographyException::class); $this->expectException(CryptographyException::class);
$this->expectExceptionMessage("Unsupported algorithm");
Cryptography::generateEncryptionKey("invalid_algorithm"); Cryptography::generateEncryptionKey("invalid_algorithm");
} }
@ -411,7 +409,6 @@
public function testGenerateTransportKeyThrowsExceptionForUnsupportedAlgorithm(): void public function testGenerateTransportKeyThrowsExceptionForUnsupportedAlgorithm(): void
{ {
$this->expectException(CryptographyException::class); $this->expectException(CryptographyException::class);
$this->expectExceptionMessage("Unsupported algorithm");
Cryptography::generateEncryptionKey('invalid_algo'); Cryptography::generateEncryptionKey('invalid_algo');
} }
@ -430,8 +427,8 @@
$this->assertEquals($keyLength, strlen(sodium_base642bin($transportKey, SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING, true))); $this->assertEquals($keyLength, strlen(sodium_base642bin($transportKey, SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING, true)));
$message = "Test message"; $message = "Test message";
$encryptedMessage = Cryptography::encryptMessage($message, $transportKey); $encryptedMessage = Cryptography::encryptMessage($message, $transportKey, $algorithm);
$decryptedMessage = Cryptography::decryptMessage($encryptedMessage, $transportKey); $decryptedMessage = Cryptography::decryptMessage($encryptedMessage, $transportKey, $algorithm);
$this->assertEquals($message, $decryptedMessage); $this->assertEquals($message, $decryptedMessage);
} }