iat-verifier: Import iat-verifier from tf-m repo
Change-Id: I93446f3f2ce06e73958833ae50d9349cf4acd369
Signed-off-by: Mate Toth-Pal <mate.toth-pal@arm.com>
diff --git a/iat-verifier/scripts/decompile_token b/iat-verifier/scripts/decompile_token
new file mode 100755
index 0000000..cc74e12
--- /dev/null
+++ b/iat-verifier/scripts/decompile_token
@@ -0,0 +1,35 @@
+#!/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__':
+ 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.''')
+ args = parser.parse_args()
+
+ verifier = PSAIoTProfile1TokenVerifier.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)
+
+