Example #1
0
        void SHATransform(uint[] output, uint[] init, uint[] data)
        {
            OpenSSL.Core.SHA256 sha = new OpenSSL.Core.SHA256();

            byte[] swapped = new byte[data.Length * 4];
            for (int i = 0; i < data.Length; i++)
            {
                int byidx = i * 4;
                swapped[byidx + 0] = (byte)((data[i] & 0xFF000000) >> 24);
                swapped[byidx + 1] = (byte)((data[i] & 0x00FF0000) >> 16);
                swapped[byidx + 2] = (byte)((data[i] & 0x0000FF00) >> 8);
                swapped[byidx + 3] = (byte)((data[i] & 0x000000FF));
            }

            Array.Copy(init, sha.ctx.h, 8);
            sha.Update(swapped);
            Buffer.BlockCopy(sha.ctx.h, 0, output, 0, 32);
        }
Example #2
0
        void SHATransform(uint[] output, byte[] data, uint[] init)
        {
            OpenSSL.Core.SHA256 sha = new OpenSSL.Core.SHA256();

            byte[] swapped = new byte[data.Length];
            int    count   = data.Length / 4;

            for (int i = 0; i < count; i++)
            {
                int byidx = i * 4;
                swapped[byidx + 0] = data[byidx + 3];
                swapped[byidx + 1] = data[byidx + 2];
                swapped[byidx + 2] = data[byidx + 1];
                swapped[byidx + 3] = data[byidx + 0];
            }

            Array.Copy(init, sha.ctx.h, 8);
            sha.Update(swapped);
            Array.Copy(sha.ctx.h, output, 8);
        }
Example #3
0
        void SHATransform(uint[] output, byte[] data, uint[] init)
        {
            OpenSSL.Core.SHA256 sha = new OpenSSL.Core.SHA256();

            byte[] swapped = new byte[data.Length];
            int count = data.Length / 4;
            for (int i = 0; i < count; i++)
            {
                int byidx = i * 4;
                swapped[byidx + 0] = data[byidx + 3];
                swapped[byidx + 1] = data[byidx + 2];
                swapped[byidx + 2] = data[byidx + 1];
                swapped[byidx + 3] = data[byidx + 0];
            }

            Array.Copy(init, sha.ctx.h, 8);
            sha.Update(swapped);
            Array.Copy(sha.ctx.h, output, 8);
        }
Example #4
0
        void SHATransform(uint[] output, uint[] init, uint[] data)
        {
            OpenSSL.Core.SHA256 sha = new OpenSSL.Core.SHA256();

            byte[] swapped = new byte[data.Length * 4];
            for (int i = 0; i < data.Length; i++)
            {
                int byidx = i * 4;
                swapped[byidx + 0] = (byte)((data[i] & 0xFF000000) >> 24);
                swapped[byidx + 1] = (byte)((data[i] & 0x00FF0000) >> 16);
                swapped[byidx + 2] = (byte)((data[i] & 0x0000FF00) >> 8);
                swapped[byidx + 3] = (byte)((data[i] & 0x000000FF) );
            }

            Array.Copy(init, sha.ctx.h, 8);
            sha.Update(swapped);
            Buffer.BlockCopy(sha.ctx.h, 0, output, 0, 32);
        }