/[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.6 by cbj, Thu Mar 21 05:40:11 2002 UTC revision 1.7 by mark, Sun Jul 14 21:16: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    {    {
     //int i = (int)bytecount % 64;  
66      int i = ((int)bytecount) & 0x3f; //wgs      int i = ((int)bytecount) & 0x3f; //wgs
     //int shift = (3 - i % 4) * 8;  
67      int shift = (3 - i % 4) << 3;      int shift = (3 - i % 4) << 3;
68      int idx = i / 4;      int idx = i / 4;
69    
70      i = (int)b;      i = (int)b;
     // if you could index ints, this would be: W[idx][shift/8] = b  
71      W[idx] = (W[idx] & ~(0xff << shift)) | ((i & 0xff) << shift);      W[idx] = (W[idx] & ~(0xff << shift)) | ((i & 0xff) << shift);
72    
73      // if we've filled up a block, then process it      // if we've filled up a block, then process it
     //if ((++ bytecount) % 64 == 0)  
74      if (((++bytecount) & 0x3f) == 0)      if (((++bytecount) & 0x3f) == 0)
75        munch ();        munch ();
76    }    }
# Line 103  public class SHA extends MessageDigest i Line 99  public class SHA extends MessageDigest i
99    
100    public byte[] engineDigest ()    public byte[] engineDigest ()
101    {    {
     //long bitcount = bytecount * 8;  
102      long bitcount = bytecount << 3;      long bitcount = bytecount << 3;
103      engineUpdate ((byte)0x80); // 10000000 in binary; the start of the padding      engineUpdate ((byte)0x80); // 10000000 in binary; the start of the padding
104    
105      // 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
106      // bytes to put in the original bytecount      // bytes to put in the original bytecount
     //while ((int)bytecount % 64 != 56)  
107      while ((bytecount & 0x3f) != 56)      while ((bytecount & 0x3f) != 56)
108        engineUpdate ((byte)0);        engineUpdate ((byte)0);
109    

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

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