|
@@ -276,6 +276,7 @@ fn generate_rsa(realm: &schema::Realm, kty: KeyType, bits: usize) -> Result<Pars
|
|
realm.keys.insert(schema::Key {
|
|
realm.keys.insert(schema::Key {
|
|
key_id: key_id.clone(),
|
|
key_id: key_id.clone(),
|
|
key_type: kty.into(),
|
|
key_type: kty.into(),
|
|
|
|
+ key_state: schema::KeyState::Active.into(),
|
|
public_data: public.into(),
|
|
public_data: public.into(),
|
|
secret_data: secret.into(),
|
|
secret_data: secret.into(),
|
|
expiry,
|
|
expiry,
|
|
@@ -291,14 +292,27 @@ pub fn generate_in(realm: &schema::Realm, kty: KeyType) -> Result<ParsedKey, UID
|
|
let rng = ring::rand::SystemRandom::new();
|
|
let rng = ring::rand::SystemRandom::new();
|
|
let mut key_id = [0u8; 16];
|
|
let mut key_id = [0u8; 16];
|
|
rng.fill(&mut key_id)
|
|
rng.fill(&mut key_id)
|
|
- .map_err(|_| UIDCError::Abort("couldn't generate random values"));
|
|
|
|
|
|
+ .map_err(|_| UIDCError::Abort("couldn't generate random values"))?;
|
|
|
|
+ let key_id = pubkey_id(&key_id);
|
|
|
|
|
|
let mut keydata = vec![];
|
|
let mut keydata = vec![];
|
|
keydata.resize(hmty.digest_width(), 0u8);
|
|
keydata.resize(hmty.digest_width(), 0u8);
|
|
rng.fill(keydata.as_mut_slice())
|
|
rng.fill(keydata.as_mut_slice())
|
|
- .map_err(|_| UIDCError::Abort("couldn't generate random values"));
|
|
|
|
|
|
+ .map_err(|_| UIDCError::Abort("couldn't generate random values"))?;
|
|
|
|
+
|
|
|
|
+ let expiry = time::OffsetDateTime::now_utc() + time::Duration::days(730);
|
|
|
|
+ realm.keys.insert(schema::Key {
|
|
|
|
+ key_id: key_id.clone(),
|
|
|
|
+ key_type: kty.into(),
|
|
|
|
+ key_state: schema::KeyState::Active.into(),
|
|
|
|
+ // no separate public data for EdDSA keys
|
|
|
|
+ public_data: vec![],
|
|
|
|
+ secret_data: keydata.clone(),
|
|
|
|
+ expiry,
|
|
|
|
+ })?;
|
|
|
|
+
|
|
Ok(ParsedKey::HMAC {
|
|
Ok(ParsedKey::HMAC {
|
|
- key_id: base64::encode(key_id),
|
|
|
|
|
|
+ key_id,
|
|
keydata,
|
|
keydata,
|
|
hmty,
|
|
hmty,
|
|
})
|
|
})
|
|
@@ -320,6 +334,7 @@ pub fn generate_in(realm: &schema::Realm, kty: KeyType) -> Result<ParsedKey, UID
|
|
realm.keys.insert(schema::Key {
|
|
realm.keys.insert(schema::Key {
|
|
key_id: key_id.clone(),
|
|
key_id: key_id.clone(),
|
|
key_type: kty.into(),
|
|
key_type: kty.into(),
|
|
|
|
+ key_state: schema::KeyState::Active.into(),
|
|
// no separate public data for EdDSA keys
|
|
// no separate public data for EdDSA keys
|
|
public_data: vec![],
|
|
public_data: vec![],
|
|
secret_data: keydata,
|
|
secret_data: keydata,
|