예제 #1
0
        /// <summary>
        ///  Creates a new modulus
        /// </summary>
        /// <param name="path">filepath where modulus is written, default is</param>
        /// <param name="length">modulus length in bits</param>
        /// <returns></returns>
        static byte[] CreateNewModulus(string path, int length = 2048)
        {
            MakwaPrivateKey privateKey = MakwaPrivateKey.Generate(length);

            byte[] modulus = Tools.I2OSP(privateKey.Modulus);
            WriteToFile(path, modulus);
            return(modulus);
        }
예제 #2
0
        /// <summary>
        /// Creates a new private key class, writes modulus and primes p,q to file
        /// </summary>
        /// <param name="path">
        /// filepath, primes are appended with "-p" and "-q" respectively
        /// </param>
        /// <param name="length">modulus length in bits, default is 2048</param>
        /// <returns>MakwaPrivateKey</returns>
        static MakwaPrivateKey CreateNewPrivateKey(string path, int length = 2048)
        {
            MakwaPrivateKey privateKey = MakwaPrivateKey.Generate(length);

            byte[] modulus = Tools.I2OSP(privateKey.Modulus);
            byte[] p       = Tools.I2OSP(privateKey.p);
            byte[] q       = Tools.I2OSP(privateKey.q);
            WriteToFile(path, modulus);
            WriteToFile(path + "-p", p);
            WriteToFile(path + "-q", q);
            return(privateKey);
        }