#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR) using System; using Org.BouncyCastle.Crypto; using Org.BouncyCastle.Security; namespace Org.BouncyCastle.Crypto.Paddings { /// A padder that adds Null byte padding to a block. public class ZeroBytePadding : IBlockCipherPadding { /// Return the name of the algorithm the cipher implements. /// /// /// the name of the algorithm the cipher implements. /// public string PaddingName { get { return "ZeroBytePadding"; } } /// Initialise the padder. /// /// /// - a SecureRandom if available. /// public void Init(SecureRandom random) { // nothing to do. } /// add the pad bytes to the passed in block, returning the /// number of bytes added. /// public int AddPadding( byte[] input, int inOff) { int added = (input.Length - inOff); while (inOff < input.Length) { input[inOff] = (byte) 0; inOff++; } return added; } /// return the number of pad bytes present in the block. public int PadCount( byte[] input) { int count = input.Length; while (count > 0) { if (input[count - 1] != 0) { break; } count--; } return input.Length - count; } } } #endif