src/java.base/share/classes/sun/security/provider/MD5.java
author coffeys
Thu, 23 Aug 2018 11:37:14 +0100
changeset 51504 c9a3e3cac9c7
parent 47216 71c04702a3d5
permissions -rw-r--r--
8209129: Further improvements to cipher buffer management Reviewed-by: weijun, igerasim
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
14342
8435a30053c1 7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents: 12685
diff changeset
     2
 * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.security.provider;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
51504
c9a3e3cac9c7 8209129: Further improvements to cipher buffer management
coffeys
parents: 47216
diff changeset
    28
import java.util.Arrays;
c9a3e3cac9c7 8209129: Further improvements to cipher buffer management
coffeys
parents: 47216
diff changeset
    29
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import static sun.security.provider.ByteArrayAccess.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * The MD5 class is used to compute an MD5 message digest over a given
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * buffer of bytes. It is an implementation of the RSA Data Security Inc
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * MD5 algorithim as described in internet RFC 1321.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * @author      Chuck McManis
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * @author      Benjamin Renaud
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * @author      Andreas Sterbenz
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
public final class MD5 extends DigestBase {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    // state of this object
12685
8a448b5b9006 4963723: Implement SHA-224
valeriep
parents: 5506
diff changeset
    44
    private int[] state;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    // temporary buffer, used by implCompress()
12685
8a448b5b9006 4963723: Implement SHA-224
valeriep
parents: 5506
diff changeset
    46
    private int[] x;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    // rotation constants
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    private static final int S11 = 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    private static final int S12 = 12;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    private static final int S13 = 17;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    private static final int S14 = 22;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    private static final int S21 = 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    private static final int S22 = 9;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    private static final int S23 = 14;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private static final int S24 = 20;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    private static final int S31 = 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    private static final int S32 = 11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    private static final int S33 = 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    private static final int S34 = 23;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    private static final int S41 = 6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    private static final int S42 = 10;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    private static final int S43 = 15;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    private static final int S44 = 21;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    // Standard constructor, creates a new MD5 instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    public MD5() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        super("MD5", 16, 64);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        state = new int[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        x = new int[16];
51504
c9a3e3cac9c7 8209129: Further improvements to cipher buffer management
coffeys
parents: 47216
diff changeset
    71
        resetHashes();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    // clone this object
12685
8a448b5b9006 4963723: Implement SHA-224
valeriep
parents: 5506
diff changeset
    75
    public Object clone() throws CloneNotSupportedException {
8a448b5b9006 4963723: Implement SHA-224
valeriep
parents: 5506
diff changeset
    76
        MD5 copy = (MD5) super.clone();
8a448b5b9006 4963723: Implement SHA-224
valeriep
parents: 5506
diff changeset
    77
        copy.state = copy.state.clone();
8a448b5b9006 4963723: Implement SHA-224
valeriep
parents: 5506
diff changeset
    78
        copy.x = new int[16];
8a448b5b9006 4963723: Implement SHA-224
valeriep
parents: 5506
diff changeset
    79
        return copy;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * Reset the state of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    void implReset() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        // Load magic initialization constants.
51504
c9a3e3cac9c7 8209129: Further improvements to cipher buffer management
coffeys
parents: 47216
diff changeset
    87
        resetHashes();
c9a3e3cac9c7 8209129: Further improvements to cipher buffer management
coffeys
parents: 47216
diff changeset
    88
        // clear out old data
c9a3e3cac9c7 8209129: Further improvements to cipher buffer management
coffeys
parents: 47216
diff changeset
    89
        Arrays.fill(x, 0);
c9a3e3cac9c7 8209129: Further improvements to cipher buffer management
coffeys
parents: 47216
diff changeset
    90
    }
c9a3e3cac9c7 8209129: Further improvements to cipher buffer management
coffeys
parents: 47216
diff changeset
    91
c9a3e3cac9c7 8209129: Further improvements to cipher buffer management
coffeys
parents: 47216
diff changeset
    92
    private void resetHashes() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        state[0] = 0x67452301;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        state[1] = 0xefcdab89;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        state[2] = 0x98badcfe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        state[3] = 0x10325476;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * Perform the final computations, any buffered bytes are added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * to the digest, the count is added to the digest, and the resulting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * digest is stored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    void implDigest(byte[] out, int ofs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        long bitsProcessed = bytesProcessed << 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        int index = (int)bytesProcessed & 0x3f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        int padLen = (index < 56) ? (56 - index) : (120 - index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        engineUpdate(padding, 0, padLen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        i2bLittle4((int)bitsProcessed, buffer, 56);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        i2bLittle4((int)(bitsProcessed >>> 32), buffer, 60);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        implCompress(buffer, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        i2bLittle(state, 0, out, ofs, 16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    /* **********************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * The MD5 Functions. The results of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * implementation were checked against the RSADSI version.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * **********************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    private static int FF(int a, int b, int c, int d, int x, int s, int ac) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        a += ((b & c) | ((~b) & d)) + x + ac;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        return ((a << s) | (a >>> (32 - s))) + b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    private static int GG(int a, int b, int c, int d, int x, int s, int ac) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        a += ((b & d) | (c & (~d))) + x + ac;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        return ((a << s) | (a >>> (32 - s))) + b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    private static int HH(int a, int b, int c, int d, int x, int s, int ac) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        a += ((b ^ c) ^ d) + x + ac;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        return ((a << s) | (a >>> (32 - s))) + b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    private static int II(int a, int b, int c, int d, int x, int s, int ac) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        a += (c ^ (b | (~d))) + x + ac;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        return ((a << s) | (a >>> (32 - s))) + b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * This is where the functions come together as the generic MD5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * transformation operation. It consumes sixteen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * bytes from the buffer, beginning at the specified offset.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    void implCompress(byte[] buf, int ofs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        b2iLittle64(buf, ofs, x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        int a = state[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        int b = state[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        int c = state[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        int d = state[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        /* Round 1 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        a = FF ( a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        d = FF ( d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        c = FF ( c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        b = FF ( b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        a = FF ( a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        d = FF ( d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        c = FF ( c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        b = FF ( b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        a = FF ( a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        d = FF ( d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        c = FF ( c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        b = FF ( b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        a = FF ( a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        d = FF ( d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        c = FF ( c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        b = FF ( b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        /* Round 2 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        a = GG ( a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        d = GG ( d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        c = GG ( c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        b = GG ( b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        a = GG ( a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        d = GG ( d, a, b, c, x[10], S22,  0x2441453); /* 22 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        c = GG ( c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        b = GG ( b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        a = GG ( a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        d = GG ( d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        c = GG ( c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        b = GG ( b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        a = GG ( a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        d = GG ( d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        c = GG ( c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        b = GG ( b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        /* Round 3 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        a = HH ( a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        d = HH ( d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        c = HH ( c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        b = HH ( b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        a = HH ( a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        d = HH ( d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        c = HH ( c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        b = HH ( b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        a = HH ( a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        d = HH ( d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        c = HH ( c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        b = HH ( b, c, d, a, x[ 6], S34,  0x4881d05); /* 44 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        a = HH ( a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        d = HH ( d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        c = HH ( c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        b = HH ( b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        /* Round 4 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        a = II ( a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        d = II ( d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        c = II ( c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        b = II ( b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        a = II ( a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        d = II ( d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        c = II ( c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        b = II ( b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        a = II ( a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        d = II ( d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        c = II ( c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        b = II ( b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        a = II ( a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        d = II ( d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        c = II ( c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        b = II ( b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        state[0] += a;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        state[1] += b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        state[2] += c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        state[3] += d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
}