crypto: Add a method to check the state of our private cross signing keys
parent
1157594530
commit
b540b8df62
|
@ -50,8 +50,8 @@ pub use identities::{
|
||||||
};
|
};
|
||||||
pub use machine::OlmMachine;
|
pub use machine::OlmMachine;
|
||||||
pub use matrix_qrcode;
|
pub use matrix_qrcode;
|
||||||
pub use olm::EncryptionSettings;
|
|
||||||
pub(crate) use olm::ReadOnlyAccount;
|
pub(crate) use olm::ReadOnlyAccount;
|
||||||
|
pub use olm::{CrossSigningStatus, EncryptionSettings};
|
||||||
pub use requests::{
|
pub use requests::{
|
||||||
IncomingResponse, KeysQueryRequest, OutgoingRequest, OutgoingRequests,
|
IncomingResponse, KeysQueryRequest, OutgoingRequest, OutgoingRequests,
|
||||||
OutgoingVerificationRequest, RoomMessageRequest, ToDeviceRequest,
|
OutgoingVerificationRequest, RoomMessageRequest, ToDeviceRequest,
|
||||||
|
|
|
@ -51,9 +51,9 @@ use crate::{
|
||||||
gossiping::GossipMachine,
|
gossiping::GossipMachine,
|
||||||
identities::{user::UserIdentities, Device, IdentityManager, UserDevices},
|
identities::{user::UserIdentities, Device, IdentityManager, UserDevices},
|
||||||
olm::{
|
olm::{
|
||||||
Account, EncryptionSettings, ExportedRoomKey, GroupSessionKey, IdentityKeys,
|
Account, CrossSigningStatus, EncryptionSettings, ExportedRoomKey, GroupSessionKey,
|
||||||
InboundGroupSession, OlmDecryptionInfo, PrivateCrossSigningIdentity, ReadOnlyAccount,
|
IdentityKeys, InboundGroupSession, OlmDecryptionInfo, PrivateCrossSigningIdentity,
|
||||||
SessionType,
|
ReadOnlyAccount, SessionType,
|
||||||
},
|
},
|
||||||
requests::{IncomingResponse, OutgoingRequest, UploadSigningKeysRequest},
|
requests::{IncomingResponse, OutgoingRequest, UploadSigningKeysRequest},
|
||||||
session_manager::{GroupSessionManager, SessionManager},
|
session_manager::{GroupSessionManager, SessionManager},
|
||||||
|
@ -1254,6 +1254,14 @@ impl OlmMachine {
|
||||||
|
|
||||||
Ok(exported)
|
Ok(exported)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the status of the private cross signing keys.
|
||||||
|
///
|
||||||
|
/// This can be used to check which private cross signing keys we have
|
||||||
|
/// stored locally.
|
||||||
|
pub async fn cross_signing_status(&self) -> CrossSigningStatus {
|
||||||
|
self.user_identity.lock().await.status().await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -34,7 +34,7 @@ use matrix_sdk_common::instant::{Duration, Instant};
|
||||||
pub use olm_rs::{account::IdentityKeys, PicklingMode};
|
pub use olm_rs::{account::IdentityKeys, PicklingMode};
|
||||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
pub use session::{PickledSession, Session, SessionPickle};
|
pub use session::{PickledSession, Session, SessionPickle};
|
||||||
pub use signing::{PickledCrossSigningIdentity, PrivateCrossSigningIdentity};
|
pub use signing::{CrossSigningStatus, PickledCrossSigningIdentity, PrivateCrossSigningIdentity};
|
||||||
pub(crate) use utility::Utility;
|
pub(crate) use utility::Utility;
|
||||||
|
|
||||||
pub(crate) fn serialize_instant<S>(instant: &Instant, serializer: S) -> Result<S::Ok, S::Error>
|
pub(crate) fn serialize_instant<S>(instant: &Instant, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
|
|
|
@ -70,6 +70,20 @@ pub struct PickledCrossSigningIdentity {
|
||||||
pub pickle: String,
|
pub pickle: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Struct representing the state of our private cross signing keys, it shows
|
||||||
|
/// which private cross signing keys we have locally stored.
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct CrossSigningStatus {
|
||||||
|
/// Do we have the master key.
|
||||||
|
pub has_master: bool,
|
||||||
|
/// Do we have the self signing key, this one is necessary to sign our own
|
||||||
|
/// devices.
|
||||||
|
pub has_self_signing: bool,
|
||||||
|
/// Do we have the user signing key, this one is necessary to sign other
|
||||||
|
/// users.
|
||||||
|
pub has_user_signing: bool,
|
||||||
|
}
|
||||||
|
|
||||||
impl PrivateCrossSigningIdentity {
|
impl PrivateCrossSigningIdentity {
|
||||||
/// Get the user id that this identity belongs to.
|
/// Get the user id that this identity belongs to.
|
||||||
pub fn user_id(&self) -> &UserId {
|
pub fn user_id(&self) -> &UserId {
|
||||||
|
@ -108,6 +122,16 @@ impl PrivateCrossSigningIdentity {
|
||||||
self.master_key.lock().await.is_some()
|
self.master_key.lock().await.is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the status of our private cross signing keys, i.e. if we have the
|
||||||
|
/// master key and the subkeys.
|
||||||
|
pub async fn status(&self) -> CrossSigningStatus {
|
||||||
|
CrossSigningStatus {
|
||||||
|
has_master: self.has_master_key().await,
|
||||||
|
has_self_signing: self.can_sign_devices().await,
|
||||||
|
has_user_signing: self.can_sign_users().await,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Get the public part of the master key, if we have one.
|
/// Get the public part of the master key, if we have one.
|
||||||
pub async fn master_public_key(&self) -> Option<MasterPubkey> {
|
pub async fn master_public_key(&self) -> Option<MasterPubkey> {
|
||||||
self.master_key.lock().await.as_ref().map(|m| m.public_key.to_owned())
|
self.master_key.lock().await.as_ref().map(|m| m.public_key.to_owned())
|
||||||
|
|
|
@ -78,6 +78,7 @@ use crate::{
|
||||||
ReadOnlyAccount, Session,
|
ReadOnlyAccount, Session,
|
||||||
},
|
},
|
||||||
verification::VerificationMachine,
|
verification::VerificationMachine,
|
||||||
|
CrossSigningStatus,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A `CryptoStore` specific result type.
|
/// A `CryptoStore` specific result type.
|
||||||
|
|
Loading…
Reference in New Issue