228 lines
11 KiB
C#
228 lines
11 KiB
C#
using System;
|
|
using System.Runtime.CompilerServices;
|
|
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: 0x02001D7C RID: 7548
|
|
[Token(Token = "0x2001D7C")]
|
|
public class RC2WrapEngine : IWrapper
|
|
{
|
|
// Token: 0x0600BBE7 RID: 48103 RVA: 0x00297084 File Offset: 0x00295284
|
|
[Token(Token = "0x600BBE7")]
|
|
[Address(RVA = "0x272D2F0", Offset = "0x272C2F0", VA = "0x18272D2F0", 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: 0x17001D7A RID: 7546
|
|
// (get) Token: 0x0600BBE8 RID: 48104 RVA: 0x00297170 File Offset: 0x00295370
|
|
[Token(Token = "0x17001D7A")]
|
|
public virtual string AlgorithmName
|
|
{
|
|
[Token(Token = "0x600BBE8")]
|
|
[Address(RVA = "0x272E1C0", Offset = "0x272D1C0", VA = "0x18272E1C0", Slot = "9")]
|
|
get
|
|
{
|
|
return "RC2";
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600BBE9 RID: 48105 RVA: 0x00297184 File Offset: 0x00295384
|
|
[Token(Token = "0x600BBE9")]
|
|
[Address(RVA = "0x272DC30", Offset = "0x272CC30", VA = "0x18272DC30", Slot = "10")]
|
|
public virtual byte[] Wrap(byte[] input, int inOff, int length)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600BBE9)
|
|
|
|
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: 0x0600BBEA RID: 48106 RVA: 0x00297418 File Offset: 0x00295618
|
|
[Token(Token = "0x600BBEA")]
|
|
[Address(RVA = "0x272D5E0", Offset = "0x272C5E0", VA = "0x18272D5E0", Slot = "11")]
|
|
public virtual byte[] Unwrap(byte[] input, int inOff, int length)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600BBEA)
|
|
|
|
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: 0x0600BBEB RID: 48107 RVA: 0x002976D0 File Offset: 0x002958D0
|
|
[Token(Token = "0x600BBEB")]
|
|
[Address(RVA = "0x272D190", Offset = "0x272C190", VA = "0x18272D190")]
|
|
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: 0x0600BBEC RID: 48108 RVA: 0x00297720 File Offset: 0x00295920
|
|
[Token(Token = "0x600BBEC")]
|
|
[Address(RVA = "0x272D270", Offset = "0x272C270", VA = "0x18272D270")]
|
|
private bool CheckCmsKeyChecksum(byte[] key, byte[] checksum)
|
|
{
|
|
return Arrays.ConstantTimeAreEqual(this.CalculateCmsKeyChecksum(key), checksum);
|
|
}
|
|
|
|
// Token: 0x0600BBED RID: 48109 RVA: 0x0029773C File Offset: 0x0029593C
|
|
[Token(Token = "0x600BBED")]
|
|
[Address(RVA = "0x272E150", Offset = "0x272D150", VA = "0x18272E150")]
|
|
public RC2WrapEngine()
|
|
{
|
|
Sha1Digest sha1Digest = new Sha1Digest();
|
|
this.sha1 = sha1Digest;
|
|
byte[] array = new byte[20];
|
|
this.digest = array;
|
|
base..ctor();
|
|
}
|
|
|
|
// Token: 0x0600BBEE RID: 48110 RVA: 0x0029776C File Offset: 0x0029596C
|
|
// Note: this type is marked as 'beforefieldinit'.
|
|
[Token(Token = "0x600BBEE")]
|
|
[Address(RVA = "0x272E0F0", Offset = "0x272D0F0", VA = "0x18272E0F0")]
|
|
static RC2WrapEngine()
|
|
{
|
|
byte[] array = new byte[8];
|
|
RuntimeHelpers.InitializeArray(array, fieldof(<PrivateImplementationDetails>.6DFD60679846B0E2064404E9EA3E1DDCE2C5709D).FieldHandle);
|
|
RC2WrapEngine.IV2 = array;
|
|
}
|
|
|
|
// Token: 0x04007675 RID: 30325
|
|
[FieldOffset(Offset = "0x10")]
|
|
[Token(Token = "0x4007675")]
|
|
private CbcBlockCipher engine;
|
|
|
|
// Token: 0x04007676 RID: 30326
|
|
[FieldOffset(Offset = "0x18")]
|
|
[Token(Token = "0x4007676")]
|
|
private ICipherParameters parameters;
|
|
|
|
// Token: 0x04007677 RID: 30327
|
|
[FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x4007677")]
|
|
private ParametersWithIV paramPlusIV;
|
|
|
|
// Token: 0x04007678 RID: 30328
|
|
[FieldOffset(Offset = "0x28")]
|
|
[Token(Token = "0x4007678")]
|
|
private byte[] iv;
|
|
|
|
// Token: 0x04007679 RID: 30329
|
|
[FieldOffset(Offset = "0x30")]
|
|
[Token(Token = "0x4007679")]
|
|
private bool forWrapping;
|
|
|
|
// Token: 0x0400767A RID: 30330
|
|
[FieldOffset(Offset = "0x38")]
|
|
[Token(Token = "0x400767A")]
|
|
private SecureRandom sr;
|
|
|
|
// Token: 0x0400767B RID: 30331
|
|
[Token(Token = "0x400767B")]
|
|
private static readonly byte[] IV2;
|
|
|
|
// Token: 0x0400767C RID: 30332
|
|
[FieldOffset(Offset = "0x40")]
|
|
[Token(Token = "0x400767C")]
|
|
private IDigest sha1;
|
|
|
|
// Token: 0x0400767D RID: 30333
|
|
[FieldOffset(Offset = "0x48")]
|
|
[Token(Token = "0x400767D")]
|
|
private byte[] digest;
|
|
}
|
|
}
|