Skip to content

Commit

Permalink
Allow to change just some options
Browse files Browse the repository at this point in the history
  • Loading branch information
bpolaszek committed Jan 23, 2020
1 parent 4d396b3 commit 7640f59
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Shh.php
Expand Up @@ -116,8 +116,9 @@ public function decrypt(string $base64EncodedPayload): string
* @param array $config
* @return array - [privateKey, publicKey]
*/
public static function generateKeyPair(?string $passphrase = null, array $config = self::DEFAULT_OPENSSL_GENERATION_CONFIGURATION): array
public static function generateKeyPair(?string $passphrase = null, array $config = []): array
{
$config += self::DEFAULT_OPENSSL_GENERATION_CONFIGURATION;
$resource = \openssl_pkey_new($config)
or ShhException::throwFromLastOpenSSLError('Unable to open resource.');

Expand Down
9 changes: 9 additions & 0 deletions tests/ShhTest.php
Expand Up @@ -135,6 +135,15 @@ public function it_generates_a_valid_keypair()
$this->assertEquals('foo', $decrypted);
}

/**
* @test
*/
public function i_can_change_generation_options()
{
$this->assertEquals(800, \strlen(Shh::generateKeyPair()[0]));
$this->assertEquals(182, \strlen(Shh::generateKeyPair(null, ['private_key_bits' => 512])[0]));
}

/**
* @test
*/
Expand Down

0 comments on commit 7640f59

Please sign in to comment.