Beispiel #1
0
        /// <summary>
        /// Raises this BigNum to a power and takes the modulus
        /// </summary>
        /// <param name="exp">The exponent</param>
        /// <param name="mod">Value to use when taking the modulus</param>
        /// <returns>this**exp % mod</returns>
        public BigNumber PowMod(BigNumber exp, BigNumber mod)
        {
            if (fDisposed)
            {
                throw new ObjectDisposedException("this");
            }
            if (exp.fDisposed)
            {
                throw new ObjectDisposedException("exp");
            }
            if (mod.fDisposed)
            {
                throw new ObjectDisposedException("mod");
            }

            IntPtr r   = OpenSSL.BN_new();
            IntPtr ctx = OpenSSL.BN_CTX_new();

            OpenSSL.BN_mod_exp(r, fBigNum, exp.fBigNum, mod.fBigNum, ctx);
            OpenSSL.BN_CTX_free(ctx);
            return(new BigNumber(r));
        }