From 0174fc8b305e844d30dc012b12e2fa23edda6790 Mon Sep 17 00:00:00 2001 From: Gustave Monce Date: Fri, 30 Aug 2024 20:41:57 +0200 Subject: [PATCH] QCParts: Check if signatures are available --- WPinternals/Models/QualcommPartition.cs | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/WPinternals/Models/QualcommPartition.cs b/WPinternals/Models/QualcommPartition.cs index 13bdf3f..7589ace 100644 --- a/WPinternals/Models/QualcommPartition.cs +++ b/WPinternals/Models/QualcommPartition.cs @@ -160,24 +160,27 @@ namespace WPinternals } } - byte[] RootCertificate = Signatures[^1]; - - for (int i = 0; i < Signatures.Count; i++) + if (Signatures.Count > 0) { - if (i + 1 != Signatures.Count) + byte[] RootCertificate = Signatures[^1]; + + for (int i = 0; i < Signatures.Count; i++) { + if (i + 1 != Signatures.Count) + { #if DEBUG - System.Diagnostics.Debug.Print("Cert: " + Converter.ConvertHexToString(SHA256.HashData(Signatures[i]), "")); + System.Diagnostics.Debug.Print("Cert: " + Converter.ConvertHexToString(SHA256.HashData(Signatures[i]), "")); #endif - } - else - { - // This is the last certificate. So this is the root key. - RootKeyHash = SHA256.HashData(Signatures[i]); + } + else + { + // This is the last certificate. So this is the root key. + RootKeyHash = SHA256.HashData(Signatures[i]); #if DEBUG - System.Diagnostics.Debug.Print("RKH: " + Converter.ConvertHexToString(RootKeyHash, "")); + System.Diagnostics.Debug.Print("RKH: " + Converter.ConvertHexToString(RootKeyHash, "")); #endif + } } } }