crypto: Expose the device/identity verification methods through the identities.

This commit is contained in:
Damir Jelić 2020-08-14 15:32:44 +02:00
parent 0fc5134563
commit f4de3580b6

View file

@ -120,6 +120,8 @@ impl UserSigningPubkey {
.next()
.ok_or(SignatureError::MissingSigningKey)?;
// TODO check that the usage is OK.
verify_json(
&self.0.user_id,
&DeviceKeyId::try_from(key_id.as_str())?,
@ -138,6 +140,8 @@ impl SelfSigningPubkey {
.next()
.ok_or(SignatureError::MissingSigningKey)?;
// TODO check that the usage is OK.
verify_json(
&self.0.user_id,
&DeviceKeyId::try_from(key_id.as_str())?,
@ -160,6 +164,10 @@ impl UserIdentity {
self_signing_key,
})
}
pub fn is_device_signed(&self, device: &Device) -> Result<(), SignatureError> {
self.self_signing_key.verify_device(device)
}
}
pub struct OwnUserIdentity {
@ -187,6 +195,11 @@ impl OwnUserIdentity {
verified: Arc::new(AtomicBool::new(false)),
})
}
pub fn is_identity_signed(&self, identity: &UserIdentity) -> Result<(), SignatureError> {
self.user_signing_key
.verify_master_key(&identity.master_key)
}
}
#[cfg(test)]