Use blake3 instead of blake2_simd

This commit is contained in:
Syrus 2020-01-13 11:58:31 +01:00
parent da0d8b39c5
commit 661df38cf2
4 changed files with 22 additions and 20 deletions

14
Cargo.lock generated
View File

@ -63,13 +63,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]]
name = "blake2b_simd"
version = "0.5.10"
name = "blake3"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8fb2d74254a3a0b5cac33ac9f8ed0e44aa50378d9dbb2e5d83bd21ed1dc2c8a"
checksum = "b8c90bf4a07dd0b816948d0915ba1b110e7ce54169797feb5b39d6139a0a81ca"
dependencies = [
"arrayref",
"arrayvec",
"cc",
"cfg-if",
"constant_time_eq",
]
@ -534,9 +536,9 @@ dependencies = [
[[package]]
name = "hex"
version = "0.3.2"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77"
checksum = "023b39be39e3a2da62a94feb433e91e8bcd37676fbc8bea371daf52b7a769a3e"
[[package]]
name = "indexmap"
@ -1788,7 +1790,7 @@ name = "wasmer-runtime-core"
version = "0.12.0"
dependencies = [
"bincode",
"blake2b_simd",
"blake3",
"cc",
"digest",
"errno",

View File

@ -13,11 +13,11 @@ edition = "2018"
nix = "0.15"
page_size = "0.4"
wasmparser = "0.45.0"
parking_lot = "0.9"
parking_lot = "0.10.0"
lazy_static = "1.4"
errno = "0.2"
libc = "0.2.60"
hex = "0.3"
hex = "0.4"
smallvec = "0.6"
bincode = "1.1"
@ -36,8 +36,8 @@ version = "1.0"
version = "0.11"
[dependencies.serde-bench]
version = "0.0.7"
[dependencies.blake2b_simd]
version = "0.5"
[dependencies.blake3]
version = "0.1.0"
[dependencies.digest]
version = "0.8"
@ -45,7 +45,7 @@ version = "0.8"
winapi = { version = "0.3", features = ["memoryapi"] }
[build-dependencies]
blake2b_simd = "0.5"
blake3 = "0.1.0"
rustc_version = "0.2"
cc = "1.0"

View File

@ -1,13 +1,13 @@
use blake2b_simd::blake2bp;
use blake3;
use std::{env, fs, io::Write, path::PathBuf};
const WASMER_VERSION: &'static str = env!("CARGO_PKG_VERSION");
fn main() {
let mut state = blake2bp::State::new();
state.update(WASMER_VERSION.as_bytes());
let mut hasher = blake3::Hasher::new();
hasher.update(WASMER_VERSION.as_bytes());
let hasher = state.finalize();
let hasher = hasher.finalize();
let hash_string = hasher.to_hex().as_str().to_owned();
let crate_dir = env::var("OUT_DIR").unwrap();

View File

@ -7,7 +7,7 @@ use crate::{
module::{Module, ModuleInfo},
sys::Memory,
};
use blake2b_simd::blake2bp;
use blake3;
use std::{fmt, io, mem, slice};
/// Indicates the invalid type of invalid cache file
@ -65,11 +65,11 @@ impl WasmHash {
let mut first_part = [0u8; 32];
let mut second_part = [0u8; 32];
let mut state = blake2bp::State::new();
state.update(wasm);
let mut hasher = blake3::Hasher::new();
hasher.update(wasm);
let hasher = state.finalize();
let generic_array = hasher.as_bytes();
let hash = hasher.finalize();
let generic_array = hash.as_bytes();
first_part.copy_from_slice(&generic_array[0..32]);
second_part.copy_from_slice(&generic_array[32..64]);