Closed
Description
When processing a content-md5 header, ExtractEntityHeaders() does the following
} else if (header.getName().equalsIgnoreCase(
HeaderConstants.HEADER_CONTENT_MD5)) {
result.setDigest(new org.restlet.data.Digest(
org.restlet.data.Digest.ALGORITHM_MD5,
org.restlet.engine.util.Base64.decode(header
.getValue())));
Since an MD5 hash is 128 bits long, its base64 encoding is 22 bytes if unpadded, or 24 bytes if padded. However, the Base64.decode() method (reasonably) requires its input to be a multiple of 4 bytes:
if (len % 4 != 0) {
throw new IllegalArgumentException(
"Base64.decode() requires input length to be a multiple of 4");
}
Thus, a fix for this issue would be for ExtractEntityHeaders() to pad a 22-byte content-md5 header value with two base64 padding characters ("==") before passing the value to Base64.decode().