Example #1
0
 public void Bug3017248()
 {
     CryptoKey key = new CryptoKey(new DSA(true));
     BIO output = BIO.MemoryBuffer();
     key.WritePrivateKey(output, Cipher.Null, "password");
     output.SetClose(BIO.CloseOption.Close);
     Console.WriteLine(output.ReadString());
 }
        /// <summary>
        /// Writes the specified cryptoKey out to the file in the fileName parameter. The contents of the
        /// file is encrypted with the triple DES algorithm with the specified password.
        /// </summary>
        /// <param name="cryptoKey">The CryptoKey containing the Private key to be written to file.</param>
        /// <param name="fileName">The name and location of the file to be written.</param>
        /// <param name="password">The password used to decrypt the file.</param>
        public static void WritePrivateKeyToFile(CryptoKey cryptoKey, string fileName, string password)
        {
            if (cryptoKey == null)
            {
                throw new ArgumentNullException("cryptoKey", "CryptoKey is null");
            }

            using (var bio = FileHelpers.Write(fileName))
            {
                cryptoKey.WritePrivateKey(bio, Cipher.DES_EDE3_CBC, password);
            }
        }