上海虹口龙之梦项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

72 lines
1.8 KiB

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