From 699c0db3dbb335f31853e0d3f3b2e5bfde5b1318 Mon Sep 17 00:00:00 2001 From: John Smith Date: Sat, 27 May 2023 18:07:24 +0100 Subject: [PATCH] fix password --- Cargo.lock | 30 +++++++++++++++++----- veilid-core/Cargo.toml | 4 +-- veilid-core/src/table_store/table_store.rs | 15 ++++++++++- veilid-core/src/tests/mod.rs | 2 +- veilid-core/tests/web.rs | 28 ++++++++++---------- veilid-server/Cargo.toml | 2 +- 6 files changed, 55 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3da52d29..495b0e9d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -767,12 +767,27 @@ dependencies = [ "cmake", ] +[[package]] +name = "bugsalot" +version = "0.2.2" +dependencies = [ + "libc", +] + [[package]] name = "bugsalot" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc12a55e9bd3840279c248c96ecf541d5ba98d6654e08869fe167121384a582c" +[[package]] +name = "bugsalot" +version = "0.2.2" +source = "git+https://github.com/crioux/bugsalot.git#336a7053faadf990b9362edf5752ef34fa1f9615" +dependencies = [ + "libc", +] + [[package]] name = "bumpalo" version = "3.12.2" @@ -2122,9 +2137,9 @@ dependencies = [ [[package]] name = "gen_ops" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f41347f4fa32183c2549b86daf6b6b12a26029a77463e25358f7287580b088b" +checksum = "e7c56cad8ee78109d547e40bf4ad78968a25157e7963d799d79921655629825a" [[package]] name = "generic-array" @@ -4243,8 +4258,9 @@ dependencies = [ [[package]] name = "range-set-blaze" -version = "0.1.4" -source = "git+https://github.com/crioux/range-set-blaze.git#102c239382a8c79414dcf1257923ac2fe4772342" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef51566f3ed218c92f4711b54af1c68c4f0c43935d31d216f9cc31b30af6ec64" dependencies = [ "gen_ops", "itertools", @@ -6033,7 +6049,7 @@ version = "0.1.0" dependencies = [ "async-std", "async-tungstenite 0.8.0", - "bugsalot", + "bugsalot 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "capnp", "capnp-rpc", "capnpc", @@ -6075,7 +6091,7 @@ dependencies = [ "async_executors", "backtrace", "blake3", - "bugsalot", + "bugsalot 0.2.2 (git+https://github.com/crioux/bugsalot.git)", "capnp", "capnpc", "cfg-if 1.0.0", @@ -6199,7 +6215,7 @@ dependencies = [ "async-std", "async-tungstenite 0.22.1", "backtrace", - "bugsalot", + "bugsalot 0.2.2", "capnp", "capnp-rpc", "capnpc", diff --git a/veilid-core/Cargo.toml b/veilid-core/Cargo.toml index 10a053ec..e145fb2c 100644 --- a/veilid-core/Cargo.toml +++ b/veilid-core/Cargo.toml @@ -69,7 +69,7 @@ keyvaluedb = { path = "../external/keyvaluedb/keyvaluedb" } rkyv = { version = "^0", default_features = false, features = ["std", "alloc", "strict", "size_32", "validation"] } data-encoding = { version = "^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" # 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"] } keyvaluedb-sqlite = { path = "../external/keyvaluedb/keyvaluedb-sqlite" } socket2 = { version = "^0", features = ["all"] } -bugsalot = "^0" +bugsalot = { git = "https://github.com/crioux/bugsalot.git" } chrono = "^0" libc = "^0" nix = "^0" diff --git a/veilid-core/src/table_store/table_store.rs b/veilid-core/src/table_store/table_store.rs index 0f86f3f3..648fa65c 100644 --- a/veilid-core/src/table_store/table_store.rs +++ b/veilid-core/src/table_store/table_store.rs @@ -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( kind, SharedSecret::try_from(&dek_bytes[4..])?, @@ -349,7 +353,16 @@ impl TableStore { 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) .await?; } diff --git a/veilid-core/src/tests/mod.rs b/veilid-core/src/tests/mod.rs index e82fa3cc..3ef5396d 100644 --- a/veilid-core/src/tests/mod.rs +++ b/veilid-core/src/tests/mod.rs @@ -12,6 +12,6 @@ use super::*; pub use common::*; pub use crypto::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 veilid_api::tests::*; diff --git a/veilid-core/tests/web.rs b/veilid-core/tests/web.rs index 4e77ee6b..f8a2b6fd 100644 --- a/veilid-core/tests/web.rs +++ b/veilid-core/tests/web.rs @@ -31,73 +31,73 @@ pub fn setup() -> () { } #[wasm_bindgen_test] -async fn run_test_host_interface() { +async fn wasm_test_host_interface() { setup(); test_host_interface::test_all().await; } #[wasm_bindgen_test] -async fn run_test_types() { +async fn wasm_test_types() { setup(); test_types::test_all().await; } #[wasm_bindgen_test] -async fn run_test_veilid_core() { +async fn wasm_test_veilid_core() { setup(); test_veilid_core::test_all().await; } #[wasm_bindgen_test] -async fn test_veilid_config() { +async fn wasm_test_veilid_config() { setup(); test_veilid_config::test_all().await; } #[wasm_bindgen_test] -async fn run_test_connection_table() { +async fn wasm_test_connection_table() { setup(); test_connection_table::test_all().await; } #[wasm_bindgen_test] -async fn run_test_signed_node_info() { +async fn wasm_test_signed_node_info() { setup(); test_signed_node_info::test_all().await; } #[wasm_bindgen_test] -async fn exec_test_table_store() { +async fn wasm_test_table_store() { setup(); test_table_store::test_all().await; } #[wasm_bindgen_test] -async fn exec_test_protected_store() { +async fn wasm_test_protected_store() { setup(); test_protected_store::test_all().await; } #[wasm_bindgen_test] -async fn exec_test_crypto() { +async fn wasm_test_crypto() { setup(); test_crypto::test_all().await; } #[wasm_bindgen_test] -async fn exec_test_envelope_receipt() { +async fn wasm_test_envelope_receipt() { setup(); test_envelope_receipt::test_all().await; } #[wasm_bindgen_test] -async fn veilid_api__test_serialize_rkyv() { +async fn wasm_test_serialize_rkyv() { setup(); - veilid_api::test_serialize_rkyv::test_all().await; + test_serialize_rkyv::test_all().await; } #[wasm_bindgen_test] -async fn routing_table__test_serialize() { +async fn wasm_test_routing_table_serialize() { setup(); - routing_table::test_serialize::test_all().await; + test_routing_table_serialize::test_all().await; } diff --git a/veilid-server/Cargo.toml b/veilid-server/Cargo.toml index b4ed29c7..11c54918 100644 --- a/veilid-server/Cargo.toml +++ b/veilid-server/Cargo.toml @@ -52,7 +52,7 @@ futures-util = { version = "^0", default_features = false, features = ["alloc"] url = "^2" ctrlc = "^3" lazy_static = "^1" -bugsalot = "^0" +bugsalot = { path = "../../bugsalot" } flume = { version = "^0", features = ["async"] } rpassword = "^6" hostname = "^0"