summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2023-05-16 09:58:58 +0200
committerNeal H. Walfield <neal@pep.foundation>2023-05-16 09:58:58 +0200
commitb69c6bd25a5081d634f69aa36addefd8083f96ef (patch)
tree44abc40aa265f88f3b38211476835a4756637a13
parent461502a06d3743fe8ec5b1d396ded31709816344 (diff)
openpgp: Upgrade base64.
- Upgrade base64 to version 0.21.
-rw-r--r--Cargo.lock12
-rw-r--r--openpgp/Cargo.toml2
-rw-r--r--openpgp/src/armor.rs30
-rw-r--r--openpgp/src/armor/base64_utils.rs5
4 files changed, 30 insertions, 19 deletions
diff --git a/Cargo.lock b/Cargo.lock
index dc283cbe..3a2eff2f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -100,6 +100,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
[[package]]
+name = "base64"
+version = "0.21.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a"
+
+[[package]]
name = "base64ct"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2236,7 +2242,7 @@ dependencies = [
name = "sequoia-autocrypt"
version = "0.25.0"
dependencies = [
- "base64",
+ "base64 0.13.1",
"sequoia-openpgp",
]
@@ -2282,7 +2288,7 @@ name = "sequoia-net"
version = "0.27.0"
dependencies = [
"anyhow",
- "base64",
+ "base64 0.13.1",
"futures-util",
"http",
"hyper",
@@ -2307,7 +2313,7 @@ version = "1.15.0"
dependencies = [
"aes",
"anyhow",
- "base64",
+ "base64 0.21.0",
"block-padding",
"blowfish",
"botan",
diff --git a/openpgp/Cargo.toml b/openpgp/Cargo.toml
index 8a4ce2fa..50fca5ed 100644
--- a/openpgp/Cargo.toml
+++ b/openpgp/Cargo.toml
@@ -29,7 +29,7 @@ maintenance = { status = "actively-developed" }
[dependencies]
anyhow = "1.0.18"
buffered-reader = { path = "../buffered-reader", version = "1.0.0", default-features = false }
-base64 = ">=0.12, <0.20"
+base64 = "0.21"
bzip2 = { version = "0.4", optional = true }
dyn-clone = "1"
flate2 = { version = "1.0.1", optional = true }
diff --git a/openpgp/src/armor.rs b/openpgp/src/armor.rs
index ed19c63a..d88ac3dc 100644
--- a/openpgp/src/armor.rs
+++ b/openpgp/src/armor.rs
@@ -42,6 +42,10 @@ use std::borrow::Cow;
#[cfg(test)]
use quickcheck::{Arbitrary, Gen};
+use base64::Engine;
+use base64::engine::general_purpose::STANDARD as base64std;
+use base64::engine::general_purpose::STANDARD_NO_PAD as base64nopad;
+
use crate::packet::prelude::*;
use crate::packet::header::{BodyLength, CTBNew, CTBOld};
use crate::parse::Cookie;
@@ -377,8 +381,7 @@ impl<W: Write> Writer<W> {
// Write any stashed bytes and pad.
if !self.stash.is_empty() {
- self.sink.write_all(base64::encode_config(
- &self.stash, base64::STANDARD).as_bytes())?;
+ self.sink.write_all(base64std.encode(&self.stash).as_bytes())?;
self.column += 4;
}
@@ -404,7 +407,7 @@ impl<W: Write> Writer<W> {
// CRC and footer.
write!(self.sink, "={}{}{}{}",
- base64::encode_config(&bytes, base64::STANDARD_NO_PAD),
+ base64nopad.encode(&bytes),
LINE_ENDING, self.kind.end(), LINE_ENDING)?;
self.dirty = false;
@@ -454,8 +457,7 @@ impl<W: Write> Write for Writer<W> {
// If this fails for some reason, and the caller retries
// the write, we might end up with a stash of size 3.
self.sink
- .write_all(base64::encode_config(
- &self.stash, base64::STANDARD_NO_PAD).as_bytes())?;
+ .write_all(base64nopad.encode(&self.stash).as_bytes())?;
self.column += 4;
self.linebreak()?;
crate::vec_truncate(&mut self.stash, 0);
@@ -472,9 +474,9 @@ impl<W: Write> Write for Writer<W> {
}
written += input_bytes;
- base64::encode_config_slice(&input[..input_bytes],
- base64::STANDARD_NO_PAD,
- &mut self.scratch[..encoded_bytes]);
+ base64nopad.encode_slice(&input[..input_bytes],
+ &mut self.scratch[..encoded_bytes])
+ .expect("buffer correctly sized");
let mut n = 0;
while ! self.scratch[n..encoded_bytes].is_empty() {
@@ -846,12 +848,14 @@ impl<'a> Reader<'a> {
let mut o = [ 0u8; 4 ];
CTBNew::new(tag).serialize_into(&mut ctb[..]).unwrap();
- base64::encode_config_slice(&ctb[..], base64::STANDARD, &mut o[..]);
+ base64std.encode_slice(&ctb[..], &mut o[..])
+ .expect("buffer correctly sized");
valid_start.push(o[0]);
CTBOld::new(tag, BodyLength::Full(0)).unwrap()
.serialize_into(&mut ctb[..]).unwrap();
- base64::encode_config_slice(&ctb[..], base64::STANDARD, &mut o[..]);
+ base64std.encode_slice(&ctb[..], &mut o[..])
+ .expect("buffer correctly sized");
valid_start.push(o[0]);
}
@@ -1241,8 +1245,7 @@ impl<'a> Reader<'a> {
// (Note: the computed size *might* be a slight
// overestimate, because the last base64 chunk may
// include padding.)
- self.decode_buffer = base64::decode_config(
- &base64data, base64::STANDARD)
+ self.decode_buffer = base64std.decode(&base64data)
.map_err(|e| Error::new(ErrorKind::InvalidData, e))?;
let copied = cmp::min(buf.len(), self.decode_buffer.len());
@@ -1253,8 +1256,7 @@ impl<'a> Reader<'a> {
} else {
// We can decode directly into the caller-supplied
// buffer.
- base64::decode_config_slice(
- &base64data, base64::STANDARD, buf)
+ base64std.decode_slice(&base64data, buf)
.map_err(|e| Error::new(ErrorKind::InvalidData, e))?
};
diff --git a/openpgp/src/armor/base64_utils.rs b/openpgp/src/armor/base64_utils.rs
index 1b6f97aa..ee24e178 100644
--- a/openpgp/src/armor/base64_utils.rs
+++ b/openpgp/src/armor/base64_utils.rs
@@ -2,6 +2,9 @@ use std::{
borrow::Cow,
};
+use base64::Engine;
+use base64::engine::general_purpose::STANDARD as base64std;
+
use crate::{
packet::Header,
};
@@ -163,7 +166,7 @@ pub fn is_armored_pgp_blob(bytes: &[u8]) -> bool {
// packet's header.
let (bytes, _, _) = base64_filter(Cow::Borrowed(bytes), 32, 0, 0);
- match base64::decode_config(&bytes, base64::STANDARD) {
+ match base64std.decode(bytes) {
Ok(d) => {
// Don't consider an empty message to be valid.
if d.is_empty() {