Org.BouncyCastle.Crypto.Engines.IdeaEngine.MulInv C# (CSharp) Method

MulInv() private method

private MulInv ( int x ) : int
x int
return int
        private int MulInv(
            int x)
        {
            int t0, t1, q, y;

            if (x < 2)
            {
                return x;
            }
            t0 = 1;
            t1 = BASE / x;
            y  = BASE % x;
            while (y != 1)
            {
                q = x / y;
                x = x % y;
                t0 = (t0 + (t1 * q)) & MASK;
                if (x == 1)
                {
                    return t0;
                }
                q = y / x;
                y = y % x;
                t1 = (t1 + (t0 * q)) & MASK;
            }
            return (1 - t1) & MASK;
        }
        /**