Exemple #1
0
    def _transform(self, W):

        for t in range(16, 80):
            W[t] = _rotateLeft(
                W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16], 1)

        A = self.H0
        B = self.H1
        C = self.H2
        D = self.H3
        E = self.H4

        """
        This loop is unrolled (via unroll_f_K) to gain some speed
        for t in range(0, 80):
            TEMP = _rotateLeft(A, 5) + f[t/20] + E + W[t] + K[t/20]
            E = D
            D = C
            C = _rotateLeft(B, 30) & 0xffffffffL
            B = A
            A = TEMP & 0xffffffffL
        """
        t0 = 0
        for f, K in unroll_f_K:
            if UNROLL_ALL:
                rng20 = unroll_range_20
            else:
                rng20 = range(20)
            for t in rng20:
                TEMP = _rotateLeft(A, 5) + f(B, C, D) + E + W[t0+t] + K
                E = D
                D = C
                C = _rotateLeft(B, 30)
                B = A
                A = TEMP
            t0 += 20

        self.H0 = self.H0 + A
        self.H1 = self.H1 + B
        self.H2 = self.H2 + C
        self.H3 = self.H3 + D
        self.H4 = self.H4 + E
Exemple #2
0
    def _transform(self, W):

        for t in range(16, 80):
            W[t] = _rotateLeft(
                W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16], 1)

        A = self.H0
        B = self.H1
        C = self.H2
        D = self.H3
        E = self.H4

        """
        This loop is unrolled (via unroll_f_K) to gain some speed
        for t in range(0, 80):
            TEMP = _rotateLeft(A, 5) + f[t/20] + E + W[t] + K[t/20]
            E = D
            D = C
            C = _rotateLeft(B, 30) & 0xffffffffL
            B = A
            A = TEMP & 0xffffffffL
        """
        t0 = 0
        for f, K in unroll_f_K:
            if UNROLL_ALL:
                rng20 = unroll_range_20
            else:
                rng20 = range(20)
            for t in rng20:
                TEMP = _rotateLeft(A, 5) + f(B, C, D) + E + W[t0+t] + K
                E = D
                D = C
                C = _rotateLeft(B, 30)
                B = A
                A = TEMP
            t0 += 20

        self.H0 = self.H0 + A
        self.H1 = self.H1 + B
        self.H2 = self.H2 + C
        self.H3 = self.H3 + D
        self.H4 = self.H4 + E
Exemple #3
0
    def _transform(self, W):

        for t in range(16, 80):
            W.append(_rotateLeft(
                W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16], 1))

        A = self.H0
        B = self.H1
        C = self.H2
        D = self.H3
        E = self.H4

        """
        This loop is unrolled (via unroll_f_K) to gain some speed
        for t in range(0, 80):
            TEMP = _rotateLeft(A, 5) + f[t/20] + E + W[t] + K[t/20]
            E = D
            D = C
            C = _rotateLeft(B, 30) & 0xffffffffL
            B = A
            A = TEMP & 0xffffffffL
        """
        t0 = 0
        for f, K in unroll_f_K:
            for t in range(t0, t0+20):
                TEMP = _rotateLeft(A, 5) + f(B, C, D) + E + W[t] + K
                E = D
                D = C
                C = _rotateLeft(B, 30)
                B = A
                A = TEMP
            t0 += 20

        self.H0 = self.H0 + A
        self.H1 = self.H1 + B
        self.H2 = self.H2 + C
        self.H3 = self.H3 + D
        self.H4 = self.H4 + E
Exemple #4
0
    def _transform(self, W):

        for t in range(16, 80):
            W.append(
                _rotateLeft(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1))

        A = self.H0
        B = self.H1
        C = self.H2
        D = self.H3
        E = self.H4
        """
        This loop is unrolled (via unroll_f_K) to gain some speed
        for t in range(0, 80):
            TEMP = _rotateLeft(A, 5) + f[t/20] + E + W[t] + K[t/20]
            E = D
            D = C
            C = _rotateLeft(B, 30) & 0xffffffffL
            B = A
            A = TEMP & 0xffffffffL
        """
        t0 = 0
        for f, K in unroll_f_K:
            for t in range(t0, t0 + 20):
                TEMP = _rotateLeft(A, 5) + f(B, C, D) + E + W[t] + K
                E = D
                D = C
                C = _rotateLeft(B, 30)
                B = A
                A = TEMP
            t0 += 20

        self.H0 = self.H0 + A
        self.H1 = self.H1 + B
        self.H2 = self.H2 + C
        self.H3 = self.H3 + D
        self.H4 = self.H4 + E