Пример #1
0
        /// <summary>
        /// Generates the whole Table and fills values to the field (uint[,,])Tables.
        /// This part is also known as Precomputation part.
        /// </summary>
        public bool GenerateTables()
        {
            // For every table
            for (uint tValue = 0; tValue < _numberOfTables; tValue++)
            {
                // for every row
                for (uint mValue = 0; mValue < _m; mValue++)
                {
                    uint rowValue = (_m * tValue) + mValue;

                    // construct starting point and ending point
                    // starting point is mValue

                    // compute ending point
                    uint endPoint = rowValue;
                    for (int i = 0; i < _t; i++)
                    {
                        endPoint = CryptoTools.OneWayFunction32Bit(endPoint);
                    }

                    // fill the byte array
                    Tables[tValue, mValue, 0] = rowValue;
                    Tables[tValue, mValue, 1] = endPoint;
                }

                if (TableProcessed != null)
                {
                    TableProcessed(tValue + 1);
                }
            }

            return(true);
        }
Пример #2
0
        public uint?FindPreimageValue(uint hashValue)
        {
            // her tablo için
            for (uint i = 0; i < _numberOfTables; i++)
            {
                // her bir satırda ending point e bak
                for (int j = 0; j < _m; j++)
                {
                    uint aradigimizsayi         = Tables[i, j, 0];
                    uint aradigimizsayininhashi = Tables[i, j, 1];
                    // hash al bak
                    for (int k = 0; k < _t; k++)
                    {
                        aradigimizsayininhashi = CryptoTools.OneWayFunction32Bit(aradigimizsayi);
                        if (aradigimizsayininhashi == hashValue)
                        {
                            return(aradigimizsayi);
                        }

                        aradigimizsayi = aradigimizsayininhashi;
                    }
                }
            }

            return(null);
        }