MessageDigestSpi.java revision 2362
3544N/A * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved. 3544N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3544N/A * This code is free software; you can redistribute it and/or modify it 3544N/A * under the terms of the GNU General Public License version 2 only, as 3544N/A * published by the Free Software Foundation. Oracle designates this 3544N/A * particular file as subject to the "Classpath" exception as provided 3544N/A * by Oracle in the LICENSE file that accompanied this code. 3544N/A * This code is distributed in the hope that it will be useful, but WITHOUT 3544N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 3544N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 3544N/A * version 2 for more details (a copy is included in the LICENSE file that 3544N/A * You should have received a copy of the GNU General Public License version 3544N/A * 2 along with this work; if not, write to the Free Software Foundation, 3544N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 3544N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 3544N/A * or visit www.oracle.com if you need additional information or have any 3544N/A * This class defines the <i>Service Provider Interface</i> (<b>SPI</b>) 3544N/A * for the <code>MessageDigest</code> class, which provides the functionality 3544N/A * of a message digest algorithm, such as MD5 or SHA. Message digests are 3544N/A * secure one-way hash functions that take arbitrary-sized data and output a 3544N/A * <p> All the abstract methods in this class must be implemented by a 3544N/A * cryptographic service provider who wishes to supply the implementation 3544N/A * of a particular message digest algorithm. 3544N/A * <p> Implementations are free to implement the Cloneable interface. 5185N/A // for re-use in engineUpdate(ByteBuffer input) 3580N/A * Returns the digest length in bytes. 5185N/A * <p>This concrete method has been added to this previously-defined 5185N/A * abstract class. (For backwards compatibility, it cannot be abstract.) 5185N/A * <p>The default behavior is to return 0. 5185N/A * <p>This method may be overridden by a provider to return the digest 3580N/A * @return the digest length in bytes. 4305N/A * Updates the digest using the specified byte. 4305N/A * @param input the byte to use for the update. 3544N/A * Updates the digest using the specified array of bytes, 5185N/A * starting at the specified offset. 5185N/A * @param input the array of bytes to use for the update. 5185N/A * @param offset the offset to start from in the array of bytes. 5185N/A * @param len the number of bytes to use, starting at 5185N/A * Update the digest using the specified ByteBuffer. The digest is 5185N/A * updated using the <code>input.remaining()</code> bytes starting 3544N/A * at <code>input.position()</code>. 3952N/A * Upon return, the buffer's position will be equal to its limit; 3544N/A * its limit will not have changed. 4305N/A * @param input the ByteBuffer 5185N/A * Completes the hash computation by performing final 5185N/A * operations such as padding. Once <code>engineDigest</code> has 5185N/A * been called, the engine should be reset (see 5185N/A * {@link #engineReset() engineReset}). 5185N/A * Resetting is the responsibility of the 5185N/A * @return the array of bytes for the resulting hash value. 5185N/A * Completes the hash computation by performing final 5185N/A * operations such as padding. Once <code>engineDigest</code> has 5185N/A * been called, the engine should be reset (see 5185N/A * {@link #engineReset() engineReset}). 5185N/A * Resetting is the responsibility of the 5185N/A * This method should be abstract, but we leave it concrete for 5185N/A * binary compatibility. Knowledgeable providers should override this 5185N/A * @param buf the output buffer in which to store the digest 5185N/A * @param offset offset to start from in the output buffer 5185N/A * @param len number of bytes within buf allotted for the digest. 5185N/A * Both this default implementation and the SUN provider do not 5185N/A * return partial digests. The presence of this parameter is solely 5185N/A * for consistency in our API's. If the value of this parameter is less 5185N/A * than the actual digest length, the method will throw a DigestException. 5185N/A * This parameter is ignored if its value is greater than or equal to 5185N/A * the actual digest length. 5185N/A * @return the length of the digest stored in the output buffer. 5185N/A * @exception DigestException if an error occurs. 5185N/A +
"buffer to store the digest");
* Resets the digest for further use. * Returns a clone if the implementation is cloneable. * @return a clone if the implementation is cloneable. * @exception CloneNotSupportedException if this is called on an * implementation that does not support <code>Cloneable</code>.