Skip to content

Commit

Permalink
Fix random shared secret being of odd length
Browse files Browse the repository at this point in the history
  • Loading branch information
Minishlink committed Mar 16, 2018
1 parent c09b8e2 commit 606aff4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Encryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static function encrypt(string $payload, string $userPublicKey, string $u

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

// generate salt
$salt = random_bytes(16);
Expand Down

0 comments on commit 606aff4

Please sign in to comment.