mrConfigId/mrOwner/mrOwnerConfig are base64 encoded SHA384 digest, can be provided for TDX attestation.
Check their decoded lengths to ensure they are 48 bytes. Signed-off-by: Zhenzhong Duan <zhenzhong.d...@intel.com> --- src/conf/domain_validate.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 1902a0544a..ed4ce6d382 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -1913,10 +1913,13 @@ virDomainDefValidateIOThreads(const virDomainDef *def) } \ } +#define SHA384_DIGEST_SIZE 48 + static int virDomainDefLaunchSecurityValidate(const virDomainDef *def) { virDomainSEVSNPDef *sev_snp; + virDomainTDXDef *tdx; if (!def->sec) return 0; @@ -1931,10 +1934,17 @@ virDomainDefLaunchSecurityValidate(const virDomainDef *def) CHECK_BASE64_LEN(sev_snp->host_data, "hostData", 32); break; + case VIR_DOMAIN_LAUNCH_SECURITY_TDX: + tdx = &def->sec->data.tdx; + + CHECK_BASE64_LEN(tdx->mrconfigid, "mrConfigId", SHA384_DIGEST_SIZE); + CHECK_BASE64_LEN(tdx->mrowner, "mrOwner", SHA384_DIGEST_SIZE); + CHECK_BASE64_LEN(tdx->mrownerconfig, "mrOwnerConfig", SHA384_DIGEST_SIZE); + break; + case VIR_DOMAIN_LAUNCH_SECURITY_NONE: case VIR_DOMAIN_LAUNCH_SECURITY_SEV: case VIR_DOMAIN_LAUNCH_SECURITY_PV: - case VIR_DOMAIN_LAUNCH_SECURITY_TDX: case VIR_DOMAIN_LAUNCH_SECURITY_LAST: break; } -- 2.34.1