changed base64 encoding to hex
This commit is contained in:
Generated
+22
-12
@@ -1261,9 +1261,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "deranged"
|
||||
version = "0.3.7"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7684a49fb1af197853ef7b2ee694bc1f5b4179556f1e5710e1760c5db6f5e929"
|
||||
checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3"
|
||||
dependencies = [
|
||||
"powerfmt",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derivative"
|
||||
@@ -4138,6 +4141,12 @@ dependencies = [
|
||||
"universal-hash",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "powerfmt"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.17"
|
||||
@@ -4812,9 +4821,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.183"
|
||||
version = "1.0.192"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c"
|
||||
checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
@@ -4839,9 +4848,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.183"
|
||||
version = "1.0.192"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816"
|
||||
checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -5742,14 +5751,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.3.25"
|
||||
version = "0.3.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b0fdd63d58b18d663fbdf70e049f00a22c8e42be082203be7f26589213cd75ea"
|
||||
checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5"
|
||||
dependencies = [
|
||||
"deranged",
|
||||
"itoa 1.0.9",
|
||||
"libc",
|
||||
"num_threads",
|
||||
"powerfmt",
|
||||
"serde",
|
||||
"time-core",
|
||||
"time-macros",
|
||||
@@ -5757,15 +5767,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "time-core"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb"
|
||||
checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3"
|
||||
|
||||
[[package]]
|
||||
name = "time-macros"
|
||||
version = "0.2.11"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eb71511c991639bb078fd5bf97757e03914361c48100d52878b8e52b46fb92cd"
|
||||
checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20"
|
||||
dependencies = [
|
||||
"time-core",
|
||||
]
|
||||
|
||||
@@ -12,12 +12,12 @@ license.workspace = true
|
||||
|
||||
[dependencies]
|
||||
anyhow = { workspace = true }
|
||||
base64 = "0.21.5"
|
||||
bytes = { version = "1.5.0", features = ["std"]}
|
||||
clap = { workspace = true, features = ["derive"] }
|
||||
dotenvy = { workspace = true }
|
||||
flate2 = "1.0.28"
|
||||
futures = { workspace = true }
|
||||
hex = "0.4.3"
|
||||
humantime = "2.1.0"
|
||||
humantime-serde = "1.1.1"
|
||||
lazy_static = { workspace = true }
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::error::NymvisorError;
|
||||
use base64::{engine::general_purpose::STANDARD, Engine as _};
|
||||
use sha2::Digest;
|
||||
use std::fs::File;
|
||||
use std::io::{BufReader, Read};
|
||||
@@ -39,6 +38,6 @@ pub fn calculate_file_checksum<D: Digest, P: AsRef<Path>>(
|
||||
Ok(hasher.finalize().to_vec())
|
||||
}
|
||||
|
||||
pub fn to_base64_string<T: AsRef<[u8]>>(input: T) -> String {
|
||||
STANDARD.encode(input)
|
||||
pub fn to_hex_string<T: AsRef<[u8]>>(input: T) -> String {
|
||||
hex::encode(input)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::error::NymvisorError;
|
||||
use crate::helpers::{init_path, to_base64_string};
|
||||
use crate::helpers::{init_path, to_hex_string};
|
||||
use crate::upgrades::types::{DownloadUrl, UpgradeInfo};
|
||||
use bytes::Buf;
|
||||
use futures::stream::StreamExt;
|
||||
@@ -97,8 +97,8 @@ fn maybe_verify_checksum(
|
||||
if checksum != download_url.checksum {
|
||||
return Err(NymvisorError::DownloadChecksumFailure {
|
||||
upgrade_name,
|
||||
encoded_checksum: to_base64_string(&checksum),
|
||||
expected_checksum: to_base64_string(&download_url.checksum),
|
||||
encoded_checksum: to_hex_string(&checksum),
|
||||
expected_checksum: to_hex_string(&download_url.checksum),
|
||||
algorithm: download_url.checksum_algorithm,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
pub(super) mod base64 {
|
||||
use base64::{engine::general_purpose::STANDARD, Engine as _};
|
||||
pub(super) mod hex {
|
||||
use serde::{Deserialize, Deserializer, Serializer};
|
||||
|
||||
pub fn serialize<S: Serializer>(bytes: &[u8], serializer: S) -> Result<S::Ok, S::Error> {
|
||||
serializer.serialize_str(&STANDARD.encode(bytes))
|
||||
serializer.serialize_str(&hex::encode(bytes))
|
||||
}
|
||||
|
||||
pub fn deserialize<'de, D: Deserializer<'de>>(deserializer: D) -> Result<Vec<u8>, D::Error> {
|
||||
let s = <String>::deserialize(deserializer)?;
|
||||
STANDARD.decode(s).map_err(serde::de::Error::custom)
|
||||
hex::decode(s).map_err(serde::de::Error::custom)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use super::serde_helpers::{base64, option_offsetdatetime};
|
||||
use super::serde_helpers::{hex, option_offsetdatetime};
|
||||
use crate::error::NymvisorError;
|
||||
use crate::helpers::{calculate_file_checksum, init_path};
|
||||
use crate::upgrades::download::os_arch;
|
||||
@@ -200,8 +200,8 @@ impl DigestAlgorithm {
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub struct DownloadUrl {
|
||||
/// The base64-encoded checksum of the file behind the download url.
|
||||
#[serde(with = "base64")]
|
||||
/// The hex-encoded checksum of the file behind the download url.
|
||||
#[serde(with = "hex")]
|
||||
pub checksum: Vec<u8>,
|
||||
|
||||
/// The algorithm used for computing the checksum
|
||||
|
||||
Reference in New Issue
Block a user