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: 0x02001C91 RID: 7313
|
|
[Token(Token = "0x2001C91")]
|
|
public class HMacDsaKCalculator : IDsaKCalculator
|
|
{
|
|
// Token: 0x0600B500 RID: 46336 RVA: 0x00271528 File Offset: 0x0026F728
|
|
[Token(Token = "0x600B500")]
|
|
[Address(RVA = "0x235C910", Offset = "0x235B910", VA = "0x18235C910")]
|
|
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: 0x17001C84 RID: 7300
|
|
// (get) Token: 0x0600B501 RID: 46337 RVA: 0x00271574 File Offset: 0x0026F774
|
|
[Token(Token = "0x17001C84")]
|
|
public virtual bool IsDeterministic
|
|
{
|
|
[Token(Token = "0x600B501")]
|
|
[Address(RVA = "0x4246A0", Offset = "0x4236A0", VA = "0x1804246A0", Slot = "8")]
|
|
get
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600B502 RID: 46338 RVA: 0x00271584 File Offset: 0x0026F784
|
|
[Token(Token = "0x600B502")]
|
|
[Address(RVA = "0x235C620", Offset = "0x235B620", VA = "0x18235C620", Slot = "9")]
|
|
public virtual void Init(BigInteger n, SecureRandom random)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600B502)
|
|
|
|
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: 0x0600B503 RID: 46339 RVA: 0x0027159C File Offset: 0x0026F79C
|
|
[Token(Token = "0x600B503")]
|
|
[Address(RVA = "0x235C170", Offset = "0x235B170", VA = "0x18235C170", 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: 0x0600B504 RID: 46340 RVA: 0x00271790 File Offset: 0x0026F990
|
|
[Token(Token = "0x600B504")]
|
|
[Address(RVA = "0x235C680", Offset = "0x235B680", VA = "0x18235C680", 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: 0x0600B505 RID: 46341 RVA: 0x002718AC File Offset: 0x0026FAAC
|
|
[Token(Token = "0x600B505")]
|
|
[Address(RVA = "0x235C0B0", Offset = "0x235B0B0", VA = "0x18235C0B0")]
|
|
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: 0x04007281 RID: 29313
|
|
[FieldOffset(Offset = "0x10")]
|
|
[Token(Token = "0x4007281")]
|
|
private readonly HMac hMac;
|
|
|
|
// Token: 0x04007282 RID: 29314
|
|
[FieldOffset(Offset = "0x18")]
|
|
[Token(Token = "0x4007282")]
|
|
private readonly byte[] K;
|
|
|
|
// Token: 0x04007283 RID: 29315
|
|
[FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x4007283")]
|
|
private readonly byte[] V;
|
|
|
|
// Token: 0x04007284 RID: 29316
|
|
[FieldOffset(Offset = "0x28")]
|
|
[Token(Token = "0x4007284")]
|
|
private BigInteger n;
|
|
}
|
|
}
|