diff --git a/rust/pvimg/man/pvimg-info.1 b/rust/pvimg/man/pvimg-info.1 index 82b42da2..aaaa3ab9 100644 --- a/rust/pvimg/man/pvimg-info.1 +++ b/rust/pvimg/man/pvimg-info.1 @@ -37,7 +37,7 @@ Possible values: .RE .RE .PP -\-\-key +\-\-hdr\-key .RS 4 Use the key in FILE to decrypt the Secure Execution header. It is the key that was specified with the command line option \fB\-\-hdr\-key\fR at the Secure diff --git a/rust/pvimg/src/cli.rs b/rust/pvimg/src/cli.rs index 9deb87aa..446e9b74 100644 --- a/rust/pvimg/src/cli.rs +++ b/rust/pvimg/src/cli.rs @@ -195,8 +195,8 @@ pub struct InfoArgs { /// /// It is the key that was specified with the command line option /// '--hdr-key' at the Secure Execution image creation. - #[arg(long, value_name = "FILE", value_hint = ValueHint::FilePath,)] - pub key: Option, + #[arg(long, value_name = "FILE", value_hint = ValueHint::FilePath, alias = "key")] + pub hdr_key: Option, } #[derive(Args, Debug)] @@ -721,6 +721,22 @@ mod test { CliOption::new("image", ["/dev/null"]), ], )), + flat_map_collect(insert( + args.clone(), + vec![ + CliOption::new("hdr-key", ["--hdr-key", "/dev/null"]), + CliOption::new("format", ["--format=json"]), + CliOption::new("image", ["/dev/null"]), + ], + )), + flat_map_collect(insert( + args.clone(), + vec![ + CliOption::new("hdr-key", ["--key", "/dev/null"]), + CliOption::new("format", ["--format=json"]), + CliOption::new("image", ["/dev/null"]), + ], + )), // separation between keyword and positional args works flat_map_collect(insert( args.clone(), @@ -761,7 +777,7 @@ mod test { // Test for invalid combinations // Input is missing - let mut pvimg_invalid_args = vec![vec!["pvimg", "test"]]; + let mut pvimg_invalid_args = vec![vec!["pvimg", "info"]]; for create_args in &valid_test_args { pvimg_valid_args.push( diff --git a/rust/pvimg/src/cmd/info.rs b/rust/pvimg/src/cmd/info.rs index 1ced0545..2f593cf0 100644 --- a/rust/pvimg/src/cmd/info.rs +++ b/rust/pvimg/src/cmd/info.rs @@ -27,7 +27,7 @@ pub fn info(opt: &InfoArgs) -> Result { SeHdr::seek_sehdr(&mut input, None)?; let hdr = SeHdr::try_from_io(input)?; - if let Some(key_path) = &opt.key { + if let Some(key_path) = &opt.hdr_key { let key = SymKey::try_from_data(hdr.key_type(), read_file(key_path, "Reading key")?.into())?; serde_json::to_writer_pretty(&mut output, &hdr.decrypt(&key)?)?;