Skip to content

Commit 606aff4

Browse files
committed
Fix random shared secret being of odd length
1 parent c09b8e2 commit 606aff4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: src/Encryption.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public static function encrypt(string $payload, string $userPublicKey, string $u
6565

6666
// get shared secret from user public key and local private key
6767
$sharedSecret = $curve->mul($userPublicKeyObject->getPoint(), $localPrivateKeyObject->getSecret())->getX();
68-
$sharedSecret = hex2bin(gmp_strval($sharedSecret, 16));
68+
$sharedSecret = hex2bin(str_pad(gmp_strval($sharedSecret, 16), 64, '0', STR_PAD_LEFT));
6969

7070
// generate salt
7171
$salt = random_bytes(16);

0 commit comments

Comments
 (0)