Mate Toth-Pal | 51b6198 | 2022-03-17 14:19:30 +0100 | [diff] [blame] | 1 | #!/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 | |
| 9 | import argparse |
| 10 | import sys |
| 11 | |
| 12 | import yaml |
| 13 | from iatverifier.util import convert_token_to_map |
| 14 | from iatverifier.psa_iot_profile1_token_verifier import PSAIoTProfile1TokenVerifier |
| 15 | |
| 16 | |
| 17 | if __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 | |