Repository navigation
·
24 commits
to main
since this release
Immutable
release. Only release title and notes can be modified.
Leooldi Release v2.26.1115
Attention
Release v2.26.1115 isn't anymore backward compatible, because of correcting keysizes in serveral ciphers!
Please use the previous version 2.25.1101 for decrypting old files, or use the new version for encrypting new files.
added StreamCiffres to C# and java
StreamCiphers
Following StreamCiphers have been added to CipherEnum:
Salsa20 = 0x20,
ChaCha = 0x21,
ChaCha7539 = 0x22,
RC4 = 0x23,
Isaac = 0x24,
HC256 = 0x25,
HC128 = 0x26,
Vmpc = 0x27,
VmpcKsa3 = 0x28,
XChaCha20 = 0x29,
XSalsa20 = 0x2a,
Rsa changed byte code in enum to 0x40
How StreamCipher basically work?
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Engines;
using Org.BouncyCastle.Crypto.Parameters;
namespace EU.CqrXs.Crypt.Cipher.Symmetric
{
/// <summary>
/// StreamCipherBC class to perform all StreamCiphers
/// </summary>
public class StreamCipherBC : IStreamCipher
{
protected internal bool initialised = false, encryption;
public IStreamCipher CryptoStreamCipher { get; private set; }
public ICipherParameters StreamCipherParameters { get; private set; }
#region IStreamCipher interface imlementation
public new string AlgorithmName => CryptoStreamCipher.AlgorithmName;
public void Reset() => CryptoStreamCipher.Reset();
public byte ReturnByte(byte input) => CryptoStreamCipher.ReturnByte(input);
public void Init(bool forEncryption, ICipherParameters parameters)
{
if (!(parameters is KeyParameter) && !(parameters is ParametersWithIV))
throw new ArgumentException("only KeyParameter or ParametersWithIV expected.", "parameters");
encryption = forEncryption;
CryptoStreamCipher.Init(forEncryption, StreamCipherParameters);
initialised = true;
}
public void ProcessBytes(byte[] input, int inOff, int length, byte[] output, int outOff)
{
output = new byte[input.Length];
int i = inOff, j = outOff;
for (i = inOff; i < (inOff + length); i++)
{
output[j++] = CryptoStreamCipher.ReturnByte(input[i]);
}
}
public void ProcessBytes(ReadOnlySpan<byte> input, Span<byte> output)
{
output = new byte[input.Length];
for (int i = 0; i < input.Length; i++)
{
output[i] = ReturnByte(input[i]);
}
}
#endregion IStreamCipher interface imlementation
/// <summary>
/// ctor for <see cref="StreamCipherBC"/>
/// </summary>
/// <param name="cparams">CryptParams</param>
/// <param name="encrytion">true for encrytion, false for decrytion</param>
public StreamCipherBC(CryptParams cparams, bool encrytion = true)
{
CryptoStreamCipher = cparams.StreamCipher == null ? new ChaChaEngine() : cparams.StreamCipher;
StreamCipherParameters = cparams.CipherParameters;
Init(encrytion, StreamCipherParameters);
}
/// <summary>
/// generic Encryt for<see cref="StreamCipherBC"/>
/// </summary>
/// <param name="plainData">lain data bytes</param>
/// <returns>ciher data bytes</returns>
public byte[] Encrypt(byte[] plainData)
{
byte[] cipherData = new byte[plainData.Length];
for (int j = 0; j < plainData.Length; j++)
{
cipherData[j] = ReturnByte(plainData[j]);
}
return cipherData;
}
/// <summary>
/// generic Decryt for <see cref="StreamCipherBC"/>
/// </summary>
/// <param name="cipherData">encryted ciher data<see cref="T:byte[]"/></param>
/// <returns>lain data data <see cref="T:byte[]"/></returns>
public byte[] Decrypt(byte[] cipherData)
{
byte[] plainData = new byte[cipherData.Length];
for (int j = 0; j < cipherData.Length; j++)
{
plainData[j] = ReturnByte(cipherData[j]);
}
return plainData;
}
}
}
new feature in menu Options -> Settings ->
Options -> Settings -> Include StreamCiphers
Checked generate mixed symmetric blockcipher and streamciphjer oipeslines.
UnChecked generate classic backward compatible symmetric blockcipher oipeslines.
🗹 Include StreamCiphers [checked]
generate mixed symmetric blockcipher and streamciphjer oipesline.
☐ Include StreamCiphers [unchecked]
generates on SetPipe or HashPipe backward compatible symmetric blockcipher oipesline.
