crypto: Allow user identities to be seralized/deserialized.
parent
4bab678e46
commit
c652762255
|
@ -20,6 +20,7 @@ use std::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::to_value;
|
use serde_json::to_value;
|
||||||
|
|
||||||
use matrix_sdk_common::{
|
use matrix_sdk_common::{
|
||||||
|
@ -33,19 +34,19 @@ use crate::{error::SignatureError, verify_json, ReadOnlyDevice};
|
||||||
///
|
///
|
||||||
/// Master keys are used to sign other cross signing keys, the self signing and
|
/// Master keys are used to sign other cross signing keys, the self signing and
|
||||||
/// user signing keys of an user will be signed by their master key.
|
/// user signing keys of an user will be signed by their master key.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct MasterPubkey(Arc<CrossSigningKey>);
|
pub struct MasterPubkey(Arc<CrossSigningKey>);
|
||||||
|
|
||||||
/// Wrapper for a cross signing key marking it as a self signing key.
|
/// Wrapper for a cross signing key marking it as a self signing key.
|
||||||
///
|
///
|
||||||
/// Self signing keys are used to sign the user's own devices.
|
/// Self signing keys are used to sign the user's own devices.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct SelfSigningPubkey(Arc<CrossSigningKey>);
|
pub struct SelfSigningPubkey(Arc<CrossSigningKey>);
|
||||||
|
|
||||||
/// Wrapper for a cross signing key marking it as a user signing key.
|
/// Wrapper for a cross signing key marking it as a user signing key.
|
||||||
///
|
///
|
||||||
/// User signing keys are used to sign the master keys of other users.
|
/// User signing keys are used to sign the master keys of other users.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct UserSigningPubkey(Arc<CrossSigningKey>);
|
pub struct UserSigningPubkey(Arc<CrossSigningKey>);
|
||||||
|
|
||||||
impl PartialEq for MasterPubkey {
|
impl PartialEq for MasterPubkey {
|
||||||
|
@ -233,7 +234,7 @@ impl SelfSigningPubkey {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Enum over the different user identity types we can have.
|
/// Enum over the different user identity types we can have.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub enum UserIdentities {
|
pub enum UserIdentities {
|
||||||
/// Our own user identity.
|
/// Our own user identity.
|
||||||
Own(OwnUserIdentity),
|
Own(OwnUserIdentity),
|
||||||
|
@ -279,7 +280,7 @@ impl PartialEq for UserIdentities {
|
||||||
/// This is the user identity of a user that isn't our own. Other users will
|
/// This is the user identity of a user that isn't our own. Other users will
|
||||||
/// only contain a master key and a self signing key, meaning that only device
|
/// only contain a master key and a self signing key, meaning that only device
|
||||||
/// signatures can be checked with this identity.
|
/// signatures can be checked with this identity.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
pub struct UserIdentity {
|
pub struct UserIdentity {
|
||||||
user_id: Arc<UserId>,
|
user_id: Arc<UserId>,
|
||||||
master_key: MasterPubkey,
|
master_key: MasterPubkey,
|
||||||
|
@ -370,7 +371,7 @@ impl UserIdentity {
|
||||||
///
|
///
|
||||||
/// This identity can verify other identities as well as devices belonging to
|
/// This identity can verify other identities as well as devices belonging to
|
||||||
/// the identity.
|
/// the identity.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
pub struct OwnUserIdentity {
|
pub struct OwnUserIdentity {
|
||||||
user_id: Arc<UserId>,
|
user_id: Arc<UserId>,
|
||||||
master_key: MasterPubkey,
|
master_key: MasterPubkey,
|
||||||
|
|
Loading…
Reference in New Issue