fix password

This commit is contained in:
John Smith 2023-05-27 18:07:24 +01:00
parent 3b96f75c94
commit 699c0db3db
6 changed files with 55 additions and 26 deletions

30
Cargo.lock generated
View File

@ -767,12 +767,27 @@ dependencies = [
"cmake", "cmake",
] ]
[[package]]
name = "bugsalot"
version = "0.2.2"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "bugsalot" name = "bugsalot"
version = "0.2.2" version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc12a55e9bd3840279c248c96ecf541d5ba98d6654e08869fe167121384a582c" checksum = "cc12a55e9bd3840279c248c96ecf541d5ba98d6654e08869fe167121384a582c"
[[package]]
name = "bugsalot"
version = "0.2.2"
source = "git+https://github.com/crioux/bugsalot.git#336a7053faadf990b9362edf5752ef34fa1f9615"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "bumpalo" name = "bumpalo"
version = "3.12.2" version = "3.12.2"
@ -2122,9 +2137,9 @@ dependencies = [
[[package]] [[package]]
name = "gen_ops" name = "gen_ops"
version = "0.2.0" version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f41347f4fa32183c2549b86daf6b6b12a26029a77463e25358f7287580b088b" checksum = "e7c56cad8ee78109d547e40bf4ad78968a25157e7963d799d79921655629825a"
[[package]] [[package]]
name = "generic-array" name = "generic-array"
@ -4243,8 +4258,9 @@ dependencies = [
[[package]] [[package]]
name = "range-set-blaze" name = "range-set-blaze"
version = "0.1.4" version = "0.1.5"
source = "git+https://github.com/crioux/range-set-blaze.git#102c239382a8c79414dcf1257923ac2fe4772342" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef51566f3ed218c92f4711b54af1c68c4f0c43935d31d216f9cc31b30af6ec64"
dependencies = [ dependencies = [
"gen_ops", "gen_ops",
"itertools", "itertools",
@ -6033,7 +6049,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"async-std", "async-std",
"async-tungstenite 0.8.0", "async-tungstenite 0.8.0",
"bugsalot", "bugsalot 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"capnp", "capnp",
"capnp-rpc", "capnp-rpc",
"capnpc", "capnpc",
@ -6075,7 +6091,7 @@ dependencies = [
"async_executors", "async_executors",
"backtrace", "backtrace",
"blake3", "blake3",
"bugsalot", "bugsalot 0.2.2 (git+https://github.com/crioux/bugsalot.git)",
"capnp", "capnp",
"capnpc", "capnpc",
"cfg-if 1.0.0", "cfg-if 1.0.0",
@ -6199,7 +6215,7 @@ dependencies = [
"async-std", "async-std",
"async-tungstenite 0.22.1", "async-tungstenite 0.22.1",
"backtrace", "backtrace",
"bugsalot", "bugsalot 0.2.2",
"capnp", "capnp",
"capnp-rpc", "capnp-rpc",
"capnpc", "capnpc",

View File

@ -69,7 +69,7 @@ keyvaluedb = { path = "../external/keyvaluedb/keyvaluedb" }
rkyv = { version = "^0", default_features = false, features = ["std", "alloc", "strict", "size_32", "validation"] } rkyv = { version = "^0", default_features = false, features = ["std", "alloc", "strict", "size_32", "validation"] }
data-encoding = { version = "^2" } data-encoding = { version = "^2" }
weak-table = "0.3.2" weak-table = "0.3.2"
range-set-blaze = { git = "https://github.com/crioux/range-set-blaze.git" } # "0.1.4" xxx replace with git repo range-set-blaze = "0.1.5"
argon2 = "0.5.0" argon2 = "0.5.0"
# Dependencies for native builds only # Dependencies for native builds only
@ -93,7 +93,7 @@ rustls-pemfile = "^0.2"
futures-util = { version = "^0", default-features = false, features = ["async-await", "sink", "std", "io"] } futures-util = { version = "^0", default-features = false, features = ["async-await", "sink", "std", "io"] }
keyvaluedb-sqlite = { path = "../external/keyvaluedb/keyvaluedb-sqlite" } keyvaluedb-sqlite = { path = "../external/keyvaluedb/keyvaluedb-sqlite" }
socket2 = { version = "^0", features = ["all"] } socket2 = { version = "^0", features = ["all"] }
bugsalot = "^0" bugsalot = { git = "https://github.com/crioux/bugsalot.git" }
chrono = "^0" chrono = "^0"
libc = "^0" libc = "^0"
nix = "^0" nix = "^0"

View File

@ -207,6 +207,10 @@ impl TableStore {
)); ));
} }
if dek_bytes.len() != (4 + SHARED_SECRET_LENGTH) {
bail!("password protected device encryption key is not valid");
}
Ok(TypedSharedSecret::new( Ok(TypedSharedSecret::new(
kind, kind,
SharedSecret::try_from(&dek_bytes[4..])?, SharedSecret::try_from(&dek_bytes[4..])?,
@ -349,7 +353,16 @@ impl TableStore {
device_encryption_key_changed = true; device_encryption_key_changed = true;
} }
if device_encryption_key_changed { // Check for password change
let changing_password = self
.config
.get()
.protected_store
.new_device_encryption_key_password
.is_some();
// Save encryption key if it has changed or if the protecting password wants to change
if device_encryption_key_changed || changing_password {
self.save_device_encryption_key(device_encryption_key) self.save_device_encryption_key(device_encryption_key)
.await?; .await?;
} }

View File

@ -12,6 +12,6 @@ use super::*;
pub use common::*; pub use common::*;
pub use crypto::tests::*; pub use crypto::tests::*;
pub use network_manager::tests::*; pub use network_manager::tests::*;
pub use routing_table::tests::*; pub use routing_table::tests::test_serialize as test_routing_table_serialize;
pub use table_store::tests::*; pub use table_store::tests::*;
pub use veilid_api::tests::*; pub use veilid_api::tests::*;

View File

@ -31,73 +31,73 @@ pub fn setup() -> () {
} }
#[wasm_bindgen_test] #[wasm_bindgen_test]
async fn run_test_host_interface() { async fn wasm_test_host_interface() {
setup(); setup();
test_host_interface::test_all().await; test_host_interface::test_all().await;
} }
#[wasm_bindgen_test] #[wasm_bindgen_test]
async fn run_test_types() { async fn wasm_test_types() {
setup(); setup();
test_types::test_all().await; test_types::test_all().await;
} }
#[wasm_bindgen_test] #[wasm_bindgen_test]
async fn run_test_veilid_core() { async fn wasm_test_veilid_core() {
setup(); setup();
test_veilid_core::test_all().await; test_veilid_core::test_all().await;
} }
#[wasm_bindgen_test] #[wasm_bindgen_test]
async fn test_veilid_config() { async fn wasm_test_veilid_config() {
setup(); setup();
test_veilid_config::test_all().await; test_veilid_config::test_all().await;
} }
#[wasm_bindgen_test] #[wasm_bindgen_test]
async fn run_test_connection_table() { async fn wasm_test_connection_table() {
setup(); setup();
test_connection_table::test_all().await; test_connection_table::test_all().await;
} }
#[wasm_bindgen_test] #[wasm_bindgen_test]
async fn run_test_signed_node_info() { async fn wasm_test_signed_node_info() {
setup(); setup();
test_signed_node_info::test_all().await; test_signed_node_info::test_all().await;
} }
#[wasm_bindgen_test] #[wasm_bindgen_test]
async fn exec_test_table_store() { async fn wasm_test_table_store() {
setup(); setup();
test_table_store::test_all().await; test_table_store::test_all().await;
} }
#[wasm_bindgen_test] #[wasm_bindgen_test]
async fn exec_test_protected_store() { async fn wasm_test_protected_store() {
setup(); setup();
test_protected_store::test_all().await; test_protected_store::test_all().await;
} }
#[wasm_bindgen_test] #[wasm_bindgen_test]
async fn exec_test_crypto() { async fn wasm_test_crypto() {
setup(); setup();
test_crypto::test_all().await; test_crypto::test_all().await;
} }
#[wasm_bindgen_test] #[wasm_bindgen_test]
async fn exec_test_envelope_receipt() { async fn wasm_test_envelope_receipt() {
setup(); setup();
test_envelope_receipt::test_all().await; test_envelope_receipt::test_all().await;
} }
#[wasm_bindgen_test] #[wasm_bindgen_test]
async fn veilid_api__test_serialize_rkyv() { async fn wasm_test_serialize_rkyv() {
setup(); setup();
veilid_api::test_serialize_rkyv::test_all().await; test_serialize_rkyv::test_all().await;
} }
#[wasm_bindgen_test] #[wasm_bindgen_test]
async fn routing_table__test_serialize() { async fn wasm_test_routing_table_serialize() {
setup(); setup();
routing_table::test_serialize::test_all().await; test_routing_table_serialize::test_all().await;
} }

View File

@ -52,7 +52,7 @@ futures-util = { version = "^0", default_features = false, features = ["alloc"]
url = "^2" url = "^2"
ctrlc = "^3" ctrlc = "^3"
lazy_static = "^1" lazy_static = "^1"
bugsalot = "^0" bugsalot = { path = "../../bugsalot" }
flume = { version = "^0", features = ["async"] } flume = { version = "^0", features = ["async"] }
rpassword = "^6" rpassword = "^6"
hostname = "^0" hostname = "^0"