Files
2026-04-08 23:40:05 +02:00

353 lines
13 KiB
C#

using System;
using System.Collections;
using System.Runtime.InteropServices;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Math;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
using Cpp2IlInjected;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines
{
// Token: 0x020016BB RID: 5819
[Token(Token = "0x20016BB")]
[StructLayout(3)]
public class NaccacheSternEngine : IAsymmetricBlockCipher
{
// Token: 0x170018D4 RID: 6356
// (get) Token: 0x06009C11 RID: 39953 RVA: 0x0023561C File Offset: 0x0023381C
[Token(Token = "0x170018D4")]
public string AlgorithmName
{
[Token(Token = "0x6009C11")]
[Address(RVA = "0x2127730", Offset = "0x2126130", VA = "0x182127730", Slot = "4")]
get
{
return "NaccacheStern";
}
}
// Token: 0x06009C12 RID: 39954 RVA: 0x00235630 File Offset: 0x00233830
[Token(Token = "0x6009C12")]
[Address(RVA = "0x2126580", Offset = "0x2124F80", VA = "0x182126580", Slot = "9")]
public virtual void Init(bool forEncryption, ICipherParameters parameters)
{
for (;;)
{
this.forEncryption = forEncryption;
if (parameters == 0 || ((parameters == 0 || (parameters != 0 && parameters != 0)) && (parameters == 0 || parameters != 0)))
{
int num = 0;
this.key = num;
if (forEncryption)
{
return;
}
int num2 = 0;
if (num != 0)
{
IList[] array = new IList[num2];
if (0 >= array)
{
return;
}
if (array != 0)
{
break;
}
}
}
}
int num3;
IList list = Platform.CreateArrayList(num3);
throw new ArrayTypeMismatchException();
}
// Token: 0x170018D5 RID: 6357
// (set) Token: 0x06009C13 RID: 39955 RVA: 0x0000220F File Offset: 0x0000040F
[Token(Token = "0x170018D5")]
[Obsolete]
public virtual bool Debug
{
[Token(Token = "0x6009C13")]
[Address(RVA = "0x3C9F60", Offset = "0x3C8960", VA = "0x1803C9F60", Slot = "10")]
set
{
throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
}
}
// Token: 0x06009C14 RID: 39956 RVA: 0x002356C8 File Offset: 0x002338C8
[Token(Token = "0x6009C14")]
[Address(RVA = "0x21264C0", Offset = "0x2124EC0", VA = "0x1821264C0", Slot = "11")]
public virtual int GetInputBlockSize()
{
NaccacheSternKeyParameters naccacheSternKeyParameters = this.key;
if (!this.forEncryption)
{
BigInteger n = naccacheSternKeyParameters.n;
int num = 0;
int num2 = n.BitLength;
num2 += num;
return num2 + 1;
}
int lowerSigmaBound = naccacheSternKeyParameters.lowerSigmaBound;
return lowerSigmaBound + 7;
}
// Token: 0x06009C15 RID: 39957 RVA: 0x00235718 File Offset: 0x00233918
[Token(Token = "0x6009C15")]
[Address(RVA = "0x2126520", Offset = "0x2124F20", VA = "0x182126520", Slot = "12")]
public virtual int GetOutputBlockSize()
{
NaccacheSternKeyParameters naccacheSternKeyParameters = this.key;
if (!this.forEncryption)
{
int lowerSigmaBound = naccacheSternKeyParameters.lowerSigmaBound;
return lowerSigmaBound + 7;
}
BigInteger n = naccacheSternKeyParameters.n;
int num = 0;
int num2 = n.BitLength;
num2 += num;
return num2 + 1;
}
// Token: 0x06009C16 RID: 39958 RVA: 0x00235768 File Offset: 0x00233968
[Token(Token = "0x6009C16")]
[Address(RVA = "0x2126A20", Offset = "0x2125420", VA = "0x182126A20", Slot = "13")]
public virtual byte[] ProcessBlock(byte[] inBytes, int inOff, int length)
{
if (this.key != (ulong)0L)
{
if (!this.forEncryption)
{
}
BigInteger bigInteger = new BigInteger(1, inBytes, length, length);
int num = 0;
if ((this.forEncryption ? 1 : 0) == num)
{
IList list = Platform.CreateArrayList();
if (num >= list)
{
BigInteger bigInteger2;
return bigInteger2.ToByteArray();
}
int num2 = 0;
BigInteger bigInteger4;
BigInteger bigInteger3 = bigInteger.ModPow(bigInteger4, num2);
IList list2 = this.lookup[num];
int intValue = bigInteger3.IntValue;
if (intValue != -1)
{
BigInteger bigInteger5 = BigInteger.ValueOf((long)intValue);
num++;
object[] array = new object[6];
throw new ArrayTypeMismatchException();
}
goto IL_B5;
}
}
InvalidOperationException ex = new InvalidOperationException("NaccacheStern engine not initialised");
IL_B5:
InvalidCipherTextException ex2 = new InvalidCipherTextException("Lookup failed");
inBytes[1] = (byte)length;
throw new ArrayTypeMismatchException();
}
// Token: 0x06009C17 RID: 39959 RVA: 0x002358AC File Offset: 0x00233AAC
[Token(Token = "0x6009C17")]
[Address(RVA = "0x21263D0", Offset = "0x2124DD0", VA = "0x1821263D0", Slot = "14")]
public virtual byte[] Encrypt(BigInteger plain)
{
BigInteger n = this.key.n;
int num = 0;
int bitLength = n.BitLength;
num += bitLength;
num++;
byte[] array = new byte[num];
NaccacheSternKeyParameters naccacheSternKeyParameters = this.key;
BigInteger g = naccacheSternKeyParameters.g;
BigInteger n2 = naccacheSternKeyParameters.n;
byte[] array2 = g.ModPow(plain, n2).ToByteArray();
int length = array2.Length;
int num2 = array.Length;
int num3 = 0;
num2 -= length;
Array.Copy(array2, num3, array, num2, length);
return array;
}
// Token: 0x06009C18 RID: 39960 RVA: 0x00235938 File Offset: 0x00233B38
[Token(Token = "0x6009C18")]
[Address(RVA = "0x2126190", Offset = "0x2124B90", VA = "0x182126190", Slot = "15")]
public virtual byte[] AddCryptedBlocks(byte[] block1, byte[] block2)
{
if (!this.forEncryption)
{
}
int inputBlockSize = this.GetInputBlockSize();
int inputBlockSize2 = this.GetInputBlockSize();
BigInteger bigInteger = new BigInteger(1, block1);
BigInteger bigInteger2 = new BigInteger(1, block2);
BigInteger bigInteger3 = bigInteger.Multiply(bigInteger2);
BigInteger n = this.key.n;
BigInteger bigInteger4 = bigInteger3.Mod(n);
BigInteger n2 = this.key.n;
int num = 0;
int bitLength = n2.BitLength;
num += bitLength;
num++;
byte[] array = new byte[num];
byte[] array2 = bigInteger4.ToByteArray();
int length = array2.Length;
int num2 = array.Length;
int num3 = 0;
num2 -= length;
Array.Copy(array2, num3, array, num2, length);
return array;
}
// Token: 0x06009C19 RID: 39961 RVA: 0x002359F8 File Offset: 0x00233BF8
[Token(Token = "0x6009C19")]
[Address(RVA = "0x2127080", Offset = "0x2125A80", VA = "0x182127080", Slot = "16")]
public virtual byte[] ProcessData(byte[] data)
{
/*
An exception occurred when decompiling this method (06009C19)
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Byte[] BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines.NaccacheSternEngine::ProcessData(System.Byte[])
---> System.Exception: Basic block has to end with unconditional control flow.
{
IL_7D:
stloc:InvalidCipherTextException(var_13_87, newobj:InvalidCipherTextException(InvalidCipherTextException::.ctor, ldstr:string("cipher returned null")))
}
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.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1878
at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1878
at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1846
at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1878
at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1878
at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1846
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: 0x06009C1A RID: 39962 RVA: 0x00235A90 File Offset: 0x00233C90
[Token(Token = "0x6009C1A")]
[Address(RVA = "0x2127260", Offset = "0x2125C60", VA = "0x182127260")]
private static BigInteger chineseRemainder(IList congruences, IList primes)
{
int num;
BigInteger zero;
BigInteger bigInteger;
BigInteger bigInteger4;
for (;;)
{
num = 0;
zero = BigInteger.Zero;
BigInteger one = BigInteger.One;
num += num;
num++;
uint num2;
if (num < (int)num2)
{
num += num;
num++;
}
if (num == 0)
{
num += num;
num++;
num += 19;
num += num;
num += 19;
}
if (num != 0)
{
int num3 = 0;
bigInteger = one.Multiply(num);
num++;
if (num < num3)
{
num += num;
num++;
}
if (num >= num)
{
goto IL_EE;
}
uint num4;
if (num < (int)num4)
{
num += num;
num++;
}
if (num == 0)
{
num++;
num += 19;
num += 19;
}
if (num != 0)
{
BigInteger bigInteger2 = bigInteger.Divide(num);
BigInteger bigInteger3 = bigInteger2.ModInverse(num);
int num5 = 0;
bigInteger4 = bigInteger2.Multiply(bigInteger3);
if (num < num5)
{
num += num;
num++;
}
if (num == 0)
{
num += num;
num += 19;
}
if (num != 0)
{
break;
}
}
}
}
BigInteger bigInteger5 = bigInteger4.Multiply(num);
BigInteger bigInteger6 = zero.Add(bigInteger5);
num++;
IL_EE:
return bigInteger6.Mod(bigInteger);
}
// Token: 0x06009C1B RID: 39963 RVA: 0x00235B9C File Offset: 0x00233D9C
[Token(Token = "0x6009C1B")]
[Address(RVA = "0x3C1670", Offset = "0x3C0070", VA = "0x1803C1670")]
public NaccacheSternEngine()
{
int num = 0;
this.Debug = num != 0;
}
// Token: 0x04006668 RID: 26216
[global::Cpp2IlInjected.FieldOffset(Offset = "0x10")]
[Token(Token = "0x4006668")]
private bool forEncryption;
// Token: 0x04006669 RID: 26217
[global::Cpp2IlInjected.FieldOffset(Offset = "0x18")]
[Token(Token = "0x4006669")]
private NaccacheSternKeyParameters key;
// Token: 0x0400666A RID: 26218
[global::Cpp2IlInjected.FieldOffset(Offset = "0x20")]
[Token(Token = "0x400666A")]
private IList[] lookup;
}
}