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

207 lines
8.5 KiB
C#

using System;
using System.Runtime.InteropServices;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Macs;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Math;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Security;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
using Cpp2IlInjected;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Signers
{
// Token: 0x020015D4 RID: 5588
[Token(Token = "0x20015D4")]
[StructLayout(3)]
public class HMacDsaKCalculator : IDsaKCalculator
{
// Token: 0x06009558 RID: 38232 RVA: 0x00210CF8 File Offset: 0x0020EEF8
[Token(Token = "0x6009558")]
[Address(RVA = "0x1E416A0", Offset = "0x1E400A0", VA = "0x181E416A0")]
public HMacDsaKCalculator(IDigest digest)
{
HMac hmac = new HMac(digest);
this.hMac = hmac;
byte[] array = new byte[hmac];
HMac hmac2 = this.hMac;
this.V = array;
byte[] array2 = new byte[0];
this.K = array2;
}
// Token: 0x170017E6 RID: 6118
// (get) Token: 0x06009559 RID: 38233 RVA: 0x00210D44 File Offset: 0x0020EF44
[Token(Token = "0x170017E6")]
public virtual bool IsDeterministic
{
[Token(Token = "0x6009559")]
[Address(RVA = "0x4405A0", Offset = "0x43EFA0", VA = "0x1804405A0", Slot = "8")]
get
{
return true;
}
}
// Token: 0x0600955A RID: 38234 RVA: 0x00210D54 File Offset: 0x0020EF54
[Token(Token = "0x600955A")]
[Address(RVA = "0x1E413B0", Offset = "0x1E3FDB0", VA = "0x181E413B0", Slot = "9")]
public virtual void Init(BigInteger n, SecureRandom random)
{
/*
An exception occurred when decompiling this method (0600955A)
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Void BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Signers.HMacDsaKCalculator::Init(BestHTTP.SecureProtocol.Org.BouncyCastle.Math.BigInteger,BestHTTP.SecureProtocol.Org.BouncyCastle.Security.SecureRandom)
---> System.Exception: Basic block has to end with unconditional control flow.
{
Block_0:
stloc:InvalidOperationException(var_0_0A, newobj:InvalidOperationException(InvalidOperationException::.ctor, ldstr:string("Operation not supported")))
}
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: 0x0600955B RID: 38235 RVA: 0x00210D6C File Offset: 0x0020EF6C
[Token(Token = "0x600955B")]
[Address(RVA = "0x1E40F00", Offset = "0x1E3F900", VA = "0x181E40F00", Slot = "6")]
public void Init(BigInteger n, BigInteger d, byte[] message)
{
byte[] v = this.V;
this.n = n;
ulong num;
Arrays.Fill(v, (byte)num);
byte[] k = this.K;
int num2 = 0;
Arrays.Fill(k, (byte)num2);
int unsignedByteLength = BigIntegers.GetUnsignedByteLength(n);
byte[] array = new byte[unsignedByteLength];
byte[] array2 = BigIntegers.AsUnsignedByteArray(d);
int length = array2.Length;
int num3 = array.Length;
int num4 = 0;
num3 -= length;
Array.Copy(array2, num4, array, num3, length);
byte[] array3 = new byte[unsignedByteLength];
BigInteger bigInteger = this.BitsToInt(message);
int num5 = bigInteger.CompareTo(n);
byte[] array4 = BigIntegers.AsUnsignedByteArray(bigInteger.Subtract(n));
int length2 = array4.Length;
int num6 = array3.Length;
int num7 = 0;
num6 -= length2;
Array.Copy(array4, num7, array3, num6, length2);
HMac hmac = this.hMac;
KeyParameter keyParameter = new KeyParameter(this.K);
IDigest underlyingDigest = hmac.GetUnderlyingDigest();
byte[] v2 = this.V;
this.hMac.Update(v2);
int macSize = this.hMac.GetMacSize();
this.hMac.Update(array);
this.hMac.Update(array3);
HMac hmac2 = this.hMac;
HMac hmac3 = this.hMac;
KeyParameter keyParameter2 = new KeyParameter(this.K);
IDigest underlyingDigest2 = hmac3.GetUnderlyingDigest();
byte[] v3 = this.V;
this.hMac.Update(v3);
HMac hmac4 = this.hMac;
byte[] v4 = this.V;
this.hMac.Update(v4);
int macSize2 = this.hMac.GetMacSize();
this.hMac.Update(array);
this.hMac.Update(array3);
HMac hmac5 = this.hMac;
HMac hmac6 = this.hMac;
KeyParameter keyParameter3 = new KeyParameter(this.K);
IDigest underlyingDigest3 = hmac6.GetUnderlyingDigest();
byte[] v5 = this.V;
this.hMac.Update(v5);
string algorithmName = ((IMac)this.hMac).AlgorithmName;
}
// Token: 0x0600955C RID: 38236 RVA: 0x00210F60 File Offset: 0x0020F160
[Token(Token = "0x600955C")]
[Address(RVA = "0x1E41410", Offset = "0x1E3FE10", VA = "0x181E41410", Slot = "10")]
public virtual BigInteger NextK()
{
byte[] array = new byte[BigIntegers.GetUnsignedByteLength(this.n)];
int num = 0;
if (num < array.Length)
{
byte[] v = this.V;
this.hMac.Update(v);
HMac hmac = this.hMac;
byte[] v2 = this.V;
int num2 = array.Length;
int length = v2.Length;
num2 -= num;
int num3 = Math.Min(num2, length);
byte[] v3 = this.V;
int num4 = 0;
Array.Copy(v3, num4, array, num, num3);
num += num3;
}
BigInteger bigInteger = this.BitsToInt(array);
if (bigInteger.sign > num)
{
BigInteger bigInteger2 = this.n;
int num5 = bigInteger.CompareTo(bigInteger2);
}
byte[] v4 = this.V;
this.hMac.Update(v4);
int macSize = this.hMac.GetMacSize();
HMac hmac2 = this.hMac;
HMac hmac3 = this.hMac;
KeyParameter keyParameter = new KeyParameter(this.K);
IDigest underlyingDigest = hmac3.GetUnderlyingDigest();
byte[] v5 = this.V;
this.hMac.Update(v5);
HMac hmac4 = this.hMac;
throw new NullReferenceException();
}
// Token: 0x0600955D RID: 38237 RVA: 0x0021107C File Offset: 0x0020F27C
[Token(Token = "0x600955D")]
[Address(RVA = "0x1E40E40", Offset = "0x1E3F840", VA = "0x181E40E40")]
private BigInteger BitsToInt(byte[] t)
{
BigInteger bigInteger = new BigInteger(1, t);
int bitLength = this.n.BitLength;
if (t.Length > bitLength)
{
int bitLength2 = this.n.BitLength;
int num = t.Length;
num -= bitLength2;
BigInteger bigInteger2 = bigInteger.ShiftRight(num);
}
return bigInteger;
}
// Token: 0x04006285 RID: 25221
[global::Cpp2IlInjected.FieldOffset(Offset = "0x10")]
[Token(Token = "0x4006285")]
private readonly HMac hMac;
// Token: 0x04006286 RID: 25222
[global::Cpp2IlInjected.FieldOffset(Offset = "0x18")]
[Token(Token = "0x4006286")]
private readonly byte[] K;
// Token: 0x04006287 RID: 25223
[global::Cpp2IlInjected.FieldOffset(Offset = "0x20")]
[Token(Token = "0x4006287")]
private readonly byte[] V;
// Token: 0x04006288 RID: 25224
[global::Cpp2IlInjected.FieldOffset(Offset = "0x28")]
[Token(Token = "0x4006288")]
private BigInteger n;
}
}