1 package org.bouncycastle.crypto; 2 3 /*- 4 * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲ 5 * SNMP Java Client 6 * ჻჻჻჻჻჻ 7 * Copyright 2023 Sentry Software, Westhawk 8 * ჻჻჻჻჻჻ 9 * This program is free software: you can redistribute it and/or modify 10 * it under the terms of the GNU Lesser General Public License as 11 * published by the Free Software Foundation, either version 3 of the 12 * License, or (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Lesser Public License for more details. 18 * 19 * You should have received a copy of the GNU General Lesser Public 20 * License along with this program. If not, see 21 * <http://www.gnu.org/licenses/lgpl-3.0.html>. 22 * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱ 23 */ 24 25 26 /** 27 * Block cipher engines are expected to conform to this interface. 28 */ 29 public interface BlockCipher 30 { 31 /** 32 * Initialise the cipher. 33 * 34 * @param forEncryption if true the cipher is initialised for 35 * encryption, if false for decryption. 36 * @param params the key and other data required by the cipher. 37 * @exception IllegalArgumentException if the params argument is 38 * inappropriate. 39 */ 40 public void init(boolean forEncryption, CipherParameters params) 41 throws IllegalArgumentException; 42 43 /** 44 * Return the name of the algorithm the cipher implements. 45 * 46 * @return the name of the algorithm the cipher implements. 47 */ 48 public String getAlgorithmName(); 49 50 /** 51 * Return the block size for this cipher (in bytes). 52 * 53 * @return the block size for this cipher in bytes. 54 */ 55 public int getBlockSize(); 56 57 /** 58 * Process one block of input from the array in and write it to 59 * the out array. 60 * 61 * @param in the array containing the input data. 62 * @param inOff offset into the in array the data starts at. 63 * @param out the array the output data will be copied into. 64 * @param outOff the offset into the out array the output will start at. 65 * @exception DataLengthException if there isn't enough data in in, or 66 * space in out. 67 * @exception IllegalStateException if the cipher isn't initialised. 68 * @return the number of bytes processed and produced. 69 */ 70 public int processBlock(byte[] in, int inOff, byte[] out, int outOff) 71 throws DataLengthException, IllegalStateException; 72 73 /** 74 * Reset the cipher. After resetting the cipher is in the same state 75 * as it was after the last init (if there was one). 76 */ 77 public void reset(); 78 }