mirror of
https://github.com/element-hq/element-android
synced 2024-12-20 00:13:12 +03:00
crypto: Upload signatures when we confirm a verification as well
This commit is contained in:
parent
3365c10fe3
commit
00d1233512
6 changed files with 54 additions and 18 deletions
|
@ -174,14 +174,20 @@ internal class QrCodeVerification(
|
||||||
*/
|
*/
|
||||||
@Throws(CryptoStoreErrorException::class)
|
@Throws(CryptoStoreErrorException::class)
|
||||||
private suspend fun confirm() {
|
private suspend fun confirm() {
|
||||||
val request = withContext(Dispatchers.IO)
|
val result = withContext(Dispatchers.IO)
|
||||||
{
|
{
|
||||||
machine.confirmVerification(request.otherUser(), request.flowId())
|
machine.confirmVerification(request.otherUser(), request.flowId())
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request != null) {
|
if (result != null) {
|
||||||
this.sender.sendVerificationRequest(request)
|
this.sender.sendVerificationRequest(result.request)
|
||||||
dispatchTxUpdated()
|
dispatchTxUpdated()
|
||||||
|
|
||||||
|
val signatureRequest = result.signatureRequest
|
||||||
|
|
||||||
|
if (signatureRequest != null) {
|
||||||
|
this.sender.sendSignatureUpload(signatureRequest)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -204,12 +204,19 @@ internal class SasVerification(
|
||||||
|
|
||||||
@Throws(CryptoStoreErrorException::class)
|
@Throws(CryptoStoreErrorException::class)
|
||||||
private suspend fun confirm() {
|
private suspend fun confirm() {
|
||||||
val request = withContext(Dispatchers.IO) {
|
val result = withContext(Dispatchers.IO) {
|
||||||
machine.confirmVerification(inner.otherUserId, inner.flowId)
|
machine.confirmVerification(inner.otherUserId, inner.flowId)
|
||||||
}
|
}
|
||||||
if (request != null) {
|
|
||||||
this.sender.sendVerificationRequest(request)
|
if (result != null) {
|
||||||
|
this.sender.sendVerificationRequest(result.request)
|
||||||
dispatchTxUpdated()
|
dispatchTxUpdated()
|
||||||
|
|
||||||
|
val signatureRequest = result.signatureRequest
|
||||||
|
|
||||||
|
if (signatureRequest != null) {
|
||||||
|
this.sender.sendSignatureUpload(signatureRequest)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ pub use responses::{
|
||||||
pub use users::UserIdentity;
|
pub use users::UserIdentity;
|
||||||
pub use verification::{
|
pub use verification::{
|
||||||
CancelInfo, QrCode, RequestVerificationResult, Sas, ScanResult, StartSasResult, Verification,
|
CancelInfo, QrCode, RequestVerificationResult, Sas, ScanResult, StartSasResult, Verification,
|
||||||
VerificationRequest,
|
VerificationRequest, ConfirmVerificationResult,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Callback that will be passed over the FFI to report progress
|
/// Callback that will be passed over the FFI to report progress
|
||||||
|
|
|
@ -38,10 +38,10 @@ use matrix_sdk_crypto::{
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{CryptoStoreError, DecryptionError, SecretImportError, SignatureError},
|
error::{CryptoStoreError, DecryptionError, SecretImportError, SignatureError},
|
||||||
responses::{response_from_string, OutgoingVerificationRequest, OwnedResponse},
|
responses::{response_from_string, OutgoingVerificationRequest, OwnedResponse},
|
||||||
BootstrapCrossSigningResult, CrossSigningKeyExport, CrossSigningStatus, DecryptedEvent, Device,
|
BootstrapCrossSigningResult, ConfirmVerificationResult, CrossSigningKeyExport,
|
||||||
DeviceLists, KeyImportError, KeysImportResult, ProgressListener, QrCode, Request, RequestType,
|
CrossSigningStatus, DecryptedEvent, Device, DeviceLists, KeyImportError, KeysImportResult,
|
||||||
RequestVerificationResult, ScanResult, SignatureUploadRequest, StartSasResult, UserIdentity,
|
ProgressListener, QrCode, Request, RequestType, RequestVerificationResult, ScanResult,
|
||||||
Verification, VerificationRequest,
|
SignatureUploadRequest, StartSasResult, UserIdentity, Verification, VerificationRequest,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A high level state machine that handles E2EE for Matrix.
|
/// A high level state machine that handles E2EE for Matrix.
|
||||||
|
@ -945,18 +945,26 @@ impl OlmMachine {
|
||||||
&self,
|
&self,
|
||||||
user_id: &str,
|
user_id: &str,
|
||||||
flow_id: &str,
|
flow_id: &str,
|
||||||
) -> Result<Option<OutgoingVerificationRequest>, CryptoStoreError> {
|
) -> Result<Option<ConfirmVerificationResult>, CryptoStoreError> {
|
||||||
let user_id = UserId::try_from(user_id)?;
|
let user_id = UserId::try_from(user_id)?;
|
||||||
|
|
||||||
Ok(
|
Ok(
|
||||||
if let Some(verification) = self.inner.get_verification(&user_id, flow_id) {
|
if let Some(verification) = self.inner.get_verification(&user_id, flow_id) {
|
||||||
match verification {
|
match verification {
|
||||||
RustVerification::SasV1(v) => {
|
RustVerification::SasV1(v) => {
|
||||||
// TODO there's a signature upload request here, we'll
|
let (request, signature_request) = self.runtime.block_on(v.confirm())?;
|
||||||
// want to return that one as well.
|
|
||||||
self.runtime.block_on(v.confirm())?.0.map(|r| r.into())
|
request.map(|r| ConfirmVerificationResult {
|
||||||
|
request: r.into(),
|
||||||
|
signature_request: signature_request.map(|s| s.into()),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
RustVerification::QrV1(v) => {
|
||||||
|
v.confirm_scanning().map(|r| ConfirmVerificationResult {
|
||||||
|
request: r.into(),
|
||||||
|
signature_request: None,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
RustVerification::QrV1(v) => v.confirm_scanning().map(|r| r.into()),
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
|
@ -180,6 +180,11 @@ dictionary RequestVerificationResult {
|
||||||
OutgoingVerificationRequest request;
|
OutgoingVerificationRequest request;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dictionary ConfirmVerificationResult {
|
||||||
|
OutgoingVerificationRequest request;
|
||||||
|
SignatureUploadRequest? signature_request;
|
||||||
|
};
|
||||||
|
|
||||||
[Enum]
|
[Enum]
|
||||||
interface Verification {
|
interface Verification {
|
||||||
SasV1(Sas sas);
|
SasV1(Sas sas);
|
||||||
|
@ -296,7 +301,7 @@ interface OlmMachine {
|
||||||
);
|
);
|
||||||
|
|
||||||
[Throws=CryptoStoreError]
|
[Throws=CryptoStoreError]
|
||||||
OutgoingVerificationRequest? confirm_verification([ByRef] string user_id, [ByRef] string flow_id);
|
ConfirmVerificationResult? confirm_verification([ByRef] string user_id, [ByRef] string flow_id);
|
||||||
OutgoingVerificationRequest? cancel_verification(
|
OutgoingVerificationRequest? cancel_verification(
|
||||||
[ByRef] string user_id,
|
[ByRef] string user_id,
|
||||||
[ByRef] string flow_id,
|
[ByRef] string flow_id,
|
||||||
|
|
|
@ -3,7 +3,7 @@ use matrix_sdk_crypto::{
|
||||||
VerificationRequest as InnerVerificationRequest,
|
VerificationRequest as InnerVerificationRequest,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::OutgoingVerificationRequest;
|
use crate::{OutgoingVerificationRequest, SignatureUploadRequest};
|
||||||
|
|
||||||
/// Enum representing the different verification flows we support.
|
/// Enum representing the different verification flows we support.
|
||||||
pub enum Verification {
|
pub enum Verification {
|
||||||
|
@ -165,6 +165,16 @@ pub struct RequestVerificationResult {
|
||||||
pub request: OutgoingVerificationRequest,
|
pub request: OutgoingVerificationRequest,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A result type for confirming verifications.
|
||||||
|
pub struct ConfirmVerificationResult {
|
||||||
|
/// The request that needs to be sent out to notify the other side that we
|
||||||
|
/// confirmed the verification.
|
||||||
|
pub request: OutgoingVerificationRequest,
|
||||||
|
/// A request that will upload signatures of the verified device or user, if
|
||||||
|
/// the verification is completed and we're able to sign devices or users
|
||||||
|
pub signature_request: Option<SignatureUploadRequest>,
|
||||||
|
}
|
||||||
|
|
||||||
/// The verificatoin request object which then can transition into some concrete
|
/// The verificatoin request object which then can transition into some concrete
|
||||||
/// verification method
|
/// verification method
|
||||||
pub struct VerificationRequest {
|
pub struct VerificationRequest {
|
||||||
|
|
Loading…
Reference in a new issue