Exemplo n.º 1
0
 private unsafe static void SHA256Expand(uint *x)
 {
     for (int i = 16; i < 64; i++)
     {
         x[i] = SHA224Managed.sigma_1(x[i - 2]) + x[i - 7] + SHA224Managed.sigma_0(x[i - 15]) + x[i - 16];
     }
 }
Exemplo n.º 2
0
        private unsafe static void SHATransform(uint *expandedBuffer, uint *state, byte *block)
        {
            uint num  = *state;
            uint num2 = state[1];
            uint num3 = state[2];
            uint num4 = state[3];
            uint num5 = state[4];
            uint num6 = state[5];
            uint num7 = state[6];
            uint num8 = state[7];

            DWORDFromBigEndian(expandedBuffer, 16, block);
            SHA224Managed.SHA256Expand(expandedBuffer);
            for (int i = 0; i < 64; i++)
            {
                uint num9  = num8 + SHA224Managed.Sigma_1(num5) + SHA224Managed.Ch(num5, num6, num7) + SHA224Managed._K[i] + expandedBuffer[i];
                uint num10 = num4 + num9;
                uint num11 = num9 + SHA224Managed.Sigma_0(num) + SHA224Managed.Maj(num, num2, num3);
                i++;
                num9 = num7 + SHA224Managed.Sigma_1(num10) + SHA224Managed.Ch(num10, num5, num6) + SHA224Managed._K[i] + expandedBuffer[i];
                uint num12 = num3 + num9;
                uint num13 = num9 + SHA224Managed.Sigma_0(num11) + SHA224Managed.Maj(num11, num, num2);
                i++;
                num9 = num6 + SHA224Managed.Sigma_1(num12) + SHA224Managed.Ch(num12, num10, num5) + SHA224Managed._K[i] + expandedBuffer[i];
                uint num14 = num2 + num9;
                uint num15 = num9 + SHA224Managed.Sigma_0(num13) + SHA224Managed.Maj(num13, num11, num);
                i++;
                num9 = num5 + SHA224Managed.Sigma_1(num14) + SHA224Managed.Ch(num14, num12, num10) + SHA224Managed._K[i] + expandedBuffer[i];
                uint num16 = num + num9;
                uint num17 = num9 + SHA224Managed.Sigma_0(num15) + SHA224Managed.Maj(num15, num13, num11);
                i++;
                num9 = num10 + SHA224Managed.Sigma_1(num16) + SHA224Managed.Ch(num16, num14, num12) + SHA224Managed._K[i] + expandedBuffer[i];
                num8 = num11 + num9;
                num4 = num9 + SHA224Managed.Sigma_0(num17) + SHA224Managed.Maj(num17, num15, num13);
                i++;
                num9 = num12 + SHA224Managed.Sigma_1(num8) + SHA224Managed.Ch(num8, num16, num14) + SHA224Managed._K[i] + expandedBuffer[i];
                num7 = num13 + num9;
                num3 = num9 + SHA224Managed.Sigma_0(num4) + SHA224Managed.Maj(num4, num17, num15);
                i++;
                num9 = num14 + SHA224Managed.Sigma_1(num7) + SHA224Managed.Ch(num7, num8, num16) + SHA224Managed._K[i] + expandedBuffer[i];
                num6 = num15 + num9;
                num2 = num9 + SHA224Managed.Sigma_0(num3) + SHA224Managed.Maj(num3, num4, num17);
                i++;
                num9 = num16 + SHA224Managed.Sigma_1(num6) + SHA224Managed.Ch(num6, num7, num8) + SHA224Managed._K[i] + expandedBuffer[i];
                num5 = num17 + num9;
                num  = num9 + SHA224Managed.Sigma_0(num2) + SHA224Managed.Maj(num2, num3, num4);
            }
            *state += num;
            state[1] += num2;
            state[2] += num3;
            state[3] += num4;
            state[4] += num5;
            state[5] += num6;
            state[6] += num7;
            state[7] += num8;
        }
Exemplo n.º 3
0
        public static new SHA224 Create(string hashName)
        {
            object o = CryptoConfig.CreateFromName(hashName);

            // in case machine.config isn't configured to use any SHA224 implementation
            if (o == null)
            {
                o = new SHA224Managed();
            }
            return((SHA224)o);
        }
Exemplo n.º 4
0
        private unsafe void _HashData(byte[] partIn, int ibStart, int cbSize)
        {
            int i    = cbSize;
            int num  = ibStart;
            int num2 = (int)(this._count & 63L);

            this._count += (long)i;
            fixed(uint *stateSHA = this._stateSHA224)
            {
                fixed(byte *buffer = this._buffer)
                {
                    fixed(uint *w = this._W)
                    {
                        if (num2 > 0 && num2 + i >= 64)
                        {
                            Buffer.BlockCopy(partIn, num, this._buffer, num2, 64 - num2);
                            num += 64 - num2;
                            i   -= 64 - num2;
                            SHA224Managed.SHATransform(w, stateSHA, buffer);
                            num2 = 0;
                        }
                        while (i >= 64)
                        {
                            Buffer.BlockCopy(partIn, num, this._buffer, 0, 64);
                            num += 64;
                            i   -= 64;
                            SHA224Managed.SHATransform(w, stateSHA, buffer);
                        }
                        if (i > 0)
                        {
                            Buffer.BlockCopy(partIn, num, this._buffer, num2, i);
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
 private static uint Sigma_1(uint x)
 {
     return(SHA224Managed.RotateRight(x, 6) ^ SHA224Managed.RotateRight(x, 11) ^ SHA224Managed.RotateRight(x, 25));
 }
Exemplo n.º 6
0
 private static uint Sigma_0(uint x)
 {
     return(SHA224Managed.RotateRight(x, 2) ^ SHA224Managed.RotateRight(x, 13) ^ SHA224Managed.RotateRight(x, 22));
 }
Exemplo n.º 7
0
 private static uint sigma_1(uint x)
 {
     return(SHA224Managed.RotateRight(x, 17) ^ SHA224Managed.RotateRight(x, 19) ^ x >> 10);
 }
Exemplo n.º 8
0
 private static uint sigma_0(uint x)
 {
     return(SHA224Managed.RotateRight(x, 7) ^ SHA224Managed.RotateRight(x, 18) ^ x >> 3);
 }