The spec. doesn't define behavior for the method
MessageDigestSpi.engineDigest(byte buff, int offset, int len)
when one of its parameters is illegal.
The spec says:
"protected int engineDigest(byte buf, int offset, int len)
Completes the hash 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.
This method should be abstract, but we leave it concrete for binary
compatibility. Knowledgeable providers should override this method.
buf - the output buffer in which to store the digest
offset - offset to start from in the output buffer
len - number of bytes within buf allotted for the digest. Both this
default implementation and the SUN provider do not return partial
digests. The presence of this parameter is solely for consistency in
our API's. If the value of this parameter is less than the actual
digest length, the method will throw a DigestException. This parameter
is ignored if its value is greater than or equal to the actual digest
the length of the digest stored in the output buffer.
DigestException - if an error occurs."
So, the behavior is defined only when len is illegal but the spec.
should also define the method behavior when:
1) 'buf' array is null
2) 'offset' is outside 'input' array bounds.