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

master
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; continue;
}; };
let one_time_key = if let Some(k) = key_map.get(&AlgorithmAndDeviceId( let one_time_key = if let Some(k) = key_map.values().nth(0) {
KeyAlgorithm::SignedCurve25519,
device_id.to_owned(),
)) {
match k { match k {
OneTimeKey::SignedKey(k) => k, OneTimeKey::SignedKey(k) => k,
OneTimeKey::Key(_) => { OneTimeKey::Key(_) => {
@ -268,7 +265,7 @@ impl OlmMachine {
.account .account
.lock() .lock()
.await .await
.create_outbound_session(&one_time_key.key, curve_key) .create_outbound_session(curve_key, &one_time_key)
{ {
Ok(s) => s, Ok(s) => s,
Err(e) => { 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::session::{OlmMessage, OlmSession, PreKeyMessage};
use olm_rs::PicklingMode; use olm_rs::PicklingMode;
use ruma_client_api::r0::keys::SignedKey;
pub struct Account { pub struct Account {
inner: OlmAccount, inner: OlmAccount,
pub(crate) shared: bool, pub(crate) shared: bool,
@ -106,11 +108,11 @@ impl Account {
pub fn create_outbound_session( pub fn create_outbound_session(
&self, &self,
their_identity_key: &str, their_identity_key: &str,
their_one_time_key: &str, their_one_time_key: &SignedKey,
) -> Result<Session, OlmSessionError> { ) -> Result<Session, OlmSessionError> {
let session = self let session = self
.inner .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(); let now = Instant::now();