summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCasey Marshall <csm@gnu.org>2006-06-06 00:07:22 +0000
committerCasey Marshall <csm@gnu.org>2006-06-06 00:07:22 +0000
commit56191318e5fb9b878f01712a6494bfcc389b601b (patch)
treeb6d9e35b37a6ed575640cfa3c665b79703c24f73
parent8ec9b4226cb460f0feb1aee5c314e12f275de776 (diff)
downloadclasspath-56191318e5fb9b878f01712a6494bfcc389b601b.tar.gz
2006-06-05 C. Scott Marshall <csm@gnu.org>
* java/security/MessageDigest.java (update): new method. * java/security/MessageDigestSpi.java (engineUpdate): new method.
-rw-r--r--ChangeLog-ssl-nio5
-rw-r--r--java/security/MessageDigest.java12
-rw-r--r--java/security/MessageDigestSpi.java19
3 files changed, 36 insertions, 0 deletions
diff --git a/ChangeLog-ssl-nio b/ChangeLog-ssl-nio
index 0915f3c78..49804ac72 100644
--- a/ChangeLog-ssl-nio
+++ b/ChangeLog-ssl-nio
@@ -1,3 +1,8 @@
+2006-06-05 C. Scott Marshall <csm@gnu.org>
+
+ * java/security/MessageDigest.java (update): new method.
+ * java/security/MessageDigestSpi.java (engineUpdate): new method.
+
2006-06-03 C. Scott Marshall <csm@gnu.org>
* gnu/javax/net/ssl/provider/ServerHelloDone.java: made public.
diff --git a/java/security/MessageDigest.java b/java/security/MessageDigest.java
index b817759f5..8a5de92df 100644
--- a/java/security/MessageDigest.java
+++ b/java/security/MessageDigest.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package java.security;
import gnu.java.security.Engine;
+import java.nio.ByteBuffer;
/**
* Message digests are secure one-way hash functions that take arbitrary-sized
@@ -224,6 +225,17 @@ public abstract class MessageDigest extends MessageDigestSpi
}
/**
+ * Updates the digest with the remaining bytes of a buffer.
+ *
+ * @param input The input byte buffer.
+ * @since 1.5
+ */
+ public void update (ByteBuffer input)
+ {
+ engineUpdate (input);
+ }
+
+ /**
* Computes the final digest of the stored data.
*
* @return a byte array representing the message digest.
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.