Пример #1
0
 public void ReadFromPacket(ref nullprof.nullDCInstance.dpa packet)
 {
     // u32 addr;
     address = packet.ReadU32();
     // void* sh4_code;
     sh4Code = packet.ReadU32();
     // void* x86_code;
     x86Code = packet.ReadU32();
     // u32 sh4_bytes;
     size = packet.ReadU32();
     // u32 x86_bytes;
     x86CodeSize = packet.ReadU32();
     // u32 sh4_cycles;
     Cycles = packet.ReadU32();
     //u64 time;
     CallTime = packet.ReadU64();
     // u32 calls;
     Calls = packet.ReadU32();
 }
Пример #2
0
        ///<summary>
        /// The core Whirlpool transform.
        ///</summary>
        void processBuffer()
        {
            int i, r;
            u64[] K = new u64[8];        /* the round key */
            u64[] block = new u64[8];    /* mu(buffer) */
            u64[] state = new u64[8];    /* the cipher state */
            u64[] L = new u64[8];
            byte[] buffer = this.buffer;
            int bufferOffset = 0;

            /*
             * map the buffer to a block:
             */
            for (i = 0; i < 8; i++, bufferOffset += 8)
            {
                block[i] =
                    (((u64)buffer[bufferOffset + 0]) << 56) ^
                    (((u64)buffer[bufferOffset + 1] & 0xffL) << 48) ^
                    (((u64)buffer[bufferOffset + 2] & 0xffL) << 40) ^
                    (((u64)buffer[bufferOffset + 3] & 0xffL) << 32) ^
                    (((u64)buffer[bufferOffset + 4] & 0xffL) << 24) ^
                    (((u64)buffer[bufferOffset + 5] & 0xffL) << 16) ^
                    (((u64)buffer[bufferOffset + 6] & 0xffL) << 8) ^
                    (((u64)buffer[bufferOffset + 7] & 0xffL));
            }
            /*
             * compute and apply K^0 to the cipher state:
             */
            state[0] = block[0] ^ (K[0] = this.hash[0]);
            state[1] = block[1] ^ (K[1] = this.hash[1]);
            state[2] = block[2] ^ (K[2] = this.hash[2]);
            state[3] = block[3] ^ (K[3] = this.hash[3]);
            state[4] = block[4] ^ (K[4] = this.hash[4]);
            state[5] = block[5] ^ (K[5] = this.hash[5]);
            state[6] = block[6] ^ (K[6] = this.hash[6]);
            state[7] = block[7] ^ (K[7] = this.hash[7]);
            /*
             * iterate over all rounds:
             */
            for (r = 1; r <= R; r++)
            {
                /*
                 * compute K^r from K^{r-1}:
                 */
                L[0] =
                    C0[(int)(K[0] >> 56)] ^
                    C1[(int)(K[7] >> 48) & 0xff] ^
                    C2[(int)(K[6] >> 40) & 0xff] ^
                    C3[(int)(K[5] >> 32) & 0xff] ^
                    C4[(int)(K[4] >> 24) & 0xff] ^
                    C5[(int)(K[3] >> 16) & 0xff] ^
                    C6[(int)(K[2] >> 8) & 0xff] ^
                    C7[(int)(K[1]) & 0xff] ^
                    rc[r];
                L[1] =
                    C0[(int)(K[1] >> 56)] ^
                    C1[(int)(K[0] >> 48) & 0xff] ^
                    C2[(int)(K[7] >> 40) & 0xff] ^
                    C3[(int)(K[6] >> 32) & 0xff] ^
                    C4[(int)(K[5] >> 24) & 0xff] ^
                    C5[(int)(K[4] >> 16) & 0xff] ^
                    C6[(int)(K[3] >> 8) & 0xff] ^
                    C7[(int)(K[2]) & 0xff];
                L[2] =
                    C0[(int)(K[2] >> 56)] ^
                    C1[(int)(K[1] >> 48) & 0xff] ^
                    C2[(int)(K[0] >> 40) & 0xff] ^
                    C3[(int)(K[7] >> 32) & 0xff] ^
                    C4[(int)(K[6] >> 24) & 0xff] ^
                    C5[(int)(K[5] >> 16) & 0xff] ^
                    C6[(int)(K[4] >> 8) & 0xff] ^
                    C7[(int)(K[3]) & 0xff];
                L[3] =
                    C0[(int)(K[3] >> 56)] ^
                    C1[(int)(K[2] >> 48) & 0xff] ^
                    C2[(int)(K[1] >> 40) & 0xff] ^
                    C3[(int)(K[0] >> 32) & 0xff] ^
                    C4[(int)(K[7] >> 24) & 0xff] ^
                    C5[(int)(K[6] >> 16) & 0xff] ^
                    C6[(int)(K[5] >> 8) & 0xff] ^
                    C7[(int)(K[4]) & 0xff];
                L[4] =
                    C0[(int)(K[4] >> 56)] ^
                    C1[(int)(K[3] >> 48) & 0xff] ^
                    C2[(int)(K[2] >> 40) & 0xff] ^
                    C3[(int)(K[1] >> 32) & 0xff] ^
                    C4[(int)(K[0] >> 24) & 0xff] ^
                    C5[(int)(K[7] >> 16) & 0xff] ^
                    C6[(int)(K[6] >> 8) & 0xff] ^
                    C7[(int)(K[5]) & 0xff];
                L[5] =
                    C0[(int)(K[5] >> 56)] ^
                    C1[(int)(K[4] >> 48) & 0xff] ^
                    C2[(int)(K[3] >> 40) & 0xff] ^
                    C3[(int)(K[2] >> 32) & 0xff] ^
                    C4[(int)(K[1] >> 24) & 0xff] ^
                    C5[(int)(K[0] >> 16) & 0xff] ^
                    C6[(int)(K[7] >> 8) & 0xff] ^
                    C7[(int)(K[6]) & 0xff];
                L[6] =
                    C0[(int)(K[6] >> 56)] ^
                    C1[(int)(K[5] >> 48) & 0xff] ^
                    C2[(int)(K[4] >> 40) & 0xff] ^
                    C3[(int)(K[3] >> 32) & 0xff] ^
                    C4[(int)(K[2] >> 24) & 0xff] ^
                    C5[(int)(K[1] >> 16) & 0xff] ^
                    C6[(int)(K[0] >> 8) & 0xff] ^
                    C7[(int)(K[7]) & 0xff];
                L[7] =
                    C0[(int)(K[7] >> 56)] ^
                    C1[(int)(K[6] >> 48) & 0xff] ^
                    C2[(int)(K[5] >> 40) & 0xff] ^
                    C3[(int)(K[4] >> 32) & 0xff] ^
                    C4[(int)(K[3] >> 24) & 0xff] ^
                    C5[(int)(K[2] >> 16) & 0xff] ^
                    C6[(int)(K[1] >> 8) & 0xff] ^
                    C7[(int)(K[0]) & 0xff];
                K[0] = L[0];
                K[1] = L[1];
                K[2] = L[2];
                K[3] = L[3];
                K[4] = L[4];
                K[5] = L[5];
                K[6] = L[6];
                K[7] = L[7];
                /*
                 * apply the r-th round transformation:
                 */
                L[0] =
                    C0[(int)(state[0] >> 56)] ^
                    C1[(int)(state[7] >> 48) & 0xff] ^
                    C2[(int)(state[6] >> 40) & 0xff] ^
                    C3[(int)(state[5] >> 32) & 0xff] ^
                    C4[(int)(state[4] >> 24) & 0xff] ^
                    C5[(int)(state[3] >> 16) & 0xff] ^
                    C6[(int)(state[2] >> 8) & 0xff] ^
                    C7[(int)(state[1]) & 0xff] ^
                    K[0];
                L[1] =
                    C0[(int)(state[1] >> 56)] ^
                    C1[(int)(state[0] >> 48) & 0xff] ^
                    C2[(int)(state[7] >> 40) & 0xff] ^
                    C3[(int)(state[6] >> 32) & 0xff] ^
                    C4[(int)(state[5] >> 24) & 0xff] ^
                    C5[(int)(state[4] >> 16) & 0xff] ^
                    C6[(int)(state[3] >> 8) & 0xff] ^
                    C7[(int)(state[2]) & 0xff] ^
                    K[1];
                L[2] =
                    C0[(int)(state[2] >> 56)] ^
                    C1[(int)(state[1] >> 48) & 0xff] ^
                    C2[(int)(state[0] >> 40) & 0xff] ^
                    C3[(int)(state[7] >> 32) & 0xff] ^
                    C4[(int)(state[6] >> 24) & 0xff] ^
                    C5[(int)(state[5] >> 16) & 0xff] ^
                    C6[(int)(state[4] >> 8) & 0xff] ^
                    C7[(int)(state[3]) & 0xff] ^
                    K[2];
                L[3] =
                    C0[(int)(state[3] >> 56)] ^
                    C1[(int)(state[2] >> 48) & 0xff] ^
                    C2[(int)(state[1] >> 40) & 0xff] ^
                    C3[(int)(state[0] >> 32) & 0xff] ^
                    C4[(int)(state[7] >> 24) & 0xff] ^
                    C5[(int)(state[6] >> 16) & 0xff] ^
                    C6[(int)(state[5] >> 8) & 0xff] ^
                    C7[(int)(state[4]) & 0xff] ^
                    K[3];
                L[4] =
                    C0[(int)(state[4] >> 56)] ^
                    C1[(int)(state[3] >> 48) & 0xff] ^
                    C2[(int)(state[2] >> 40) & 0xff] ^
                    C3[(int)(state[1] >> 32) & 0xff] ^
                    C4[(int)(state[0] >> 24) & 0xff] ^
                    C5[(int)(state[7] >> 16) & 0xff] ^
                    C6[(int)(state[6] >> 8) & 0xff] ^
                    C7[(int)(state[5]) & 0xff] ^
                    K[4];
                L[5] =
                    C0[(int)(state[5] >> 56)] ^
                    C1[(int)(state[4] >> 48) & 0xff] ^
                    C2[(int)(state[3] >> 40) & 0xff] ^
                    C3[(int)(state[2] >> 32) & 0xff] ^
                    C4[(int)(state[1] >> 24) & 0xff] ^
                    C5[(int)(state[0] >> 16) & 0xff] ^
                    C6[(int)(state[7] >> 8) & 0xff] ^
                    C7[(int)(state[6]) & 0xff] ^
                    K[5];
                L[6] =
                    C0[(int)(state[6] >> 56)] ^
                    C1[(int)(state[5] >> 48) & 0xff] ^
                    C2[(int)(state[4] >> 40) & 0xff] ^
                    C3[(int)(state[3] >> 32) & 0xff] ^
                    C4[(int)(state[2] >> 24) & 0xff] ^
                    C5[(int)(state[1] >> 16) & 0xff] ^
                    C6[(int)(state[0] >> 8) & 0xff] ^
                    C7[(int)(state[7]) & 0xff] ^
                    K[6];
                L[7] =
                    C0[(int)(state[7] >> 56)] ^
                    C1[(int)(state[6] >> 48) & 0xff] ^
                    C2[(int)(state[5] >> 40) & 0xff] ^
                    C3[(int)(state[4] >> 32) & 0xff] ^
                    C4[(int)(state[3] >> 24) & 0xff] ^
                    C5[(int)(state[2] >> 16) & 0xff] ^
                    C6[(int)(state[1] >> 8) & 0xff] ^
                    C7[(int)(state[0]) & 0xff] ^
                    K[7];
                state[0] = L[0];
                state[1] = L[1];
                state[2] = L[2];
                state[3] = L[3];
                state[4] = L[4];
                state[5] = L[5];
                state[6] = L[6];
                state[7] = L[7];
            }
            /*
             * apply the Miyaguchi-Preneel compression function:
             */
            this.hash[0] ^= state[0] ^ block[0];
            this.hash[1] ^= state[1] ^ block[1];
            this.hash[2] ^= state[2] ^ block[2];
            this.hash[3] ^= state[3] ^ block[3];
            this.hash[4] ^= state[4] ^ block[4];
            this.hash[5] ^= state[5] ^ block[5];
            this.hash[6] ^= state[6] ^ block[6];
            this.hash[7] ^= state[7] ^ block[7];
        }
Пример #3
0
 private static u64 LL(u64 ul) { return ul; }