Пример #1
0
        public static BigNumber operator /(BigNumber left, BigNumber right)
        {
            //Ensure that the BigNums have not been disposed
            if (left.fDisposed)
            {
                throw new ObjectDisposedException("left");
            }
            if (right.fDisposed)
            {
                throw new ObjectDisposedException("right");
            }

            //Actually do the operation
            IntPtr res = OpenSSL.BN_new();
            IntPtr ctx = OpenSSL.BN_CTX_new();

            OpenSSL.BN_div(res, IntPtr.Zero, left.fBigNum, right.fBigNum, ctx);
            OpenSSL.BN_CTX_free(ctx);
            return(new BigNumber(res));
        }
Пример #2
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));
        }