Example #1
0
 private string ReadMachineKey()
 {
     try
     {
         using (var guid = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Default).OpenSubKey(@"SOFTWARE\Microsoft\Cryptography"))
         {
             var machineGuid = Guid.ParseExact(guid.GetValue("MachineGuid").ToString(), "d");
             return(_hash.CalculateHash(machineGuid.ToByteArray()));
         }
     }
     catch (Exception e)
     {
         _logger.Debug(e, "Couldn't read Machine GUID.");
         return(new string('=', 10));
     }
 }
Example #2
0
        public void ValidateHash(string path, string sha256)
        {
            _logger.Trace("Starting checksum verification");


            var hash = _calculateHash.CalculateHash(path);

            if (!string.Equals(hash, sha256, StringComparison.OrdinalIgnoreCase))
            {
                _logger.Warn($"Checksum verification failed for {path}. File: {hash}  Manifest:{sha256}");

                throw new ChecksumVerificationException(
                          $"SHA256 Checksum verification failed for {path}.");
            }

            _logger.Info("Checksum verification PASSED");
        }