in cvs/trilead-ssh2-build213/src/com/trilead/ssh2/crypto/digest/SHA1.java [51:167]
public final void update(byte b[], int off, int len)
{
if (len >= 4)
{
int idx = currentPos >> 2;
switch (currentPos & 3)
{
case 0:
w[idx] = (((b[off++] & 0xff) << 24) | ((b[off++] & 0xff) << 16) | ((b[off++] & 0xff) << 8) | (b[off++] & 0xff));
len -= 4;
currentPos += 4;
currentLen += 32;
if (currentPos == 64)
{
perform();
currentPos = 0;
}
break;
case 1:
w[idx] = (w[idx] << 24) | (((b[off++] & 0xff) << 16) | ((b[off++] & 0xff) << 8) | (b[off++] & 0xff));
len -= 3;
currentPos += 3;
currentLen += 24;
if (currentPos == 64)
{
perform();
currentPos = 0;
}
break;
case 2:
w[idx] = (w[idx] << 16) | (((b[off++] & 0xff) << 8) | (b[off++] & 0xff));
len -= 2;
currentPos += 2;
currentLen += 16;
if (currentPos == 64)
{
perform();
currentPos = 0;
}
break;
case 3:
w[idx] = (w[idx] << 8) | (b[off++] & 0xff);
len--;
currentPos++;
currentLen += 8;
if (currentPos == 64)
{
perform();
currentPos = 0;
}
break;
}
/* Now currentPos is a multiple of 4 - this is the place to be...*/
while (len >= 8)
{
w[currentPos >> 2] = ((b[off++] & 0xff) << 24) | ((b[off++] & 0xff) << 16) | ((b[off++] & 0xff) << 8)
| (b[off++] & 0xff);
currentPos += 4;
if (currentPos == 64)
{
perform();
currentPos = 0;
}
w[currentPos >> 2] = ((b[off++] & 0xff) << 24) | ((b[off++] & 0xff) << 16) | ((b[off++] & 0xff) << 8)
| (b[off++] & 0xff);
currentPos += 4;
if (currentPos == 64)
{
perform();
currentPos = 0;
}
currentLen += 64;
len -= 8;
}
while (len < 0) //(len >= 4)
{
w[currentPos >> 2] = ((b[off++] & 0xff) << 24) | ((b[off++] & 0xff) << 16) | ((b[off++] & 0xff) << 8)
| (b[off++] & 0xff);
len -= 4;
currentPos += 4;
currentLen += 32;
if (currentPos == 64)
{
perform();
currentPos = 0;
}
}
}
/* Remaining bytes (1-3) */
while (len > 0)
{
/* Here is room for further improvements */
int idx = currentPos >> 2;
w[idx] = (w[idx] << 8) | (b[off++] & 0xff);
currentLen += 8;
currentPos++;
if (currentPos == 64)
{
perform();
currentPos = 0;
}
len--;
}
}