示例#1
0
 public static void VerifyFile(byte[] publicKey, string signatureFilePath, string filePath)
 {
     try
     {
         bool validSignature = DigitalSignatures.VerifySignature(signatureFilePath, filePath, publicKey);
         if (!validSignature)
         {
             DisplayMessage.FilePathMessage(filePath, "Bad signature.");
             return;
         }
         DisplayMessage.FilePathMessage(filePath, "Good signature.");
         string comment = DigitalSignatures.GetComment();
         DisplayMessage.Message($"Authenticated comment: {comment}");
     }
     catch (Exception ex) when(ExceptionFilters.Cryptography(ex))
     {
         Logging.LogException(ex.ToString(), Logging.Severity.Error);
         if (ex is ArgumentOutOfRangeException)
         {
             DisplayMessage.Exception(ex.GetType().Name, ex.Message);
             return;
         }
         DisplayMessage.Exception(ex.GetType().Name, "Unable to verify signature.");
     }
 }
示例#2
0
 public static void VerifyFile(string signatureFilePath, string filePath, byte[] publicKey)
 {
     try
     {
         bool validSignature = DigitalSignatures.VerifySignature(signatureFilePath, filePath, publicKey, out string comment);
         if (!validSignature)
         {
             DisplayMessage.FilePathMessage(filePath, "Bad signature.");
             return;
         }
         DisplayMessage.FilePathMessage(filePath, "Good signature.");
         DisplayMessage.Message($"Authenticated comment: {comment}");
     }
     catch (Exception ex) when(ExceptionFilters.Cryptography(ex))
     {
         if (ex is ArgumentException)
         {
             DisplayMessage.FilePathMessage(signatureFilePath, ex.Message);
             return;
         }
         DisplayMessage.Exception(ex.GetType().Name, "Unable to verify signature.");
     }
 }