Skip to content

Commit 4620f3f

Browse files
authored
Merge pull request #376 from Superhepper/error-code-in-hex
Changes print of errors to hex format.
2 parents f123b99 + e37d67a commit 4620f3f

19 files changed

+94
-73
lines changed

tss-esapi/src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl Context {
101101
)
102102
},
103103
|ret| {
104-
error!("Error when creating a new context: {}", ret);
104+
error!("Error when creating a new context: {:#010X}", ret);
105105
},
106106
)?;
107107

tss-esapi/src/context/general_esys_tr.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl Context {
4141
unsafe { Esys_TR_SetAuth(self.mut_context(), object_handle.into(), &auth_value) },
4242
|ret| {
4343
auth_value.buffer.zeroize();
44-
error!("Error when setting authentication value: {}", ret);
44+
error!("Error when setting authentication value: {:#010X}", ret);
4545
},
4646
)
4747
}
@@ -131,7 +131,7 @@ impl Context {
131131
ReturnCode::ensure_success(
132132
unsafe { Esys_TR_GetName(self.mut_context(), object_handle.into(), &mut name_ptr) },
133133
|ret| {
134-
error!("Error in getting name: {}", ret);
134+
error!("Error in getting name: {:#010X}", ret);
135135
},
136136
)?;
137137
Name::try_from(Context::ffi_data_to_owned(name_ptr))
@@ -249,7 +249,10 @@ impl Context {
249249
)
250250
},
251251
|ret| {
252-
error!("Error when getting ESYS handle from TPM handle: {}", ret);
252+
error!(
253+
"Error when getting ESYS handle from TPM handle: {:#010X}",
254+
ret
255+
);
253256
},
254257
)?;
255258
self.handle_manager.add_handle(
@@ -357,7 +360,7 @@ impl Context {
357360
ReturnCode::ensure_success(
358361
unsafe { Esys_TR_Close(self.mut_context(), &mut rsrc_handle) },
359362
|ret| {
360-
error!("Error when closing an ESYS handle: {}", ret);
363+
error!("Error when closing an ESYS handle: {:#010X}", ret);
361364
},
362365
)?;
363366

@@ -376,7 +379,10 @@ impl Context {
376379
Esys_TR_GetTpmHandle(self.mut_context(), object_handle.into(), &mut tpm_handle)
377380
},
378381
|ret| {
379-
error!("Error when getting TPM handle from ESYS handle: {}", ret);
382+
error!(
383+
"Error when getting TPM handle from ESYS handle: {:#010X}",
384+
ret
385+
);
380386
},
381387
)?;
382388
TpmHandle::try_from(tpm_handle)

tss-esapi/src/context/session_administration.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl Context {
2727
)
2828
},
2929
|ret| {
30-
error!("Error when setting session attributes: {}", ret);
30+
error!("Error when setting session attributes: {:#010X}", ret);
3131
},
3232
)
3333
}
@@ -44,7 +44,7 @@ impl Context {
4444
)
4545
},
4646
|ret| {
47-
error!("Error when getting session attributes: {}", ret);
47+
error!("Error when getting session attributes: {:#010X}", ret);
4848
},
4949
)?;
5050
Ok(SessionAttributes(flags))

tss-esapi/src/context/tpm_commands/asymmetric_primitives.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl Context {
3636
)
3737
},
3838
|ret| {
39-
error!("Error when performing RSA encryption: {}", ret);
39+
error!("Error when performing RSA encryption: {:#010X}", ret);
4040
},
4141
)?;
4242
PublicKeyRsa::try_from(Context::ffi_data_to_owned(out_data_ptr))
@@ -66,7 +66,7 @@ impl Context {
6666
)
6767
},
6868
|ret| {
69-
error!("Error when performing RSA decryption: {}", ret);
69+
error!("Error when performing RSA decryption: {:#010X}", ret);
7070
},
7171
)?;
7272
PublicKeyRsa::try_from(Context::ffi_data_to_owned(message_ptr))
@@ -194,7 +194,7 @@ impl Context {
194194
)
195195
},
196196
|ret| {
197-
error!("Error when generating ECDH keypair: {}", ret);
197+
error!("Error when generating ECDH keypair: {:#010X}", ret);
198198
},
199199
)?;
200200

@@ -330,7 +330,7 @@ impl Context {
330330
)
331331
},
332332
|ret| {
333-
error!("Error when performing ECDH ZGen: {}", ret);
333+
error!("Error when performing ECDH ZGen: {:#010X}", ret);
334334
},
335335
)?;
336336
let out_point = Context::ffi_data_to_owned(out_point_ptr);

tss-esapi/src/context/tpm_commands/attestation_commands.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl Context {
140140
)
141141
},
142142
|ret| {
143-
error!("Error in certifying: {}", ret);
143+
error!("Error in certifying: {:#010X}", ret);
144144
},
145145
)?;
146146

@@ -183,7 +183,7 @@ impl Context {
183183
)
184184
},
185185
|ret| {
186-
error!("Error in quoting PCR: {}", ret);
186+
error!("Error in quoting PCR: {:#010X}", ret);
187187
},
188188
)?;
189189

tss-esapi/src/context/tpm_commands/capability_commands.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl Context {
6464
)
6565
},
6666
|ret| {
67-
error!("Error when getting capabilities: {}", ret);
67+
error!("Error when getting capabilities: {:#010X}", ret);
6868
},
6969
)?;
7070

@@ -91,7 +91,10 @@ impl Context {
9191
)
9292
},
9393
|ret| {
94-
warn!("Parameters under test could not be unmarshalled: {}", ret);
94+
warn!(
95+
"Parameters under test could not be unmarshalled: {:#010X}",
96+
ret
97+
);
9598
},
9699
)
97100
}

tss-esapi/src/context/tpm_commands/context_management.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl Context {
2323
ReturnCode::ensure_success(
2424
unsafe { Esys_ContextSave(self.mut_context(), handle.into(), &mut context_ptr) },
2525
|ret| {
26-
error!("Error in saving context: {}", ret);
26+
error!("Error in saving context: {:#010X}", ret);
2727
},
2828
)?;
2929
TpmsContext::try_from(Context::ffi_data_to_owned(context_ptr))
@@ -45,7 +45,7 @@ impl Context {
4545
)
4646
},
4747
|ret| {
48-
error!("Error in loading context: {}", ret);
48+
error!("Error in loading context: {:#010X}", ret);
4949
},
5050
)?;
5151
let loaded_handle = ObjectHandle::from(esys_loaded_handle);
@@ -137,7 +137,7 @@ impl Context {
137137
ReturnCode::ensure_success(
138138
unsafe { Esys_FlushContext(self.mut_context(), handle.try_into_not_none()?) },
139139
|ret| {
140-
error!("Error in flushing context: {}", ret);
140+
error!("Error in flushing context: {:#010X}", ret);
141141
},
142142
)?;
143143
self.handle_manager.set_as_flushed(handle)
@@ -430,7 +430,7 @@ impl Context {
430430
)
431431
},
432432
|ret| {
433-
error!("Error in evict control: {}", ret);
433+
error!("Error in evict control: {:#010X}", ret);
434434
},
435435
)?;
436436
let new_object_handle = ObjectHandle::from(new_object_handle);

tss-esapi/src/context/tpm_commands/duplication_commands.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ impl Context {
322322
)
323323
},
324324
|ret| {
325-
error!("Error when performing duplication: {}", ret);
325+
error!("Error when performing duplication: {:#010X}", ret);
326326
},
327327
)?;
328328

@@ -680,7 +680,7 @@ impl Context {
680680
)
681681
},
682682
|ret| {
683-
error!("Error when performing import: {}", ret);
683+
error!("Error when performing import: {:#010X}", ret);
684684
},
685685
)?;
686686
Private::try_from(Context::ffi_data_to_owned(out_private_ptr))

tss-esapi/src/context/tpm_commands/enhanced_authorization_ea_commands.rs

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl Context {
6060
)
6161
},
6262
|ret| {
63-
error!("Error when sending policy signed: {}", ret);
63+
error!("Error when sending policy signed: {:#010X}", ret);
6464
},
6565
)?;
6666
Ok((
@@ -102,7 +102,7 @@ impl Context {
102102
)
103103
},
104104
|ret| {
105-
error!("Error when sending policy secret: {}", ret);
105+
error!("Error when sending policy secret: {:#010X}", ret);
106106
},
107107
)?;
108108
Ok((
@@ -150,7 +150,7 @@ impl Context {
150150
)
151151
},
152152
|ret| {
153-
error!("Error when computing policy OR: {}", ret);
153+
error!("Error when computing policy OR: {:#010X}", ret);
154154
},
155155
)
156156
}
@@ -185,7 +185,7 @@ impl Context {
185185
)
186186
},
187187
|ret| {
188-
error!("Error when computing policy PCR: {}", ret);
188+
error!("Error when computing policy PCR: {:#010X}", ret);
189189
},
190190
)
191191
}
@@ -211,7 +211,7 @@ impl Context {
211211
)
212212
},
213213
|ret| {
214-
error!("Error when computing policy locality: {}", ret);
214+
error!("Error when computing policy locality: {:#010X}", ret);
215215
},
216216
)
217217
}
@@ -240,7 +240,7 @@ impl Context {
240240
)
241241
},
242242
|ret| {
243-
error!("Error when computing policy command code: {}", ret);
243+
error!("Error when computing policy command code: {:#010X}", ret);
244244
},
245245
)
246246
}
@@ -261,7 +261,10 @@ impl Context {
261261
)
262262
},
263263
|ret| {
264-
error!("Error when computing policy physical presence: {}", ret);
264+
error!(
265+
"Error when computing policy physical presence: {:#010X}",
266+
ret
267+
);
265268
},
266269
)
267270
}
@@ -287,7 +290,10 @@ impl Context {
287290
)
288291
},
289292
|ret| {
290-
error!("Error when computing policy command parameters: {}", ret);
293+
error!(
294+
"Error when computing policy command parameters: {:#010X}",
295+
ret
296+
);
291297
},
292298
)
293299
}
@@ -313,7 +319,7 @@ impl Context {
313319
)
314320
},
315321
|ret| {
316-
error!("Error when computing policy name hash: {}", ret);
322+
error!("Error when computing policy name hash: {:#010X}", ret);
317323
},
318324
)
319325
}
@@ -419,7 +425,10 @@ impl Context {
419425
)
420426
},
421427
|ret| {
422-
error!("Error when computing policy duplication select: {}", ret);
428+
error!(
429+
"Error when computing policy duplication select: {:#010X}",
430+
ret
431+
);
423432
},
424433
)
425434
}
@@ -454,7 +463,7 @@ impl Context {
454463
)
455464
},
456465
|ret| {
457-
error!("Error when computing policy authorize: {}", ret);
466+
error!("Error when computing policy authorize: {:#010X}", ret);
458467
},
459468
)
460469
}
@@ -475,7 +484,7 @@ impl Context {
475484
)
476485
},
477486
|ret| {
478-
error!("Error when computing policy auth value: {}", ret);
487+
error!("Error when computing policy auth value: {:#010X}", ret);
479488
},
480489
)
481490
}
@@ -496,7 +505,7 @@ impl Context {
496505
)
497506
},
498507
|ret| {
499-
error!("Error when computing policy password: {}", ret);
508+
error!("Error when computing policy password: {:#010X}", ret);
500509
},
501510
)
502511
}
@@ -518,7 +527,7 @@ impl Context {
518527
},
519528
|ret| {
520529
error!(
521-
"Error failed to perform policy get digest operation: {}.",
530+
"Error failed to perform policy get digest operation: {:#010X}.",
522531
ret
523532
);
524533
},
@@ -547,7 +556,10 @@ impl Context {
547556
)
548557
},
549558
|ret| {
550-
error!("Error when computing policy NV written state: {}", ret);
559+
error!(
560+
"Error when computing policy NV written state: {:#010X}",
561+
ret
562+
);
551563
},
552564
)
553565
}
@@ -575,7 +587,7 @@ impl Context {
575587
},
576588
|ret| {
577589
error!(
578-
"Failed to bind template to a specific creation template: {}",
590+
"Failed to bind template to a specific creation template: {:#010X}",
579591
ret
580592
);
581593
},

tss-esapi/src/context/tpm_commands/hierarchy_commands.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl Context {
6767
)
6868
},
6969
|ret| {
70-
error!("Error in creating primary key: {}", ret);
70+
error!("Error in creating primary key: {:#010X}", ret);
7171
},
7272
)?;
7373
let out_public_owned = Context::ffi_data_to_owned(out_public_ptr);
@@ -105,7 +105,7 @@ impl Context {
105105
)
106106
},
107107
|ret| {
108-
error!("Error in clearing TPM hierarchy: {}", ret);
108+
error!("Error in clearing TPM hierarchy: {:#010X}", ret);
109109
},
110110
)
111111
}
@@ -124,7 +124,7 @@ impl Context {
124124
)
125125
},
126126
|ret| {
127-
error!("Error in controlling clear command: {}", ret);
127+
error!("Error in controlling clear command: {:#010X}", ret);
128128
},
129129
)
130130
}
@@ -143,7 +143,7 @@ impl Context {
143143
)
144144
},
145145
|ret| {
146-
error!("Error changing hierarchy auth: {}", ret);
146+
error!("Error changing hierarchy auth: {:#010X}", ret);
147147
},
148148
)
149149
}

0 commit comments

Comments
 (0)