From d8ab6e373ec32ac8c7c35021c237f3878a6d2241 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Fri, 30 Dec 2022 05:01:24 +0000 Subject: [PATCH] base64 0.20 --- Cargo.lock | 14 ++++++++++---- Cargo.toml | 2 +- src/format.rs | 14 +++++++++++--- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b19c6cf..154573a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -24,7 +24,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3d2e815ac879dc23c1139e720d21c6cd4d1276345c772587285d965a69b8f32" dependencies = [ - "base64", + "base64 0.13.1", "chacha20poly1305", "cookie-factory", "hkdf", @@ -43,7 +43,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4564b93d746fc5947e08ee2b9b3f990df89133803857b6ee0dad8b0efeb8bc79" dependencies = [ "age-core", - "base64", + "base64 0.13.1", "bech32", "chrono", ] @@ -54,7 +54,7 @@ version = "0.3.2" dependencies = [ "age-core", "age-plugin", - "base64", + "base64 0.20.0", "bech32", "console", "dialoguer", @@ -154,6 +154,12 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +[[package]] +name = "base64" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea22880d78093b0cbe17c89f64a7d457941e65759157ec6cb31a31d652b05e5" + [[package]] name = "base64ct" version = "1.5.3" @@ -2103,7 +2109,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0ecbeb7b67ce215e40e3cc7f2ff902f94a223acf44995934763467e7b1febc8" dependencies = [ "asn1-rs", - "base64", + "base64 0.13.1", "data-encoding", "der-parser", "lazy_static", diff --git a/Cargo.toml b/Cargo.toml index b2071b1..d30d230 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ assets = [ [dependencies] age-core = "0.9" age-plugin = "0.4" -base64 = "0.13" +base64 = "0.20" bech32 = "0.9" console = { version = "0.15", default-features = false } dialoguer = { version = "0.9", default-features = false, features = ["password"] } diff --git a/src/format.rs b/src/format.rs index d55e9f6..d9c0bd2 100644 --- a/src/format.rs +++ b/src/format.rs @@ -18,6 +18,14 @@ const TAG_BYTES: usize = 4; const EPK_BYTES: usize = 33; const ENCRYPTED_FILE_KEY_BYTES: usize = 32; +const STANDARD_NO_PAD: &base64::engine::fast_portable::FastPortable = { + use base64::{ + alphabet::STANDARD, + engine::fast_portable::{FastPortable, NO_PAD}, + }; + &FastPortable::from(&STANDARD, NO_PAD) +}; + /// The ephemeral key bytes in a piv-p256 stanza. /// /// The bytes contain a compressed SEC-1 encoding of a valid point. @@ -65,8 +73,8 @@ impl From for Stanza { Stanza { tag: STANZA_TAG.to_owned(), args: vec![ - base64::encode_config(&r.tag, base64::STANDARD_NO_PAD), - base64::encode_config(r.epk_bytes.as_bytes(), base64::STANDARD_NO_PAD), + base64::encode_engine(&r.tag, STANDARD_NO_PAD), + base64::encode_engine(r.epk_bytes.as_bytes(), STANDARD_NO_PAD), ], body: r.encrypted_file_key.to_vec(), } @@ -84,7 +92,7 @@ impl RecipientLine { return None; } - base64::decode_config_slice(arg, base64::STANDARD_NO_PAD, buf.as_mut()) + base64::decode_engine_slice(arg, buf.as_mut(), STANDARD_NO_PAD) .ok() .map(|_| buf) }