This repository has been archived by the owner on Jul 27, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Problem: no gen keypackage command in dev-utils (fix #1692)
Solution: add gen-keypackage tidy up more detail in message tidy up print error in stderr remove gen-keypackage in client-cli fix integration test add path for dev-utils tidy up update hmac
- Loading branch information
1 parent
b8dabf9
commit 87a885b
Showing
18 changed files
with
167 additions
and
60 deletions.
There are no files selected for viewing
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
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
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
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,13 +1,15 @@ | ||
mod genesis_command; | ||
mod genesis_dev_config; | ||
mod init_command; | ||
mod keypackage_command; | ||
mod run_command; | ||
mod stop_command; | ||
mod test_vector_command; | ||
|
||
pub use self::genesis_command::GenesisCommand; | ||
pub use self::genesis_dev_config::{GenesisDevConfig, InitialFeePolicy}; | ||
pub use self::init_command::InitCommand; | ||
pub use self::keypackage_command::KeypackageCommand; | ||
pub use self::run_command::RunCommand; | ||
pub use self::stop_command::StopCommand; | ||
pub use self::test_vector_command::TestVectorCommand; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
use crate::{gen_keypackage, verify_keypackage}; | ||
use client_common::{ErrorKind, Result, ResultExt}; | ||
use structopt::StructOpt; | ||
#[derive(Debug, StructOpt)] | ||
pub enum KeypackageCommand { | ||
#[structopt(name = "generate", about = "Generate key-package")] | ||
GenKeypackage { | ||
#[structopt( | ||
name = "Path to mls enclave", | ||
short = "p", | ||
long = "path", | ||
help = "Path to mls enclave (e.g. mls.sgxs)" | ||
)] | ||
path: String, | ||
#[structopt( | ||
name = "Path to key-package", | ||
short = "o", | ||
long = "output", | ||
help = "Path to key-package (e.g. key.txt)" | ||
)] | ||
output: String, | ||
}, | ||
#[structopt(name = "verify", about = "Verify key-package")] | ||
VerifyKeypackage { | ||
#[structopt( | ||
name = "Path to base64 encoded keypackage", | ||
short = "p", | ||
long = "path", | ||
help = "Path to keypackage enclave which is base64 encoded" | ||
)] | ||
path: String, | ||
}, | ||
} | ||
|
||
impl KeypackageCommand { | ||
pub fn execute(&self) -> Result<()> { | ||
match self { | ||
KeypackageCommand::GenKeypackage { path, output } => { | ||
let blob = gen_keypackage(&path)?; | ||
let encoded = base64::encode(&blob); | ||
std::fs::write(&output, &encoded) | ||
.chain(|| (ErrorKind::IoError, "Cannot write encoded key-package"))?; | ||
Ok(()) | ||
} | ||
KeypackageCommand::VerifyKeypackage { path } => { | ||
let contents = std::fs::read_to_string(&path) | ||
.chain(|| (ErrorKind::IoError, "Unable to read keypackage"))?; | ||
let kp = base64::decode(&contents) | ||
.chain(|| (ErrorKind::IoError, "Unable to parse keypackage"))?; | ||
verify_keypackage(&kp)?; | ||
Ok(()) | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.