Index: modules/security/src/main/java/common/java/security/MessageDigestSpi.java =================================================================== --- modules/security/src/main/java/common/java/security/MessageDigestSpi.java (revision 431312) +++ modules/security/src/main/java/common/java/security/MessageDigestSpi.java (working copy) @@ -98,7 +98,7 @@ engineReset(); throw new DigestException("Invalid negative offset"); } - if (offset + len > buf.length) { + if ((long)offset + (long)len > buf.length) { engineReset(); throw new DigestException("Incorrect offset or len value"); } Index: modules/security/src/main/java/common/java/security/MessageDigest.java =================================================================== --- modules/security/src/main/java/common/java/security/MessageDigest.java (revision 431312) +++ modules/security/src/main/java/common/java/security/MessageDigest.java (working copy) @@ -200,11 +200,12 @@ * */ public int digest(byte[] buf, int offset, int len) throws DigestException { - if (buf == null || offset < 0 || len < 0 || - (long)offset + (long)len > buf.length) { - throw new IllegalArgumentException( - "Incorrect offset/len parameters"); - } + if (buf == null) + throw new IllegalArgumentException("No output buffer given"); + if (offset < 0) + throw new IndexOutOfBoundsException(); + if ((long)offset + (long)len > buf.length) + throw new IllegalArgumentException("Output buffer too small for specified offset and length"); return engineDigest(buf, offset, len); }