Don't need to use temporary buffer if remaining length equals digest length. (cherry picked from commit 3f6b6f0b)