| #!/usr/bin/env python3 |
| #------------------------------------------------------------------------------- |
| # Copyright (c) 2019-2022, Arm Limited. All rights reserved. |
| # |
| # SPDX-License-Identifier: BSD-3-Clause |
| # |
| #------------------------------------------------------------------------------- |
| |
| import argparse |
| import sys |
| |
| import yaml |
| from iatverifier.util import convert_token_to_map |
| from iatverifier.psa_iot_profile1_token_verifier import PSAIoTProfile1TokenVerifier |
| |
| |
| if __name__ == '__main__': |
| |
| token_verifiers = { |
| "PSA-IoT-Profile1-token": PSAIoTProfile1TokenVerifier, |
| } |
| |
| parser = argparse.ArgumentParser() |
| parser.add_argument('source', help='A compiled COSE IAT token.') |
| parser.add_argument('-o', '--outfile', |
| help='''Output file for the depompiled claims. If this is not |
| specified, the claims will be written to standard output.''') |
| parser.add_argument('-t', '--token-type', |
| help='''The type of the Token.''', |
| choices=token_verifiers.keys(), |
| required=True) |
| args = parser.parse_args() |
| |
| verifier = token_verifiers[args.token_type].get_verifier() |
| with open(args.source, 'rb') as fh: |
| token_map = convert_token_to_map(fh.read(), verifier) |
| |
| if args.outfile: |
| with open(args.outfile, 'w') as wfh: |
| yaml.dump(token_map, wfh) |
| else: |
| yaml.dump(token_map, sys.stdout) |
| |
| |