crypto: Allow user identities to be seralized/deserialized.

master
Damir Jelić 2020-09-02 11:54:04 +02:00
parent 4bab678e46
commit c652762255
1 changed files with 7 additions and 6 deletions

View File

@ -20,6 +20,7 @@ use std::{
},
};
use serde::{Deserialize, Serialize};
use serde_json::to_value;
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
/// 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>);
/// 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.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SelfSigningPubkey(Arc<CrossSigningKey>);
/// 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.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserSigningPubkey(Arc<CrossSigningKey>);
impl PartialEq for MasterPubkey {
@ -233,7 +234,7 @@ impl SelfSigningPubkey {
}
/// Enum over the different user identity types we can have.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum UserIdentities {
/// Our own user identity.
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
/// only contain a master key and a self signing key, meaning that only device
/// signatures can be checked with this identity.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct UserIdentity {
user_id: Arc<UserId>,
master_key: MasterPubkey,
@ -370,7 +371,7 @@ impl UserIdentity {
///
/// This identity can verify other identities as well as devices belonging to
/// the identity.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct OwnUserIdentity {
user_id: Arc<UserId>,
master_key: MasterPubkey,