Package org.bouncycastle.crypto.engines
Class ChaChaEngine
java.lang.Object
org.bouncycastle.crypto.engines.Salsa20Engine
org.bouncycastle.crypto.engines.ChaChaEngine
- All Implemented Interfaces:
SkippingCipher,SkippingStreamCipher,StreamCipher
Implementation of Daniel J. Bernstein's ChaCha stream cipher.
-
Field Summary
Fields inherited from class org.bouncycastle.crypto.engines.Salsa20Engine
DEFAULT_ROUNDS, engineState, rounds, sigma, tau, x -
Constructor Summary
ConstructorsConstructorDescriptionCreates a 20 rounds ChaCha engine.ChaChaEngine(int rounds) Creates a ChaCha engine with a specific number of rounds. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected voidadvanceCounter(long diff) static voidchachaCore(int rounds, int[] input, int[] x) ChaCha functionprotected voidgenerateKeyStream(byte[] output) Return the name of the algorithm the cipher implements.protected longprotected voidprotected voidprotected voidretreatCounter(long diff) protected voidsetKey(byte[] keyBytes, byte[] ivBytes) Methods inherited from class org.bouncycastle.crypto.engines.Salsa20Engine
getNonceSize, getPosition, init, packTauOrSigma, processBytes, reset, returnByte, salsaCore, seekTo, skip
-
Constructor Details
-
ChaChaEngine
public ChaChaEngine()Creates a 20 rounds ChaCha engine. -
ChaChaEngine
public ChaChaEngine(int rounds) Creates a ChaCha engine with a specific number of rounds.- Parameters:
rounds- the number of rounds (must be an even number).
-
-
Method Details
-
getAlgorithmName
Description copied from interface:StreamCipherReturn the name of the algorithm the cipher implements.- Specified by:
getAlgorithmNamein interfaceStreamCipher- Overrides:
getAlgorithmNamein classSalsa20Engine- Returns:
- the name of the algorithm the cipher implements.
-
advanceCounter
protected void advanceCounter(long diff) - Overrides:
advanceCounterin classSalsa20Engine
-
advanceCounter
protected void advanceCounter()- Overrides:
advanceCounterin classSalsa20Engine
-
retreatCounter
protected void retreatCounter(long diff) - Overrides:
retreatCounterin classSalsa20Engine
-
retreatCounter
protected void retreatCounter()- Overrides:
retreatCounterin classSalsa20Engine
-
getCounter
protected long getCounter()- Overrides:
getCounterin classSalsa20Engine
-
resetCounter
protected void resetCounter()- Overrides:
resetCounterin classSalsa20Engine
-
setKey
protected void setKey(byte[] keyBytes, byte[] ivBytes) - Overrides:
setKeyin classSalsa20Engine
-
generateKeyStream
protected void generateKeyStream(byte[] output) - Overrides:
generateKeyStreamin classSalsa20Engine
-
chachaCore
public static void chachaCore(int rounds, int[] input, int[] x) ChaCha function- Parameters:
input- input data
-