Files
Jan2021-Cpp2Il-Dump/Assembly-CSharp/BestHTTP/SecureProtocol/Org/BouncyCastle/Crypto/Engines/RC2WrapEngine.cs
T
2026-04-08 23:40:05 +02:00

230 lines
11 KiB
C#

using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Digests;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Modes;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Security;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
using Cpp2IlInjected;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines
{
// Token: 0x020016BF RID: 5823
[Token(Token = "0x20016BF")]
[StructLayout(3)]
public class RC2WrapEngine : IWrapper
{
// Token: 0x06009C3F RID: 39999 RVA: 0x002367F8 File Offset: 0x002349F8
[Token(Token = "0x6009C3F")]
[Address(RVA = "0x212A440", Offset = "0x2128E40", VA = "0x18212A440", Slot = "8")]
public virtual void Init(bool forWrapping, ICipherParameters parameters)
{
for (;;)
{
this.forWrapping = forWrapping;
RC2Engine rc2Engine;
rc2Engine.Reset();
CbcBlockCipher cbcBlockCipher = new CbcBlockCipher(rc2Engine);
this.engine = cbcBlockCipher;
if (parameters != 0 && parameters != 0)
{
int num = 0;
if (parameters == 0)
{
continue;
}
this.sr = num;
}
SecureRandom secureRandom = new SecureRandom();
this.sr = secureRandom;
if (parameters == 0 || parameters == 0)
{
break;
}
if (forWrapping && parameters != 0)
{
this.paramPlusIV = parameters;
ParametersWithIV parametersWithIV = this.paramPlusIV;
byte[] array;
this.iv = array;
ICipherParameters cipherParameters = parametersWithIV.parameters;
if (array.Length == 8)
{
break;
}
}
}
this.parameters = parameters;
if (this.forWrapping != parameters)
{
byte[] array2 = new byte[8];
SecureRandom secureRandom2 = this.sr;
this.iv = array2;
double num2 = secureRandom2.NextDouble();
ICipherParameters cipherParameters2 = this.parameters;
byte[] array3 = this.iv;
ParametersWithIV parametersWithIV2 = new ParametersWithIV(cipherParameters2, array3);
this.paramPlusIV = parametersWithIV2;
}
}
// Token: 0x170018DC RID: 6364
// (get) Token: 0x06009C40 RID: 40000 RVA: 0x002368E4 File Offset: 0x00234AE4
[Token(Token = "0x170018DC")]
public virtual string AlgorithmName
{
[Token(Token = "0x6009C40")]
[Address(RVA = "0x212B310", Offset = "0x2129D10", VA = "0x18212B310", Slot = "9")]
get
{
return "RC2";
}
}
// Token: 0x06009C41 RID: 40001 RVA: 0x002368F8 File Offset: 0x00234AF8
[Token(Token = "0x6009C41")]
[Address(RVA = "0x212AD80", Offset = "0x2129780", VA = "0x18212AD80", Slot = "10")]
public virtual byte[] Wrap(byte[] input, int inOff, int length)
{
/*
An exception occurred when decompiling this method (06009C41)
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Byte[] BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines.RC2WrapEngine::Wrap(System.Byte[],System.Int32,System.Int32)
---> System.Exception: Basic block has to end with unconditional control flow.
{
IL_27B:
stloc:InvalidOperationException(var_52_285, newobj:InvalidOperationException(InvalidOperationException::.ctor, ldstr:string("Not multiple of block length")))
}
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: 0x06009C42 RID: 40002 RVA: 0x00236B8C File Offset: 0x00234D8C
[Token(Token = "0x6009C42")]
[Address(RVA = "0x212A730", Offset = "0x2129130", VA = "0x18212A730", Slot = "11")]
public virtual byte[] Unwrap(byte[] input, int inOff, int length)
{
/*
An exception occurred when decompiling this method (06009C42)
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Byte[] BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines.RC2WrapEngine::Unwrap(System.Byte[],System.Int32,System.Int32)
---> System.Exception: Basic block has to end with unconditional control flow.
{
IL_29E:
stloc:InvalidOperationException(var_58_2A8, newobj:InvalidOperationException(InvalidOperationException::.ctor, ldstr:string("Not set for unwrapping")))
}
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: 0x06009C43 RID: 40003 RVA: 0x00236E44 File Offset: 0x00235044
[Token(Token = "0x6009C43")]
[Address(RVA = "0x212A2E0", Offset = "0x2128CE0", VA = "0x18212A2E0")]
private byte[] CalculateCmsKeyChecksum(byte[] key)
{
IDigest digest = this.sha1;
int length = key.Length;
IDigest digest2 = this.sha1;
byte[] array = new byte[8];
byte[] array2 = this.digest;
int num = 0;
int num2 = 0;
ulong num3;
Array.Copy(array2, num2, array, num, (int)num3);
return array;
}
// Token: 0x06009C44 RID: 40004 RVA: 0x00236E94 File Offset: 0x00235094
[Token(Token = "0x6009C44")]
[Address(RVA = "0x212A3C0", Offset = "0x2128DC0", VA = "0x18212A3C0")]
private bool CheckCmsKeyChecksum(byte[] key, byte[] checksum)
{
return Arrays.ConstantTimeAreEqual(this.CalculateCmsKeyChecksum(key), checksum);
}
// Token: 0x06009C45 RID: 40005 RVA: 0x00236EB0 File Offset: 0x002350B0
[Token(Token = "0x6009C45")]
[Address(RVA = "0x212B2A0", Offset = "0x2129CA0", VA = "0x18212B2A0")]
public RC2WrapEngine()
{
Sha1Digest sha1Digest = new Sha1Digest();
this.sha1 = sha1Digest;
byte[] array = new byte[20];
this.digest = array;
base..ctor();
}
// Token: 0x06009C46 RID: 40006 RVA: 0x00236EE0 File Offset: 0x002350E0
// Note: this type is marked as 'beforefieldinit'.
[Token(Token = "0x6009C46")]
[Address(RVA = "0x212B240", Offset = "0x2129C40", VA = "0x18212B240")]
static RC2WrapEngine()
{
byte[] array = new byte[8];
RuntimeHelpers.InitializeArray(array, fieldof(<PrivateImplementationDetails>.6DFD60679846B0E2064404E9EA3E1DDCE2C5709D).FieldHandle);
RC2WrapEngine.IV2 = array;
}
// Token: 0x04006679 RID: 26233
[global::Cpp2IlInjected.FieldOffset(Offset = "0x10")]
[Token(Token = "0x4006679")]
private CbcBlockCipher engine;
// Token: 0x0400667A RID: 26234
[global::Cpp2IlInjected.FieldOffset(Offset = "0x18")]
[Token(Token = "0x400667A")]
private ICipherParameters parameters;
// Token: 0x0400667B RID: 26235
[global::Cpp2IlInjected.FieldOffset(Offset = "0x20")]
[Token(Token = "0x400667B")]
private ParametersWithIV paramPlusIV;
// Token: 0x0400667C RID: 26236
[global::Cpp2IlInjected.FieldOffset(Offset = "0x28")]
[Token(Token = "0x400667C")]
private byte[] iv;
// Token: 0x0400667D RID: 26237
[global::Cpp2IlInjected.FieldOffset(Offset = "0x30")]
[Token(Token = "0x400667D")]
private bool forWrapping;
// Token: 0x0400667E RID: 26238
[global::Cpp2IlInjected.FieldOffset(Offset = "0x38")]
[Token(Token = "0x400667E")]
private SecureRandom sr;
// Token: 0x0400667F RID: 26239
[Token(Token = "0x400667F")]
private static readonly byte[] IV2;
// Token: 0x04006680 RID: 26240
[global::Cpp2IlInjected.FieldOffset(Offset = "0x40")]
[Token(Token = "0x4006680")]
private IDigest sha1;
// Token: 0x04006681 RID: 26241
[global::Cpp2IlInjected.FieldOffset(Offset = "0x48")]
[Token(Token = "0x4006681")]
private byte[] digest;
}
}