Example #1
0
 public void SetUp()
 {
     _fileSignatureVerificator = new FileSignatureVerificator();
     var issuerInformation = new IssuerInformation("Nomad",
                                                   new NullSignatureAlgorithm());
     _fileSignatureVerificator.AddTrustedIssuer(issuerInformation);
 }
Example #2
0
 public void returns_correct_issuer_when_one_registered()
 {
     string issuerName = "testIssuer";
     var issuer = new IssuerInformation(issuerName, new NullSignatureAlgorithm());
     _signatureProvider.Register(issuer);
     Assert.AreSame(issuer, _signatureProvider.GetIssuer(issuerName),
                    "Incorrect issuer returned");
 }
Example #3
0
        /// <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);
            }
        }
Example #4
0
 /// <summary>
 /// Trust specified issuer
 /// </summary>
 /// <param name="issuerInformation"><see cref="IssuerInformation"/> to trust</param>
 public void AddTrustedIssuer(IssuerInformation issuerInformation)
 {
     _issuers.Add(issuerInformation.IssuerName, issuerInformation);
 }
 /// <summary>
 /// Trust specified issuer
 /// </summary>
 /// <param name="issuerInformation"><see cref="IssuerInformation"/> to trust</param>
 public void AddTrustedIssuer(IssuerInformation issuerInformation)
 {
     _issuers.Add(issuerInformation.IssuerName, issuerInformation);
 }