Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(crypto)!: Remove unused OneTimeKey::Key and SessionCreationError::OneTimeKeyUnknown variants #4194

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions crates/matrix-sdk-crypto/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,6 @@ pub enum SessionCreationError {
)]
OneTimeKeyMissing(OwnedUserId, OwnedDeviceId),

/// The one-time key algorithm is unsupported.
#[error(
"Tried to create a new Olm session for {0} {1}, but the one-time \
key algorithm is unsupported"
)]
OneTimeKeyUnknown(OwnedUserId, OwnedDeviceId),

/// Failed to verify the one-time key signatures.
#[error(
"Failed to verify the signature of a one-time key, key: {one_time_key:?}, \
Expand Down
4 changes: 0 additions & 4 deletions crates/matrix-sdk-crypto/src/olm/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -962,10 +962,6 @@ impl Account {

let result = match first_key {
OneTimeKey::SignedKey(key) => Ok(PrekeyBundle::Olm3DH { key }),
_ => Err(SessionCreationError::OneTimeKeyUnknown(
device.user_id().to_owned(),
device.device_id().into(),
)),
};

trace!(?result, "Finished searching for a valid pre-key bundle");
Expand Down
17 changes: 1 addition & 16 deletions crates/matrix-sdk-crypto/src/types/one_time_keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ impl SignedKey {
pub enum OneTimeKey {
/// A signed Curve25519 one-time key.
SignedKey(SignedKey),

/// An unsigned Curve25519 one-time key.
#[serde(serialize_with = "serialize_curve_key")]
Key(Curve25519PublicKey),
}

impl OneTimeKey {
Expand All @@ -121,17 +117,7 @@ impl OneTimeKey {
let key: SignedKey = key.deserialize_as()?;
Ok(OneTimeKey::SignedKey(key))
}
_ => match algorithm.as_str() {
"curve25519" => {
let key: String = key.deserialize_as()?;
Ok(OneTimeKey::Key(
Curve25519PublicKey::from_base64(&key).map_err(serde::de::Error::custom)?,
))
}
_ => {
Err(serde::de::Error::custom(format!("Unsupported key algorithm {algorithm}")))
}
},
_ => Err(serde::de::Error::custom(format!("Unsupported key algorithm {algorithm}"))),
}
}
}
Expand All @@ -141,7 +127,6 @@ impl OneTimeKey {
pub fn fallback(&self) -> bool {
match self {
OneTimeKey::SignedKey(s) => s.fallback(),
OneTimeKey::Key(_) => false,
}
}
}
Expand Down
Loading