diff --git a/Cargo.lock b/Cargo.lock index 3cd4947ba..9be6bf3cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3195,7 +3195,6 @@ version = "0.1.0" dependencies = [ "anyhow", "assert_matches", - "base64 0.21.2", "futures-util", "hmac", "http", diff --git a/bindings/matrix-sdk-crypto-ffi/Cargo.toml b/bindings/matrix-sdk-crypto-ffi/Cargo.toml index e11aae441..d9e0c28cf 100644 --- a/bindings/matrix-sdk-crypto-ffi/Cargo.toml +++ b/bindings/matrix-sdk-crypto-ffi/Cargo.toml @@ -18,7 +18,6 @@ bundled-sqlite = ["matrix-sdk-sqlite/bundled"] [dependencies] anyhow = { workspace = true } -base64 = { workspace = true } futures-util = "0.3.25" hmac = "0.12.1" http = { workspace = true } diff --git a/bindings/matrix-sdk-crypto-ffi/src/verification.rs b/bindings/matrix-sdk-crypto-ffi/src/verification.rs index 552f1d814..011231301 100644 --- a/bindings/matrix-sdk-crypto-ffi/src/verification.rs +++ b/bindings/matrix-sdk-crypto-ffi/src/verification.rs @@ -1,10 +1,5 @@ use std::sync::Arc; -use base64::{ - alphabet, - engine::{general_purpose, GeneralPurpose}, - Engine, -}; use futures_util::{Stream, StreamExt}; use matrix_sdk_crypto::{ matrix_sdk_qrcode::QrVerificationData, CancelInfo as RustCancelInfo, QrVerification as InnerQr, @@ -14,12 +9,10 @@ use matrix_sdk_crypto::{ }; use ruma::events::key::verification::VerificationMethod; use tokio::runtime::Handle; +use vodozemac::{base64_decode, base64_encode}; use crate::{CryptoStoreError, OutgoingVerificationRequest, SignatureUploadRequest}; -const STANDARD_NO_PAD: GeneralPurpose = - GeneralPurpose::new(&alphabet::STANDARD, general_purpose::NO_PAD); - /// Listener that will be passed over the FFI to report changes to a SAS /// verification. #[uniffi::export(callback_interface)] @@ -420,7 +413,7 @@ impl QrCode { /// decoded on the other side before it can be put through a QR code /// generator. pub fn generate_qr_code(&self) -> Option { - self.inner.to_bytes().map(|data| STANDARD_NO_PAD.encode(data)).ok() + self.inner.to_bytes().map(base64_encode).ok() } /// Set a listener for changes in the QrCode verification process. @@ -713,7 +706,7 @@ impl VerificationRequest { /// * `data` - The data that was extracted from the scanned QR code as an /// base64 encoded string, without padding. pub fn scan_qr_code(&self, data: String) -> Option { - let data = STANDARD_NO_PAD.decode(data).ok()?; + let data = base64_decode(data).ok()?; let data = QrVerificationData::from_bytes(data).ok()?; if let Some(qr) = self.runtime.block_on(self.inner.scan_qr_code(data)).ok()? {