205 lines
8.3 KiB
C#
205 lines
8.3 KiB
C#
using System;
|
|
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: 0x02001BB1 RID: 7089
|
|
[Token(Token = "0x2001BB1")]
|
|
public class HMacDsaKCalculator : IDsaKCalculator
|
|
{
|
|
// Token: 0x0600B132 RID: 45362 RVA: 0x00268364 File Offset: 0x00266564
|
|
[Token(Token = "0x600B132")]
|
|
[Address(RVA = "0x1898FA0", Offset = "0x1897DA0", VA = "0x181898FA0")]
|
|
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: 0x17001BE7 RID: 7143
|
|
// (get) Token: 0x0600B133 RID: 45363 RVA: 0x002683B0 File Offset: 0x002665B0
|
|
[Token(Token = "0x17001BE7")]
|
|
public virtual bool IsDeterministic
|
|
{
|
|
[Token(Token = "0x600B133")]
|
|
[Address(RVA = "0x460D40", Offset = "0x45FB40", VA = "0x180460D40", Slot = "8")]
|
|
get
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600B134 RID: 45364 RVA: 0x002683C0 File Offset: 0x002665C0
|
|
[Token(Token = "0x600B134")]
|
|
[Address(RVA = "0x1898CB0", Offset = "0x1897AB0", VA = "0x181898CB0", Slot = "9")]
|
|
public virtual void Init(BigInteger n, SecureRandom random)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600B134)
|
|
|
|
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 1660
|
|
*/;
|
|
}
|
|
|
|
// Token: 0x0600B135 RID: 45365 RVA: 0x002683D8 File Offset: 0x002665D8
|
|
[Token(Token = "0x600B135")]
|
|
[Address(RVA = "0x1898800", Offset = "0x1897600", VA = "0x181898800", 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: 0x0600B136 RID: 45366 RVA: 0x002685CC File Offset: 0x002667CC
|
|
[Token(Token = "0x600B136")]
|
|
[Address(RVA = "0x1898D10", Offset = "0x1897B10", VA = "0x181898D10", 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: 0x0600B137 RID: 45367 RVA: 0x002686E8 File Offset: 0x002668E8
|
|
[Token(Token = "0x600B137")]
|
|
[Address(RVA = "0x1898740", Offset = "0x1897540", VA = "0x181898740")]
|
|
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: 0x040070C8 RID: 28872
|
|
[FieldOffset(Offset = "0x10")]
|
|
[Token(Token = "0x40070C8")]
|
|
private readonly HMac hMac;
|
|
|
|
// Token: 0x040070C9 RID: 28873
|
|
[FieldOffset(Offset = "0x18")]
|
|
[Token(Token = "0x40070C9")]
|
|
private readonly byte[] K;
|
|
|
|
// Token: 0x040070CA RID: 28874
|
|
[FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x40070CA")]
|
|
private readonly byte[] V;
|
|
|
|
// Token: 0x040070CB RID: 28875
|
|
[FieldOffset(Offset = "0x28")]
|
|
[Token(Token = "0x40070CB")]
|
|
private BigInteger n;
|
|
}
|
|
}
|