156 lines
4.9 KiB
C#
156 lines
4.9 KiB
C#
using System;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Math;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines
|
|
{
|
|
// Token: 0x02001CA4 RID: 7332
|
|
[Token(Token = "0x2001CA4")]
|
|
public class RsaBlindingEngine : IAsymmetricBlockCipher
|
|
{
|
|
// Token: 0x0600B867 RID: 47207 RVA: 0x0028FDC4 File Offset: 0x0028DFC4
|
|
[Token(Token = "0x600B867")]
|
|
[Address(RVA = "0x1DF9CC0", Offset = "0x1DF8AC0", VA = "0x181DF9CC0")]
|
|
public RsaBlindingEngine()
|
|
{
|
|
RsaCoreEngine rsaCoreEngine = new RsaCoreEngine();
|
|
base..ctor();
|
|
this.core = rsaCoreEngine;
|
|
}
|
|
|
|
// Token: 0x0600B868 RID: 47208 RVA: 0x0028FDE4 File Offset: 0x0028DFE4
|
|
[Token(Token = "0x600B868")]
|
|
[Address(RVA = "0x3FFB80", Offset = "0x3FE980", VA = "0x1803FFB80")]
|
|
public RsaBlindingEngine(IRsa rsa)
|
|
{
|
|
this.core = rsa;
|
|
}
|
|
|
|
// Token: 0x17001CE8 RID: 7400
|
|
// (get) Token: 0x0600B869 RID: 47209 RVA: 0x0028FE00 File Offset: 0x0028E000
|
|
[Token(Token = "0x17001CE8")]
|
|
public virtual string AlgorithmName
|
|
{
|
|
[Token(Token = "0x600B869")]
|
|
[Address(RVA = "0x1DF9D20", Offset = "0x1DF8B20", VA = "0x181DF9D20", Slot = "9")]
|
|
get
|
|
{
|
|
return "RSA";
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600B86A RID: 47210 RVA: 0x0028FE14 File Offset: 0x0028E014
|
|
[Token(Token = "0x600B86A")]
|
|
[Address(RVA = "0x1DF9920", Offset = "0x1DF8720", VA = "0x181DF9920", Slot = "10")]
|
|
public virtual void Init(bool forEncryption, ICipherParameters param)
|
|
{
|
|
int num;
|
|
for (;;)
|
|
{
|
|
if ((param != 0 || param != 0) && param != 0 && param != 0)
|
|
{
|
|
num = 0;
|
|
if (param != 0)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
IRsa rsa = this.core;
|
|
this.forEncryption = forEncryption;
|
|
this.key = num;
|
|
this.blindingFactor = num;
|
|
}
|
|
|
|
// Token: 0x0600B86B RID: 47211 RVA: 0x0028FE68 File Offset: 0x0028E068
|
|
[Token(Token = "0x600B86B")]
|
|
[Address(RVA = "0x1DF9880", Offset = "0x1DF8680", VA = "0x181DF9880", Slot = "11")]
|
|
public virtual int GetInputBlockSize()
|
|
{
|
|
IRsa rsa = this.core;
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x0600B86C RID: 47212 RVA: 0x0028FE84 File Offset: 0x0028E084
|
|
[Token(Token = "0x600B86C")]
|
|
[Address(RVA = "0x1DF98D0", Offset = "0x1DF86D0", VA = "0x181DF98D0", Slot = "12")]
|
|
public virtual int GetOutputBlockSize()
|
|
{
|
|
IRsa rsa = this.core;
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x0600B86D RID: 47213 RVA: 0x0028FEA0 File Offset: 0x0028E0A0
|
|
[Token(Token = "0x600B86D")]
|
|
[Address(RVA = "0x1DF9B10", Offset = "0x1DF8910", VA = "0x181DF9B10", Slot = "13")]
|
|
public virtual byte[] ProcessBlock(byte[] inBuf, int inOff, int inLen)
|
|
{
|
|
IRsa rsa = this.core;
|
|
RsaKeyParameters rsaKeyParameters = this.key;
|
|
if (!this.forEncryption)
|
|
{
|
|
BigInteger bigInteger = this.blindingFactor;
|
|
BigInteger modulus = rsaKeyParameters.modulus;
|
|
BigInteger bigInteger2 = bigInteger.ModInverse(modulus);
|
|
}
|
|
BigInteger bigInteger3 = this.blindingFactor;
|
|
BigInteger modulus2 = rsaKeyParameters.modulus;
|
|
BigInteger exponent = rsaKeyParameters.exponent;
|
|
BigInteger bigInteger4 = bigInteger3.ModPow(exponent, modulus2);
|
|
BigInteger modulus3 = this.key.modulus;
|
|
BigInteger bigInteger6;
|
|
BigInteger bigInteger5 = bigInteger6.Mod(modulus3);
|
|
IRsa rsa2 = this.core;
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x0600B86E RID: 47214 RVA: 0x0028FF28 File Offset: 0x0028E128
|
|
[Token(Token = "0x600B86E")]
|
|
[Address(RVA = "0x1DF9800", Offset = "0x1DF8600", VA = "0x181DF9800")]
|
|
private BigInteger BlindMessage(BigInteger msg)
|
|
{
|
|
RsaKeyParameters rsaKeyParameters = this.key;
|
|
BigInteger bigInteger = this.blindingFactor;
|
|
BigInteger modulus = rsaKeyParameters.modulus;
|
|
BigInteger exponent = rsaKeyParameters.exponent;
|
|
BigInteger bigInteger2 = bigInteger.ModPow(exponent, modulus);
|
|
BigInteger bigInteger3 = msg.Multiply(bigInteger2);
|
|
BigInteger modulus2 = this.key.modulus;
|
|
return bigInteger3.Mod(modulus2);
|
|
}
|
|
|
|
// Token: 0x0600B86F RID: 47215 RVA: 0x0028FF84 File Offset: 0x0028E184
|
|
[Token(Token = "0x600B86F")]
|
|
[Address(RVA = "0x1DF9C50", Offset = "0x1DF8A50", VA = "0x181DF9C50")]
|
|
private BigInteger UnblindMessage(BigInteger blindedMsg)
|
|
{
|
|
RsaKeyParameters rsaKeyParameters = this.key;
|
|
BigInteger bigInteger = this.blindingFactor;
|
|
BigInteger modulus = rsaKeyParameters.modulus;
|
|
BigInteger bigInteger2 = bigInteger.ModInverse(modulus);
|
|
return blindedMsg.Multiply(bigInteger2).Mod(modulus);
|
|
}
|
|
|
|
// Token: 0x040074E9 RID: 29929
|
|
[FieldOffset(Offset = "0x10")]
|
|
[Token(Token = "0x40074E9")]
|
|
private readonly IRsa core;
|
|
|
|
// Token: 0x040074EA RID: 29930
|
|
[FieldOffset(Offset = "0x18")]
|
|
[Token(Token = "0x40074EA")]
|
|
private RsaKeyParameters key;
|
|
|
|
// Token: 0x040074EB RID: 29931
|
|
[FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x40074EB")]
|
|
private BigInteger blindingFactor;
|
|
|
|
// Token: 0x040074EC RID: 29932
|
|
[FieldOffset(Offset = "0x28")]
|
|
[Token(Token = "0x40074EC")]
|
|
private bool forEncryption;
|
|
}
|
|
}
|