1 package org.bouncycastle.crypto; 2 3 /*- 4 * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲ 5 * SNMP Java Client 6 * ჻჻჻჻჻჻ 7 * Copyright 2023 MetricsHub, 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 * Initialise the cipher. 32 * 33 * @param forEncryption if true the cipher is initialised for 34 * encryption, if false for decryption. 35 * @param params the key and other data required by the cipher. 36 * @exception IllegalArgumentException if the params argument is 37 * inappropriate. 38 */ 39 public void init(boolean forEncryption, CipherParameters params) 40 throws IllegalArgumentException; 41 42 /** 43 * Return the name of the algorithm the cipher implements. 44 * 45 * @return the name of the algorithm the cipher implements. 46 */ 47 public String getAlgorithmName(); 48 49 /** 50 * Return the block size for this cipher (in bytes). 51 * 52 * @return the block size for this cipher in bytes. 53 */ 54 public int getBlockSize(); 55 56 /** 57 * Process one block of input from the array in and write it to 58 * the out array. 59 * 60 * @param in the array containing the input data. 61 * @param inOff offset into the in array the data starts at. 62 * @param out the array the output data will be copied into. 63 * @param outOff the offset into the out array the output will start at. 64 * @exception DataLengthException if there isn't enough data in in, or 65 * space in out. 66 * @exception IllegalStateException if the cipher isn't initialised. 67 * @return the number of bytes processed and produced. 68 */ 69 public int processBlock(byte[] in, int inOff, byte[] out, int outOff) 70 throws DataLengthException, IllegalStateException; 71 72 /** 73 * Reset the cipher. After resetting the cipher is in the same state 74 * as it was after the last init (if there was one). 75 */ 76 public void reset(); 77 }