Ignore:
Timestamp:
01/06/10 19:40:17 (2 years ago)
Author:
octorian
Message:

Fix for some FindBugs issues

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LogicMail/src/org/logicprobe/LogicMail/util/MD5.java

    r90 r601  
    135135         */ 
    136136        int state[]; 
    137          
     137 
    138138        /** 
    139139         * 64-bit character count 
    140140         */ 
    141141        long count; 
    142          
     142 
    143143        /** 
    144144         * 64-byte buffer (512 bits) for storing to-be-hashed characters 
    145145         */ 
    146146        byte buffer[]; 
    147          
     147 
    148148        public MD5State() { 
    149149            buffer = new byte[64]; 
    150150            count = 0; 
    151151            state = new int[4]; 
    152              
     152 
    153153            state[0] = 0x67452301; 
    154154            state[1] = 0xefcdab89; 
     
    156156            state[3] = 0x10325476; 
    157157        } 
    158          
     158 
    159159        /** Create this State as a copy of another state */ 
    160160        public MD5State(MD5State from) { 
     
    168168        } 
    169169    }; 
    170      
     170 
    171171    private MD5State state; 
    172172    private MD5State finals; 
    173      
     173 
    174174    private static final byte padding[] = 
    175         {(byte)0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    176           0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    177           0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    178           0, 0, 0, 0, 0, 0, 0, 0 }; 
    179      
     175    {(byte)0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
     176        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
     177        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
     178        0, 0, 0, 0, 0, 0, 0, 0 }; 
     179 
    180180    /* 
    181181     * len += shift; for (int i = 0; shift < len; i++, shift += 4) { out[i] = 
     
    185185     */ 
    186186 
    187      
     187 
    188188    private final void decode( final byte buffer[], final int shift, final int[] out) { 
    189189        out[0] = (buffer[shift] & 0xff) | ((buffer[shift + 1] & 0xff) << 8) 
     
    249249        | (buffer[shift + 63] << 24); 
    250250    } 
    251      
     251 
    252252    private final void transform(MD5State state, byte buffer[], int shift, int[] decode_buf) { 
    253253        int a = state.state[0], b = state.state[1], c = state.state[2], d = state.state[3], x[] = decode_buf; 
    254          
     254 
    255255        decode(buffer, shift, decode_buf); 
    256          
     256 
    257257        /* Round 1 */ 
    258258        a += ((b & c) | (~b & d)) + x[0] + 0xd76aa478; /* 1 */ 
     
    264264        b += ((c & d) | (~c & a)) + x[3] + 0xc1bdceee; /* 4 */ 
    265265        b = ((b << 22) | (b >>> 10)) + c; 
    266          
     266 
    267267        a += ((b & c) | (~b & d)) + x[4] + 0xf57c0faf; /* 5 */ 
    268268        a = ((a << 7) | (a >>> 25)) + b; 
     
    273273        b += ((c & d) | (~c & a)) + x[7] + 0xfd469501; /* 8 */ 
    274274        b = ((b << 22) | (b >>> 10)) + c; 
    275          
     275 
    276276        a += ((b & c) | (~b & d)) + x[8] + 0x698098d8; /* 9 */ 
    277277        a = ((a << 7) | (a >>> 25)) + b; 
     
    282282        b += ((c & d) | (~c & a)) + x[11] + 0x895cd7be; /* 12 */ 
    283283        b = ((b << 22) | (b >>> 10)) + c; 
    284          
     284 
    285285        a += ((b & c) | (~b & d)) + x[12] + 0x6b901122; /* 13 */ 
    286286        a = ((a << 7) | (a >>> 25)) + b; 
     
    291291        b += ((c & d) | (~c & a)) + x[15] + 0x49b40821; /* 16 */ 
    292292        b = ((b << 22) | (b >>> 10)) + c; 
    293          
     293 
    294294        /* Round 2 */ 
    295295        a += ((b & d) | (c & ~d)) + x[1] + 0xf61e2562; /* 17 */ 
     
    301301        b += ((c & a) | (d & ~a)) + x[0] + 0xe9b6c7aa; /* 20 */ 
    302302        b = ((b << 20) | (b >>> 12)) + c; 
    303          
     303 
    304304        a += ((b & d) | (c & ~d)) + x[5] + 0xd62f105d; /* 21 */ 
    305305        a = ((a << 5) | (a >>> 27)) + b; 
     
    310310        b += ((c & a) | (d & ~a)) + x[4] + 0xe7d3fbc8; /* 24 */ 
    311311        b = ((b << 20) | (b >>> 12)) + c; 
    312          
     312 
    313313        a += ((b & d) | (c & ~d)) + x[9] + 0x21e1cde6; /* 25 */ 
    314314        a = ((a << 5) | (a >>> 27)) + b; 
     
    319319        b += ((c & a) | (d & ~a)) + x[8] + 0x455a14ed; /* 28 */ 
    320320        b = ((b << 20) | (b >>> 12)) + c; 
    321          
     321 
    322322        a += ((b & d) | (c & ~d)) + x[13] + 0xa9e3e905; /* 29 */ 
    323323        a = ((a << 5) | (a >>> 27)) + b; 
     
    328328        b += ((c & a) | (d & ~a)) + x[12] + 0x8d2a4c8a; /* 32 */ 
    329329        b = ((b << 20) | (b >>> 12)) + c; 
    330          
     330 
    331331        /* Round 3 */ 
    332332        a += (b ^ c ^ d) + x[5] + 0xfffa3942; /* 33 */ 
     
    338338        b += (c ^ d ^ a) + x[14] + 0xfde5380c; /* 36 */ 
    339339        b = ((b << 23) | (b >>> 9)) + c; 
    340          
     340 
    341341        a += (b ^ c ^ d) + x[1] + 0xa4beea44; /* 37 */ 
    342342        a = ((a << 4) | (a >>> 28)) + b; 
     
    347347        b += (c ^ d ^ a) + x[10] + 0xbebfbc70; /* 40 */ 
    348348        b = ((b << 23) | (b >>> 9)) + c; 
    349          
     349 
    350350        a += (b ^ c ^ d) + x[13] + 0x289b7ec6; /* 41 */ 
    351351        a = ((a << 4) | (a >>> 28)) + b; 
     
    356356        b += (c ^ d ^ a) + x[6] + 0x04881d05; /* 44 */ 
    357357        b = ((b << 23) | (b >>> 9)) + c; 
    358          
     358 
    359359        a += (b ^ c ^ d) + x[9] + 0xd9d4d039; /* 33 */ 
    360360        a = ((a << 4) | (a >>> 28)) + b; 
     
    365365        b += (c ^ d ^ a) + x[2] + 0xc4ac5665; /* 36 */ 
    366366        b = ((b << 23) | (b >>> 9)) + c; 
    367          
     367 
    368368        /* Round 4 */ 
    369369        a += (c ^ (b | ~d)) + x[0] + 0xf4292244; /* 49 */ 
     
    375375        b += (d ^ (c | ~a)) + x[5] + 0xfc93a039; /* 52 */ 
    376376        b = ((b << 21) | (b >>> 11)) + c; 
    377          
     377 
    378378        a += (c ^ (b | ~d)) + x[12] + 0x655b59c3; /* 53 */ 
    379379        a = ((a << 6) | (a >>> 26)) + b; 
     
    384384        b += (d ^ (c | ~a)) + x[1] + 0x85845dd1; /* 56 */ 
    385385        b = ((b << 21) | (b >>> 11)) + c; 
    386          
     386 
    387387        a += (c ^ (b | ~d)) + x[8] + 0x6fa87e4f; /* 57 */ 
    388388        a = ((a << 6) | (a >>> 26)) + b; 
     
    393393        b += (d ^ (c | ~a)) + x[13] + 0x4e0811a1; /* 60 */ 
    394394        b = ((b << 21) | (b >>> 11)) + c; 
    395          
     395 
    396396        a += (c ^ (b | ~d)) + x[4] + 0xf7537e82; /* 61 */ 
    397397        a = ((a << 6) | (a >>> 26)) + b; 
     
    402402        b += (d ^ (c | ~a)) + x[9] + 0xeb86d391; /* 64 */ 
    403403        b = ((b << 21) | (b >>> 11)) + c; 
    404          
     404 
    405405        state.state[0] += a; 
    406406        state.state[1] += b; 
     
    408408        state.state[3] += d; 
    409409    } 
    410      
     410 
    411411    /** 
    412412     * Updates hash with the bytebuffer given (using at maximum length bytes 
     
    430430            length = buffer.length - offset; 
    431431        } 
    432          
     432 
    433433        /* compute number of bytes mod 64 */ 
    434          
     434 
    435435        index = (int) (stat.count & 0x3f); 
    436436        stat.count += length; 
    437          
     437 
    438438        partlen = 64 - index; 
    439          
     439 
    440440        if (length >= partlen) { 
    441441            // update state (using only Java) to reflect input 
     
    462462        } 
    463463    } 
    464      
     464 
    465465    private static final byte[] encode( final int input[], final int len) { 
    466466        int i, j; 
     
    475475        return out; 
    476476    } 
    477      
     477 
    478478    public MD5() { 
    479479        state = new MD5State(); 
    480480        finals = null; 
    481481    } 
    482      
     482 
    483483    public void reset() { 
    484484        state = new MD5State(); 
    485485        finals = null; 
    486486    } 
    487      
     487 
    488488    /** 
    489489     * Updates hash with given array of bytes 
     
    498498        update( state, buffer,0, buffer.length ); 
    499499    } 
    500      
     500 
    501501    /** 
    502502     * Returns array of bytes (16 bytes) representing hash as of the current 
     
    506506     * @return Array of 16 bytes, the hash of all updated bytes 
    507507     */ 
    508     public synchronized final byte[] getDigest() { 
     508    public final byte[] getDigest() { 
    509509        byte bits[]; 
    510510        int index, padlen; 
     
    521521            finals = fin; 
    522522        } 
    523          
     523 
    524524        return encode(finals.state, 16); 
    525525    } 
Note: See TracChangeset for help on using the changeset viewer.