blob: e97a6f5bfa6a3faecd55a6fda7bb865429f66ba7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#!/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('--auth-value', dest='auth_value', metavar='AUTH_VALUE',
type=lambda x: getattr(x, 'decode')('hex'),
default='',
help='20 byte auth value in hex')
args = parser.parse_args()
flags = 0
if args.debug:
flags |= tpm2.Client.FLAG_DEBUG
client = tpm2.Client(flags)
try:
handle = client.create_root_key(args.auth_value)
except tpm2.ProtocolError, e:
sys.stderr.write(str(e) + os.linesep)
sys.exit(1)
print(format(handle, '#010x'))
if __name__ == '__main__':
main()
|