Class Salsa20Engine
- Namespace
- Org.BouncyCastle.Crypto.Engines
- Assembly
- BouncyCastle.Cryptography.dll
Implementation of Daniel J. Bernstein's Salsa20 stream cipher, Snuffle 2005
public class Salsa20Engine : IStreamCipher
- Inheritance
-
Salsa20Engine
- Implements
- Derived
- Inherited Members
Constructors
Salsa20Engine()
Creates a 20 round Salsa20 engine.
public Salsa20Engine()
Salsa20Engine(int)
Creates a Salsa20 engine with a specific number of rounds.
public Salsa20Engine(int rounds)
Parameters
roundsintthe number of rounds (must be an even number).
Fields
DEFAULT_ROUNDS
public static readonly int DEFAULT_ROUNDS
Field Value
rounds
protected int rounds
Field Value
Properties
AlgorithmName
The name of the algorithm this cipher implements.
public virtual string AlgorithmName { get; }
Property Value
NonceSize
protected virtual int NonceSize { get; }
Property Value
Methods
AdvanceCounter()
protected virtual void AdvanceCounter()
GenerateKeyStream(byte[])
protected virtual void GenerateKeyStream(byte[] output)
Parameters
outputbyte[]
Init(bool, ICipherParameters)
Initialise the cipher.
public virtual void Init(bool forEncryption, ICipherParameters parameters)
Parameters
forEncryptionboolIf true the cipher is initialised for encryption, if false for decryption.
parametersICipherParametersThe key and other data required by the cipher.
Exceptions
- ArgumentException
If the parameters argument is inappropriate.
ProcessBytes(byte[], int, int, byte[], int)
Process a block of bytes from input, putting the result into output.
public virtual void ProcessBytes(byte[] inBytes, int inOff, int len, byte[] outBytes, int outOff)
Parameters
inBytesbyte[]inOffintThe offset into
inputwhere the data to be processed starts.lenintoutBytesbyte[]outOffintThe offset into
outputthe processed data starts at.
Exceptions
- DataLengthException
If the input buffer is too small.
- OutputLengthException
If the output buffer is too small.
ProcessBytes(ReadOnlySpan<byte>, Span<byte>)
Process a block of bytes from input, putting the result into output.
public virtual void ProcessBytes(ReadOnlySpan<byte> input, Span<byte> output)
Parameters
inputReadOnlySpan<byte>The input span.
outputSpan<byte>The output span.
Exceptions
- OutputLengthException
If the output span is too small.
Reset()
Reset the cipher to the same state as it was after the last init (if there was one).
public virtual void Reset()
ResetCounter()
protected virtual void ResetCounter()
ReturnByte(byte)
encrypt/decrypt a single byte returning the result.
public virtual byte ReturnByte(byte input)
Parameters
inputbytethe byte to be processed.
Returns
- byte
the result of processing the input byte.
SetKey(byte[], byte[])
protected virtual void SetKey(byte[] keyBytes, byte[] ivBytes)