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,44 @@
using Org.BouncyCastle.Security;
namespace Org.BouncyCastle.Crypto.Paddings;
public class X923Padding : IBlockCipherPadding
{
private SecureRandom random;
public string PaddingName => "X9.23";
public void Init(SecureRandom random)
{
this.random = random;
}
public int AddPadding(byte[] input, int inOff)
{
byte b = (byte)(input.Length - inOff);
while (inOff < input.Length - 1)
{
if (random == null)
{
input[inOff] = 0;
}
else
{
input[inOff] = (byte)random.NextInt();
}
inOff++;
}
input[inOff] = b;
return b;
}
public int PadCount(byte[] input)
{
int num = input[^1] & 0xFF;
if (num > input.Length)
{
throw new InvalidCipherTextException("pad block corrupted");
}
return num;
}
}