|
3 | 3 | // SPDX-License-Identifier: Apache-2.0 |
4 | 4 |
|
5 | 5 | import fs from 'fs' |
6 | | -import { sha384 } from '@noble/hashes/sha512' |
7 | 6 | import { send_rpc_request } from './send-rpc-request' |
8 | 7 | export { getComposeHash } from './get-compose-hash' |
9 | 8 | export { verifyEnvEncryptPublicKey, verifyEnvEncryptPublicKeyLegacy } from './verify-env-encrypt-public-key' |
@@ -101,8 +100,6 @@ export interface GetQuoteResponse { |
101 | 100 | report_data?: Hex |
102 | 101 | vm_config?: string |
103 | 102 | attestation?: Hex |
104 | | - |
105 | | - replayRtmrs: () => string[] |
106 | 103 | } |
107 | 104 |
|
108 | 105 | export interface AttestResponse { |
@@ -149,36 +146,6 @@ function x509key_to_uint8array(pem: string, max_length?: number) { |
149 | 146 | return result |
150 | 147 | } |
151 | 148 |
|
152 | | -function replay_rtmr(history: string[]): string { |
153 | | - const INIT_MR = "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" |
154 | | - if (history.length === 0) { |
155 | | - return INIT_MR |
156 | | - } |
157 | | - let mr = Buffer.from(INIT_MR, 'hex') |
158 | | - for (const content of history) { |
159 | | - // Convert hex string to buffer |
160 | | - let contentBuffer = Buffer.from(content, 'hex') |
161 | | - // Pad content with zeros if shorter than 48 bytes |
162 | | - if (contentBuffer.length < 48) { |
163 | | - const padding = Buffer.alloc(48 - contentBuffer.length, 0) |
164 | | - contentBuffer = Buffer.concat([contentBuffer, padding]) |
165 | | - } |
166 | | - mr = Buffer.from(sha384(Buffer.concat([mr, contentBuffer]))) |
167 | | - } |
168 | | - return mr.toString('hex') |
169 | | -} |
170 | | - |
171 | | -function reply_rtmrs(event_log: EventLog[]): Record<number, string> { |
172 | | - const rtmrs: Array<string> = [] |
173 | | - for (let idx = 0; idx < 4; idx++) { |
174 | | - const history = event_log |
175 | | - .filter(event => event.imr === idx) |
176 | | - .map(event => event.digest) |
177 | | - rtmrs[idx] = replay_rtmr(history) |
178 | | - } |
179 | | - return rtmrs |
180 | | -} |
181 | | - |
182 | 149 | export interface TlsKeyOptions { |
183 | 150 | path?: string; |
184 | 151 | subject?: string; |
@@ -312,11 +279,6 @@ export class DstackClient<T extends TcbInfo = TcbInfoV05x> { |
312 | 279 | const err = result['error'] as string |
313 | 280 | throw new Error(err) |
314 | 281 | } |
315 | | - Object.defineProperty(result, 'replayRtmrs', { |
316 | | - get: () => () => reply_rtmrs(JSON.parse(result.event_log) as EventLog[]), |
317 | | - enumerable: true, |
318 | | - configurable: false, |
319 | | - }) |
320 | 282 | return Object.freeze(result) |
321 | 283 | } |
322 | 284 |
|
@@ -531,11 +493,6 @@ export class TappdClient extends DstackClient<TcbInfoV03x> { |
531 | 493 | const err = result['error'] as string |
532 | 494 | throw new Error(err) |
533 | 495 | } |
534 | | - Object.defineProperty(result, 'replayRtmrs', { |
535 | | - get: () => () => reply_rtmrs(JSON.parse(result.event_log) as EventLog[]), |
536 | | - enumerable: true, |
537 | | - configurable: false, |
538 | | - }) |
539 | 496 | return Object.freeze(result) |
540 | 497 | } |
541 | 498 |
|
|
0 commit comments