src/java.base/share/classes/sun/security/provider/SHA2.java
changeset 51504 c9a3e3cac9c7
parent 47216 71c04702a3d5
equal deleted inserted replaced
51503:0265a70ea2a5 51504:c9a3e3cac9c7
    23  * questions.
    23  * questions.
    24  */
    24  */
    25 
    25 
    26 package sun.security.provider;
    26 package sun.security.provider;
    27 
    27 
       
    28 import java.util.Arrays;
    28 import java.util.Objects;
    29 import java.util.Objects;
    29 
    30 
    30 import jdk.internal.HotSpotIntrinsicCandidate;
    31 import jdk.internal.HotSpotIntrinsicCandidate;
    31 import static sun.security.provider.ByteArrayAccess.*;
    32 import static sun.security.provider.ByteArrayAccess.*;
    32 
    33 
    81     SHA2(String name, int digestLength, int[] initialHashes) {
    82     SHA2(String name, int digestLength, int[] initialHashes) {
    82         super(name, digestLength, 64);
    83         super(name, digestLength, 64);
    83         this.initialHashes = initialHashes;
    84         this.initialHashes = initialHashes;
    84         state = new int[8];
    85         state = new int[8];
    85         W = new int[64];
    86         W = new int[64];
    86         implReset();
    87         resetHashes();
    87     }
    88     }
    88 
    89 
    89     /**
    90     /**
    90      * Resets the buffers and hash value to start a new hash.
    91      * Resets the buffers and hash value to start a new hash.
    91      */
    92      */
    92     void implReset() {
    93     void implReset() {
       
    94         resetHashes();
       
    95         Arrays.fill(W, 0);
       
    96     }
       
    97 
       
    98     private void resetHashes() {
    93         System.arraycopy(initialHashes, 0, state, 0, state.length);
    99         System.arraycopy(initialHashes, 0, state, 0, state.length);
    94     }
   100     }
    95 
   101 
    96     void implDigest(byte[] out, int ofs) {
   102     void implDigest(byte[] out, int ofs) {
    97         long bitsProcessed = bytesProcessed << 3;
   103         long bitsProcessed = bytesProcessed << 3;