170 lines
6.7 KiB
C#
170 lines
6.7 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines
|
|
{
|
|
// Token: 0x020016C0 RID: 5824
|
|
[Token(Token = "0x20016C0")]
|
|
[StructLayout(3)]
|
|
public class RC4Engine : IStreamCipher
|
|
{
|
|
// Token: 0x06009C47 RID: 40007 RVA: 0x00236F08 File Offset: 0x00235108
|
|
[Token(Token = "0x6009C47")]
|
|
[Address(RVA = "0x212B340", Offset = "0x2129D40", VA = "0x18212B340", Slot = "9")]
|
|
public virtual void Init(bool forEncryption, ICipherParameters parameters)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (06009C47)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Void BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines.RC4Engine::Init(System.Boolean,BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.ICipherParameters)
|
|
|
|
---> System.Exception: Basic block has to end with unconditional control flow.
|
|
{
|
|
IL_25:
|
|
stloc:ArgumentException(var_5_36, newobj:ArgumentException(ArgumentException::.ctor, call:string(string::Concat, ldstr:string("invalid parameter passed to RC4 init - "), ldloc:string(var_4))))
|
|
}
|
|
|
|
at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1852
|
|
at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.Optimize(DecompilerContext context, ILBlock method, AutoPropertyProvider autoPropertyProvider, StateMachineKind& stateMachineKind, MethodDef& inlinedMethod, AsyncMethodDebugInfo& asyncInfo, ILAstOptimizationStep abortBeforeStep) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 355
|
|
at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(IEnumerable`1 parameters, MethodDebugInfoBuilder& builder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 123
|
|
at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(MethodDef methodDef, DecompilerContext context, AutoPropertyProvider autoPropertyProvider, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, StringBuilder sb, MethodDebugInfoBuilder& stmtsBuilder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 88
|
|
--- End of inner exception stack trace ---
|
|
at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(MethodDef methodDef, DecompilerContext context, AutoPropertyProvider autoPropertyProvider, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, StringBuilder sb, MethodDebugInfoBuilder& stmtsBuilder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 92
|
|
at ICSharpCode.Decompiler.Ast.AstBuilder.AddMethodBody(EntityDeclaration methodNode, EntityDeclaration& updatedNode, MethodDef method, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, MethodKind methodKind) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstBuilder.cs:line 1663
|
|
*/;
|
|
}
|
|
|
|
// Token: 0x170018DD RID: 6365
|
|
// (get) Token: 0x06009C48 RID: 40008 RVA: 0x00236F4C File Offset: 0x0023514C
|
|
[Token(Token = "0x170018DD")]
|
|
public virtual string AlgorithmName
|
|
{
|
|
[Token(Token = "0x6009C48")]
|
|
[Address(RVA = "0x212BB20", Offset = "0x212A520", VA = "0x18212BB20", Slot = "10")]
|
|
get
|
|
{
|
|
return "RC4";
|
|
}
|
|
}
|
|
|
|
// Token: 0x06009C49 RID: 40009 RVA: 0x00236F60 File Offset: 0x00235160
|
|
[Token(Token = "0x6009C49")]
|
|
[Address(RVA = "0x212B750", Offset = "0x212A150", VA = "0x18212B750", Slot = "11")]
|
|
public virtual byte ReturnByte(byte input)
|
|
{
|
|
int num = this.x;
|
|
byte[] array = this.engineState;
|
|
num++;
|
|
this.x = num;
|
|
byte b;
|
|
this.y = (int)b;
|
|
int length = array.Length;
|
|
byte[] array2 = this.engineState;
|
|
int num2 = this.y;
|
|
byte[] array3 = this.engineState;
|
|
int num3 = this.x;
|
|
int length2 = array3.Length;
|
|
int num4 = this.y;
|
|
byte b2;
|
|
byte b3;
|
|
b2 += b3;
|
|
b3 = b2;
|
|
byte b4;
|
|
return b4;
|
|
}
|
|
|
|
// Token: 0x06009C4A RID: 40010 RVA: 0x00236FD8 File Offset: 0x002351D8
|
|
[Token(Token = "0x6009C4A")]
|
|
[Address(RVA = "0x212B4D0", Offset = "0x2129ED0", VA = "0x18212B4D0", Slot = "12")]
|
|
public virtual void ProcessBytes(byte[] input, int inOff, int length, byte[] output, int outOff)
|
|
{
|
|
Check.DataLength(input, inOff, inOff, "input buffer too short");
|
|
if (length > 0)
|
|
{
|
|
int num = this.x;
|
|
byte[] array = this.engineState;
|
|
num++;
|
|
this.x = num;
|
|
byte b;
|
|
this.y = (int)b;
|
|
int length2 = array.Length;
|
|
byte[] array2 = this.engineState;
|
|
int num2 = this.y;
|
|
byte[] array3 = this.engineState;
|
|
int num3 = this.x;
|
|
int length3 = array3.Length;
|
|
int num4 = this.y;
|
|
byte b2;
|
|
byte b3;
|
|
b2 += b3;
|
|
}
|
|
}
|
|
|
|
// Token: 0x06009C4B RID: 40011 RVA: 0x00237060 File Offset: 0x00235260
|
|
[Token(Token = "0x6009C4B")]
|
|
[Address(RVA = "0x212B740", Offset = "0x212A140", VA = "0x18212B740", Slot = "13")]
|
|
public virtual void Reset()
|
|
{
|
|
byte[] array = this.workingKey;
|
|
this.SetKey(array);
|
|
}
|
|
|
|
// Token: 0x06009C4C RID: 40012 RVA: 0x0023707C File Offset: 0x0023527C
|
|
[Token(Token = "0x6009C4C")]
|
|
[Address(RVA = "0x212B8C0", Offset = "0x212A2C0", VA = "0x18212B8C0")]
|
|
private void SetKey(byte[] keyBytes)
|
|
{
|
|
int num = 0;
|
|
this.workingKey = keyBytes;
|
|
this.x = num;
|
|
if (this.engineState == num)
|
|
{
|
|
byte[] array = new byte[RC4Engine.STATE_LENGTH];
|
|
this.engineState = array;
|
|
}
|
|
byte[] array2 = this.engineState;
|
|
if (num < "{il2cpp array field local5->}")
|
|
{
|
|
int length = this.engineState.Length;
|
|
byte b = (byte)((int)b + num);
|
|
byte b2;
|
|
b += b2;
|
|
byte[] array3 = this.engineState;
|
|
num++;
|
|
}
|
|
}
|
|
|
|
// Token: 0x06009C4D RID: 40013 RVA: 0x002370F0 File Offset: 0x002352F0
|
|
[Token(Token = "0x6009C4D")]
|
|
[Address(RVA = "0x3C1670", Offset = "0x3C0070", VA = "0x1803C1670")]
|
|
public RC4Engine()
|
|
{
|
|
}
|
|
|
|
// Token: 0x04006682 RID: 26242
|
|
[Token(Token = "0x4006682")]
|
|
private static readonly int STATE_LENGTH;
|
|
|
|
// Token: 0x04006683 RID: 26243
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x10")]
|
|
[Token(Token = "0x4006683")]
|
|
private byte[] engineState;
|
|
|
|
// Token: 0x04006684 RID: 26244
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x18")]
|
|
[Token(Token = "0x4006684")]
|
|
private int x;
|
|
|
|
// Token: 0x04006685 RID: 26245
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x1C")]
|
|
[Token(Token = "0x4006685")]
|
|
private int y;
|
|
|
|
// Token: 0x04006686 RID: 26246
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x4006686")]
|
|
private byte[] workingKey;
|
|
}
|
|
}
|