-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core,gen-cli): add utils to generate device bundle use it in gen…
…-cli this works for v2 configs for now as that's what is still used on holoports as of now. even though that's about to change in the short-term, it might come in handy to generate v2 configs to test the tranisitioning to v3 configs.
- Loading branch information
Showing
7 changed files
with
95 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod config; | ||
pub mod public_key; | ||
pub mod utils; | ||
|
||
pub use config::{admin_keypair_from, Config}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/// Generate a new device bundle and lock it with the given passphrase. | ||
pub fn generate_device_bundle( | ||
passphrase: &str, | ||
maybe_derivation_path: Option<u32>, | ||
) -> Result<Box<[u8]>, failure::Error> { | ||
let rt = tokio::runtime::Runtime::new()?; | ||
let passphrase = sodoken::BufRead::from(passphrase.as_bytes()); | ||
rt.block_on(async move { | ||
let master = hc_seed_bundle::UnlockedSeedBundle::new_random() | ||
.await | ||
.unwrap(); | ||
|
||
let derivation_path = maybe_derivation_path.unwrap_or(DEFAULT_DERIVATION_PATH_V2); | ||
|
||
let device_bundle = master.derive(derivation_path).await.unwrap(); | ||
device_bundle | ||
.lock() | ||
.add_pwhash_cipher(passphrase) | ||
.lock() | ||
.await | ||
}) | ||
.map_err(Into::into) | ||
} | ||
|
||
pub const DEFAULT_DERIVATION_PATH_V2: u32 = 3; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters