(&self)
| 1296 | } |
| 1297 | |
| 1298 | fn measure_app_info(&self) -> Result<AppInfo> { |
| 1299 | let compose_hash = sha256_file(self.shared.dir.app_compose_file())?; |
| 1300 | let truncated_compose_hash = truncate(&compose_hash, 20); |
| 1301 | let kms_enabled = self.shared.app_compose.kms_enabled(); |
| 1302 | let key_provider = self.shared.app_compose.key_provider(); |
| 1303 | let mut instance_info = self.shared.instance_info.clone(); |
| 1304 | |
| 1305 | if instance_info.app_id.is_empty() { |
| 1306 | instance_info.app_id = truncated_compose_hash.to_vec(); |
| 1307 | } |
| 1308 | if instance_info.app_id.len() != 20 { |
| 1309 | bail!( |
| 1310 | "Invalid app id length: expected 20 bytes, got {}", |
| 1311 | instance_info.app_id.len() |
| 1312 | ); |
| 1313 | } |
| 1314 | |
| 1315 | let disk_reusable = !key_provider.is_none(); |
| 1316 | if (!disk_reusable) || instance_info.instance_id_seed.is_empty() { |
| 1317 | instance_info.instance_id_seed = { |
| 1318 | let mut rand_id = vec![0u8; 20]; |
| 1319 | getrandom::fill(&mut rand_id)?; |
| 1320 | rand_id |
| 1321 | }; |
| 1322 | } |
| 1323 | let instance_id = if self.shared.app_compose.no_instance_id { |
| 1324 | vec![] |
| 1325 | } else { |
| 1326 | let mut id_path = instance_info.instance_id_seed.clone(); |
| 1327 | id_path.extend_from_slice(&instance_info.app_id); |
| 1328 | sha256(&id_path)[..20].to_vec() |
| 1329 | }; |
| 1330 | instance_info.instance_id = instance_id.clone(); |
| 1331 | let app_id = if kms_enabled { |
| 1332 | instance_info.app_id.clone() |
| 1333 | } else { |
| 1334 | truncated_compose_hash.to_vec() |
| 1335 | }; |
| 1336 | |
| 1337 | emit_runtime_event("system-preparing", &[])?; |
| 1338 | emit_runtime_event("app-id", &app_id)?; |
| 1339 | emit_runtime_event("compose-hash", &compose_hash)?; |
| 1340 | emit_runtime_event("instance-id", &instance_id)?; |
| 1341 | emit_runtime_event("boot-mr-done", &[])?; |
| 1342 | Ok(AppInfo { |
| 1343 | instance_info, |
| 1344 | compose_hash, |
| 1345 | }) |
| 1346 | } |
| 1347 | |
| 1348 | fn verify_app(&self, app_info: &AppInfo, keys: &AppKeys) -> Result<()> { |
| 1349 | config_id_verifier::verify_mr_config_id( |
no test coverage detected