Files
SuperVPN/output/Libraries/BouncyCastle.Crypto/Org/BouncyCastle/Crypto/Paddings/ISO10126d2Padding.cs
2025-10-09 09:57:24 +09:00

38 lines
732 B
C#

using Org.BouncyCastle.Security;
namespace Org.BouncyCastle.Crypto.Paddings;
public class ISO10126d2Padding : IBlockCipherPadding
{
private SecureRandom random;
public string PaddingName => "ISO10126-2";
public void Init(SecureRandom random)
{
this.random = ((random != null) ? random : new SecureRandom());
}
public int AddPadding(byte[] input, int inOff)
{
byte b = (byte)(input.Length - inOff);
while (inOff < input.Length - 1)
{
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;
}
}