blob: cc74e12d66f048add4157878ff8c6f54a185dd8f [file] [log] [blame]
Mate Toth-Pal51b61982022-03-17 14:19:30 +01001#!/usr/bin/env python3
2#-------------------------------------------------------------------------------
3# Copyright (c) 2019-2022, Arm Limited. All rights reserved.
4#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7#-------------------------------------------------------------------------------
8
9import argparse
10import sys
11
12import yaml
13from iatverifier.util import convert_token_to_map
14from iatverifier.psa_iot_profile1_token_verifier import PSAIoTProfile1TokenVerifier
15
16
17if __name__ == '__main__':
18 parser = argparse.ArgumentParser()
19 parser.add_argument('source', help='A compiled COSE IAT token.')
20 parser.add_argument('-o', '--outfile',
21 help='''Output file for the depompiled claims. If this is not
22 specified, the claims will be written to standard output.''')
23 args = parser.parse_args()
24
25 verifier = PSAIoTProfile1TokenVerifier.get_verifier()
26 with open(args.source, 'rb') as fh:
27 token_map = convert_token_to_map(fh.read(), verifier)
28
29 if args.outfile:
30 with open(args.outfile, 'w') as wfh:
31 yaml.dump(token_map, wfh)
32 else:
33 yaml.dump(token_map, sys.stdout)
34
35