use openidconnect::JsonWebKeyId;
use openidconnect::core::{CoreJsonCurveType, CoreJsonWebKey};
#[derive(Clone)]
pub enum PublicKeyMaterial {
Rsa {
n: Vec<u8>, e: Vec<u8>, },
Ec {
crv: CoreJsonCurveType, x: Vec<u8>, y: Vec<u8>, },
Okp {
crv: CoreJsonCurveType, x: Vec<u8>,
},
}
pub(crate) fn build_json_web_key(kid: String, material: PublicKeyMaterial) -> CoreJsonWebKey {
let key_id = JsonWebKeyId::new(kid);
match material {
PublicKeyMaterial::Rsa { n, e, .. } => CoreJsonWebKey::new_rsa(n, e, Some(key_id)),
PublicKeyMaterial::Ec { crv, x, y, .. } => CoreJsonWebKey::new_ec(x, y, crv, Some(key_id)),
PublicKeyMaterial::Okp { crv, x, .. } => CoreJsonWebKey::new_okp(x, crv, Some(key_id)),
}
}