145 lines
6.5 KiB
C#
145 lines
6.5 KiB
C#
using System;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Generators;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.OpenSsl
|
|
{
|
|
// Token: 0x02001A79 RID: 6777
|
|
[Token(Token = "0x2001A79")]
|
|
internal sealed class PemUtilities
|
|
{
|
|
// Token: 0x0600A05A RID: 41050 RVA: 0x00213654 File Offset: 0x00211854
|
|
[Token(Token = "0x600A05A")]
|
|
[Address(RVA = "0x63F7F0", Offset = "0x63E7F0", VA = "0x18063F7F0")]
|
|
static PemUtilities()
|
|
{
|
|
Enum arbitraryValue = Enums.GetArbitraryValue(typeof(PemUtilities.PemBaseAlg));
|
|
Enum arbitraryValue2 = Enums.GetArbitraryValue(typeof(PemUtilities.PemMode));
|
|
}
|
|
|
|
// Token: 0x0600A05B RID: 41051 RVA: 0x0021369C File Offset: 0x0021189C
|
|
[Token(Token = "0x600A05B")]
|
|
[Address(RVA = "0x63F570", Offset = "0x63E570", VA = "0x18063F570")]
|
|
private static void ParseDekAlgName(string dekAlgName, out PemUtilities.PemBaseAlg baseAlg, out PemUtilities.PemMode mode)
|
|
{
|
|
Type typeFromHandle = typeof(PemUtilities.PemBaseAlg);
|
|
int num = 0;
|
|
int num2;
|
|
string text = dekAlgName.Substring(num, num2);
|
|
Enum enumValue = Enums.GetEnumValue(typeFromHandle, text);
|
|
baseAlg.value__ = enumValue;
|
|
Type typeFromHandle2 = typeof(PemUtilities.PemMode);
|
|
int num3 = num2 + 1;
|
|
string text2 = dekAlgName.Substring(num3);
|
|
Enum enumValue2 = Enums.GetEnumValue(typeFromHandle2, text2);
|
|
mode.value__ = enumValue2;
|
|
Enum enumValue3 = Enums.GetEnumValue(typeof(PemUtilities.PemBaseAlg), dekAlgName);
|
|
baseAlg.value__ = enumValue3;
|
|
}
|
|
|
|
// Token: 0x0600A05C RID: 41052 RVA: 0x00213744 File Offset: 0x00211944
|
|
[Token(Token = "0x600A05C")]
|
|
[Address(RVA = "0x63EDD0", Offset = "0x63DDD0", VA = "0x18063EDD0")]
|
|
internal static byte[] Crypt(bool encrypt, byte[] bytes, char[] password, string dekAlgName, byte[] iv)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600A05C)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Byte[] BestHTTP.SecureProtocol.Org.BouncyCastle.OpenSsl.PemUtilities::Crypt(System.Boolean,System.Byte[],System.Char[],System.String,System.Byte[])
|
|
|
|
---> System.Exception: Basic block has to end with unconditional control flow.
|
|
{
|
|
IL_B6:
|
|
stloc:EncryptionException(var_15_C7, newobj:EncryptionException(EncryptionException::.ctor, call:string(string::Concat, ldstr:string("Unknown DEK algorithm: "), ldloc:string(var_13))))
|
|
}
|
|
|
|
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: 0x0600A05D RID: 41053 RVA: 0x0021381C File Offset: 0x00211A1C
|
|
[Token(Token = "0x600A05D")]
|
|
[Address(RVA = "0x63F3E0", Offset = "0x63E3E0", VA = "0x18063F3E0")]
|
|
private static ICipherParameters GetCipherParameters(char[] password, PemUtilities.PemBaseAlg baseAlg, byte[] salt)
|
|
{
|
|
if (baseAlg <= PemUtilities.PemBaseAlg.RC2_64)
|
|
{
|
|
OpenSslPbeParametersGenerator openSslPbeParametersGenerator = new OpenSslPbeParametersGenerator();
|
|
byte[] array = PbeParametersGenerator.Pkcs5PasswordToBytes(password);
|
|
ICipherParameters cipherParameters;
|
|
return cipherParameters;
|
|
}
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x0600A05E RID: 41054 RVA: 0x00213844 File Offset: 0x00211A44
|
|
[Token(Token = "0x600A05E")]
|
|
[Address(RVA = "0x412370", Offset = "0x411370", VA = "0x180412370")]
|
|
public PemUtilities()
|
|
{
|
|
}
|
|
|
|
// Token: 0x02001A7A RID: 6778
|
|
[Token(Token = "0x2001A7A")]
|
|
private enum PemBaseAlg
|
|
{
|
|
// Token: 0x04006AF6 RID: 27382
|
|
[Token(Token = "0x4006AF6")]
|
|
AES_128,
|
|
// Token: 0x04006AF7 RID: 27383
|
|
[Token(Token = "0x4006AF7")]
|
|
AES_192,
|
|
// Token: 0x04006AF8 RID: 27384
|
|
[Token(Token = "0x4006AF8")]
|
|
AES_256,
|
|
// Token: 0x04006AF9 RID: 27385
|
|
[Token(Token = "0x4006AF9")]
|
|
BF,
|
|
// Token: 0x04006AFA RID: 27386
|
|
[Token(Token = "0x4006AFA")]
|
|
DES,
|
|
// Token: 0x04006AFB RID: 27387
|
|
[Token(Token = "0x4006AFB")]
|
|
DES_EDE,
|
|
// Token: 0x04006AFC RID: 27388
|
|
[Token(Token = "0x4006AFC")]
|
|
DES_EDE3,
|
|
// Token: 0x04006AFD RID: 27389
|
|
[Token(Token = "0x4006AFD")]
|
|
RC2,
|
|
// Token: 0x04006AFE RID: 27390
|
|
[Token(Token = "0x4006AFE")]
|
|
RC2_40,
|
|
// Token: 0x04006AFF RID: 27391
|
|
[Token(Token = "0x4006AFF")]
|
|
RC2_64
|
|
}
|
|
|
|
// Token: 0x02001A7B RID: 6779
|
|
[Token(Token = "0x2001A7B")]
|
|
private enum PemMode
|
|
{
|
|
// Token: 0x04006B01 RID: 27393
|
|
[Token(Token = "0x4006B01")]
|
|
CBC,
|
|
// Token: 0x04006B02 RID: 27394
|
|
[Token(Token = "0x4006B02")]
|
|
CFB,
|
|
// Token: 0x04006B03 RID: 27395
|
|
[Token(Token = "0x4006B03")]
|
|
ECB,
|
|
// Token: 0x04006B04 RID: 27396
|
|
[Token(Token = "0x4006B04")]
|
|
OFB
|
|
}
|
|
}
|
|
}
|