public static function createKey(array $config)
{
Assertion::keyExists($config, 'kty', 'The key "kty" must be set');
$supported_types = ['RSA' => 'RSA', 'OKP' => 'OKP', 'EC' => 'EC', 'oct' => 'Oct', 'none' => 'None'];
$kty = $config['kty'];
Assertion::keyExists($supported_types, $kty, sprintf('The key type "%s" is not supported. Please use one of %s', $kty, json_encode(array_keys($supported_types))));
$method = sprintf('create%sKey', $supported_types[$kty]);
return self::$method($config);
}
/** * @return \Jose\Object\JWKInterface */ protected function createJWK() { $data = JWKFactory::createKey($this->parameters)->getAll(); $data['kid'] = Base64Url::encode(random_bytes(64)); return JWKFactory::createFromValues($data); }