diff options
Diffstat (limited to 'java/security/MessageDigestSpi.java')
-rw-r--r-- | java/security/MessageDigestSpi.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/java/security/MessageDigestSpi.java b/java/security/MessageDigestSpi.java index df3bd3ead..6615b1d93 100644 --- a/java/security/MessageDigestSpi.java +++ b/java/security/MessageDigestSpi.java @@ -37,6 +37,8 @@ exception statement from your version. */ package java.security; +import java.nio.ByteBuffer; + /** This is the Service Provider Interface (SPI) for MessageDigest class in java.security. It provides the back end functionality @@ -98,6 +100,23 @@ public abstract class MessageDigestSpi protected abstract void engineUpdate(byte[]input, int offset, int len); /** + * Updates this digest with the remaining bytes of a byte buffer. + * + * @param input The input buffer. + * @since 1.5 + */ + protected void engineUpdate (ByteBuffer input) + { + byte[] buf = new byte[1024]; + while (input.hasRemaining()) + { + int n = Math.min(input.remaining(), buf.length); + input.get (buf, 0, n); + engineUpdate (buf, 0, n); + } + } + + /** Computes the final digest of the stored bytes and returns them. It performs any necessary padding. The message digest should reset sensitive data after performing the digest. |