KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > util > crypto > BlockCipher


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.geronimo.util.crypto;
19
20
21 /**
22  * Block cipher engines are expected to conform to this interface.
23  */

24 public interface BlockCipher
25 {
26     /**
27      * Initialise the cipher.
28      *
29      * @param forEncryption if true the cipher is initialised for
30      * encryption, if false for decryption.
31      * @param params the key and other data required by the cipher.
32      * @exception IllegalArgumentException if the params argument is
33      * inappropriate.
34      */

35     public void init(boolean forEncryption, CipherParameters params)
36         throws IllegalArgumentException JavaDoc;
37
38     /**
39      * Return the name of the algorithm the cipher implements.
40      *
41      * @return the name of the algorithm the cipher implements.
42      */

43     public String JavaDoc getAlgorithmName();
44
45     /**
46      * Return the block size for this cipher (in bytes).
47      *
48      * @return the block size for this cipher in bytes.
49      */

50     public int getBlockSize();
51
52     /**
53      * Process one block of input from the array in and write it to
54      * the out array.
55      *
56      * @param in the array containing the input data.
57      * @param inOff offset into the in array the data starts at.
58      * @param out the array the output data will be copied into.
59      * @param outOff the offset into the out array the output will start at.
60      * @exception DataLengthException if there isn't enough data in in, or
61      * space in out.
62      * @exception IllegalStateException if the cipher isn't initialised.
63      * @return the number of bytes processed and produced.
64      */

65     public int processBlock(byte[] in, int inOff, byte[] out, int outOff)
66         throws DataLengthException, IllegalStateException JavaDoc;
67
68     /**
69      * Reset the cipher. After resetting the cipher is in the same state
70      * as it was after the last init (if there was one).
71      */

72     public void reset();
73 }
74
Popular Tags