private void btnImportKey_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtFileToImport.Text))
            {
                lblResult.Text    = "Please specify file for key to import...";
                lblResult.Visible = true;
            }
            else
            {
                lblResult.Visible = false;
            }

            if (File.Exists(txtFileToImport.Text))
            {
                lblResult.Visible = false;
                ImportKey impKey   = new ImportKey();
                string    fileName = Path.GetFileName(txtFileToImport.Text);
                string    dirName  = Path.GetDirectoryName(txtFileToImport.Text);
                if (m_caller == "Secret")
                {
                    int cnt = impKey.ImportSecretKey(fileName, dirName, Global.keyDb);
                }
                else
                {
                    int cnt = impKey.ImportPublicKey(fileName, dirName, Global.keyDb);
                }
                lblResult.Text    = "Key imported successfully.";
                lblResult.Visible = true;
            }
            else
            {
                lblResult.Text    = "File specified does not exist!";
                lblResult.Visible = true;
            }
        }
Esempio n. 2
0
        async Task createKpFinish_CommitAsync(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtFolder.Text))
            {
                txtFolder.Text = AppDomain.CurrentDomain.BaseDirectory;
            }
            bool runOk = await LynxPrivacyLib.GenerateKeys.GenerateKeyRing(txtFirstName.Text + " " + txtSurname.Text + " <" + txtEMail.Text + ">",
                                                                           m_passphrase1, txtFolder.Text);

            ImportKey impKey = new ImportKey();
            int       cntP   = impKey.ImportPublicKey(txtPublicKeyname.Text, txtFolder.Text, Global.keyDb);
            int       cntS   = impKey.ImportSecretKey(txtSecretKeyname.Text, txtFolder.Text, Global.keyDb);
        }
Esempio n. 3
0
        public async Task TestMethod2()
        {
            if (!m_keysGenerated)
            {
                await GenerateKeys.GenerateKeyRing("John W. Davidson <*****@*****.**>", new char[] { 'W', 'i', '7', 'a', 'r', 'd', 'r', 'y', '!', 'T', 'e', 's', 't' }, @"C:\Users\John\BcPGP\");

                m_keysGenerated = true;
            }
            ImportKey impKey = new ImportKey();

            using (KeyStoreDB keyDB = new KeyStoreDB()) {
                int cnt = impKey.ImportSecretKey("*****@*****.**", @"C:\Users\John\BcPGP", keyDB);
                Assert.IsTrue(cnt == 1);
            }
        }
        public static void InitClass(TestContext ctx)
        {
            string secretKeyFile = @"-----BEGIN PGP PRIVATE KEY BLOCK-----
Version: BCPG C# v1.7.4137.9688

lQc0BFTbeXUBEACgRx6VZYo0M8Vhv7D+ukhEPAIQHmbv41oae3vCINyEk+qdlkRQ
qa+prxLyM3wvHi2WyUQUG67TgEhOKGiu5iRT3SDf7/o2+GyzkcJxVf4SsauvPNM9
chRtayHhtgNbkz+qS3G+zGgO52ck/W9J4EvxzeMaV+hN9TJm4nurZ52ZxqjxXDX2
9/loc639n/OCQTx3BKNPwt8TE3vaHUi7QScfL3Yj/zL3FDR8ct2Ymh4xWM2GjTb6
3mPWAt0pOfFOS0wxWpWYg9gl3p6iw8Sl7O5cqlxNlpA3b1b4mdF1v96kNfxkT4MI
lNhfeNQ6e9cUZbMSJxt/gzY29xERa7kYpVC5QOgI57VZg/hsO8Uoh55H7LgKQ8Zw
y4IQ/BZxBvMgBMVjYOHyhfC1rx81btPZbMHN6rwQFlXgXc+pbKTSzxmsCh00lc9z
Ib653ByqHLeF4H++T6aU7L15C+8xOuFctF1wYLGjnr6ZX5tZINuyOqq2ifQ0wkkk
xu7Ev/AIhE9oOYmn8HfwbUZOb28FbSqYssxzI76QTaPzOULJ+q/M94Z6WCTyXxHV
uTFbhhlOn6FMK4AbUAseLO34w8rxYuwL50XdUlapW6yCxbtJILa118KxuC3CLxc5
Scfi//yDmlfqc+fYDLQu2173G5+PsSaTAs9xr6tedhRzpuWg63VyOnA3BQARAQAB
/wkDAplemXfJ8EImYBVeK6Wpxj7yffXhSTElCFoRzQYDW1fv6RDytlxLPLHtpAG3
TQJTttt49uctJg6dpOhxS3jsTTST1YCZ5LTAoIbdFtK9gjfjpe9Eb8VCchzoQZxD
wJDggdT3NKSDupbIeqAcCHfdCP33OAdhpi/xDPDmxQ1dpgsOCKGI60YXF1kMfHRF
933oLCq+NwUtv5+hlR+4JQSIrUPwrlJNfzgRZY7lc0YIEuVNgAIpDrw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nESRqcl00Evx7/o
viUOB7IZCHwFa3yRoyM8ZC2/p3phK8dreV2xPaPyyNbkl0768Spoa7s+59D9MoXC
TP0+SvCeBf8jJpJ6/O/xUAvyPRvyk75+H6kOu0+4G7erK0AABb1WQvmYah1wPzD3
1ptfooPAKf193dtiOC2AoJdGu/oFmffgh0WhcbPCKlHv0zecx0DTGDkAQWAe9L+i
BQ7R6w==
=Z4JC
-----END PGP PRIVATE KEY BLOCK-----";

            File.WriteAllText(Path.Combine(@"C:\Users\John\BcPGP", "testuser1@example_com_secret.asc"), secretKeyFile);
            ImportKey impKey = new ImportKey();

            using (KeyStoreDB keyDB = new KeyStoreDB()) {
                int cnt = impKey.ImportSecretKey("testuser1@example_com_secret.asc", @"C:\Users\John\BcPGP", keyDB);
            }
        }