@@ -60,16 +60,8 @@ enum Command {
60
60
/// Generates a nonce, attestation and verifies it
61
61
VerifyRoundTrip {
62
62
/// Path to file holding trust anchor for the associated PKI.
63
- #[ clap(
64
- long,
65
- env = "VERIFIER_CLI_CA_CERT" ,
66
- conflicts_with = "self_signed"
67
- ) ]
63
+ #[ clap( long, env = "VERIFIER_CLI_CA_CERT" ) ]
68
64
ca_cert : Option < PathBuf > ,
69
-
70
- /// Verify the final cert in the provided PkiPath against itself.
71
- #[ clap( long, env, conflicts_with = "ca_cert" ) ]
72
- self_signed : bool ,
73
65
} ,
74
66
/// Verify the log against the given set of measurements
75
67
VerifyLog {
@@ -167,7 +159,7 @@ impl Ipcc {
167
159
& mut rot_message,
168
160
& HostToRotCommand :: Attest ,
169
161
|buf| {
170
- buf[ ..nonce. len ( ) ] . copy_from_slice ( & nonce) ;
162
+ buf[ ..nonce. len ( ) ] . copy_from_slice ( nonce) ;
171
163
32
172
164
} ,
173
165
)
@@ -185,6 +177,7 @@ impl Ipcc {
185
177
}
186
178
187
179
fn main ( ) -> Result < ( ) > {
180
+ env_logger:: init ( ) ;
188
181
let handle = Ipcc :: new ( ) ?;
189
182
190
183
let args = Args :: parse ( ) ;
@@ -232,7 +225,7 @@ fn main() -> Result<()> {
232
225
let nonce = std:: fs:: read ( nonce) ?;
233
226
let nonce = Nonce :: try_from ( & nonce[ ..] ) ?;
234
227
235
- let attest = handle. attest ( & nonce. as_ref ( ) ) ?;
228
+ let attest = handle. attest ( nonce. as_ref ( ) ) ?;
236
229
237
230
std:: fs:: write ( & out, & attest) ?;
238
231
info ! ( "Wrote attestation to {:?}" , out) ;
@@ -261,6 +254,38 @@ fn main() -> Result<()> {
261
254
& log,
262
255
& nonce,
263
256
) ?;
257
+ info ! ( "Attestation succeeded." ) ;
258
+ }
259
+ Command :: VerifyRoundTrip { ca_cert } => {
260
+ let nonce = Nonce :: from_platform_rng ( ) ?;
261
+
262
+ let attestation = handle. attest ( nonce. as_ref ( ) ) ?;
263
+ let ( attestation, _) = hubpack:: deserialize :: < Attestation > (
264
+ & attestation,
265
+ )
266
+ . map_err ( |e| anyhow ! ( "Failed to deserialize Attestation: {}" , e) ) ?;
267
+
268
+ let log = handle. get_measurement_log ( ) ?;
269
+
270
+ let chain = handle. get_certificates ( ) ?;
271
+ let root = match ca_cert {
272
+ Some ( r) => {
273
+ let root = std:: fs:: read ( r) ?;
274
+ Some ( Certificate :: from_pem ( root) ?)
275
+ }
276
+ None => None ,
277
+ } ;
278
+
279
+ let verifier = PkiPathSignatureVerifier :: new ( root) ?;
280
+ verifier. verify ( & chain) ?;
281
+
282
+ dice_verifier:: verify_attestation (
283
+ & chain[ 0 ] ,
284
+ & attestation,
285
+ & log,
286
+ & nonce,
287
+ ) ?;
288
+ info ! ( "Success." ) ;
264
289
}
265
290
_ => todo ! ( ) ,
266
291
}
0 commit comments