/[classpath]/classpath/gnu/java/security/provider/SHA.java
ViewVC logotype

Diff of /classpath/gnu/java/security/provider/SHA.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by mark, Tue Jan 22 22:26:58 2002 UTC revision 1.6 by cbj, Thu Mar 21 05:40:11 2002 UTC
# Line 63  public class SHA extends MessageDigest i Line 63  public class SHA extends MessageDigest i
63    
64    public void engineUpdate (byte b)    public void engineUpdate (byte b)
65    {    {
66      int i = (int)bytecount % 64;      //int i = (int)bytecount % 64;
67      int shift = (3 - i % 4) * 8;      int i = ((int)bytecount) & 0x3f; //wgs
68        //int shift = (3 - i % 4) * 8;
69        int shift = (3 - i % 4) << 3;
70      int idx = i / 4;      int idx = i / 4;
71    
72        i = (int)b;
73      // if you could index ints, this would be: W[idx][shift/8] = b      // if you could index ints, this would be: W[idx][shift/8] = b
74      W[idx] = (W[idx] & ~(0xff << shift)) | ((b & 0xff) << shift);      W[idx] = (W[idx] & ~(0xff << shift)) | ((i & 0xff) << shift);
75    
76      // if we've filled up a block, then process it      // if we've filled up a block, then process it
77      if ((++ bytecount) % 64 == 0)      //if ((++ bytecount) % 64 == 0)
78        if (((++bytecount) & 0x3f) == 0)
79        munch ();        munch ();
80    }    }
81    
# Line 99  public class SHA extends MessageDigest i Line 103  public class SHA extends MessageDigest i
103    
104    public byte[] engineDigest ()    public byte[] engineDigest ()
105    {    {
106      long bitcount = bytecount * 8;      //long bitcount = bytecount * 8;
107        long bitcount = bytecount << 3;
108      engineUpdate ((byte)0x80); // 10000000 in binary; the start of the padding      engineUpdate ((byte)0x80); // 10000000 in binary; the start of the padding
109    
110      // add the rest of the padding to fill this block out, but leave 8      // add the rest of the padding to fill this block out, but leave 8
111      // bytes to put in the original bytecount      // bytes to put in the original bytecount
112      while ((int)bytecount % 64 != 56)      //while ((int)bytecount % 64 != 56)
113        while ((bytecount & 0x3f) != 56)
114        engineUpdate ((byte)0);        engineUpdate ((byte)0);
115    
116      // add the length of the original, unpadded block to the end of      // add the length of the original, unpadded block to the end of

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26