private bool VerifyHash() { if (SignedHash == null) { return(false); } // 2. Initialize a hash algorithm context. HashAlgorithm hashAlgorithm; switch (SignedHash.Length) { case 16: hashAlgorithm = MD5.Create(); break; case 20: hashAlgorithm = SHA1.Create(); break; case 32: hashAlgorithm = SHA256.Create(); break; case 48: hashAlgorithm = SHA384.Create(); break; case 64: hashAlgorithm = SHA512.Create(); break; default: return(false); } var hash = ComputeAuthenticodeHashFromPeFile(hashAlgorithm); return(SignedHash.SequenceEqual(hash)); }
private bool CheckSignature() { if (SignedHash == null) { return(false); } // 2. Initialize a hash algorithm context. HashAlgorithm ha; switch (SignedHash.Length) { case 16: ha = MD5.Create(); break; case 20: ha = SHA1.Create(); break; case 32: ha = SHA256.Create(); break; case 48: ha = SHA384.Create(); break; case 64: ha = SHA512.Create(); break; default: return(false); } var hash = GetHash(ha); return(SignedHash.SequenceEqual(hash)); }