src/java.base/share/classes/sun/security/provider/MD5.java
changeset 51504 c9a3e3cac9c7
parent 47216 71c04702a3d5
equal deleted inserted replaced
51503:0265a70ea2a5 51504:c9a3e3cac9c7
    22  * or visit www.oracle.com if you need additional information or have any
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    23  * questions.
    24  */
    24  */
    25 
    25 
    26 package sun.security.provider;
    26 package sun.security.provider;
       
    27 
       
    28 import java.util.Arrays;
    27 
    29 
    28 import static sun.security.provider.ByteArrayAccess.*;
    30 import static sun.security.provider.ByteArrayAccess.*;
    29 
    31 
    30 /**
    32 /**
    31  * The MD5 class is used to compute an MD5 message digest over a given
    33  * The MD5 class is used to compute an MD5 message digest over a given
    64     // Standard constructor, creates a new MD5 instance.
    66     // Standard constructor, creates a new MD5 instance.
    65     public MD5() {
    67     public MD5() {
    66         super("MD5", 16, 64);
    68         super("MD5", 16, 64);
    67         state = new int[4];
    69         state = new int[4];
    68         x = new int[16];
    70         x = new int[16];
    69         implReset();
    71         resetHashes();
    70     }
    72     }
    71 
    73 
    72     // clone this object
    74     // clone this object
    73     public Object clone() throws CloneNotSupportedException {
    75     public Object clone() throws CloneNotSupportedException {
    74         MD5 copy = (MD5) super.clone();
    76         MD5 copy = (MD5) super.clone();
    80     /**
    82     /**
    81      * Reset the state of this object.
    83      * Reset the state of this object.
    82      */
    84      */
    83     void implReset() {
    85     void implReset() {
    84         // Load magic initialization constants.
    86         // Load magic initialization constants.
       
    87         resetHashes();
       
    88         // clear out old data
       
    89         Arrays.fill(x, 0);
       
    90     }
       
    91 
       
    92     private void resetHashes() {
    85         state[0] = 0x67452301;
    93         state[0] = 0x67452301;
    86         state[1] = 0xefcdab89;
    94         state[1] = 0xefcdab89;
    87         state[2] = 0x98badcfe;
    95         state[2] = 0x98badcfe;
    88         state[3] = 0x10325476;
    96         state[3] = 0x10325476;
    89     }
    97     }