Top Description Fields Constructors Methods
org.bouncycastle.pqc.addon

pack-priv Class Salsa20Engine

extends Object
Class Inheritance
Known Direct Subclasses
org.bouncycastle.pqc.addon.ChaChaEngine
Imports
org.bouncycastle.util.Pack, .Strings

Implementation of Daniel J. Bernstein's Salsa20 stream cipher, Snuffle 2005

Field Summary

Modifier and TypeField and Description
private int
private int
private int
public static final int
protected int[]
private int
private boolean
private byte[]
protected int
protected static final byte[]
sigma

Deprecated
private static final int
STATE_SIZE

Constants

protected static final byte[]
tau

Deprecated
private static final int[]
protected int[]
x

Constructor Summary

AccessConstructor and Description
public
Salsa20Engine()

Creates a 20 round Salsa20 engine.

public
Salsa20Engine(int
the number of rounds (must be an even number).
rounds
)

Creates a Salsa20 engine with a specific number of rounds.

Method Summary

Modifier and TypeMethod and Description
protected void
advanceCounter(long diff)

protected void
protected void
generateKeyStream(byte[] output)

public String
protected long
protected int
public long
public void
init(boolean
whether or not we are for encryption.
forEncryption
,
ParametersWithIV
the parameters required to set up the cipher.
params
)

initialise a Salsa20 cipher.

private boolean
private boolean
limitExceeded(int len)

protected void
packTauOrSigma(int keyLength, int[] state, int stateOffset)

public int
processBytes(byte[] in, int inOff, int len, byte[] out, int outOff)

public void
protected void
private void
protected void
retreatCounter(long diff)

protected void
public byte
returnByte(byte in)

protected static int

Returns:

rotated x
rotl
(int
value to rotate
x
,
int
amount to rotate x
y
)

Rotate left

public static void
salsaCore(int rounds, int[]
input data
input
,
int[] x)

Salsa20 function

public long
seekTo(long position)

protected void
setKey(byte[] keyBytes, byte[] ivBytes)

public long
skip(long numberOfBytes)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cW0back to summary
private int cW0
cW1back to summary
private int cW1
cW2back to summary
private int cW2
DEFAULT_ROUNDSback to summary
public static final int DEFAULT_ROUNDS
engineStateback to summary
protected int[] engineState
indexback to summary
private int index
initialisedback to summary
private boolean initialised
keyStreamback to summary
private byte[] keyStream
roundsback to summary
protected int rounds
sigmaback to summary
protected static final byte[] sigma

Deprecated

STATE_SIZEback to summary
private static final int STATE_SIZE

Constants

tauback to summary
protected static final byte[] tau

Deprecated

TAU_SIGMAback to summary
private static final int[] TAU_SIGMA
xback to summary
protected int[] x

Constructor Detail

Salsa20Engineback to summary
public Salsa20Engine()

Creates a 20 round Salsa20 engine.

Salsa20Engineback to summary
public Salsa20Engine(int rounds)

Creates a Salsa20 engine with a specific number of rounds.

Parameters
rounds:int

the number of rounds (must be an even number).

Method Detail

advanceCounterback to summary
protected void advanceCounter(long diff)
advanceCounterback to summary
protected void advanceCounter()
generateKeyStreamback to summary
protected void generateKeyStream(byte[] output)
getAlgorithmNameback to summary
public String getAlgorithmName()
getCounterback to summary
protected long getCounter()
getNonceSizeback to summary
protected int getNonceSize()
getPositionback to summary
public long getPosition()
initback to summary
public void init(boolean forEncryption, ParametersWithIV params)

initialise a Salsa20 cipher.

Parameters
forEncryption:boolean

whether or not we are for encryption.

params:ParametersWithIV

the parameters required to set up the cipher.

Exceptions
IllegalArgumentException:
if the params argument is inappropriate.
limitExceededback to summary
private boolean limitExceeded()
limitExceededback to summary
private boolean limitExceeded(int len)
packTauOrSigmaback to summary
protected void packTauOrSigma(int keyLength, int[] state, int stateOffset)
processBytesback to summary
public int processBytes(byte[] in, int inOff, int len, byte[] out, int outOff)
resetback to summary
public void reset()
resetCounterback to summary
protected void resetCounter()
resetLimitCounterback to summary
private void resetLimitCounter()
retreatCounterback to summary
protected void retreatCounter(long diff)
retreatCounterback to summary
protected void retreatCounter()
returnByteback to summary
public byte returnByte(byte in)
rotlback to summary
protected static int rotl(int x, int y)

Rotate left

Parameters
x:int

value to rotate

y:int

amount to rotate x

Returns:int

rotated x

salsaCoreback to summary
public static void salsaCore(int rounds, int[] input, int[] x)

Salsa20 function

Parameters
input:int[]

input data

seekToback to summary
public long seekTo(long position)
setKeyback to summary
protected void setKey(byte[] keyBytes, byte[] ivBytes)
skipback to summary
public long skip(long numberOfBytes)