Beispiel #1
0
 public void verification_against_trusted_issuer_with_incorrect_filename()
 {
     var signature = new FileSignature()
                         {
                             FileName = "Nomad2.dll",
                             IssuerName = "Nomad",
                             Signature = new byte[] {65, 64, 63, 62, 61}
                         };
     var file = new File()
                    {FileName = "Nomad.dll", Data = new byte[] {65, 64, 63, 62, 61, 60}};
     Assert.IsFalse(_fileSignatureVerificator.VerifyFile(file, signature));
 }
 /// <summary>
 /// Check if specified file is trusted
 /// </summary>
 /// <param name="file"><see cref="File"/> to verify</param>
 /// <param name="signature"><see cref="FileSignature"/> of file we are verifying provided</param>
 /// <returns>true when file comes from trusted source</returns>
 public bool VerifyFile(File file, FileSignature signature)
 {
     IssuerInformation information = null;
     if (_issuers.TryGetValue(signature.IssuerName, out information))
     {
         return information.IssuerAlgorithm.Verify(file.Data, signature.Signature)
                && file.FileName == signature.FileName;
     }
     else
     {
         return false;
     }
 }