using System; using System.Runtime.InteropServices; namespace System.Security.Cryptography { /// Converts a from base 64. // Token: 0x02000500 RID: 1280 [ComVisible(true)] public class FromBase64Transform : IDisposable, ICryptoTransform { /// Initializes a new instance of the class. // Token: 0x06002F3E RID: 12094 RVA: 0x00098240 File Offset: 0x00096440 public FromBase64Transform() : this(FromBase64TransformMode.IgnoreWhiteSpaces) { } /// Initializes a new instance of the class with the specified transformation mode. /// One of the values. // Token: 0x06002F3F RID: 12095 RVA: 0x0009824C File Offset: 0x0009644C public FromBase64Transform(FromBase64TransformMode whitespaces) { this.mode = whitespaces; this.accumulator = new byte[4]; this.accPtr = 0; this.m_disposed = false; } /// Releases the unmanaged resources used by the and optionally releases the managed resources. // Token: 0x06002F40 RID: 12096 RVA: 0x00098278 File Offset: 0x00096478 void IDisposable.Dispose() { this.Dispose(true); GC.SuppressFinalize(this); } /// Releases the unmanaged resources used by the . // Token: 0x06002F41 RID: 12097 RVA: 0x00098288 File Offset: 0x00096488 ~FromBase64Transform() { this.Dispose(false); } /// Gets a value that indicates whether multiple blocks can be transformed. /// Always false. // Token: 0x17000953 RID: 2387 // (get) Token: 0x06002F42 RID: 12098 RVA: 0x000982C4 File Offset: 0x000964C4 public bool CanTransformMultipleBlocks { get { return false; } } /// Gets a value indicating whether the current transform can be reused. /// Always true. // Token: 0x17000954 RID: 2388 // (get) Token: 0x06002F43 RID: 12099 RVA: 0x000982C8 File Offset: 0x000964C8 public virtual bool CanReuseTransform { get { return true; } } /// Gets the input block size. /// The size of the input data blocks in bytes. // Token: 0x17000955 RID: 2389 // (get) Token: 0x06002F44 RID: 12100 RVA: 0x000982CC File Offset: 0x000964CC public int InputBlockSize { get { return 1; } } /// Gets the output block size. /// The size of the output data blocks in bytes. // Token: 0x17000956 RID: 2390 // (get) Token: 0x06002F45 RID: 12101 RVA: 0x000982D0 File Offset: 0x000964D0 public int OutputBlockSize { get { return 3; } } /// Releases all resources used by the . // Token: 0x06002F46 RID: 12102 RVA: 0x000982D4 File Offset: 0x000964D4 public void Clear() { this.Dispose(true); } /// Releases the unmanaged resources used by the and optionally releases the managed resources. /// true to release both managed and unmanaged resources; false to release only unmanaged resources. // Token: 0x06002F47 RID: 12103 RVA: 0x000982E0 File Offset: 0x000964E0 protected virtual void Dispose(bool disposing) { if (!this.m_disposed) { if (this.accumulator != null) { Array.Clear(this.accumulator, 0, this.accumulator.Length); } if (disposing) { this.accumulator = null; } this.m_disposed = true; } } // Token: 0x06002F48 RID: 12104 RVA: 0x0009832C File Offset: 0x0009652C private byte lookup(byte input) { if ((int)input >= this.lookupTable.Length) { throw new FormatException(Locale.GetText("Invalid character in a Base-64 string.")); } byte b = this.lookupTable[(int)input]; if (b == 255) { throw new FormatException(Locale.GetText("Invalid character in a Base-64 string.")); } return b; } // Token: 0x06002F49 RID: 12105 RVA: 0x0009837C File Offset: 0x0009657C private int ProcessBlock(byte[] output, int offset) { int num = 0; if (this.accumulator[3] == 61) { num++; } if (this.accumulator[2] == 61) { num++; } this.lookupTable = Base64Constants.DecodeTable; switch (num) { case 0: { int num2 = (int)this.lookup(this.accumulator[0]); int num3 = (int)this.lookup(this.accumulator[1]); int num4 = (int)this.lookup(this.accumulator[2]); int num5 = (int)this.lookup(this.accumulator[3]); output[offset++] = (byte)((num2 << 2) | (num3 >> 4)); output[offset++] = (byte)((num3 << 4) | (num4 >> 2)); output[offset] = (byte)((num4 << 6) | num5); break; } case 1: { int num2 = (int)this.lookup(this.accumulator[0]); int num3 = (int)this.lookup(this.accumulator[1]); int num4 = (int)this.lookup(this.accumulator[2]); output[offset++] = (byte)((num2 << 2) | (num3 >> 4)); output[offset] = (byte)((num3 << 4) | (num4 >> 2)); break; } case 2: { int num2 = (int)this.lookup(this.accumulator[0]); int num3 = (int)this.lookup(this.accumulator[1]); output[offset] = (byte)((num2 << 2) | (num3 >> 4)); break; } } return 3 - num; } // Token: 0x06002F4A RID: 12106 RVA: 0x000984C4 File Offset: 0x000966C4 private void CheckInputParameters(byte[] inputBuffer, int inputOffset, int inputCount) { if (inputBuffer == null) { throw new ArgumentNullException("inputBuffer"); } if (inputOffset < 0) { throw new ArgumentOutOfRangeException("inputOffset", "< 0"); } if (inputCount > inputBuffer.Length) { throw new OutOfMemoryException("inputCount " + Locale.GetText("Overflow")); } if (inputOffset > inputBuffer.Length - inputCount) { throw new ArgumentException("inputOffset", Locale.GetText("Overflow")); } if (inputCount < 0) { throw new OverflowException("inputCount < 0"); } } /// Converts the specified region of the input byte array from base 64 and copies the result to the specified region of the output byte array. /// The number of bytes written. /// The input to compute from base 64. /// The offset into the input byte array from which to begin using data. /// The number of bytes in the input byte array to use as data. /// The output to which to write the result. /// The offset into the output byte array from which to begin writing data. /// The current object has already been disposed. /// /// uses an invalid value.-or- has an invalid offset length. /// /// is out of range. This parameter requires a non-negative number. /// /// is null. // Token: 0x06002F4B RID: 12107 RVA: 0x00098550 File Offset: 0x00096750 public int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset) { if (this.m_disposed) { throw new ObjectDisposedException("FromBase64Transform"); } this.CheckInputParameters(inputBuffer, inputOffset, inputCount); if (outputBuffer == null || outputOffset < 0) { throw new FormatException("outputBuffer"); } int num = 0; while (inputCount > 0) { if (this.accPtr < 4) { byte b = inputBuffer[inputOffset++]; if (this.mode == FromBase64TransformMode.IgnoreWhiteSpaces) { if (!char.IsWhiteSpace((char)b)) { this.accumulator[this.accPtr++] = b; } } else { this.accumulator[this.accPtr++] = b; } } if (this.accPtr == 4) { num += this.ProcessBlock(outputBuffer, outputOffset); outputOffset += 3; this.accPtr = 0; } inputCount--; } return num; } /// Converts the specified region of the specified byte array from base 64. /// The computed conversion. /// The input to convert from base 64. /// The offset into the byte array from which to begin using data. /// The number of bytes in the byte array to use as data. /// The current object has already been disposed. /// /// has an invalid offset length.-or- has an invalid value. /// /// is out of range. This parameter requires a non-negative number. /// /// is null. // Token: 0x06002F4C RID: 12108 RVA: 0x00098634 File Offset: 0x00096834 public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount) { if (this.m_disposed) { throw new ObjectDisposedException("FromBase64Transform"); } this.CheckInputParameters(inputBuffer, inputOffset, inputCount); int num = 0; int num2 = 0; if (this.mode == FromBase64TransformMode.IgnoreWhiteSpaces) { int num3 = inputOffset; for (int i = 0; i < inputCount; i++) { if (char.IsWhiteSpace((char)inputBuffer[num3])) { num++; } num3++; } if (num == inputCount) { return new byte[0]; } int num4 = inputOffset + inputCount - 1; int j = Math.Min(2, inputCount); while (j > 0) { char c = (char)inputBuffer[num4--]; if (c == '=') { num2++; j--; } else if (!char.IsWhiteSpace(c)) { break; } } } else { if (inputBuffer[inputOffset + inputCount - 1] == 61) { num2++; } if (inputBuffer[inputOffset + inputCount - 2] == 61) { num2++; } } if (inputCount < 4 && num2 < 2) { if (this.accPtr > 2 && this.accumulator[3] == 61) { num2++; } if (this.accPtr > 1 && this.accumulator[2] == 61) { num2++; } } int num5 = (this.accPtr + inputCount - num >> 2) * 3 - num2; if (num5 <= 0) { return new byte[0]; } byte[] array = new byte[num5]; this.TransformBlock(inputBuffer, inputOffset, inputCount, array, 0); return array; } // Token: 0x0400134B RID: 4939 private const byte TerminatorByte = 61; // Token: 0x0400134C RID: 4940 private FromBase64TransformMode mode; // Token: 0x0400134D RID: 4941 private byte[] accumulator; // Token: 0x0400134E RID: 4942 private int accPtr; // Token: 0x0400134F RID: 4943 private bool m_disposed; // Token: 0x04001350 RID: 4944 private byte[] lookupTable; } }