public void TestMethod1_EncryptArmoured()
        {
            RetrievePgpKeys keySetEnc = new RetrievePgpKeys(new List <string> {
                "jwdavidson+BcPGPTest@gmail_com_public.asc",
                "testuser@example_com_public.asc"
            },
                                                            "jwdavidson+BcPGPTest@gmail_com_secret.asc",
                                                            new char[] { 'W', 'i', '7', 'a', 'r', 'd', 'r', 'y', '!', 'T', 'e', 's', 't' },
                                                            @"C:\Users\John\BcPGP\", true);
            StringBuilder testString = new StringBuilder();

            testString.AppendLine("This is some text to test the encryption algorithm in my code for PGP.");
            testString.AppendLine("This is a second line of text with a      series    of spaces  in the    middle of the text.");
            PgpEncryptString testEncrypt = new PgpEncryptString(keySetEnc);
            string           Returned    = testEncrypt.EncryptAndSign(testString.ToString(), true);

            RetrievePgpKeys keySetUnc = new RetrievePgpKeys(new List <string> {
                "jwdavidson+BcPGPTest@gmail_com_public.asc"
            },
                                                            "jwdavidson+BcPGPTest@gmail_com_secret.asc",
                                                            new char[] { 'W', 'i', '7', 'a', 'r', 'd', 'r', 'y', '!', 'T', 'e', 's', 't' },
                                                            @"C:\Users\John\BcPGP\", true);

            byte[] unencryptedBytes = PGPDecryptString.Decrypt(Returned, keySetUnc);
            string Decrypted        = Encoding.UTF8.GetString(unencryptedBytes);

            Assert.IsTrue(Decrypted.Equals(testString.ToString()));
        }
        public void TestMethod1_DecryptArmoured()
        {
            RetrievePgpKeys keySet = new RetrievePgpKeys(new List <string> {
                "jwdavidson+BcPGPTest@gmail_com_public.asc"
            },
                                                         "jwdavidson+BcPGPTest@gmail_com_secret.asc",
                                                         new char[] { 'W', 'i', '7', 'a', 'r', 'd', 'r', 'y', '!', 'T', 'e', 's', 't' },
                                                         @"C:\Users\John\BcPGP\", true);
            PgpEncryptFile testEncrypt = new PgpEncryptFile(keySet);
            FileInfo       testFile    = new FileInfo(@"C:\Users\John\BcPGP\AliceInWonderland.txt");

            using (FileStream myStream = new FileStream(testFile.FullName + ".pgp", FileMode.Create, FileAccess.Write)) {
                testEncrypt.EncryptAndSign(myStream, testFile, true);
            }

            RetrievePgpKeys keySet1 = new RetrievePgpKeys(new List <string> {
                "jwdavidson+BcPGPTest@gmail_com_public.asc"
            },
                                                          "jwdavidson+BcPGPTest@gmail_com_secret.asc",
                                                          new char[] { 'W', 'i', '7', 'a', 'r', 'd', 'r', 'y', '!', 'T', 'e', 's', 't' },
                                                          @"C:\Users\John\BcPGP\", false);

            PgpDecryptFile testDescrypt = new PgpDecryptFile(@"C:\Users\John\BcPGP\AliceInWonderland.txt.pgp", keySet1,
                                                             @"C:\Users\John\BcPGP\");
            FileStream fs = File.Open(@"C:\Users\John\BcPGP\AliceInWonderland.txt.pgp", FileMode.Open);

            testDescrypt.Decrypt(fs, @"C:\Users\John\BcPGP\");
        }
Ejemplo n.º 3
0
        private void btnChangePassphrase_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            RetrievePgpKeys keySet = new RetrievePgpKeys(txtEmail.Text, true, Global.keyDb);

            PgpSecretKeyPassphraseChange.KeyChangePassphrase(keySet.SecretKey, m_passphrase0,
                                                             m_passphrase1, Global.keyDb, string.Empty);
            lblResult.Text    = "Passphrase updated successfully.";
            lblResult.Visible = true;
            Cursor.Current    = Cursors.Default;
        }
        public void TestMethod1()
        {
            long   keyId          = 0;
            string originalArmour = string.Empty;

            using (KeyStoreDB keyDB = new KeyStoreDB()) {
                RetrievePgpKeys keySet = new RetrievePgpKeys("*****@*****.**", true, keyDB);
                keyId = keySet.SecretKey.KeyId;
                PgpPublicKeyModifySignatures.AddSignature(keySet.SecretKey.PublicKey, keyDB, "", keySet.SecretKey,
                                                          new char[] { 't', 'e', 's', 't', 'u', 's', 'e', 'r' }, SignatureOperation.RevokeKey, DateTime.MinValue);
            }
        }
        public void TestMethod1()
        {
            RetrievePgpKeys keySet = new RetrievePgpKeys(new List <string> {
                "jwdavidson+BcPGPTest@gmail_com_public.asc"
            },
                                                         "jwdavidson+BcPGPTest@gmail_com_secret.asc",
                                                         new char[] { 'W', 'i', '7', 'a', 'r', 'd', 'r', 'y', '!', 'T', 'e', 's', 't' },
                                                         @"C:\Users\John\BcPGP\", true);
            StringBuilder testString = new StringBuilder();

            testString.AppendLine("This is some text to test the encryption algorithm in my code for PGP.");
            testString.AppendLine("This is a second line of text with a      series    of spaces  in the    middle of the text.");
            PgpEncryptString testEncrypt = new PgpEncryptString(keySet);
            string           Returned    = testEncrypt.EncryptAndSign(testString.ToString(), true);
        }
        public void TestMethod2()
        {
            RetrievePgpKeys keySet = new RetrievePgpKeys(new List <string> {
                "jwdavidson+BcPGPTest@gmail_com_public.asc",
                "testuser@example_com_public.asc"
            },
                                                         "jwdavidson+BcPGPTest@gmail_com_secret.asc",
                                                         new char[] { 'W', 'i', '7', 'a', 'r', 'd', 'r', 'y', '!', 'T', 'e', 's', 't' },
                                                         @"C:\Users\John\BcPGP\", false);

            PgpDecryptFile testDescrypt = new PgpDecryptFile(@"C:\Users\John\BcPGP\AliceInWonderland.txt.pgp", keySet,
                                                             @"C:\Users\John\BcPGP\");
            FileStream fs = File.Open(@"C:\Users\John\BcPGP\AliceInWonderland.txt.pgp", FileMode.Open);

            testDescrypt.Decrypt(fs, @"C:\Users\John\BcPGP\");
        }
Ejemplo n.º 7
0
        public void TestMethod3_SignOnly()
        {
            RetrievePgpKeys keySet = new RetrievePgpKeys(new List <string> {
                "jwdavidson+BcPGPTest@gmail_com_public.asc",
                "testuser@example_com_public.asc"
            },
                                                         "jwdavidson+BcPGPTest@gmail_com_secret.asc",
                                                         new char[] { 'W', 'i', '7', 'a', 'r', 'd', 'r', 'y', '!', 'T', 'e', 's', 't' },
                                                         @"C:\Users\John\BcPGP\", true);
            PgpEncryptFile testEncrypt = new PgpEncryptFile(keySet);
            FileInfo       testFile    = new FileInfo(@"C:\Users\John\BcPGP\AliceInWonderland.txt");

            using (FileStream myStream = new FileStream(testFile.FullName + ".sig", FileMode.Create, FileAccess.Write)) {
                testEncrypt.EncryptAndSign(myStream, testFile, false, true);
            }
        }
Ejemplo n.º 8
0
        public void TestMethod1()
        {
            RetrievePgpKeys keySet = new RetrievePgpKeys(new List <string> {
                "testuser@example_com_public.asc"
            },
                                                         "jwdavidson+BcPGPTest@gmail_com_secret.asc",
                                                         new char[] { 'W', 'i', '7', 'a', 'r', 'd', 'r', 'y', '!', 'T', 'e', 's', 't' },
                                                         @"C:\Users\John\BcPGP\", true);

            Assert.IsNotNull(keySet.PrivateKey);
            Assert.IsNotNull(keySet.PublicKeys);
            Assert.IsNotNull(keySet.SecretKey);

            Assert.IsTrue(keySet.PublicKeys[0].BitStrength == 4096);
            Assert.IsTrue(keySet.PrivateKey.Key.IsPrivate);
            Assert.IsTrue(keySet.SecretKey.IsMasterKey);
        }
        public void TestMethod1()
        {
            long   keyId          = 0;
            string originalArmour = string.Empty;

            using (KeyStoreDB keyDB = new KeyStoreDB()) {
                RetrievePgpKeys keySet = new RetrievePgpKeys("*****@*****.**", true, keyDB);
                keyId          = keySet.SecretKey.KeyId;
                originalArmour = keyDB.KeyStores.Find(keyId).ArmouredKeyFile;
                PgpSecretKeyPassphraseChange.KeyChangePassphrase(keySet.SecretKey, new char[] { 't', 'e', 's', 't', 'u', 's', 'e', 'r' },
                                                                 new char[] { 't', 'e', 's', 't', 'u', 's', 'e', 'r', '1' }, keyDB, string.Empty);
            }
            using (KeyStoreDB keyDbNew = new KeyStoreDB()) {
                string newArmour = keyDbNew.KeyStores.Find(keyId).ArmouredKeyFile;
                Assert.IsFalse(originalArmour.Equals(newArmour));
            }
        }
Ejemplo n.º 10
0
        public void TestMethod3()
        {
            RetrievePgpKeys keySet = new RetrievePgpKeys(new List <string> {
                "JWD_Kleopatra_Public.pgp"
            },
                                                         "JWD_Kleopatra_Secret.asc",
                                                         new char[] { 'W', 'i', '7', 'a', 'r', 'd', 'r', 'y', '!' },
                                                         @"C:\Users\John\BcPGP\", false);

            Assert.IsNotNull(keySet.PrivateKey);
            Assert.IsNotNull(keySet.PublicKeys);
            Assert.IsNotNull(keySet.SecretKey);
            Assert.IsTrue(keySet.SecretKey.PublicKey.KeyId == keySet.PublicKeys[0].KeyId);

            Assert.IsTrue(keySet.PublicKeys[0].BitStrength == 4096);
            Assert.IsTrue(keySet.PrivateKey.Key.IsPrivate);
            Assert.IsTrue(keySet.SecretKey.IsMasterKey);
        }