/**
* Method to generate a new encryption key object.
*
* @param array $options Key generation options.
*
* @return Key
*
* @since 3.5
* @throws \RuntimeException
*/
public function generateKey(array $options = array())
{
// Generate the encryption key.
try {
$public = \Crypto::CreateNewRandomKey();
} catch (\CryptoTestFailedException $ex) {
throw new \RuntimeException('Cannot safely create a key', $ex->getCode(), $ex);
} catch (\CannotPerformOperationException $ex) {
throw new \RuntimeException('Cannot safely create a key', $ex->getCode(), $ex);
}
// Explicitly flag the private as unused in this cipher.
$private = 'unused';
return new Key('crypto', $private, $public);
}