(bootInfo: BootInfo, isKms: boolean)
| 87 | } |
| 88 | |
| 89 | async checkBoot(bootInfo: BootInfo, isKms: boolean): Promise<BootResponse> { |
| 90 | const config = this.loadConfig(); |
| 91 | const osImageHash = normalizeHex(bootInfo.osImageHash); |
| 92 | const deviceId = normalizeHex(bootInfo.deviceId); |
| 93 | |
| 94 | // check TCB status |
| 95 | if (bootInfo.tcbStatus !== 'UpToDate') { |
| 96 | return { |
| 97 | isAllowed: false, |
| 98 | reason: 'TCB status is not up to date', |
| 99 | gatewayAppId: config.gatewayAppId |
| 100 | }; |
| 101 | } |
| 102 | |
| 103 | // check OS image |
| 104 | const allowedOsImages = config.osImages.map(normalizeHex); |
| 105 | if (!allowedOsImages.includes(osImageHash)) { |
| 106 | return { |
| 107 | isAllowed: false, |
| 108 | reason: 'OS image is not allowed', |
| 109 | gatewayAppId: config.gatewayAppId |
| 110 | }; |
| 111 | } |
| 112 | |
| 113 | if (isKms) { |
| 114 | return this.checkKmsBoot(bootInfo, config, deviceId); |
| 115 | } else { |
| 116 | return this.checkAppBoot(bootInfo, config, deviceId); |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | private checkKmsBoot(bootInfo: BootInfo, config: AuthConfig, deviceId: string): BootResponse { |
| 121 | const mrAggregated = normalizeHex(bootInfo.mrAggregated); |
no test coverage detected