// Token: 0x060000AF RID: 175 RVA: 0x0000A3F4 File Offset: 0x000085F4 public static string Decrypt(byte[] encryptedBytes, byte[] key, byte[] iv) { string text = string.Empty; string result; try { GcmBlockCipher gcmBlockCipher = new GcmBlockCipher(new AesFastEngine()); AeadParameters parameters = new AeadParameters(new KeyParameter(key), 128, iv, null); gcmBlockCipher.Init(false, parameters); byte[] array = new byte[gcmBlockCipher.GetOutputSize(encryptedBytes.Length)]; int outOff = gcmBlockCipher.ProcessBytes(encryptedBytes, 0, encryptedBytes.Length, array, 0); gcmBlockCipher.DoFinal(array, outOff); text = Encoding.UTF8.GetString(array).TrimEnd("\r\n\0".ToCharArray()); result = text; } catch { result = text; } return(result); }
// Token: 0x06000077 RID: 119 RVA: 0x00008E70 File Offset: 0x00007070 public virtual void Init(bool forEncryption, ICipherParameters parameters) { this.forEncryption = forEncryption; this.macBlock = null; if (parameters is AeadParameters) { AeadParameters aeadParameters = (AeadParameters)parameters; this.nonce = aeadParameters.GetNonce(); this.A = aeadParameters.GetAssociatedText(); int num = aeadParameters.MacSize; if (num < 96 || num > 128 || num % 8 != 0) { throw new ArgumentException("Invalid value for MAC size: " + num.ToString()); } this.macSize = num / 8; this.keyParam = aeadParameters.Key; } else { if (!(parameters is ParametersWithIV)) { throw new ArgumentException("invalid parameters passed to GCM"); } ParametersWithIV parametersWithIV = (ParametersWithIV)parameters; this.nonce = parametersWithIV.GetIV(); this.A = null; this.macSize = 16; this.keyParam = (KeyParameter)parametersWithIV.Parameters; } int num2 = forEncryption ? 16 : (16 + this.macSize); this.bufBlock = new byte[num2]; if (this.nonce == null || this.nonce.Length < 1) { throw new ArgumentException("IV must be at least 1 byte"); } if (this.A == null) { this.A = new byte[0]; } this.cipher.Init(true, this.keyParam); this.H = new byte[16]; this.cipher.ProcessBlock(this.H, 0, this.H, 0); this.multiplier.Init(this.H); this.initS = this.gHASH(this.A); if (this.nonce.Length == 12) { this.J0 = new byte[16]; Array.Copy(this.nonce, 0, this.J0, 0, this.nonce.Length); this.J0[15] = 1; } else { this.J0 = this.gHASH(this.nonce); byte[] array = new byte[16]; GcmBlockCipher.packLength((ulong)((long)this.nonce.Length * 8L), array, 8); GcmUtilities.Xor(this.J0, array); this.multiplier.MultiplyH(this.J0); } this.S = Arrays.Clone(this.initS); this.counter = Arrays.Clone(this.J0); this.bufOff = 0; this.totalLength = 0UL; }