Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * Lesser General Public License for more details.
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site:
 package org.jboss.crypto.digest;

The SHA_Interleave algorithm as described in section 3.1 of RFC2945. This needs an SHA MessageDigest provider to function.

 public class SHAInterleave extends MessageDigestSpi
    private static final int SHA_HASH_LEN = 20;
    private int count;
    private boolean skipLeadingZeros;
    private MessageDigest sha;

Creates a new instance of SHAInterleave

ProviderException thrown if MessageDigest.getInstance("SHA") throws a NoSuchAlgorithmException.
    public SHAInterleave()
           = MessageDigest.getInstance("SHA");
       catch(NoSuchAlgorithmException e)
          throw PicketBoxMessages.MESSAGES.failedToObtainSHAMessageDigest(e);
        = new ByteArrayOutputStream();
        = new ByteArrayOutputStream();
    protected int engineGetDigestLength()
       return 2 * ;

Completes the digest computation by performing final operations such as padding. Once engineDigest has been called, the engine should be reset (see engineReset). Resetting is the responsibility of the engine implementor.

the array of bytes for the resulting digest value.
    protected byte[] engineDigest()
       byte[] E = .toByteArray();
       byte[] G = .digest(E);
       // If the count is odd, drop the first byte
       byte[] F = .toByteArray();
       int offset = 0;
       if % 2 == 1 )
          offset = 1;
       byte[] H = .digest();
       int length = G.length + H.length;
       byte[] digest = new byte[length];
       for(int i = 0; i < G.length; ++i)
          digest[2 * i] = G[i];
       for(int i = 0; i < H.length; ++i)
          digest[2 * i + 1] = H[i];
      return digest;

Resets the digest for further use.
   protected void engineReset()
       = true;
       = 0;

Updates the digest using the specified byte.

input the byte to use for the update.
   protected void engineUpdate(byte input)
      if == true && input == 0 )
       = false;
      if % 2 == 0 )

Updates the digest using the specified array of bytes, starting at the specified offset.

input the array of bytes to use for the update.
offset the offset to start from in the array of bytes.
len the input of bytes to use, starting at offset.
   protected void engineUpdate(byte[] inputint offsetint len)
      for(int i = offseti < offset+leni ++)
New to GrepCode? Check out our FAQ X