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)
|
||||
private suspend fun confirm() {
|
||||
val request = withContext(Dispatchers.IO)
|
||||
val result = withContext(Dispatchers.IO)
|
||||
{
|
||||
machine.confirmVerification(request.otherUser(), request.flowId())
|
||||
}
|
||||
|
||||
if (request != null) {
|
||||
this.sender.sendVerificationRequest(request)
|
||||
if (result != null) {
|
||||
this.sender.sendVerificationRequest(result.request)
|
||||
dispatchTxUpdated()
|
||||
|
||||
val signatureRequest = result.signatureRequest
|
||||
|
||||
if (signatureRequest != null) {
|
||||
this.sender.sendSignatureUpload(signatureRequest)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -204,12 +204,19 @@ internal class SasVerification(
|
|||
|
||||
@Throws(CryptoStoreErrorException::class)
|
||||
private suspend fun confirm() {
|
||||
val request = withContext(Dispatchers.IO) {
|
||||
val result = withContext(Dispatchers.IO) {
|
||||
machine.confirmVerification(inner.otherUserId, inner.flowId)
|
||||
}
|
||||
if (request != null) {
|
||||
this.sender.sendVerificationRequest(request)
|
||||
|
||||
if (result != null) {
|
||||
this.sender.sendVerificationRequest(result.request)
|
||||
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 verification::{
|
||||
CancelInfo, QrCode, RequestVerificationResult, Sas, ScanResult, StartSasResult, Verification,
|
||||
VerificationRequest,
|
||||
VerificationRequest, ConfirmVerificationResult,
|
||||
};
|
||||
|
||||
/// Callback that will be passed over the FFI to report progress
|
||||
|
|
|
@ -38,10 +38,10 @@ use matrix_sdk_crypto::{
|
|||
use crate::{
|
||||
error::{CryptoStoreError, DecryptionError, SecretImportError, SignatureError},
|
||||
responses::{response_from_string, OutgoingVerificationRequest, OwnedResponse},
|
||||
BootstrapCrossSigningResult, CrossSigningKeyExport, CrossSigningStatus, DecryptedEvent, Device,
|
||||
DeviceLists, KeyImportError, KeysImportResult, ProgressListener, QrCode, Request, RequestType,
|
||||
RequestVerificationResult, ScanResult, SignatureUploadRequest, StartSasResult, UserIdentity,
|
||||
Verification, VerificationRequest,
|
||||
BootstrapCrossSigningResult, ConfirmVerificationResult, CrossSigningKeyExport,
|
||||
CrossSigningStatus, DecryptedEvent, Device, DeviceLists, KeyImportError, KeysImportResult,
|
||||
ProgressListener, QrCode, Request, RequestType, RequestVerificationResult, ScanResult,
|
||||
SignatureUploadRequest, StartSasResult, UserIdentity, Verification, VerificationRequest,
|
||||
};
|
||||
|
||||
/// A high level state machine that handles E2EE for Matrix.
|
||||
|
@ -945,18 +945,26 @@ impl OlmMachine {
|
|||
&self,
|
||||
user_id: &str,
|
||||
flow_id: &str,
|
||||
) -> Result<Option<OutgoingVerificationRequest>, CryptoStoreError> {
|
||||
) -> Result<Option<ConfirmVerificationResult>, CryptoStoreError> {
|
||||
let user_id = UserId::try_from(user_id)?;
|
||||
|
||||
Ok(
|
||||
if let Some(verification) = self.inner.get_verification(&user_id, flow_id) {
|
||||
match verification {
|
||||
RustVerification::SasV1(v) => {
|
||||
// TODO there's a signature upload request here, we'll
|
||||
// want to return that one as well.
|
||||
self.runtime.block_on(v.confirm())?.0.map(|r| r.into())
|
||||
let (request, signature_request) = self.runtime.block_on(v.confirm())?;
|
||||
|
||||
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 {
|
||||
None
|
||||
|
|
|
@ -180,6 +180,11 @@ dictionary RequestVerificationResult {
|
|||
OutgoingVerificationRequest request;
|
||||
};
|
||||
|
||||
dictionary ConfirmVerificationResult {
|
||||
OutgoingVerificationRequest request;
|
||||
SignatureUploadRequest? signature_request;
|
||||
};
|
||||
|
||||
[Enum]
|
||||
interface Verification {
|
||||
SasV1(Sas sas);
|
||||
|
@ -296,7 +301,7 @@ interface OlmMachine {
|
|||
);
|
||||
|
||||
[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(
|
||||
[ByRef] string user_id,
|
||||
[ByRef] string flow_id,
|
||||
|
|
|
@ -3,7 +3,7 @@ use matrix_sdk_crypto::{
|
|||
VerificationRequest as InnerVerificationRequest,
|
||||
};
|
||||
|
||||
use crate::OutgoingVerificationRequest;
|
||||
use crate::{OutgoingVerificationRequest, SignatureUploadRequest};
|
||||
|
||||
/// Enum representing the different verification flows we support.
|
||||
pub enum Verification {
|
||||
|
@ -165,6 +165,16 @@ pub struct RequestVerificationResult {
|
|||
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
|
||||
/// verification method
|
||||
pub struct VerificationRequest {
|
||||
|
|
Loading…
Reference in a new issue