rust/genprotimg: Add support for '--(enable|disable)-(pckmo-hmac|backup-keys)'

Add support for enabling/disabling the backup keys and HMAC-PCKMO key
encryption function plaintext control flags in the Secure Execution
header.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Marc Hartmayer
2024-11-28 21:25:37 +01:00
committed by Jan Höppner
parent d2de7f2808
commit 72aa64495c
2 changed files with 30 additions and 0 deletions
+18
View File
@@ -124,6 +124,22 @@ pub struct CreateBootImageLegacyFlags {
/// functions.
#[arg(long, action = clap::ArgAction::SetTrue, conflicts_with="enable_pckmo", group="header-flags")]
pub disable_pckmo: Option<bool>,
/// Enable the support for the HMAC PCKMO key encryption function.
#[arg(long, action = clap::ArgAction::SetTrue, group="header-flags")]
pub enable_pckmo_hmac: Option<bool>,
/// Disable the support for the HMAC PCKMO key encryption function (default).
#[arg(long, action = clap::ArgAction::SetTrue, conflicts_with="enable_pckmo_hmac", group="header-flags")]
pub disable_pckmo_hmac: Option<bool>,
/// Enable the support for backup target keys.
#[arg(long, action = clap::ArgAction::SetTrue, group="header-flags")]
pub enable_backup_keys: Option<bool>,
/// Disable the support for backup target keys (default).
#[arg(long, action = clap::ArgAction::SetTrue, conflicts_with="enable_backup_keys", group="header-flags")]
pub disable_backup_keys: Option<bool>,
}
#[non_exhaustive]
@@ -450,6 +466,8 @@ mod test {
flat_map_collect(insert(mvca.clone(), vec![CliOption::new("x-psw", ["--x-psw", "0x0"])])),
flat_map_collect(insert(mvca.clone(), vec![CliOption::new("no-component-check", ["--no-component-check"])])),
flat_map_collect(insert(mvca.clone(), vec![CliOption::new("enable-pckmo", ["--enable-pckmo"])])),
flat_map_collect(insert(mvca.clone(), vec![CliOption::new("enable-pckmo-hmac", ["--enable-pckmo-hmac"])])),
flat_map_collect(insert(mvca.clone(), vec![CliOption::new("enable-backup-keys", ["--enable-backup-keys"])])),
];
let invalid_create_args = [
flat_map_collect(remove(mvcanv.clone(), "no-verify")),
+12
View File
@@ -68,6 +68,18 @@ fn parse_flags(
PcfV1::PckmoDeaTdea,
PcfV1::PckmoEcc,
]))),
lf.disable_pckmo_hmac
.filter(|x| *x)
.and(Some(PcfV1::all_disabled([PcfV1::PckmoHmac]))),
lf.enable_pckmo_hmac
.filter(|x| *x)
.and(Some(PcfV1::all_enabled([PcfV1::PckmoHmac]))),
lf.disable_backup_keys
.filter(|x| *x)
.and(Some(PcfV1::all_disabled([PcfV1::BackupTargetKeys]))),
lf.enable_backup_keys
.filter(|x| *x)
.and(Some(PcfV1::all_enabled([PcfV1::BackupTargetKeys]))),
]
.into_iter()
.flatten()