< prev index next >

src/java.base/share/classes/java/security/MessageDigest.java

Print this page

        

*** 30,44 **** import java.io.IOException; import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.io.InputStream; import java.io.ByteArrayInputStream; ! import java.nio.ByteBuffer; import sun.security.util.Debug; /** * This MessageDigest class provides applications the functionality of a * message digest algorithm, such as SHA-1 or SHA-256. * Message digests are secure one-way hash functions that take arbitrary-sized * data and output a fixed-length hash value. --- 30,47 ---- import java.io.IOException; import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.io.InputStream; import java.io.ByteArrayInputStream; ! import java.security.InvalidKeyException; import java.nio.ByteBuffer; import sun.security.util.Debug; + import sun.security.util.MessageDigestSpi2; + import javax.crypto.SecretKey; + /** * This MessageDigest class provides applications the functionality of a * message digest algorithm, such as SHA-1 or SHA-256. * Message digests are secure one-way hash functions that take arbitrary-sized * data and output a fixed-length hash value.
*** 546,556 **** * moved up the hierarchy into a new class (MessageDigestSpi), which has * been interposed in the hierarchy between the API (MessageDigest) * and its original parent (Object). */ ! static class Delegate extends MessageDigest { // The provider implementation (delegate) private MessageDigestSpi digestSpi; // constructor --- 549,559 ---- * moved up the hierarchy into a new class (MessageDigestSpi), which has * been interposed in the hierarchy between the API (MessageDigest) * and its original parent (Object). */ ! static class Delegate extends MessageDigest implements MessageDigestSpi2 { // The provider implementation (delegate) private MessageDigestSpi digestSpi; // constructor
*** 599,608 **** --- 602,619 ---- protected void engineUpdate(ByteBuffer input) { digestSpi.engineUpdate(input); } + public void engineUpdate(SecretKey key) throws InvalidKeyException { + if (digestSpi instanceof MessageDigestSpi2) { + ((MessageDigestSpi2)digestSpi).engineUpdate(key); + } else { + throw new UnsupportedOperationException + ("Digest does not support update of SecretKey object"); + } + } protected byte[] engineDigest() { return digestSpi.engineDigest(); } protected int engineDigest(byte[] buf, int offset, int len)
< prev index next >