diff options
author | Casey Marshall <csm@gnu.org> | 2006-06-28 22:56:36 +0000 |
---|---|---|
committer | Casey Marshall <csm@gnu.org> | 2006-06-28 22:56:36 +0000 |
commit | 2be1f59cabb48fd8a8110263f5c9d2a771ed23f9 (patch) | |
tree | 67e409f4e379eae73606a7fb68bc9dcc698e35a0 | |
parent | 0d6b3c6bd6181ca9bd6c2b3fd1dc5caf0b8433c4 (diff) | |
download | classpath-2be1f59cabb48fd8a8110263f5c9d2a771ed23f9.tar.gz |
2006-06-28 Casey Marshall <csm@gnu.org>
* java/security/Signature.java (update): new method.
* java/security/SignatureSpi.java (engineUpdate): new method.
-rw-r--r-- | ChangeLog-ssl-nio | 5 | ||||
-rw-r--r-- | java/security/Signature.java | 17 | ||||
-rw-r--r-- | java/security/SignatureSpi.java | 19 |
3 files changed, 41 insertions, 0 deletions
diff --git a/ChangeLog-ssl-nio b/ChangeLog-ssl-nio index 4da5570cb..96702f846 100644 --- a/ChangeLog-ssl-nio +++ b/ChangeLog-ssl-nio @@ -1,3 +1,8 @@ +2006-06-28 Casey Marshall <csm@gnu.org> + + * java/security/Signature.java (update): new method. + * java/security/SignatureSpi.java (engineUpdate): new method. + 2006-06-10 Casey Marshall <csm@gnu.org> * jessie-tests/testClientHello.java: update for extensions diff --git a/java/security/Signature.java b/java/security/Signature.java index 845a77a8b..68ae99d42 100644 --- a/java/security/Signature.java +++ b/java/security/Signature.java @@ -40,6 +40,7 @@ package java.security; import gnu.java.security.Engine; +import java.nio.ByteBuffer; import java.security.cert.Certificate; import java.security.cert.X509Certificate; import java.security.spec.AlgorithmParameterSpec; @@ -467,6 +468,22 @@ public abstract class Signature extends SignatureSpi else throw new SignatureException(); } + + /** + * Update this signature with the {@link java.nio.Buffer#remaining()} + * bytes of the input buffer. + * + * @param input The input buffer. + * @throws SignatureException If this instance was not properly + * initialized. + */ + public final void update(ByteBuffer input) throws SignatureException + { + if (state != UNINITIALIZED) + engineUpdate(input); + else + throw new SignatureException("not initialized"); + } /** * Returns the name of the algorithm currently used. The names of algorithms diff --git a/java/security/SignatureSpi.java b/java/security/SignatureSpi.java index 25d49dedd..3b46815ec 100644 --- a/java/security/SignatureSpi.java +++ b/java/security/SignatureSpi.java @@ -37,6 +37,7 @@ exception statement from your version. */ package java.security; +import java.nio.ByteBuffer; import java.security.spec.AlgorithmParameterSpec; /** @@ -131,6 +132,24 @@ public abstract class SignatureSpi throws SignatureException; /** + * Update this signature with the {@link java.nio.Buffer#remaining()} + * bytes of the given buffer. + * + * @param input The input buffer. + * @throws SignatureException + */ + protected void engineUpdate(ByteBuffer input) throws SignatureException + { + byte[] buf = new byte[4096]; + while (input.hasRemaining()) + { + int l = Math.min(input.remaining(), buf.length); + input.get(buf, 0, l); + engineUpdate(buf, 0, l); + } + } + + /** * Returns the signature bytes of all the data fed to this instance. The * format of the output depends on the underlying signature algorithm. * |