public function generateNewKeypair($usedForPasswords = false)
{
$keyResource = openssl_pkey_new($this->openSSLConfiguration);
if ($keyResource === false) {
throw new SecurityException('OpenSSL private key generation failed.', 1254838154);
}
$modulus = $this->getModulus($keyResource);
$privateKeyString = $this->getPrivateKeyString($keyResource);
$publicKeyString = $this->getPublicKeyString($keyResource);
$privateKey = new OpenSslRsaKey($modulus, $privateKeyString);
$publicKey = new OpenSslRsaKey($modulus, $publicKeyString);
return $this->storeKeyPair($publicKey, $privateKey, $usedForPasswords);
}