Skip to content

Commit

Permalink
chore: Upgrade workspace dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
jplatte committed Feb 8, 2023
1 parent e25061f commit efdeba7
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 88 deletions.
111 changes: 82 additions & 29 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ rust-version = "1.65"
anyhow = "1.0.68"
async-stream = "0.3.3"
async-trait = "0.1.60"
base64 = "0.20.0"
base64 = "0.21.0"
byteorder = "1.4.3"
ctor = "0.1.26"
dashmap = "5.2.0"
http = "0.2.6"
ruma = { git = "https://github.com/ruma/ruma", rev = "00045e559f864eabff08295d603f7b3238288b6f", features = ["client-api-c"] }
ruma-common = { git = "https://github.com/ruma/ruma", rev = "00045e559f864eabff08295d603f7b3238288b6f" }
ruma = { version = "0.8.0", features = ["client-api-c"] }
ruma-common = "0.11.2"
once_cell = "1.16.0"
serde = "1.0.151"
serde_html_form = "0.2.0"
Expand Down
13 changes: 7 additions & 6 deletions bindings/matrix-sdk-crypto-ffi/src/verification.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use std::sync::Arc;

use base64::{
alphabet, decode_engine, encode_engine,
engine::fast_portable::{self, FastPortable},
alphabet,
engine::{general_purpose, GeneralPurpose},
Engine,
};
use futures_util::{Stream, StreamExt};
use matrix_sdk_crypto::{
Expand All @@ -16,8 +17,8 @@ use tokio::runtime::Handle;

use crate::{CryptoStoreError, OutgoingVerificationRequest, SignatureUploadRequest};

const STANDARD_NO_PAD: FastPortable =
FastPortable::from(&alphabet::STANDARD, fast_portable::NO_PAD);
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.
Expand Down Expand Up @@ -407,7 +408,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<String> {
self.inner.to_bytes().map(|data| encode_engine(data, &STANDARD_NO_PAD)).ok()
self.inner.to_bytes().map(|data| STANDARD_NO_PAD.encode(data)).ok()
}

/// Set a listener for changes in the QrCode verification process.
Expand Down Expand Up @@ -709,7 +710,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: &str) -> Option<ScanResult> {
let data = decode_engine(data, &STANDARD_NO_PAD).ok()?;
let data = STANDARD_NO_PAD.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()? {
Expand Down
13 changes: 7 additions & 6 deletions crates/matrix-sdk-crypto/src/utilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,23 @@ use std::{

pub use base64::DecodeError;
use base64::{
alphabet, decode_engine, encode_engine,
engine::fast_portable::{self, FastPortable},
alphabet,
engine::{general_purpose, GeneralPurpose},
Engine,
};
use matrix_sdk_common::instant::Instant;

const STANDARD_NO_PAD: FastPortable =
FastPortable::from(&alphabet::STANDARD, fast_portable::NO_PAD);
const STANDARD_NO_PAD: GeneralPurpose =
GeneralPurpose::new(&alphabet::STANDARD, general_purpose::NO_PAD);

/// Decode the input as base64 with no padding.
pub fn decode(input: impl AsRef<[u8]>) -> Result<Vec<u8>, DecodeError> {
decode_engine(input, &STANDARD_NO_PAD)
STANDARD_NO_PAD.decode(input)
}

/// Encode the input as base64 with no padding.
pub fn encode(input: impl AsRef<[u8]>) -> String {
encode_engine(input, &STANDARD_NO_PAD)
STANDARD_NO_PAD.encode(input)
}

#[cfg(test)]
Expand Down
Loading

0 comments on commit efdeba7

Please sign in to comment.