public void createKey()
        {
        	var openPgp = new API_OpenPgp();
			openPgp.createKey(); 
			//openPgp.moveFilesToFolder(@"C:\O2\_USERDATA\Pgp");
			var file = @"C:\O2\_USERDATA\Pgp\PgpDetails for {0}.xml".format(openPgp.Identity);
			openPgp.save(file); 
			//show.file(file); 
			Assert.That(openPgp.PrivateKey.fileExists(), "PrivateKey file did not exist");
			Assert.That(openPgp.PublicKey.fileExists(), "PublicKey  file did not exist");
			Assert.That(file.fileExists(), "Saved API_OpenPgp file did not exist");			
        }
        public void createKey()
        {
            var openPgp = new API_OpenPgp();

            openPgp.createKey();
            //openPgp.moveFilesToFolder(@"C:\O2\_USERDATA\Pgp");
            var file = @"C:\O2\_USERDATA\Pgp\PgpDetails for {0}.xml".format(openPgp.Identity);

            openPgp.save(file);
            //show.file(file);
            Assert.That(openPgp.PrivateKey.fileExists(), "PrivateKey file did not exist");
            Assert.That(openPgp.PublicKey.fileExists(), "PublicKey  file did not exist");
            Assert.That(file.fileExists(), "Saved API_OpenPgp file did not exist");
        }
示例#3
0
        public static string createKey(this API_OpenPgp openPgp, string identity, string passPhrase, string pathTo_PrivateKey, string pathTo_PublicKey)
        {
            if (identity.valid().isFalse())
            {
                "[API_OpenPgp] there was no value provided for the mandatory field: PGP Identity".error();
                return(null);
            }
            IAsymmetricCipherKeyPairGenerator kpg = GeneratorUtilities.GetKeyPairGenerator("RSA");

            kpg.Init(new RsaKeyGenerationParameters(
                         //BigInteger.ValueOf(0x10001), new SecureRandom(), 1024, 25));
                         BigInteger.ValueOf(0x10001), new SecureRandom(), 2048, 25));

            AsymmetricCipherKeyPair kp = kpg.GenerateKeyPair();

            Stream privateKey, publicKey;

            privateKey = File.Create(pathTo_PrivateKey);
            publicKey  = File.Create(pathTo_PublicKey);

            new RsaKeyRingGenerator().ExportKeyPair(privateKey, publicKey, kp.Public, kp.Private, identity, passPhrase.ToCharArray(), true);

            privateKey.Close();
            publicKey.Close();

            openPgp.PrivateKey = pathTo_PrivateKey;
            openPgp.PublicKey  = pathTo_PublicKey;
            openPgp.Identity   = identity;
            openPgp.PassPhrase = passPhrase;

            var openPgpFile = pathTo_PublicKey.directoryName().pathCombine("{0}_OpenPgp.xml".format(identity));

            openPgp.save(openPgpFile);
            "[API_OpenPgp] Pgp mappings for identity '{0}' saved to: {0}".debug(openPgpFile);
            return(openPgpFile);
        }
示例#4
0
 public static string save(this API_OpenPgp openPgp)
 {
     return(openPgp.save("_API_OpenPgp.xml".tempFile()));
 }