Drop ring crate (#5242)

This commit is contained in:
Michael Vines 2019-07-22 23:11:40 -07:00 committed by GitHub
parent 2c8e0bcf87
commit c2f74330ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 34 deletions

20
Cargo.lock generated
View File

@ -2039,17 +2039,6 @@ dependencies = [
"winreg 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "winreg 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "ring"
version = "0.13.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)",
"untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "rocksdb" name = "rocksdb"
version = "0.11.0" version = "0.11.0"
@ -2641,10 +2630,10 @@ dependencies = [
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)",
"reqwest 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)",
"ring 0.13.5 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)", "serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)",
"sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"solana-client 0.17.0", "solana-client 0.17.0",
"solana-config-api 0.17.0", "solana-config-api 0.17.0",
"solana-logger 0.17.0", "solana-logger 0.17.0",
@ -3491,11 +3480,6 @@ name = "unicode-xid"
version = "0.1.0" version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "untrusted"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "untrusted" name = "untrusted"
version = "0.7.0" version = "0.7.0"
@ -3896,7 +3880,6 @@ dependencies = [
"checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96" "checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96"
"checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5"
"checksum reqwest 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)" = "1d0777154c2c3eb54f5c480db01de845652d941e47191277cc673634c3853939" "checksum reqwest 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)" = "1d0777154c2c3eb54f5c480db01de845652d941e47191277cc673634c3853939"
"checksum ring 0.13.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2c4db68a2e35f3497146b7e4563df7d4773a2433230c5e4b448328e31740458a"
"checksum rocksdb 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f1651697fefd273bfb4fd69466cc2a9d20de557a0213b97233b22b5e95924b5e" "checksum rocksdb 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f1651697fefd273bfb4fd69466cc2a9d20de557a0213b97233b22b5e95924b5e"
"checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" "checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619"
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
@ -3975,7 +3958,6 @@ dependencies = [
"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" "checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526"
"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" "checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc"
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
"checksum untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "55cd1f4b4e96b46aeb8d4855db4a7a9bd96eeeb5c6a1ab54593328761642ce2f"
"checksum untrusted 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60369ef7a31de49bcb3f6ca728d4ba7300d9a1658f94c727d4cab8c8d9f4aece" "checksum untrusted 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60369ef7a31de49bcb3f6ca728d4ba7300d9a1658f94c727d4cab8c8d9f4aece"
"checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" "checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a"
"checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737" "checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737"

View File

@ -27,10 +27,10 @@ lazy_static = "1.3.0"
log = "0.4.7" log = "0.4.7"
nix = "0.14.1" nix = "0.14.1"
reqwest = "0.9.19" reqwest = "0.9.19"
ring = "0.13.2"
serde = "1.0.94" serde = "1.0.94"
serde_derive = "1.0.94" serde_derive = "1.0.94"
serde_yaml = "0.8.9" serde_yaml = "0.8.9"
sha2 = "0.8.0"
solana-client = { path = "../client", version = "0.17.0" } solana-client = { path = "../client", version = "0.17.0" }
solana-config-api = { path = "../programs/config_api", version = "0.17.0" } solana-config-api = { path = "../programs/config_api", version = "0.17.0" }
solana-logger = { path = "../logger", version = "0.17.0" } solana-logger = { path = "../logger", version = "0.17.0" }

View File

@ -4,7 +4,7 @@ use crate::update_manifest::{SignedUpdateManifest, UpdateManifest};
use chrono::{Local, TimeZone}; use chrono::{Local, TimeZone};
use console::{style, Emoji}; use console::{style, Emoji};
use indicatif::{ProgressBar, ProgressStyle}; use indicatif::{ProgressBar, ProgressStyle};
use ring::digest::{Context, Digest, SHA256}; use sha2::{Digest, Sha256};
use solana_client::rpc_client::RpcClient; use solana_client::rpc_client::RpcClient;
use solana_config_api::config_instruction::{self, ConfigKeys}; use solana_config_api::config_instruction::{self, ConfigKeys};
use solana_sdk::message::Message; use solana_sdk::message::Message;
@ -52,25 +52,20 @@ fn download_to_temp_archive(
url: &str, url: &str,
expected_sha256: Option<&str>, expected_sha256: Option<&str>,
) -> Result<(TempDir, PathBuf, String), Box<dyn std::error::Error>> { ) -> Result<(TempDir, PathBuf, String), Box<dyn std::error::Error>> {
fn sha256_digest<R: Read>(mut reader: R) -> Result<Digest, Box<dyn std::error::Error>> { fn sha256_file_digest<P: AsRef<Path>>(path: P) -> Result<String, Box<dyn std::error::Error>> {
let mut context = Context::new(&SHA256); let input = File::open(path)?;
let mut buffer = [0; 1024]; let mut reader = BufReader::new(input);
let mut hasher = Sha256::new();
let mut buffer = [0; 1024];
loop { loop {
let count = reader.read(&mut buffer)?; let count = reader.read(&mut buffer)?;
if count == 0 { if count == 0 {
break; break;
} }
context.update(&buffer[..count]); hasher.input(&buffer[..count]);
} }
Ok(bs58::encode(hasher.result()).into_string())
Ok(context.finish())
}
fn sha256_file_digest<P: AsRef<Path>>(path: P) -> Result<Digest, Box<dyn std::error::Error>> {
let input = File::open(path)?;
let reader = BufReader::new(input);
sha256_digest(reader)
} }
let url = Url::parse(url).map_err(|err| format!("Unable to parse {}: {}", url, err))?; let url = Url::parse(url).map_err(|err| format!("Unable to parse {}: {}", url, err))?;
@ -129,7 +124,6 @@ fn download_to_temp_archive(
let temp_file_sha256 = sha256_file_digest(&temp_file) let temp_file_sha256 = sha256_file_digest(&temp_file)
.map_err(|err| format!("Unable to hash {:?}: {}", temp_file, err))?; .map_err(|err| format!("Unable to hash {:?}: {}", temp_file, err))?;
let temp_file_sha256 = bs58::encode(temp_file_sha256).into_string();
if expected_sha256.is_some() && expected_sha256 != Some(&temp_file_sha256) { if expected_sha256.is_some() && expected_sha256 != Some(&temp_file_sha256) {
Err(io::Error::new(io::ErrorKind::Other, "Incorrect hash"))?; Err(io::Error::new(io::ErrorKind::Other, "Incorrect hash"))?;