| #!/usr/bin/env python |
| |
| from argparse import ArgumentParser |
| from argparse import FileType |
| import os |
| import sys |
| import tpm2 |
| |
| def main(): |
| parser = ArgumentParser(description='Create a storage root key') |
| parser.add_argument('--debug', |
| action='store_true', |
| help = 'dump TPM commands and replies') |
| parser.add_argument('handles', metavar='H', type = (lambda x: int(x, 0)), |
| nargs='+', help = 'a TPM resource handle') |
| args = parser.parse_args() |
| |
| flags = 0 |
| |
| if args.debug: |
| flags |= tpm2.Client.FLAG_DEBUG |
| |
| client = tpm2.Client(flags) |
| |
| if len(args.handles) == 0: |
| parser.print_help() |
| sys.exit(1) |
| |
| try: |
| for h in args.handles: |
| client.flush_context(h) |
| except tpm2.ProtocolError, e: |
| sys.stderr.write(str(e) + os.linesep) |
| sys.exit(1) |
| |
| if __name__ == '__main__': |
| main() |