mirror of
https://github.com/mailscope/kumomta.git
synced 2026-09-06 10:38:56 +00:00
deps: base64 -> data_encoding
dependabot wanted to upgrade to base64 0.21, but I resent that the API for the common case of base64 encoding got more difficult in the move from 0.13. So, I'm switching us to data_encoding's implementation instead. Note that the overall rust ecosystem on which we depend here, transitively depends on 3 different versions of the base64 crate, so even though we've removed direct deps on base64 from kumomta, the lock file still references base64 0.10, 0.13 and 0.21, so that kinda sucks.
This commit is contained in:
Generated
+5
-6
@@ -2470,9 +2470,9 @@ dependencies = [
|
||||
name = "kumo-dkim"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"base64 0.21.7",
|
||||
"chrono",
|
||||
"criterion",
|
||||
"data-encoding",
|
||||
"ed25519-dalek",
|
||||
"foreign-types",
|
||||
"futures",
|
||||
@@ -2500,9 +2500,9 @@ name = "kumo-log-types"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"base64 0.13.1",
|
||||
"bounce-classify",
|
||||
"chrono",
|
||||
"data-encoding",
|
||||
"k9",
|
||||
"mailparsing",
|
||||
"rfc5321",
|
||||
@@ -2520,11 +2520,11 @@ dependencies = [
|
||||
"axum-client-ip",
|
||||
"axum-server",
|
||||
"backtrace",
|
||||
"base64 0.13.1",
|
||||
"cidr-map",
|
||||
"clap 4.4.18",
|
||||
"config",
|
||||
"console-subscriber",
|
||||
"data-encoding",
|
||||
"data-loader",
|
||||
"domain-map",
|
||||
"gethostname",
|
||||
@@ -2620,13 +2620,13 @@ dependencies = [
|
||||
"axum",
|
||||
"axum-client-ip",
|
||||
"axum-server",
|
||||
"base64 0.13.1",
|
||||
"bounce-classify",
|
||||
"caps",
|
||||
"chrono",
|
||||
"cidr-map",
|
||||
"clap 4.4.18",
|
||||
"config",
|
||||
"data-encoding",
|
||||
"data-loader",
|
||||
"dns-resolver",
|
||||
"duration-serde",
|
||||
@@ -3065,7 +3065,6 @@ name = "message"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"base64 0.13.1",
|
||||
"bitflags 2.4.2",
|
||||
"chrono",
|
||||
"chrono-tz",
|
||||
@@ -4580,7 +4579,7 @@ dependencies = [
|
||||
name = "rfc5321"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"base64 0.13.1",
|
||||
"data-encoding",
|
||||
"duration-serde",
|
||||
"hickory-proto",
|
||||
"memchr",
|
||||
|
||||
@@ -15,8 +15,8 @@ openssl = ["dep:openssl", "dep:openssl-sys", "dep:foreign-types"]
|
||||
default = ["openssl"]
|
||||
|
||||
[dependencies]
|
||||
base64 = "0.21.0"
|
||||
chrono = { version = "0.4.26", default-features = false, features = ["clock", "std"] }
|
||||
data-encoding = "2.5"
|
||||
ed25519-dalek = {workspace=true, features=["pkcs8"]}
|
||||
futures = {workspace=true}
|
||||
indexmap = "1.9.3"
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use crate::header::HEADER;
|
||||
use crate::{canonicalization, DKIMError, DKIMHeader, ParsedEmail};
|
||||
use base64::engine::general_purpose;
|
||||
use base64::Engine;
|
||||
use data_encoding::BASE64;
|
||||
use sha1::{Digest as _, Sha1};
|
||||
use sha2::Sha256;
|
||||
use std::collections::HashMap;
|
||||
@@ -78,8 +77,8 @@ impl HashImpl {
|
||||
|
||||
pub fn finalize(self) -> String {
|
||||
match self {
|
||||
Self::Sha1(hasher) => general_purpose::STANDARD.encode(hasher.finalize()),
|
||||
Self::Sha256(hasher) => general_purpose::STANDARD.encode(hasher.finalize()),
|
||||
Self::Sha1(hasher) => BASE64.encode(&hasher.finalize()),
|
||||
Self::Sha256(hasher) => BASE64.encode(&hasher.finalize()),
|
||||
#[cfg(test)]
|
||||
Self::Copy(data) => String::from_utf8_lossy(&data).into(),
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
use crate::errors::Status;
|
||||
use crate::hash::HeaderList;
|
||||
use base64::engine::general_purpose;
|
||||
use base64::Engine;
|
||||
use ed25519_dalek::SigningKey;
|
||||
use hickory_resolver::TokioAsyncResolver;
|
||||
use mailparsing::AuthenticationResult;
|
||||
@@ -210,8 +208,8 @@ async fn verify_email_header<'a>(
|
||||
return Err(DKIMError::BodyHashDidNotVerify);
|
||||
}
|
||||
|
||||
let signature = general_purpose::STANDARD
|
||||
.decode(dkim_header.get_required_tag("b"))
|
||||
let signature = data_encoding::BASE64
|
||||
.decode(dkim_header.get_required_tag("b").as_bytes())
|
||||
.map_err(|err| {
|
||||
DKIMError::SignatureSyntaxError(format!("failed to decode signature: {}", err))
|
||||
})?;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
use base64::engine::general_purpose;
|
||||
use base64::Engine;
|
||||
use rsa::{pkcs1, pkcs8};
|
||||
use std::collections::HashMap;
|
||||
|
||||
@@ -51,8 +49,8 @@ pub(crate) async fn retrieve_public_key(
|
||||
};
|
||||
|
||||
let tag = tags_map.get("p").ok_or(DKIMError::NoKeyForSignature)?;
|
||||
let bytes = general_purpose::STANDARD
|
||||
.decode(&tag.value)
|
||||
let bytes = data_encoding::BASE64
|
||||
.decode(tag.value.as_bytes())
|
||||
.map_err(|err| {
|
||||
DKIMError::KeyUnavailable(format!("failed to decode public key: {}", err))
|
||||
})?;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use crate::header::DKIMHeaderBuilder;
|
||||
use crate::{canonicalization, hash, DKIMError, DkimPrivateKey, HeaderList, ParsedEmail, HEADER};
|
||||
use base64::engine::general_purpose;
|
||||
use base64::Engine;
|
||||
use data_encoding::BASE64;
|
||||
use ed25519_dalek::Signer as _;
|
||||
use rsa::Pkcs1v15Sign;
|
||||
use sha1::Sha1;
|
||||
@@ -243,7 +242,7 @@ impl Signer {
|
||||
|
||||
// add the signature into the DKIM header and generate the header
|
||||
let dkim_header = dkim_header_builder
|
||||
.add_tag("b", &general_purpose::STANDARD.encode(signature))
|
||||
.add_tag("b", &BASE64.encode(&signature))
|
||||
.build();
|
||||
|
||||
Ok(format!("{}: {}", HEADER, dkim_header.raw_bytes))
|
||||
@@ -461,7 +460,7 @@ Joe."#
|
||||
let email = ParsedEmail::parse(raw_email).unwrap();
|
||||
|
||||
let file_content = fs::read("./test/keys/ed.private").unwrap();
|
||||
let file_decoded = general_purpose::STANDARD.decode(file_content).unwrap();
|
||||
let file_decoded = BASE64.decode(&file_content).unwrap();
|
||||
let mut key_bytes = [0u8; ed25519_dalek::SECRET_KEY_LENGTH];
|
||||
key_bytes.copy_from_slice(&file_decoded);
|
||||
let secret_key = ed25519_dalek::SigningKey::from_bytes(&key_bytes);
|
||||
|
||||
@@ -7,9 +7,9 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0"
|
||||
base64 = "0.13"
|
||||
bounce-classify = {path="../bounce-classify"}
|
||||
chrono = {version="0.4", default-features=false, features=["serde", "std"]}
|
||||
data-encoding = "2.5"
|
||||
mailparsing = {path="../mailparsing"}
|
||||
rfc5321 = {path="../rfc5321", default-features=false}
|
||||
serde = {version="1.0", features=["derive"]}
|
||||
|
||||
@@ -73,7 +73,9 @@ impl ARFReport {
|
||||
if !(hdr.get_name().starts_with("X-") || hdr.get_name().starts_with("x-")) {
|
||||
continue;
|
||||
}
|
||||
if let Ok(decoded) = base64::decode(hdr.get_raw_value()) {
|
||||
if let Ok(decoded) =
|
||||
data_encoding::BASE64.decode(hdr.get_raw_value().as_bytes())
|
||||
{
|
||||
#[derive(Deserialize)]
|
||||
struct Wrap {
|
||||
#[serde(rename = "_@_")]
|
||||
|
||||
@@ -11,11 +11,11 @@ axum = {workspace=true}
|
||||
axum-client-ip = "0.4"
|
||||
axum-server = {workspace=true, features=["tls-rustls"]}
|
||||
backtrace = "0.3"
|
||||
base64 = "0.13"
|
||||
cidr-map = {path="../cidr-map"}
|
||||
clap = {version="4.1", features=["derive"]}
|
||||
config = {path="../config"}
|
||||
console-subscriber = "0.1"
|
||||
data-encoding = "2.5"
|
||||
data-loader = {path="../data-loader"}
|
||||
domain-map = {path="../domain-map"}
|
||||
gethostname = "0.4"
|
||||
|
||||
@@ -28,7 +28,7 @@ impl AuthKind {
|
||||
let (kind, contents) = authorization.split_once(' ')?;
|
||||
match kind {
|
||||
"Basic" => {
|
||||
let decoded = base64::decode(contents).ok()?;
|
||||
let decoded = data_encoding::BASE64.decode(contents.as_bytes()).ok()?;
|
||||
let decoded = String::from_utf8(decoded).ok()?;
|
||||
let (user, password) = if let Some((id, password)) = decoded.split_once(':') {
|
||||
(id.to_string(), Some(password.to_string()))
|
||||
|
||||
@@ -13,12 +13,12 @@ async-trait = "0.1"
|
||||
axum = {workspace=true, features=["ws"]}
|
||||
axum-client-ip = "=0.4"
|
||||
axum-server = {workspace=true, features=["tls-rustls"]}
|
||||
base64 = "0.13"
|
||||
bounce-classify = {path="../bounce-classify"}
|
||||
chrono = {version="0.4", default-features=false, features=["serde"]}
|
||||
cidr-map = {path="../cidr-map"}
|
||||
clap = {version="4.1", features=["derive"]}
|
||||
config = {path="../config"}
|
||||
data-encoding = "2.5"
|
||||
data-loader = {path="../data-loader"}
|
||||
dns-resolver = {path="../dns-resolver", features=["unbound"]}
|
||||
duration-serde = {path="../duration-serde"}
|
||||
|
||||
@@ -418,7 +418,7 @@ impl InjectV1Request {
|
||||
let part = MimePart::new_binary(
|
||||
&a.content_type,
|
||||
if a.base64 {
|
||||
decoded_data = base64::decode(&a.data)?;
|
||||
decoded_data = data_encoding::BASE64.decode(a.data.as_bytes())?;
|
||||
&decoded_data
|
||||
} else {
|
||||
a.data.as_bytes()
|
||||
|
||||
@@ -8,6 +8,7 @@ use anyhow::{anyhow, Context};
|
||||
use chrono::Utc;
|
||||
use cidr_map::{AnyIpCidr, CidrSet};
|
||||
use config::{any_err, load_config, serialize_options, CallbackSignature, LuaConfig};
|
||||
use data_encoding::BASE64;
|
||||
use data_loader::KeySource;
|
||||
use kumo_log_types::ResolvedAddress;
|
||||
use kumo_server_lifecycle::{Activity, ShutdownSubcription};
|
||||
@@ -1028,7 +1029,7 @@ impl SmtpServer {
|
||||
continue;
|
||||
}
|
||||
|
||||
match base64::decode(&response) {
|
||||
match BASE64.decode(response.as_bytes()) {
|
||||
Ok(payload) => {
|
||||
// RFC 4616 says that the message is:
|
||||
// [authzid] NUL authcid NUL passwd
|
||||
@@ -1432,7 +1433,7 @@ impl SmtpServer {
|
||||
}
|
||||
}
|
||||
|
||||
let value = base64::encode(serde_json::to_string(&object)?);
|
||||
let value = BASE64.encode(serde_json::to_string(&object)?.as_bytes());
|
||||
message.prepend_header(Some(&self.params.trace_headers.header_name), &value);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ impl = ["dep:kumo-dkim", "dep:data-loader", "data-loader/impl", "dep:lruttl", "d
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0"
|
||||
base64 = "0.13"
|
||||
bitflags = "2.3"
|
||||
kumo-dkim = {path="../dkim", optional=true}
|
||||
config = {path="../config"}
|
||||
|
||||
@@ -10,7 +10,7 @@ default = ["client"]
|
||||
client = ["dep:openssl", "dep:tokio-rustls", "dep:tokio-openssl", "dep:tracing", "dep:tokio", "dep:hickory-proto", "dep:webpki-roots"]
|
||||
|
||||
[dependencies]
|
||||
base64 = "0.13"
|
||||
data-encoding = "2.5"
|
||||
duration-serde = {path="../duration-serde"}
|
||||
memchr = "2.5"
|
||||
once_cell = "1.17"
|
||||
|
||||
@@ -367,7 +367,7 @@ impl SmtpClient {
|
||||
// [authzid] NUL authcid NUL passwd
|
||||
let password = password.unwrap_or("");
|
||||
let payload = format!("\x00{username}\x00{password}");
|
||||
let payload = base64::encode(&payload);
|
||||
let payload = data_encoding::BASE64.encode(payload.as_bytes());
|
||||
|
||||
let response = self
|
||||
.send_command(&Command::Auth {
|
||||
|
||||
Reference in New Issue
Block a user