1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- #include "tpm2.h"
- #include "tpm2_tool.h"
- typedef struct tpm2_shutdown_ctx tpm2_shutdown_ctx;
- struct tpm2_shutdown_ctx {
- UINT8 clear : 1;
- };
- static tpm2_shutdown_ctx ctx;
- static bool on_option(char key, char *value) {
- UNUSED(value);
- switch (key) {
- case 'c':
- ctx.clear = 1;
- break;
-
- }
- return true;
- }
- static bool tpm2_tool_onstart(tpm2_options **opts) {
- static struct option topts [] = {
- { "clear", no_argument, NULL, 'c' },
- };
- *opts = tpm2_options_new("c", ARRAY_LEN(topts), topts, on_option, NULL, 0);
- return *opts != NULL;
- }
- static tool_rc tpm2_tool_onrun(ESYS_CONTEXT *context, tpm2_option_flags flags) {
- UNUSED(flags);
- TPM2_SU shutdown_type = ctx.clear ? TPM2_SU_CLEAR : TPM2_SU_STATE;
- return tpm2_shutdown(context, shutdown_type);
- }
- TPM2_TOOL_REGISTER("shutdown", tpm2_tool_onstart, tpm2_tool_onrun, NULL, NULL)
|