From 88f129cbd6f03046588ac0274b00d9ca66e558ea Mon Sep 17 00:00:00 2001 From: seiya-git Date: Fri, 10 Nov 2023 21:36:59 +0300 Subject: [PATCH] add verify levels to verify script --- py/nstools/lib/Verify.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/py/nstools/lib/Verify.py b/py/nstools/lib/Verify.py index b77eea3..e644eb4 100644 --- a/py/nstools/lib/Verify.py +++ b/py/nstools/lib/Verify.py @@ -63,7 +63,10 @@ def parse_name(file: str): 'version': version, } -def verify(file: str): +def verify(file: str, vlevel: int = 3): + if vlevel not in range(1, 3, 1): + vlevel = 3 + try: filename = os.path.abspath(file) @@ -84,13 +87,15 @@ def verify(file: str): if check_decrypt == False: check = False - check_sig, headerlist, vmsg = verify_sig(f, vmsg) - if check_sig == False: - check = False + if vlevel > 1: + check_sig, headerlist, vmsg = verify_sig(f, vmsg) + if check_sig == False: + check = False - check_hash, vmsg = verify_hash(f, headerlist, vmsg) - if check_hash == False: - check = False + if vlevel > 2: + check_hash, vmsg = verify_hash(f, headerlist, vmsg) + if check_hash == False: + check = False f.flush() f.close()