for (int ii=0; ii<algorithmName.length; ii++) {
try {
MessageDigest md = MessageDigest.getInstance(algorithmName[ii]);
InputStream is = new ByteArrayInputStream(myMessage);
DigestInputStream dis = new DigestInputStream(is, md);
byte[] bArray = new byte[MY_MESSAGE_LEN];
for (int i=0; i<MY_MESSAGE_LEN/(CHUNK_SIZE+1); i++) {
// check that read(byte[],int,int) returns valid value
assertTrue("retval1",
dis.read(bArray, i*(CHUNK_SIZE+1), CHUNK_SIZE+1) ==
CHUNK_SIZE + 1);
}
// check that last call returns right
// number of remaining bytes
assertTrue("retval2",
dis.read(bArray,
MY_MESSAGE_LEN/(CHUNK_SIZE+1)*(CHUNK_SIZE+1),
MY_MESSAGE_LEN % (CHUNK_SIZE+1)) ==
(MY_MESSAGE_LEN % (CHUNK_SIZE+1)));
// check that bArray has been filled properly
assertTrue("bArray", Arrays.equals(myMessage, bArray));
// check that associated digest has been updated properly
assertTrue("update", Arrays.equals(dis.getMessageDigest().digest(),
MDGoldenData.getDigest(algorithmName[ii])));
return;
} catch (NoSuchAlgorithmException e) {
// allowed failure
}