package gnu.crypto.assembly; // ---------------------------------------------------------------------------- // $Id: $ // // Copyright (C) 2003, Free Software Foundation, Inc. // // This file is part of GNU Crypto. // // GNU Crypto is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // GNU Crypto is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; see the file COPYING. If not, write to the // // Free Software Foundation Inc., // 59 Temple Place - Suite 330, // Boston, MA 02111-1307 // USA // // Linking this library statically or dynamically with other modules is // making a combined work based on this library. Thus, the terms and // conditions of the GNU General Public License cover the whole // combination. // // As a special exception, the copyright holders of this library give // you permission to link this library with independent modules to // produce an executable, regardless of the license terms of these // independent modules, and to copy and distribute the resulting // executable under terms of your choice, provided that you also meet, // for each linked independent module, the terms and conditions of the // license of that module. An independent module is a module which is // not derived from or based on this library. If you modify this // library, you may extend this exception to your version of the // library, but you are not obligated to do so. If you do not wish to // do so, delete this exception statement from your version. // ---------------------------------------------------------------------------- import java.security.InvalidKeyException; /** *
The visible methods of every Stage in a Cascade Cipher.
* *Each stage may be either an implementation of a Block Cipher Mode of * Operation (address@hidden gnu.crypto.mode.IMode}) or a Cascade Cipher (address@hidden * Cascade}). Each stage has also a natural state (operational direction) * when constructed for inclusion within a address@hidden Cascade}. This natural * state dictates how data flows from one stage into another when they are * chained ogether. One can think of a stage and its state as the specification * of how to wire the stage to the chain. The following diagrams may help * understand the paradigme. The first shows two stages chained together, each * with a address@hidden State#FORWARD} state.
** FORWARD FORWARD * +------+ +-------+ * | | | | * | +--in --+ | +--in --+ * ---+ | Stage | | | Stage | +--- * +--out--+ | +--out--+ | * | | | | * +-------+ +------+ **
The second diagram shows two stages chained together, the first with a * address@hidden State#FORWARD} state, while the second is wired in a address@hidden * State#BACKWARD} state.
** FORWARD BACKWARD * +------+ +------+ * | | | | * | +--in --+ +--in --+ | * ---+ | Stage | | Stage | +--- * +--out--+ +--out--+ * | | * +---------------+ ** * @see Stage * @see ModeStage * @see CascadeStage * @version $Revision: $ */ public interface IStage extends Cloneable { // Constants // ------------------------------------------------------------------------- // Methods // ------------------------------------------------------------------------- /** * Initialises the stage for the designated operation. * * @param state the state to initialise the stage for. * @exception IllegalStateException if the instance is not initialised. * @throws InvalidKeyException * @see State#FORWARD * @see State#BACKWARD */ void init(State state) throws InvalidKeyException; /** * Returns the currently set block size for the stage. * * @return the current block size for this stage. * @exception IllegalStateException if the instance is not initialised. */ int currentBlockSize() throws IllegalStateException; /** * Resets the stage for re-initialisation and use with other characteristics. * This method always succeeds. */ void reset(); /** * Processes exactly one block of plaintext (if initialised in the * address@hidden State#FORWARD} state) or ciphertext (if initialised in the * address@hidden State#BACKWARD} state). * * @param in the plaintext. * @param inOffset index of
in
from which to start considering
* data.
* @param out the ciphertext.
* @param outOffset index of out
from which to store result.
* @exception IllegalStateException if the instance is not initialised.
*/
void update(byte[] in, int inOffset, byte[] out, int outOffset);
/**
* Conducts a simple correctness test that consists of basic symmetric
* encryption / decryption test(s) for all supported block and key sizes of
* underlying block cipher(s) wrapped by Mode leafs. The test also includes
* one (1) variable key Known Answer Test (KAT) for each block cipher.
*
* @return true
if the implementation passes simple
* correctness tests. Returns false
otherwise.
*/
boolean selfTest();
/**
* Returns a clone of this instance.
*
* @return a clone copy of this instance.
*/
Object clone();
}