2362N/A * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * Common base message digest implementation for the Sun provider. 0N/A * It implements all the JCA methods as suitable for a Java message digest 0N/A * implementation of an algorithm based on a compression function (as all 0N/A * commonly used algorithms are). The individual digest subclasses only need to 0N/A * implement the following methods: 0N/A * . abstract void implCompress(byte[] b, int ofs); 0N/A * . abstract void implDigest(byte[] out, int ofs); 0N/A * . abstract void implReset(); 0N/A * . public abstract Object clone(); 0N/A * See the inline documentation for details. 0N/A * @author Andreas Sterbenz 0N/A // one element byte array, temporary storage for update(byte) 0N/A // algorithm name to use in the exception message 0N/A // length of the message digest in bytes 0N/A // size of the input to the compression function in bytes 0N/A // buffer to store partial blocks, blockSize bytes large 0N/A // Subclasses should not access this array directly except possibly in their 0N/A // offset into buffer 0N/A // number of bytes processed so far. subclasses should not modify 0N/A // also used as a flag to indicate reset status 0N/A // -1: need to call engineReset() before next call to update() 0N/A // 0: is already reset 0N/A * Constructor for cloning. Replicates common data. 0N/A // return digest length. See JCA doc. 0N/A // single byte update. See JCA doc. 0N/A // array update. See JCA doc. 0N/A // if buffer is not empty, we need to fill it before proceeding 0N/A // compress completed block now 0N/A // compress complete blocks 0N/A // copy remainder to buffer 0N/A // reset this object. See JCA doc. 0N/A // already reset, ignore 0N/A // return the digest. See JCA doc. 0N/A // return the digest in the specified array. See JCA doc. 0N/A * Core compression function. Processes blockSize bytes at a time 0N/A * and updates the state of this object. 0N/A * Return the digest. Subclasses do not need to reset() themselves, 0N/A * DigestBase calls implReset() when necessary. 0N/A * Reset subclass specific state to their initial values. DigestBase 0N/A * calls this method when necessary. 0N/A * Clone this digest. Should be implemented as "return new MyDigest(this)". 0N/A * That constructor should first call "super(baseDigest)" and then copy 0N/A * subclass specific data. 0N/A // padding used for the MD5, and SHA-* message digests 0N/A // we need 128 byte padding for SHA-384/512 0N/A // and an additional 8 bytes for the high 8 bytes of the 16 0N/A // byte bit counter in SHA-384/512