Beispiel #1
0
        public void TestSignatureUsingEmbeddedKeys()
        {
            this.CleanTempPath(true);
            this.PopulateTempPath();

            //this.MakeEncryptedArchive(rsa);
            this.MakeEncryptedArchive();

            // should now have archive.enc and archive.enc.sig at temppath
            // let's verify the sig file
            var crypto = new SequoiaCryptoProvider(false);

            string pathToArchive = Path.Combine(this.tempPath, "archive.enc");
            string pathToSig     = Path.Combine(this.tempPath, "archive.enc.sig");

            bool verified = crypto.VerifySignature(pathToSig, pathToArchive);

            Assert.IsTrue(verified);
        }
        /// <summary>
        ///     Verifies the archive signature.
        /// </summary>
        /// <param name="selectedArchivePath">The selected archive path.</param>
        /// <externalUnit/>
        /// <revision revisor="dev13" date="11/18/2009" version="1.1.3.6">
        ///     Added documentation header
        /// </revision>
        private void VerifyArchiveSignature(string selectedArchivePath)
        {
            string pathToSigFile = selectedArchivePath + ".sig";

            if (!File.Exists(pathToSigFile))
            {
                MessageBox.Show(
                    "Please select a valid file which has a signature file " +
                    "of the same name, plus '.sig.'",
                    "No signature file present",
                    MessageBoxButton.OK,
                    MessageBoxImage.Error);
            }
            else
            {
                var sequoiaCryptoProvider = new SequoiaCryptoProvider();

                bool verified =
                    sequoiaCryptoProvider.VerifySignature(
                        pathToSigFile, selectedArchivePath);

                if (verified)
                {
                    MessageBox.Show(
                        "The file matches the signature!",
                        "File Signature Test",
                        MessageBoxButton.OK,
                        MessageBoxImage.Information);
                }
                else
                {
                    MessageBox.Show(
                        "the file does NOT match the signature.",
                        "File Signature Test",
                        MessageBoxButton.OK,
                        MessageBoxImage.Error);
                }
            }
        }