Skip to content

Commit 75683d2

Browse files
zecakehpoljar
authored andcommitted
refactor(crypto)!: Remove unused OneTimeKey::Key and SessionCreationError::OneTimeKeyUnknown variants
Signed-off-by: Kévin Commaille <[email protected]>
1 parent 71abbeb commit 75683d2

File tree

3 files changed

+1
-27
lines changed

3 files changed

+1
-27
lines changed

crates/matrix-sdk-crypto/src/error.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,6 @@ pub enum SessionCreationError {
305305
)]
306306
OneTimeKeyMissing(OwnedUserId, OwnedDeviceId),
307307

308-
/// The one-time key algorithm is unsupported.
309-
#[error(
310-
"Tried to create a new Olm session for {0} {1}, but the one-time \
311-
key algorithm is unsupported"
312-
)]
313-
OneTimeKeyUnknown(OwnedUserId, OwnedDeviceId),
314-
315308
/// Failed to verify the one-time key signatures.
316309
#[error(
317310
"Failed to verify the signature of a one-time key, key: {one_time_key:?}, \

crates/matrix-sdk-crypto/src/olm/account.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -962,10 +962,6 @@ impl Account {
962962

963963
let result = match first_key {
964964
OneTimeKey::SignedKey(key) => Ok(PrekeyBundle::Olm3DH { key }),
965-
_ => Err(SessionCreationError::OneTimeKeyUnknown(
966-
device.user_id().to_owned(),
967-
device.device_id().into(),
968-
)),
969965
};
970966

971967
trace!(?result, "Finished searching for a valid pre-key bundle");

crates/matrix-sdk-crypto/src/types/one_time_keys.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,6 @@ impl SignedKey {
103103
pub enum OneTimeKey {
104104
/// A signed Curve25519 one-time key.
105105
SignedKey(SignedKey),
106-
107-
/// An unsigned Curve25519 one-time key.
108-
#[serde(serialize_with = "serialize_curve_key")]
109-
Key(Curve25519PublicKey),
110106
}
111107

112108
impl OneTimeKey {
@@ -121,17 +117,7 @@ impl OneTimeKey {
121117
let key: SignedKey = key.deserialize_as()?;
122118
Ok(OneTimeKey::SignedKey(key))
123119
}
124-
_ => match algorithm.as_str() {
125-
"curve25519" => {
126-
let key: String = key.deserialize_as()?;
127-
Ok(OneTimeKey::Key(
128-
Curve25519PublicKey::from_base64(&key).map_err(serde::de::Error::custom)?,
129-
))
130-
}
131-
_ => {
132-
Err(serde::de::Error::custom(format!("Unsupported key algorithm {algorithm}")))
133-
}
134-
},
120+
_ => Err(serde::de::Error::custom(format!("Unsupported key algorithm {algorithm}"))),
135121
}
136122
}
137123
}
@@ -141,7 +127,6 @@ impl OneTimeKey {
141127
pub fn fallback(&self) -> bool {
142128
match self {
143129
OneTimeKey::SignedKey(s) => s.fallback(),
144-
OneTimeKey::Key(_) => false,
145130
}
146131
}
147132
}

0 commit comments

Comments
 (0)