2024-09-11 22:01:51 +02:00
|
|
|
#!/usr/bin/env python3
|
2023-01-14 15:02:02 +01:00
|
|
|
|
2024-10-12 19:04:19 +02:00
|
|
|
# Copyright (C) 2024, Mark Qvist
|
2023-01-14 00:11:02 +01:00
|
|
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
2022-11-01 22:06:38 +01:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import RNS
|
|
|
|
import json
|
|
|
|
import hashlib
|
|
|
|
|
|
|
|
major_version = None
|
|
|
|
minor_version = None
|
|
|
|
target_version = None
|
|
|
|
|
|
|
|
target_file = os.path.join(sys.argv[1])
|
|
|
|
|
|
|
|
firmware_data = open(target_file, "rb").read()
|
|
|
|
calc_hash = hashlib.sha256(firmware_data[0:-32]).digest()
|
|
|
|
part_hash = firmware_data[-32:]
|
|
|
|
|
|
|
|
if calc_hash == part_hash:
|
2024-01-09 14:51:03 +01:00
|
|
|
print(RNS.hexrep(part_hash, delimit=False))
|