init commit

This commit is contained in:
2025-10-09 09:57:24 +09:00
commit 4d551bd74f
6636 changed files with 1218703 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
using System;
namespace Org.BouncyCastle.Crypto;
public class StreamBlockCipher : IStreamCipher
{
private readonly IBlockCipher cipher;
private readonly byte[] oneByte = new byte[1];
public string AlgorithmName => cipher.AlgorithmName;
public StreamBlockCipher(IBlockCipher cipher)
{
if (cipher == null)
{
throw new ArgumentNullException("cipher");
}
if (cipher.GetBlockSize() != 1)
{
throw new ArgumentException("block cipher block size != 1.", "cipher");
}
this.cipher = cipher;
}
public void Init(bool forEncryption, ICipherParameters parameters)
{
cipher.Init(forEncryption, parameters);
}
public byte ReturnByte(byte input)
{
oneByte[0] = input;
cipher.ProcessBlock(oneByte, 0, oneByte, 0);
return oneByte[0];
}
public void ProcessBytes(byte[] input, int inOff, int length, byte[] output, int outOff)
{
if (outOff + length > output.Length)
{
throw new DataLengthException("output buffer too small in ProcessBytes()");
}
for (int i = 0; i != length; i++)
{
cipher.ProcessBlock(input, inOff + i, output, outOff + i);
}
}
public void Reset()
{
cipher.Reset();
}
}