crypto: Use a SignedKey type when creating outbound Olm sessions.

This commit is contained in:
Damir Jelić 2020-04-03 10:16:20 +02:00
parent aa7bedbefd
commit ff9bcdddb9
2 changed files with 6 additions and 7 deletions

View file

@ -205,10 +205,7 @@ impl OlmMachine {
continue;
};
let one_time_key = if let Some(k) = key_map.get(&AlgorithmAndDeviceId(
KeyAlgorithm::SignedCurve25519,
device_id.to_owned(),
)) {
let one_time_key = if let Some(k) = key_map.values().nth(0) {
match k {
OneTimeKey::SignedKey(k) => k,
OneTimeKey::Key(_) => {
@ -268,7 +265,7 @@ impl OlmMachine {
.account
.lock()
.await
.create_outbound_session(&one_time_key.key, curve_key)
.create_outbound_session(curve_key, &one_time_key)
{
Ok(s) => s,
Err(e) => {

View file

@ -21,6 +21,8 @@ use olm_rs::inbound_group_session::OlmInboundGroupSession;
use olm_rs::session::{OlmMessage, OlmSession, PreKeyMessage};
use olm_rs::PicklingMode;
use ruma_client_api::r0::keys::SignedKey;
pub struct Account {
inner: OlmAccount,
pub(crate) shared: bool,
@ -106,11 +108,11 @@ impl Account {
pub fn create_outbound_session(
&self,
their_identity_key: &str,
their_one_time_key: &str,
their_one_time_key: &SignedKey,
) -> Result<Session, OlmSessionError> {
let session = self
.inner
.create_outbound_session(their_identity_key, their_one_time_key)?;
.create_outbound_session(their_identity_key, &their_one_time_key.key)?;
let now = Instant::now();