scripts
This commit is contained in:
@@ -0,0 +1,1456 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Text;
|
||||
|
||||
namespace Mono
|
||||
{
|
||||
// Token: 0x020000F4 RID: 244
|
||||
internal abstract class DataConverter
|
||||
{
|
||||
// Token: 0x06000C17 RID: 3095
|
||||
public abstract double GetDouble(byte[] data, int index);
|
||||
|
||||
// Token: 0x06000C18 RID: 3096
|
||||
public abstract float GetFloat(byte[] data, int index);
|
||||
|
||||
// Token: 0x06000C19 RID: 3097
|
||||
public abstract long GetInt64(byte[] data, int index);
|
||||
|
||||
// Token: 0x06000C1A RID: 3098
|
||||
public abstract int GetInt32(byte[] data, int index);
|
||||
|
||||
// Token: 0x06000C1B RID: 3099
|
||||
public abstract short GetInt16(byte[] data, int index);
|
||||
|
||||
// Token: 0x06000C1C RID: 3100
|
||||
[CLSCompliant(false)]
|
||||
public abstract uint GetUInt32(byte[] data, int index);
|
||||
|
||||
// Token: 0x06000C1D RID: 3101
|
||||
[CLSCompliant(false)]
|
||||
public abstract ushort GetUInt16(byte[] data, int index);
|
||||
|
||||
// Token: 0x06000C1E RID: 3102
|
||||
[CLSCompliant(false)]
|
||||
public abstract ulong GetUInt64(byte[] data, int index);
|
||||
|
||||
// Token: 0x06000C1F RID: 3103
|
||||
public abstract void PutBytes(byte[] dest, int destIdx, double value);
|
||||
|
||||
// Token: 0x06000C20 RID: 3104
|
||||
public abstract void PutBytes(byte[] dest, int destIdx, float value);
|
||||
|
||||
// Token: 0x06000C21 RID: 3105
|
||||
public abstract void PutBytes(byte[] dest, int destIdx, int value);
|
||||
|
||||
// Token: 0x06000C22 RID: 3106
|
||||
public abstract void PutBytes(byte[] dest, int destIdx, long value);
|
||||
|
||||
// Token: 0x06000C23 RID: 3107
|
||||
public abstract void PutBytes(byte[] dest, int destIdx, short value);
|
||||
|
||||
// Token: 0x06000C24 RID: 3108
|
||||
[CLSCompliant(false)]
|
||||
public abstract void PutBytes(byte[] dest, int destIdx, ushort value);
|
||||
|
||||
// Token: 0x06000C25 RID: 3109
|
||||
[CLSCompliant(false)]
|
||||
public abstract void PutBytes(byte[] dest, int destIdx, uint value);
|
||||
|
||||
// Token: 0x06000C26 RID: 3110
|
||||
[CLSCompliant(false)]
|
||||
public abstract void PutBytes(byte[] dest, int destIdx, ulong value);
|
||||
|
||||
// Token: 0x06000C27 RID: 3111 RVA: 0x00036968 File Offset: 0x00034B68
|
||||
public byte[] GetBytes(double value)
|
||||
{
|
||||
byte[] array = new byte[8];
|
||||
this.PutBytes(array, 0, value);
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x06000C28 RID: 3112 RVA: 0x00036988 File Offset: 0x00034B88
|
||||
public byte[] GetBytes(float value)
|
||||
{
|
||||
byte[] array = new byte[4];
|
||||
this.PutBytes(array, 0, value);
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x06000C29 RID: 3113 RVA: 0x000369A8 File Offset: 0x00034BA8
|
||||
public byte[] GetBytes(int value)
|
||||
{
|
||||
byte[] array = new byte[4];
|
||||
this.PutBytes(array, 0, value);
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x06000C2A RID: 3114 RVA: 0x000369C8 File Offset: 0x00034BC8
|
||||
public byte[] GetBytes(long value)
|
||||
{
|
||||
byte[] array = new byte[8];
|
||||
this.PutBytes(array, 0, value);
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x06000C2B RID: 3115 RVA: 0x000369E8 File Offset: 0x00034BE8
|
||||
public byte[] GetBytes(short value)
|
||||
{
|
||||
byte[] array = new byte[2];
|
||||
this.PutBytes(array, 0, value);
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x06000C2C RID: 3116 RVA: 0x00036A08 File Offset: 0x00034C08
|
||||
[CLSCompliant(false)]
|
||||
public byte[] GetBytes(ushort value)
|
||||
{
|
||||
byte[] array = new byte[2];
|
||||
this.PutBytes(array, 0, value);
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x06000C2D RID: 3117 RVA: 0x00036A28 File Offset: 0x00034C28
|
||||
[CLSCompliant(false)]
|
||||
public byte[] GetBytes(uint value)
|
||||
{
|
||||
byte[] array = new byte[4];
|
||||
this.PutBytes(array, 0, value);
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x06000C2E RID: 3118 RVA: 0x00036A48 File Offset: 0x00034C48
|
||||
[CLSCompliant(false)]
|
||||
public byte[] GetBytes(ulong value)
|
||||
{
|
||||
byte[] array = new byte[8];
|
||||
this.PutBytes(array, 0, value);
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x170001C2 RID: 450
|
||||
// (get) Token: 0x06000C2F RID: 3119 RVA: 0x00036A68 File Offset: 0x00034C68
|
||||
public static DataConverter LittleEndian
|
||||
{
|
||||
get
|
||||
{
|
||||
return (!BitConverter.IsLittleEndian) ? DataConverter.SwapConv : DataConverter.CopyConv;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001C3 RID: 451
|
||||
// (get) Token: 0x06000C30 RID: 3120 RVA: 0x00036A84 File Offset: 0x00034C84
|
||||
public static DataConverter BigEndian
|
||||
{
|
||||
get
|
||||
{
|
||||
return (!BitConverter.IsLittleEndian) ? DataConverter.CopyConv : DataConverter.SwapConv;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001C4 RID: 452
|
||||
// (get) Token: 0x06000C31 RID: 3121 RVA: 0x00036AA0 File Offset: 0x00034CA0
|
||||
public static DataConverter Native
|
||||
{
|
||||
get
|
||||
{
|
||||
return DataConverter.CopyConv;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000C32 RID: 3122 RVA: 0x00036AA8 File Offset: 0x00034CA8
|
||||
private static int Align(int current, int align)
|
||||
{
|
||||
return (current + align - 1) / align * align;
|
||||
}
|
||||
|
||||
// Token: 0x06000C33 RID: 3123 RVA: 0x00036AB4 File Offset: 0x00034CB4
|
||||
public static byte[] Pack(string description, params object[] args)
|
||||
{
|
||||
int num = 0;
|
||||
DataConverter.PackContext packContext = new DataConverter.PackContext();
|
||||
packContext.conv = DataConverter.CopyConv;
|
||||
packContext.description = description;
|
||||
packContext.i = 0;
|
||||
while (packContext.i < description.Length)
|
||||
{
|
||||
object obj;
|
||||
if (num < args.Length)
|
||||
{
|
||||
obj = args[num];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (packContext.repeat != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
obj = null;
|
||||
}
|
||||
int i = packContext.i;
|
||||
if (DataConverter.PackOne(packContext, obj))
|
||||
{
|
||||
num++;
|
||||
if (packContext.repeat > 0)
|
||||
{
|
||||
if (--packContext.repeat > 0)
|
||||
{
|
||||
packContext.i = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
packContext.i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
packContext.i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
packContext.i++;
|
||||
}
|
||||
}
|
||||
return packContext.Get();
|
||||
}
|
||||
|
||||
// Token: 0x06000C34 RID: 3124 RVA: 0x00036BA0 File Offset: 0x00034DA0
|
||||
public static byte[] PackEnumerable(string description, IEnumerable args)
|
||||
{
|
||||
DataConverter.PackContext packContext = new DataConverter.PackContext();
|
||||
packContext.conv = DataConverter.CopyConv;
|
||||
packContext.description = description;
|
||||
IEnumerator enumerator = args.GetEnumerator();
|
||||
bool flag = enumerator.MoveNext();
|
||||
packContext.i = 0;
|
||||
while (packContext.i < description.Length)
|
||||
{
|
||||
object obj;
|
||||
if (flag)
|
||||
{
|
||||
obj = enumerator.Current;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (packContext.repeat != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
obj = null;
|
||||
}
|
||||
int i = packContext.i;
|
||||
if (DataConverter.PackOne(packContext, obj))
|
||||
{
|
||||
flag = enumerator.MoveNext();
|
||||
if (packContext.repeat > 0)
|
||||
{
|
||||
if (--packContext.repeat > 0)
|
||||
{
|
||||
packContext.i = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
packContext.i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
packContext.i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
packContext.i++;
|
||||
}
|
||||
}
|
||||
return packContext.Get();
|
||||
}
|
||||
|
||||
// Token: 0x06000C35 RID: 3125 RVA: 0x00036C9C File Offset: 0x00034E9C
|
||||
private static bool PackOne(DataConverter.PackContext b, object oarg)
|
||||
{
|
||||
char c = b.description[b.i];
|
||||
switch (c)
|
||||
{
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
b.repeat = (int)((short)b.description[b.i] - 48);
|
||||
return false;
|
||||
default:
|
||||
switch (c)
|
||||
{
|
||||
case '[':
|
||||
{
|
||||
int num = -1;
|
||||
int i;
|
||||
for (i = b.i + 1; i < b.description.Length; i++)
|
||||
{
|
||||
if (b.description[i] == ']')
|
||||
{
|
||||
break;
|
||||
}
|
||||
int num2 = (int)((short)b.description[i] - 48);
|
||||
if (num2 >= 0 && num2 <= 9)
|
||||
{
|
||||
if (num == -1)
|
||||
{
|
||||
num = num2;
|
||||
}
|
||||
else
|
||||
{
|
||||
num = num * 10 + num2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (num == -1)
|
||||
{
|
||||
throw new ArgumentException("invalid size specification");
|
||||
}
|
||||
b.i = i;
|
||||
b.repeat = num;
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case '!':
|
||||
b.align = -1;
|
||||
return false;
|
||||
default:
|
||||
switch (c)
|
||||
{
|
||||
case 'I':
|
||||
b.Add(b.conv.GetBytes(Convert.ToUInt32(oarg)));
|
||||
return true;
|
||||
default:
|
||||
switch (c)
|
||||
{
|
||||
case 'x':
|
||||
b.Add(new byte[1]);
|
||||
return false;
|
||||
default:
|
||||
if (c == '*')
|
||||
{
|
||||
b.repeat = int.MaxValue;
|
||||
return false;
|
||||
}
|
||||
if (c == 'S')
|
||||
{
|
||||
b.Add(b.conv.GetBytes(Convert.ToUInt16(oarg)));
|
||||
return true;
|
||||
}
|
||||
if (c != 's')
|
||||
{
|
||||
throw new ArgumentException(string.Format("invalid format specified `{0}'", b.description[b.i]));
|
||||
}
|
||||
b.Add(b.conv.GetBytes(Convert.ToInt16(oarg)));
|
||||
return true;
|
||||
case 'z':
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'L':
|
||||
b.Add(b.conv.GetBytes(Convert.ToUInt64(oarg)));
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case '$':
|
||||
break;
|
||||
case '%':
|
||||
b.conv = DataConverter.Native;
|
||||
return false;
|
||||
}
|
||||
bool flag = b.description[b.i] == 'z';
|
||||
b.i++;
|
||||
if (b.i >= b.description.Length)
|
||||
{
|
||||
throw new ArgumentException("$ description needs a type specified", "description");
|
||||
}
|
||||
char c2 = b.description[b.i];
|
||||
char c3 = c2;
|
||||
int num2;
|
||||
Encoding encoding;
|
||||
switch (c3)
|
||||
{
|
||||
case '3':
|
||||
encoding = Encoding.GetEncoding(12000);
|
||||
num2 = 4;
|
||||
break;
|
||||
case '4':
|
||||
encoding = Encoding.GetEncoding(12001);
|
||||
num2 = 4;
|
||||
break;
|
||||
default:
|
||||
if (c3 != 'b')
|
||||
{
|
||||
throw new ArgumentException("Invalid format for $ specifier", "description");
|
||||
}
|
||||
encoding = Encoding.BigEndianUnicode;
|
||||
num2 = 2;
|
||||
break;
|
||||
case '6':
|
||||
encoding = Encoding.Unicode;
|
||||
num2 = 2;
|
||||
break;
|
||||
case '7':
|
||||
encoding = Encoding.UTF7;
|
||||
num2 = 1;
|
||||
break;
|
||||
case '8':
|
||||
encoding = Encoding.UTF8;
|
||||
num2 = 1;
|
||||
break;
|
||||
}
|
||||
if (b.align == -1)
|
||||
{
|
||||
b.align = 4;
|
||||
}
|
||||
b.Add(encoding.GetBytes(Convert.ToString(oarg)));
|
||||
if (flag)
|
||||
{
|
||||
b.Add(new byte[num2]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '^':
|
||||
b.conv = DataConverter.BigEndian;
|
||||
return false;
|
||||
case '_':
|
||||
b.conv = DataConverter.LittleEndian;
|
||||
return false;
|
||||
case 'b':
|
||||
b.Add(new byte[] { Convert.ToByte(oarg) });
|
||||
break;
|
||||
case 'c':
|
||||
b.Add(new byte[] { (byte)Convert.ToSByte(oarg) });
|
||||
break;
|
||||
case 'd':
|
||||
b.Add(b.conv.GetBytes(Convert.ToDouble(oarg)));
|
||||
break;
|
||||
case 'f':
|
||||
b.Add(b.conv.GetBytes(Convert.ToSingle(oarg)));
|
||||
break;
|
||||
case 'i':
|
||||
b.Add(b.conv.GetBytes(Convert.ToInt32(oarg)));
|
||||
break;
|
||||
case 'l':
|
||||
b.Add(b.conv.GetBytes(Convert.ToInt64(oarg)));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'C':
|
||||
b.Add(new byte[] { Convert.ToByte(oarg) });
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x06000C36 RID: 3126 RVA: 0x00037160 File Offset: 0x00035360
|
||||
private static bool Prepare(byte[] buffer, ref int idx, int size, ref bool align)
|
||||
{
|
||||
if (align)
|
||||
{
|
||||
idx = DataConverter.Align(idx, size);
|
||||
align = false;
|
||||
}
|
||||
if (idx + size > buffer.Length)
|
||||
{
|
||||
idx = buffer.Length;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x06000C37 RID: 3127 RVA: 0x00037198 File Offset: 0x00035398
|
||||
public static IList Unpack(string description, byte[] buffer, int startIndex)
|
||||
{
|
||||
DataConverter dataConverter = DataConverter.CopyConv;
|
||||
ArrayList arrayList = new ArrayList();
|
||||
int num = startIndex;
|
||||
bool flag = false;
|
||||
int num2 = 0;
|
||||
int num3 = 0;
|
||||
while (num3 < description.Length && num < buffer.Length)
|
||||
{
|
||||
int num4 = num3;
|
||||
char c = description[num3];
|
||||
switch (c)
|
||||
{
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
num2 = (int)((short)description[num3] - 48);
|
||||
num4 = num3 + 1;
|
||||
break;
|
||||
default:
|
||||
switch (c)
|
||||
{
|
||||
case '[':
|
||||
{
|
||||
int num5 = -1;
|
||||
int i;
|
||||
for (i = num3 + 1; i < description.Length; i++)
|
||||
{
|
||||
if (description[i] == ']')
|
||||
{
|
||||
break;
|
||||
}
|
||||
int num6 = (int)((short)description[i] - 48);
|
||||
if (num6 >= 0 && num6 <= 9)
|
||||
{
|
||||
if (num5 == -1)
|
||||
{
|
||||
num5 = num6;
|
||||
}
|
||||
else
|
||||
{
|
||||
num5 = num5 * 10 + num6;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (num5 == -1)
|
||||
{
|
||||
throw new ArgumentException("invalid size specification");
|
||||
}
|
||||
num3 = i;
|
||||
num2 = num5;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case '!':
|
||||
flag = true;
|
||||
goto IL_683;
|
||||
default:
|
||||
switch (c)
|
||||
{
|
||||
case 'I':
|
||||
if (DataConverter.Prepare(buffer, ref num, 4, ref flag))
|
||||
{
|
||||
arrayList.Add(dataConverter.GetUInt32(buffer, num));
|
||||
num += 4;
|
||||
}
|
||||
goto IL_683;
|
||||
default:
|
||||
switch (c)
|
||||
{
|
||||
case 'x':
|
||||
num++;
|
||||
goto IL_683;
|
||||
default:
|
||||
if (c == '*')
|
||||
{
|
||||
num2 = int.MaxValue;
|
||||
goto IL_683;
|
||||
}
|
||||
if (c == 'S')
|
||||
{
|
||||
if (DataConverter.Prepare(buffer, ref num, 2, ref flag))
|
||||
{
|
||||
arrayList.Add(dataConverter.GetUInt16(buffer, num));
|
||||
num += 2;
|
||||
}
|
||||
goto IL_683;
|
||||
}
|
||||
if (c != 's')
|
||||
{
|
||||
throw new ArgumentException(string.Format("invalid format specified `{0}'", description[num3]));
|
||||
}
|
||||
if (DataConverter.Prepare(buffer, ref num, 2, ref flag))
|
||||
{
|
||||
arrayList.Add(dataConverter.GetInt16(buffer, num));
|
||||
num += 2;
|
||||
}
|
||||
goto IL_683;
|
||||
case 'z':
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'L':
|
||||
if (DataConverter.Prepare(buffer, ref num, 8, ref flag))
|
||||
{
|
||||
arrayList.Add(dataConverter.GetUInt64(buffer, num));
|
||||
num += 8;
|
||||
}
|
||||
goto IL_683;
|
||||
}
|
||||
break;
|
||||
case '$':
|
||||
break;
|
||||
case '%':
|
||||
dataConverter = DataConverter.Native;
|
||||
goto IL_683;
|
||||
}
|
||||
num3++;
|
||||
if (num3 >= description.Length)
|
||||
{
|
||||
throw new ArgumentException("$ description needs a type specified", "description");
|
||||
}
|
||||
char c2 = description[num3];
|
||||
if (flag)
|
||||
{
|
||||
num = DataConverter.Align(num, 4);
|
||||
flag = false;
|
||||
}
|
||||
if (num < buffer.Length)
|
||||
{
|
||||
char c3 = c2;
|
||||
int num6;
|
||||
Encoding encoding;
|
||||
switch (c3)
|
||||
{
|
||||
case '3':
|
||||
encoding = Encoding.GetEncoding(12000);
|
||||
num6 = 4;
|
||||
break;
|
||||
case '4':
|
||||
encoding = Encoding.GetEncoding(12001);
|
||||
num6 = 4;
|
||||
break;
|
||||
default:
|
||||
if (c3 != 'b')
|
||||
{
|
||||
throw new ArgumentException("Invalid format for $ specifier", "description");
|
||||
}
|
||||
encoding = Encoding.BigEndianUnicode;
|
||||
num6 = 2;
|
||||
break;
|
||||
case '6':
|
||||
encoding = Encoding.Unicode;
|
||||
num6 = 2;
|
||||
break;
|
||||
case '7':
|
||||
encoding = Encoding.UTF7;
|
||||
num6 = 1;
|
||||
break;
|
||||
case '8':
|
||||
encoding = Encoding.UTF8;
|
||||
num6 = 1;
|
||||
break;
|
||||
}
|
||||
int j = num;
|
||||
switch (num6)
|
||||
{
|
||||
case 1:
|
||||
while (j < buffer.Length && buffer[j] != 0)
|
||||
{
|
||||
j++;
|
||||
}
|
||||
arrayList.Add(encoding.GetChars(buffer, num, j - num));
|
||||
if (j == buffer.Length)
|
||||
{
|
||||
num = j;
|
||||
}
|
||||
else
|
||||
{
|
||||
num = j + 1;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
while (j < buffer.Length)
|
||||
{
|
||||
if (j + 1 == buffer.Length)
|
||||
{
|
||||
j++;
|
||||
break;
|
||||
}
|
||||
if (buffer[j] == 0 && buffer[j + 1] == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
arrayList.Add(encoding.GetChars(buffer, num, j - num));
|
||||
if (j == buffer.Length)
|
||||
{
|
||||
num = j;
|
||||
}
|
||||
else
|
||||
{
|
||||
num = j + 2;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
while (j < buffer.Length)
|
||||
{
|
||||
if (j + 3 >= buffer.Length)
|
||||
{
|
||||
j = buffer.Length;
|
||||
break;
|
||||
}
|
||||
if (buffer[j] == 0 && buffer[j + 1] == 0 && buffer[j + 2] == 0 && buffer[j + 3] == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
arrayList.Add(encoding.GetChars(buffer, num, j - num));
|
||||
if (j == buffer.Length)
|
||||
{
|
||||
num = j;
|
||||
}
|
||||
else
|
||||
{
|
||||
num = j + 4;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '^':
|
||||
dataConverter = DataConverter.BigEndian;
|
||||
break;
|
||||
case '_':
|
||||
dataConverter = DataConverter.LittleEndian;
|
||||
break;
|
||||
case 'b':
|
||||
if (DataConverter.Prepare(buffer, ref num, 1, ref flag))
|
||||
{
|
||||
arrayList.Add(buffer[num]);
|
||||
num++;
|
||||
}
|
||||
break;
|
||||
case 'c':
|
||||
goto IL_300;
|
||||
case 'd':
|
||||
if (DataConverter.Prepare(buffer, ref num, 8, ref flag))
|
||||
{
|
||||
arrayList.Add(dataConverter.GetDouble(buffer, num));
|
||||
num += 8;
|
||||
}
|
||||
break;
|
||||
case 'f':
|
||||
if (DataConverter.Prepare(buffer, ref num, 4, ref flag))
|
||||
{
|
||||
arrayList.Add(dataConverter.GetDouble(buffer, num));
|
||||
num += 4;
|
||||
}
|
||||
break;
|
||||
case 'i':
|
||||
if (DataConverter.Prepare(buffer, ref num, 4, ref flag))
|
||||
{
|
||||
arrayList.Add(dataConverter.GetInt32(buffer, num));
|
||||
num += 4;
|
||||
}
|
||||
break;
|
||||
case 'l':
|
||||
if (DataConverter.Prepare(buffer, ref num, 8, ref flag))
|
||||
{
|
||||
arrayList.Add(dataConverter.GetInt64(buffer, num));
|
||||
num += 8;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'C':
|
||||
goto IL_300;
|
||||
}
|
||||
IL_683:
|
||||
if (num2 > 0)
|
||||
{
|
||||
if (--num2 > 0)
|
||||
{
|
||||
num3 = num4;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
num3++;
|
||||
continue;
|
||||
IL_300:
|
||||
if (DataConverter.Prepare(buffer, ref num, 1, ref flag))
|
||||
{
|
||||
char c4;
|
||||
if (description[num3] == 'c')
|
||||
{
|
||||
c4 = (char)((sbyte)buffer[num]);
|
||||
}
|
||||
else
|
||||
{
|
||||
c4 = (char)buffer[num];
|
||||
}
|
||||
arrayList.Add(c4);
|
||||
num++;
|
||||
}
|
||||
goto IL_683;
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
// Token: 0x06000C38 RID: 3128 RVA: 0x00037864 File Offset: 0x00035A64
|
||||
internal void Check(byte[] dest, int destIdx, int size)
|
||||
{
|
||||
if (dest == null)
|
||||
{
|
||||
throw new ArgumentNullException("dest");
|
||||
}
|
||||
if (destIdx < 0 || destIdx > dest.Length - size)
|
||||
{
|
||||
throw new ArgumentException("destIdx");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x04000353 RID: 851
|
||||
private static DataConverter SwapConv = new DataConverter.SwapConverter();
|
||||
|
||||
// Token: 0x04000354 RID: 852
|
||||
private static DataConverter CopyConv = new DataConverter.CopyConverter();
|
||||
|
||||
// Token: 0x04000355 RID: 853
|
||||
public static readonly bool IsLittleEndian = BitConverter.IsLittleEndian;
|
||||
|
||||
// Token: 0x020000F5 RID: 245
|
||||
private class PackContext
|
||||
{
|
||||
// Token: 0x06000C3A RID: 3130 RVA: 0x000378A8 File Offset: 0x00035AA8
|
||||
public void Add(byte[] group)
|
||||
{
|
||||
if (this.buffer == null)
|
||||
{
|
||||
this.buffer = group;
|
||||
this.next = group.Length;
|
||||
return;
|
||||
}
|
||||
if (this.align != 0)
|
||||
{
|
||||
if (this.align == -1)
|
||||
{
|
||||
this.next = DataConverter.Align(this.next, group.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.next = DataConverter.Align(this.next, this.align);
|
||||
}
|
||||
this.align = 0;
|
||||
}
|
||||
if (this.next + group.Length > this.buffer.Length)
|
||||
{
|
||||
byte[] array = new byte[Math.Max(this.next, 16) * 2 + group.Length];
|
||||
Array.Copy(this.buffer, array, this.buffer.Length);
|
||||
Array.Copy(group, 0, array, this.next, group.Length);
|
||||
this.next += group.Length;
|
||||
this.buffer = array;
|
||||
}
|
||||
else
|
||||
{
|
||||
Array.Copy(group, 0, this.buffer, this.next, group.Length);
|
||||
this.next += group.Length;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000C3B RID: 3131 RVA: 0x000379B8 File Offset: 0x00035BB8
|
||||
public byte[] Get()
|
||||
{
|
||||
if (this.buffer == null)
|
||||
{
|
||||
return new byte[0];
|
||||
}
|
||||
if (this.buffer.Length != this.next)
|
||||
{
|
||||
byte[] array = new byte[this.next];
|
||||
Array.Copy(this.buffer, array, this.next);
|
||||
return array;
|
||||
}
|
||||
return this.buffer;
|
||||
}
|
||||
|
||||
// Token: 0x04000356 RID: 854
|
||||
public byte[] buffer;
|
||||
|
||||
// Token: 0x04000357 RID: 855
|
||||
private int next;
|
||||
|
||||
// Token: 0x04000358 RID: 856
|
||||
public string description;
|
||||
|
||||
// Token: 0x04000359 RID: 857
|
||||
public int i;
|
||||
|
||||
// Token: 0x0400035A RID: 858
|
||||
public DataConverter conv;
|
||||
|
||||
// Token: 0x0400035B RID: 859
|
||||
public int repeat;
|
||||
|
||||
// Token: 0x0400035C RID: 860
|
||||
public int align;
|
||||
}
|
||||
|
||||
// Token: 0x020000F6 RID: 246
|
||||
private class CopyConverter : DataConverter
|
||||
{
|
||||
// Token: 0x06000C3D RID: 3133 RVA: 0x00037A18 File Offset: 0x00035C18
|
||||
public unsafe override double GetDouble(byte[] data, int index)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
throw new ArgumentNullException("data");
|
||||
}
|
||||
if (data.Length - index < 8)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
if (index < 0)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
double num;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
*((ref num) + i) = data[index + i];
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x06000C3E RID: 3134 RVA: 0x00037A80 File Offset: 0x00035C80
|
||||
public unsafe override ulong GetUInt64(byte[] data, int index)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
throw new ArgumentNullException("data");
|
||||
}
|
||||
if (data.Length - index < 8)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
if (index < 0)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
ulong num;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
*((ref num) + i) = data[index + i];
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x06000C3F RID: 3135 RVA: 0x00037AE8 File Offset: 0x00035CE8
|
||||
public unsafe override long GetInt64(byte[] data, int index)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
throw new ArgumentNullException("data");
|
||||
}
|
||||
if (data.Length - index < 8)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
if (index < 0)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
long num;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
*((ref num) + i) = data[index + i];
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x06000C40 RID: 3136 RVA: 0x00037B50 File Offset: 0x00035D50
|
||||
public unsafe override float GetFloat(byte[] data, int index)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
throw new ArgumentNullException("data");
|
||||
}
|
||||
if (data.Length - index < 4)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
if (index < 0)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
float num;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
*((ref num) + i) = data[index + i];
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x06000C41 RID: 3137 RVA: 0x00037BB8 File Offset: 0x00035DB8
|
||||
public unsafe override int GetInt32(byte[] data, int index)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
throw new ArgumentNullException("data");
|
||||
}
|
||||
if (data.Length - index < 4)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
if (index < 0)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
int num;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
*((ref num) + i) = data[index + i];
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x06000C42 RID: 3138 RVA: 0x00037C20 File Offset: 0x00035E20
|
||||
public unsafe override uint GetUInt32(byte[] data, int index)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
throw new ArgumentNullException("data");
|
||||
}
|
||||
if (data.Length - index < 4)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
if (index < 0)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
uint num;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
*((ref num) + i) = data[index + i];
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x06000C43 RID: 3139 RVA: 0x00037C88 File Offset: 0x00035E88
|
||||
public unsafe override short GetInt16(byte[] data, int index)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
throw new ArgumentNullException("data");
|
||||
}
|
||||
if (data.Length - index < 2)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
if (index < 0)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
short num;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
*((ref num) + i) = data[index + i];
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x06000C44 RID: 3140 RVA: 0x00037CF0 File Offset: 0x00035EF0
|
||||
public unsafe override ushort GetUInt16(byte[] data, int index)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
throw new ArgumentNullException("data");
|
||||
}
|
||||
if (data.Length - index < 2)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
if (index < 0)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
ushort num;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
*((ref num) + i) = data[index + i];
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x06000C45 RID: 3141 RVA: 0x00037D58 File Offset: 0x00035F58
|
||||
public unsafe override void PutBytes(byte[] dest, int destIdx, double value)
|
||||
{
|
||||
base.Check(dest, destIdx, 8);
|
||||
fixed (byte* ptr = &dest[destIdx])
|
||||
{
|
||||
*(long*)ptr = (long)value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000C46 RID: 3142 RVA: 0x00037D80 File Offset: 0x00035F80
|
||||
public unsafe override void PutBytes(byte[] dest, int destIdx, float value)
|
||||
{
|
||||
base.Check(dest, destIdx, 4);
|
||||
fixed (byte* ptr = &dest[destIdx])
|
||||
{
|
||||
*(int*)ptr = (int)value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000C47 RID: 3143 RVA: 0x00037DA8 File Offset: 0x00035FA8
|
||||
public unsafe override void PutBytes(byte[] dest, int destIdx, int value)
|
||||
{
|
||||
base.Check(dest, destIdx, 4);
|
||||
fixed (byte* ptr = &dest[destIdx])
|
||||
{
|
||||
*(int*)ptr = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000C48 RID: 3144 RVA: 0x00037DD0 File Offset: 0x00035FD0
|
||||
public unsafe override void PutBytes(byte[] dest, int destIdx, uint value)
|
||||
{
|
||||
base.Check(dest, destIdx, 4);
|
||||
fixed (byte* ptr = &dest[destIdx])
|
||||
{
|
||||
*(int*)ptr = (int)value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000C49 RID: 3145 RVA: 0x00037DF8 File Offset: 0x00035FF8
|
||||
public unsafe override void PutBytes(byte[] dest, int destIdx, long value)
|
||||
{
|
||||
base.Check(dest, destIdx, 8);
|
||||
fixed (byte* ptr = &dest[destIdx])
|
||||
{
|
||||
*(long*)ptr = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000C4A RID: 3146 RVA: 0x00037E20 File Offset: 0x00036020
|
||||
public unsafe override void PutBytes(byte[] dest, int destIdx, ulong value)
|
||||
{
|
||||
base.Check(dest, destIdx, 8);
|
||||
fixed (byte* ptr = &dest[destIdx])
|
||||
{
|
||||
*(long*)ptr = (long)value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000C4B RID: 3147 RVA: 0x00037E48 File Offset: 0x00036048
|
||||
public unsafe override void PutBytes(byte[] dest, int destIdx, short value)
|
||||
{
|
||||
base.Check(dest, destIdx, 2);
|
||||
fixed (byte* ptr = &dest[destIdx])
|
||||
{
|
||||
*(short*)ptr = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000C4C RID: 3148 RVA: 0x00037E70 File Offset: 0x00036070
|
||||
public unsafe override void PutBytes(byte[] dest, int destIdx, ushort value)
|
||||
{
|
||||
base.Check(dest, destIdx, 2);
|
||||
fixed (byte* ptr = &dest[destIdx])
|
||||
{
|
||||
*(short*)ptr = (short)value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000F7 RID: 247
|
||||
private class SwapConverter : DataConverter
|
||||
{
|
||||
// Token: 0x06000C4E RID: 3150 RVA: 0x00037EA0 File Offset: 0x000360A0
|
||||
public unsafe override double GetDouble(byte[] data, int index)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
throw new ArgumentNullException("data");
|
||||
}
|
||||
if (data.Length - index < 8)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
if (index < 0)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
double num;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
*((ref num) + (7 - i)) = data[index + i];
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x06000C4F RID: 3151 RVA: 0x00037F08 File Offset: 0x00036108
|
||||
public unsafe override ulong GetUInt64(byte[] data, int index)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
throw new ArgumentNullException("data");
|
||||
}
|
||||
if (data.Length - index < 8)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
if (index < 0)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
ulong num;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
*((ref num) + (7 - i)) = data[index + i];
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x06000C50 RID: 3152 RVA: 0x00037F70 File Offset: 0x00036170
|
||||
public unsafe override long GetInt64(byte[] data, int index)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
throw new ArgumentNullException("data");
|
||||
}
|
||||
if (data.Length - index < 8)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
if (index < 0)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
long num;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
*((ref num) + (7 - i)) = data[index + i];
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x06000C51 RID: 3153 RVA: 0x00037FD8 File Offset: 0x000361D8
|
||||
public unsafe override float GetFloat(byte[] data, int index)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
throw new ArgumentNullException("data");
|
||||
}
|
||||
if (data.Length - index < 4)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
if (index < 0)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
float num;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
*((ref num) + (3 - i)) = data[index + i];
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x06000C52 RID: 3154 RVA: 0x00038040 File Offset: 0x00036240
|
||||
public unsafe override int GetInt32(byte[] data, int index)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
throw new ArgumentNullException("data");
|
||||
}
|
||||
if (data.Length - index < 4)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
if (index < 0)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
int num;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
*((ref num) + (3 - i)) = data[index + i];
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x06000C53 RID: 3155 RVA: 0x000380A8 File Offset: 0x000362A8
|
||||
public unsafe override uint GetUInt32(byte[] data, int index)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
throw new ArgumentNullException("data");
|
||||
}
|
||||
if (data.Length - index < 4)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
if (index < 0)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
uint num;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
*((ref num) + (3 - i)) = data[index + i];
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x06000C54 RID: 3156 RVA: 0x00038110 File Offset: 0x00036310
|
||||
public unsafe override short GetInt16(byte[] data, int index)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
throw new ArgumentNullException("data");
|
||||
}
|
||||
if (data.Length - index < 2)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
if (index < 0)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
short num;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
*((ref num) + (1 - i)) = data[index + i];
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x06000C55 RID: 3157 RVA: 0x00038178 File Offset: 0x00036378
|
||||
public unsafe override ushort GetUInt16(byte[] data, int index)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
throw new ArgumentNullException("data");
|
||||
}
|
||||
if (data.Length - index < 2)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
if (index < 0)
|
||||
{
|
||||
throw new ArgumentException("index");
|
||||
}
|
||||
ushort num;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
*((ref num) + (1 - i)) = data[index + i];
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x06000C56 RID: 3158 RVA: 0x000381E0 File Offset: 0x000363E0
|
||||
public unsafe override void PutBytes(byte[] dest, int destIdx, double value)
|
||||
{
|
||||
base.Check(dest, destIdx, 8);
|
||||
fixed (byte* ptr = &dest[destIdx])
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
ptr[i] = *((ref value) + (7 - i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000C57 RID: 3159 RVA: 0x00038220 File Offset: 0x00036420
|
||||
public unsafe override void PutBytes(byte[] dest, int destIdx, float value)
|
||||
{
|
||||
base.Check(dest, destIdx, 4);
|
||||
fixed (byte* ptr = &dest[destIdx])
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
ptr[i] = *((ref value) + (3 - i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000C58 RID: 3160 RVA: 0x00038260 File Offset: 0x00036460
|
||||
public unsafe override void PutBytes(byte[] dest, int destIdx, int value)
|
||||
{
|
||||
base.Check(dest, destIdx, 4);
|
||||
fixed (byte* ptr = &dest[destIdx])
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
ptr[i] = *((ref value) + (3 - i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000C59 RID: 3161 RVA: 0x000382A0 File Offset: 0x000364A0
|
||||
public unsafe override void PutBytes(byte[] dest, int destIdx, uint value)
|
||||
{
|
||||
base.Check(dest, destIdx, 4);
|
||||
fixed (byte* ptr = &dest[destIdx])
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
ptr[i] = *((ref value) + (3 - i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000C5A RID: 3162 RVA: 0x000382E0 File Offset: 0x000364E0
|
||||
public unsafe override void PutBytes(byte[] dest, int destIdx, long value)
|
||||
{
|
||||
base.Check(dest, destIdx, 8);
|
||||
fixed (byte* ptr = &dest[destIdx])
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
ptr[i] = *((ref value) + (7 - i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000C5B RID: 3163 RVA: 0x00038320 File Offset: 0x00036520
|
||||
public unsafe override void PutBytes(byte[] dest, int destIdx, ulong value)
|
||||
{
|
||||
base.Check(dest, destIdx, 8);
|
||||
fixed (byte* ptr = &dest[destIdx])
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
ptr[i] = *((ref value) + (7 - i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000C5C RID: 3164 RVA: 0x00038360 File Offset: 0x00036560
|
||||
public unsafe override void PutBytes(byte[] dest, int destIdx, short value)
|
||||
{
|
||||
base.Check(dest, destIdx, 2);
|
||||
fixed (byte* ptr = &dest[destIdx])
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
ptr[i] = *((ref value) + (1 - i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000C5D RID: 3165 RVA: 0x000383A0 File Offset: 0x000365A0
|
||||
public unsafe override void PutBytes(byte[] dest, int destIdx, ushort value)
|
||||
{
|
||||
base.Check(dest, destIdx, 2);
|
||||
fixed (byte* ptr = &dest[destIdx])
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
ptr[i] = *((ref value) + (1 - i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Globalization.Unicode
|
||||
{
|
||||
// Token: 0x0200007E RID: 126
|
||||
internal class CodePointIndexer
|
||||
{
|
||||
// Token: 0x06000789 RID: 1929 RVA: 0x00017D80 File Offset: 0x00015F80
|
||||
public CodePointIndexer(int[] starts, int[] ends, int defaultIndex, int defaultCP)
|
||||
{
|
||||
this.defaultIndex = defaultIndex;
|
||||
this.defaultCP = defaultCP;
|
||||
this.ranges = new CodePointIndexer.TableRange[starts.Length];
|
||||
for (int i = 0; i < this.ranges.Length; i++)
|
||||
{
|
||||
this.ranges[i] = new CodePointIndexer.TableRange(starts[i], ends[i], (i != 0) ? (this.ranges[i - 1].IndexStart + this.ranges[i - 1].Count) : 0);
|
||||
}
|
||||
for (int j = 0; j < this.ranges.Length; j++)
|
||||
{
|
||||
this.TotalCount += this.ranges[j].Count;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600078A RID: 1930 RVA: 0x00017E50 File Offset: 0x00016050
|
||||
public static Array CompressArray(Array source, Type type, CodePointIndexer indexer)
|
||||
{
|
||||
int num = 0;
|
||||
for (int i = 0; i < indexer.ranges.Length; i++)
|
||||
{
|
||||
num += indexer.ranges[i].Count;
|
||||
}
|
||||
Array array = Array.CreateInstance(type, num);
|
||||
for (int j = 0; j < indexer.ranges.Length; j++)
|
||||
{
|
||||
Array.Copy(source, indexer.ranges[j].Start, array, indexer.ranges[j].IndexStart, indexer.ranges[j].Count);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x0600078B RID: 1931 RVA: 0x00017EE8 File Offset: 0x000160E8
|
||||
public int ToIndex(int cp)
|
||||
{
|
||||
for (int i = 0; i < this.ranges.Length; i++)
|
||||
{
|
||||
if (cp < this.ranges[i].Start)
|
||||
{
|
||||
return this.defaultIndex;
|
||||
}
|
||||
if (cp < this.ranges[i].End)
|
||||
{
|
||||
return cp - this.ranges[i].Start + this.ranges[i].IndexStart;
|
||||
}
|
||||
}
|
||||
return this.defaultIndex;
|
||||
}
|
||||
|
||||
// Token: 0x0600078C RID: 1932 RVA: 0x00017F70 File Offset: 0x00016170
|
||||
public int ToCodePoint(int i)
|
||||
{
|
||||
for (int j = 0; j < this.ranges.Length; j++)
|
||||
{
|
||||
if (i < this.ranges[j].IndexStart)
|
||||
{
|
||||
return this.defaultCP;
|
||||
}
|
||||
if (i < this.ranges[j].IndexEnd)
|
||||
{
|
||||
return i - this.ranges[j].IndexStart + this.ranges[j].Start;
|
||||
}
|
||||
}
|
||||
return this.defaultCP;
|
||||
}
|
||||
|
||||
// Token: 0x04000116 RID: 278
|
||||
private readonly CodePointIndexer.TableRange[] ranges;
|
||||
|
||||
// Token: 0x04000117 RID: 279
|
||||
public readonly int TotalCount;
|
||||
|
||||
// Token: 0x04000118 RID: 280
|
||||
private int defaultIndex;
|
||||
|
||||
// Token: 0x04000119 RID: 281
|
||||
private int defaultCP;
|
||||
|
||||
// Token: 0x0200007F RID: 127
|
||||
[Serializable]
|
||||
internal struct TableRange
|
||||
{
|
||||
// Token: 0x0600078D RID: 1933 RVA: 0x00017FF8 File Offset: 0x000161F8
|
||||
public TableRange(int start, int end, int indexStart)
|
||||
{
|
||||
this.Start = start;
|
||||
this.End = end;
|
||||
this.Count = this.End - this.Start;
|
||||
this.IndexStart = indexStart;
|
||||
this.IndexEnd = this.IndexStart + this.Count;
|
||||
}
|
||||
|
||||
// Token: 0x0400011A RID: 282
|
||||
public readonly int Start;
|
||||
|
||||
// Token: 0x0400011B RID: 283
|
||||
public readonly int End;
|
||||
|
||||
// Token: 0x0400011C RID: 284
|
||||
public readonly int Count;
|
||||
|
||||
// Token: 0x0400011D RID: 285
|
||||
public readonly int IndexStart;
|
||||
|
||||
// Token: 0x0400011E RID: 286
|
||||
public readonly int IndexEnd;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Globalization.Unicode
|
||||
{
|
||||
// Token: 0x02000081 RID: 129
|
||||
internal class Contraction
|
||||
{
|
||||
// Token: 0x0600078F RID: 1935 RVA: 0x00018060 File Offset: 0x00016260
|
||||
public Contraction(char[] source, string replacement, byte[] sortkey)
|
||||
{
|
||||
this.Source = source;
|
||||
this.Replacement = replacement;
|
||||
this.SortKey = sortkey;
|
||||
}
|
||||
|
||||
// Token: 0x04000123 RID: 291
|
||||
public readonly char[] Source;
|
||||
|
||||
// Token: 0x04000124 RID: 292
|
||||
public readonly string Replacement;
|
||||
|
||||
// Token: 0x04000125 RID: 293
|
||||
public readonly byte[] SortKey;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace Mono.Globalization.Unicode
|
||||
{
|
||||
// Token: 0x02000082 RID: 130
|
||||
internal class ContractionComparer : IComparer
|
||||
{
|
||||
// Token: 0x06000792 RID: 1938 RVA: 0x00018094 File Offset: 0x00016294
|
||||
public int Compare(object o1, object o2)
|
||||
{
|
||||
Contraction contraction = (Contraction)o1;
|
||||
Contraction contraction2 = (Contraction)o2;
|
||||
char[] source = contraction.Source;
|
||||
char[] source2 = contraction2.Source;
|
||||
int num = ((source.Length <= source2.Length) ? source.Length : source2.Length);
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
if (source[i] != source2[i])
|
||||
{
|
||||
return (int)(source[i] - source2[i]);
|
||||
}
|
||||
}
|
||||
return source.Length - source2.Length;
|
||||
}
|
||||
|
||||
// Token: 0x04000126 RID: 294
|
||||
public static readonly ContractionComparer Instance = new ContractionComparer();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Globalization.Unicode
|
||||
{
|
||||
// Token: 0x02000083 RID: 131
|
||||
internal class Level2Map
|
||||
{
|
||||
// Token: 0x06000793 RID: 1939 RVA: 0x0001810C File Offset: 0x0001630C
|
||||
public Level2Map(byte source, byte replace)
|
||||
{
|
||||
this.Source = source;
|
||||
this.Replace = replace;
|
||||
}
|
||||
|
||||
// Token: 0x04000127 RID: 295
|
||||
public byte Source;
|
||||
|
||||
// Token: 0x04000128 RID: 296
|
||||
public byte Replace;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace Mono.Globalization.Unicode
|
||||
{
|
||||
// Token: 0x02000084 RID: 132
|
||||
internal class Level2MapComparer : IComparer
|
||||
{
|
||||
// Token: 0x06000796 RID: 1942 RVA: 0x00018138 File Offset: 0x00016338
|
||||
public int Compare(object o1, object o2)
|
||||
{
|
||||
Level2Map level2Map = (Level2Map)o1;
|
||||
Level2Map level2Map2 = (Level2Map)o2;
|
||||
return (int)(level2Map.Source - level2Map2.Source);
|
||||
}
|
||||
|
||||
// Token: 0x04000129 RID: 297
|
||||
public static readonly Level2MapComparer Instance = new Level2MapComparer();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,686 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Mono.Globalization.Unicode
|
||||
{
|
||||
// Token: 0x02000085 RID: 133
|
||||
internal class MSCompatUnicodeTable
|
||||
{
|
||||
// Token: 0x06000798 RID: 1944 RVA: 0x00018168 File Offset: 0x00016368
|
||||
unsafe static MSCompatUnicodeTable()
|
||||
{
|
||||
IntPtr intPtr = MSCompatUnicodeTable.GetResource("collation.core.bin");
|
||||
if (intPtr == IntPtr.Zero)
|
||||
{
|
||||
return;
|
||||
}
|
||||
byte* ptr = (byte*)(void*)intPtr;
|
||||
intPtr = MSCompatUnicodeTable.GetResource("collation.tailoring.bin");
|
||||
if (intPtr == IntPtr.Zero)
|
||||
{
|
||||
return;
|
||||
}
|
||||
byte* ptr2 = (byte*)(void*)intPtr;
|
||||
if (ptr == null || ptr2 == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (*ptr != 3 || *ptr2 != 3)
|
||||
{
|
||||
return;
|
||||
}
|
||||
uint num = 1U;
|
||||
uint num2 = MSCompatUnicodeTable.UInt32FromBytePtr(ptr, num);
|
||||
num += 4U;
|
||||
MSCompatUnicodeTable.ignorableFlags = ptr + num;
|
||||
num += num2;
|
||||
num2 = MSCompatUnicodeTable.UInt32FromBytePtr(ptr, num);
|
||||
num += 4U;
|
||||
MSCompatUnicodeTable.categories = ptr + num;
|
||||
num += num2;
|
||||
num2 = MSCompatUnicodeTable.UInt32FromBytePtr(ptr, num);
|
||||
num += 4U;
|
||||
MSCompatUnicodeTable.level1 = ptr + num;
|
||||
num += num2;
|
||||
num2 = MSCompatUnicodeTable.UInt32FromBytePtr(ptr, num);
|
||||
num += 4U;
|
||||
MSCompatUnicodeTable.level2 = ptr + num;
|
||||
num += num2;
|
||||
num2 = MSCompatUnicodeTable.UInt32FromBytePtr(ptr, num);
|
||||
num += 4U;
|
||||
MSCompatUnicodeTable.level3 = ptr + num;
|
||||
num += num2;
|
||||
num = 1U;
|
||||
uint num3 = MSCompatUnicodeTable.UInt32FromBytePtr(ptr2, num);
|
||||
num += 4U;
|
||||
MSCompatUnicodeTable.tailoringInfos = new TailoringInfo[num3];
|
||||
int num4 = 0;
|
||||
while ((long)num4 < (long)((ulong)num3))
|
||||
{
|
||||
int num5 = (int)MSCompatUnicodeTable.UInt32FromBytePtr(ptr2, num);
|
||||
num += 4U;
|
||||
int num6 = (int)MSCompatUnicodeTable.UInt32FromBytePtr(ptr2, num);
|
||||
num += 4U;
|
||||
int num7 = (int)MSCompatUnicodeTable.UInt32FromBytePtr(ptr2, num);
|
||||
num += 4U;
|
||||
TailoringInfo tailoringInfo = new TailoringInfo(num5, num6, num7, ptr2[(UIntPtr)(num++)] != 0);
|
||||
MSCompatUnicodeTable.tailoringInfos[num4] = tailoringInfo;
|
||||
num4++;
|
||||
}
|
||||
num += 2U;
|
||||
num3 = MSCompatUnicodeTable.UInt32FromBytePtr(ptr2, num);
|
||||
num += 4U;
|
||||
MSCompatUnicodeTable.tailoringArr = new char[num3];
|
||||
int num8 = 0;
|
||||
while ((long)num8 < (long)((ulong)num3))
|
||||
{
|
||||
MSCompatUnicodeTable.tailoringArr[num8] = (char)((int)ptr2[num] + ((int)ptr2[num + 1U] << 8));
|
||||
num8++;
|
||||
num += 2U;
|
||||
}
|
||||
MSCompatUnicodeTable.isReady = true;
|
||||
}
|
||||
|
||||
// Token: 0x06000799 RID: 1945 RVA: 0x0001834C File Offset: 0x0001654C
|
||||
public static TailoringInfo GetTailoringInfo(int lcid)
|
||||
{
|
||||
for (int i = 0; i < MSCompatUnicodeTable.tailoringInfos.Length; i++)
|
||||
{
|
||||
if (MSCompatUnicodeTable.tailoringInfos[i].LCID == lcid)
|
||||
{
|
||||
return MSCompatUnicodeTable.tailoringInfos[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x0600079A RID: 1946 RVA: 0x0001838C File Offset: 0x0001658C
|
||||
public unsafe static void BuildTailoringTables(CultureInfo culture, TailoringInfo t, ref Contraction[] contractions, ref Level2Map[] diacriticals)
|
||||
{
|
||||
ArrayList arrayList = new ArrayList();
|
||||
ArrayList arrayList2 = new ArrayList();
|
||||
fixed (char* ptr = (ref MSCompatUnicodeTable.tailoringArr != null && MSCompatUnicodeTable.tailoringArr.Length != 0 ? ref MSCompatUnicodeTable.tailoringArr[0] : ref *null))
|
||||
{
|
||||
int i = t.TailoringIndex;
|
||||
int num = i + t.TailoringCount;
|
||||
while (i < num)
|
||||
{
|
||||
int num2 = i + 1;
|
||||
switch (ptr[i])
|
||||
{
|
||||
case '\u0001':
|
||||
{
|
||||
i++;
|
||||
while (ptr[num2] != '\0')
|
||||
{
|
||||
num2++;
|
||||
}
|
||||
char[] array = new char[num2 - i];
|
||||
Marshal.Copy((IntPtr)((void*)(ptr + i)), array, 0, num2 - i);
|
||||
byte[] array2 = new byte[4];
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
array2[j] = (byte)ptr[num2 + 1 + j];
|
||||
}
|
||||
arrayList.Add(new Contraction(array, null, array2));
|
||||
i = num2 + 6;
|
||||
break;
|
||||
}
|
||||
case '\u0002':
|
||||
arrayList2.Add(new Level2Map((byte)ptr[i + 1], (byte)ptr[i + 2]));
|
||||
i += 3;
|
||||
break;
|
||||
case '\u0003':
|
||||
{
|
||||
i++;
|
||||
while (ptr[num2] != '\0')
|
||||
{
|
||||
num2++;
|
||||
}
|
||||
char[] array = new char[num2 - i];
|
||||
Marshal.Copy((IntPtr)((void*)(ptr + i)), array, 0, num2 - i);
|
||||
num2++;
|
||||
int num3 = num2;
|
||||
while (ptr[num3] != '\0')
|
||||
{
|
||||
num3++;
|
||||
}
|
||||
string text = new string(ptr, num2, num3 - num2);
|
||||
arrayList.Add(new Contraction(array, text, null));
|
||||
i = num3 + 1;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new NotImplementedException(string.Format("Mono INTERNAL ERROR (Should not happen): Collation tailoring table is broken for culture {0} ({1}) at 0x{2:X}", culture.LCID, culture.Name, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
arrayList.Sort(ContractionComparer.Instance);
|
||||
arrayList2.Sort(Level2MapComparer.Instance);
|
||||
contractions = arrayList.ToArray(typeof(Contraction)) as Contraction[];
|
||||
diacriticals = arrayList2.ToArray(typeof(Level2Map)) as Level2Map[];
|
||||
}
|
||||
|
||||
// Token: 0x0600079B RID: 1947 RVA: 0x000185BC File Offset: 0x000167BC
|
||||
private unsafe static void SetCJKReferences(string name, ref CodePointIndexer cjkIndexer, ref byte* catTable, ref byte* lv1Table, ref CodePointIndexer lv2Indexer, ref byte* lv2Table)
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "zh-CHS":
|
||||
catTable = MSCompatUnicodeTable.cjkCHScategory;
|
||||
lv1Table = MSCompatUnicodeTable.cjkCHSlv1;
|
||||
cjkIndexer = MSCompatUnicodeTableUtil.CjkCHS;
|
||||
break;
|
||||
case "zh-CHT":
|
||||
catTable = MSCompatUnicodeTable.cjkCHTcategory;
|
||||
lv1Table = MSCompatUnicodeTable.cjkCHTlv1;
|
||||
cjkIndexer = MSCompatUnicodeTableUtil.Cjk;
|
||||
break;
|
||||
case "ja":
|
||||
catTable = MSCompatUnicodeTable.cjkJAcategory;
|
||||
lv1Table = MSCompatUnicodeTable.cjkJAlv1;
|
||||
cjkIndexer = MSCompatUnicodeTableUtil.Cjk;
|
||||
break;
|
||||
case "ko":
|
||||
catTable = MSCompatUnicodeTable.cjkKOcategory;
|
||||
lv1Table = MSCompatUnicodeTable.cjkKOlv1;
|
||||
lv2Table = MSCompatUnicodeTable.cjkKOlv2;
|
||||
cjkIndexer = MSCompatUnicodeTableUtil.Cjk;
|
||||
lv2Indexer = MSCompatUnicodeTableUtil.Cjk;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600079C RID: 1948 RVA: 0x000186C0 File Offset: 0x000168C0
|
||||
public unsafe static byte Category(int cp)
|
||||
{
|
||||
return MSCompatUnicodeTable.categories[MSCompatUnicodeTableUtil.Category.ToIndex(cp)];
|
||||
}
|
||||
|
||||
// Token: 0x0600079D RID: 1949 RVA: 0x000186D4 File Offset: 0x000168D4
|
||||
public unsafe static byte Level1(int cp)
|
||||
{
|
||||
return MSCompatUnicodeTable.level1[MSCompatUnicodeTableUtil.Level1.ToIndex(cp)];
|
||||
}
|
||||
|
||||
// Token: 0x0600079E RID: 1950 RVA: 0x000186E8 File Offset: 0x000168E8
|
||||
public unsafe static byte Level2(int cp)
|
||||
{
|
||||
return MSCompatUnicodeTable.level2[MSCompatUnicodeTableUtil.Level2.ToIndex(cp)];
|
||||
}
|
||||
|
||||
// Token: 0x0600079F RID: 1951 RVA: 0x000186FC File Offset: 0x000168FC
|
||||
public unsafe static byte Level3(int cp)
|
||||
{
|
||||
return MSCompatUnicodeTable.level3[MSCompatUnicodeTableUtil.Level3.ToIndex(cp)];
|
||||
}
|
||||
|
||||
// Token: 0x060007A0 RID: 1952 RVA: 0x00018710 File Offset: 0x00016910
|
||||
public static bool IsSortable(string s)
|
||||
{
|
||||
foreach (char c in s)
|
||||
{
|
||||
if (!MSCompatUnicodeTable.IsSortable((int)c))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x060007A1 RID: 1953 RVA: 0x0001874C File Offset: 0x0001694C
|
||||
public static bool IsSortable(int cp)
|
||||
{
|
||||
return !MSCompatUnicodeTable.IsIgnorable(cp) || cp == 0 || cp == 1600 || cp == 65279 || (6155 <= cp && cp <= 6158) || (8204 <= cp && cp <= 8207) || (8234 <= cp && cp <= 8238) || (8298 <= cp && cp <= 8303) || (8204 <= cp && cp <= 8207) || (65529 <= cp && cp <= 65533);
|
||||
}
|
||||
|
||||
// Token: 0x060007A2 RID: 1954 RVA: 0x00018818 File Offset: 0x00016A18
|
||||
public static bool IsIgnorable(int cp)
|
||||
{
|
||||
return MSCompatUnicodeTable.IsIgnorable(cp, 1);
|
||||
}
|
||||
|
||||
// Token: 0x060007A3 RID: 1955 RVA: 0x00018824 File Offset: 0x00016A24
|
||||
public unsafe static bool IsIgnorable(int cp, byte flag)
|
||||
{
|
||||
if (cp == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ((flag & 1) != 0)
|
||||
{
|
||||
UnicodeCategory unicodeCategory = char.GetUnicodeCategory((char)cp);
|
||||
if (unicodeCategory == UnicodeCategory.OtherNotAssigned)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (55424 <= cp && cp < 56192)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
int num = MSCompatUnicodeTableUtil.Ignorable.ToIndex(cp);
|
||||
return num >= 0 && (MSCompatUnicodeTable.ignorableFlags[num] & flag) != 0;
|
||||
}
|
||||
|
||||
// Token: 0x060007A4 RID: 1956 RVA: 0x00018894 File Offset: 0x00016A94
|
||||
public static bool IsIgnorableSymbol(int cp)
|
||||
{
|
||||
return MSCompatUnicodeTable.IsIgnorable(cp, 2);
|
||||
}
|
||||
|
||||
// Token: 0x060007A5 RID: 1957 RVA: 0x000188A0 File Offset: 0x00016AA0
|
||||
public static bool IsIgnorableNonSpacing(int cp)
|
||||
{
|
||||
return MSCompatUnicodeTable.IsIgnorable(cp, 4);
|
||||
}
|
||||
|
||||
// Token: 0x060007A6 RID: 1958 RVA: 0x000188AC File Offset: 0x00016AAC
|
||||
public static int ToKanaTypeInsensitive(int i)
|
||||
{
|
||||
return (12353 > i || i > 12436) ? i : (i + 96);
|
||||
}
|
||||
|
||||
// Token: 0x060007A7 RID: 1959 RVA: 0x000188DC File Offset: 0x00016ADC
|
||||
public static int ToWidthCompat(int i)
|
||||
{
|
||||
if (i < 8592)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
if (i > 65280)
|
||||
{
|
||||
if (i <= 65374)
|
||||
{
|
||||
return i - 65280 + 32;
|
||||
}
|
||||
switch (i)
|
||||
{
|
||||
case 65504:
|
||||
return 162;
|
||||
case 65505:
|
||||
return 163;
|
||||
case 65506:
|
||||
return 172;
|
||||
case 65507:
|
||||
return 175;
|
||||
case 65508:
|
||||
return 166;
|
||||
case 65509:
|
||||
return 165;
|
||||
case 65510:
|
||||
return 8361;
|
||||
}
|
||||
}
|
||||
if (i > 13054)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
if (i <= 8595)
|
||||
{
|
||||
return 56921 + i;
|
||||
}
|
||||
if (i < 9474)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
if (i <= 9675)
|
||||
{
|
||||
if (i == 9474)
|
||||
{
|
||||
return 65512;
|
||||
}
|
||||
if (i == 9632)
|
||||
{
|
||||
return 65517;
|
||||
}
|
||||
if (i != 9675)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
return 65518;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i < 12288)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
if (i < 12593)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 12288:
|
||||
return 32;
|
||||
case 12289:
|
||||
return 65380;
|
||||
case 12290:
|
||||
return 65377;
|
||||
default:
|
||||
if (i == 12300)
|
||||
{
|
||||
return 65378;
|
||||
}
|
||||
if (i == 12301)
|
||||
{
|
||||
return 65379;
|
||||
}
|
||||
if (i != 12539)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
return 65381;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i < 12644)
|
||||
{
|
||||
return i - 12592 + 65440;
|
||||
}
|
||||
if (i == 12644)
|
||||
{
|
||||
return 65440;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060007A8 RID: 1960 RVA: 0x00018A8C File Offset: 0x00016C8C
|
||||
public static bool HasSpecialWeight(char c)
|
||||
{
|
||||
if (c < 'ぁ')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ('ヲ' <= c && c < '゙')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if ('㌀' <= c)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (c < 'ゝ')
|
||||
{
|
||||
return c < '\u3099';
|
||||
}
|
||||
if (c < '\u3100')
|
||||
{
|
||||
return c != '・';
|
||||
}
|
||||
return c >= '㋐' && c < '㋿';
|
||||
}
|
||||
|
||||
// Token: 0x060007A9 RID: 1961 RVA: 0x00018B14 File Offset: 0x00016D14
|
||||
public static byte GetJapaneseDashType(char c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 'ー':
|
||||
return 5;
|
||||
case 'ヽ':
|
||||
case 'ヾ':
|
||||
break;
|
||||
default:
|
||||
if (c != 'ゝ' && c != 'ゞ' && c != 'ー')
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
|
||||
// Token: 0x060007AA RID: 1962 RVA: 0x00018B68 File Offset: 0x00016D68
|
||||
public static bool IsHalfWidthKana(char c)
|
||||
{
|
||||
return 'ヲ' <= c && c <= 'ン';
|
||||
}
|
||||
|
||||
// Token: 0x060007AB RID: 1963 RVA: 0x00018B84 File Offset: 0x00016D84
|
||||
public static bool IsHiragana(char c)
|
||||
{
|
||||
return 'ぁ' <= c && c <= 'ゔ';
|
||||
}
|
||||
|
||||
// Token: 0x060007AC RID: 1964 RVA: 0x00018BA0 File Offset: 0x00016DA0
|
||||
public static bool IsJapaneseSmallLetter(char c)
|
||||
{
|
||||
if ('ァ' <= c && c <= 'ッ')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if ('\u3040' < c && c < 'ヺ')
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 'ぁ':
|
||||
case 'ぃ':
|
||||
case 'ぅ':
|
||||
case 'ぇ':
|
||||
case 'ぉ':
|
||||
break;
|
||||
default:
|
||||
switch (c)
|
||||
{
|
||||
case 'ァ':
|
||||
case 'ィ':
|
||||
case 'ゥ':
|
||||
case 'ェ':
|
||||
case 'ォ':
|
||||
break;
|
||||
default:
|
||||
switch (c)
|
||||
{
|
||||
case 'ゃ':
|
||||
case 'ゅ':
|
||||
case 'ょ':
|
||||
break;
|
||||
default:
|
||||
switch (c)
|
||||
{
|
||||
case 'ャ':
|
||||
case 'ュ':
|
||||
case 'ョ':
|
||||
break;
|
||||
default:
|
||||
if (c != 'ヵ' && c != 'ヶ' && c != 'っ' && c != 'ゎ' && c != 'ッ' && c != 'ヮ')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Token: 0x170000DC RID: 220
|
||||
// (get) Token: 0x060007AD RID: 1965 RVA: 0x00018CC8 File Offset: 0x00016EC8
|
||||
public static bool IsReady
|
||||
{
|
||||
get
|
||||
{
|
||||
return MSCompatUnicodeTable.isReady;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060007AE RID: 1966 RVA: 0x00018CD0 File Offset: 0x00016ED0
|
||||
private static IntPtr GetResource(string name)
|
||||
{
|
||||
int num;
|
||||
Module module;
|
||||
return Assembly.GetExecutingAssembly().GetManifestResourceInternal(name, out num, out module);
|
||||
}
|
||||
|
||||
// Token: 0x060007AF RID: 1967 RVA: 0x00018CEC File Offset: 0x00016EEC
|
||||
private unsafe static uint UInt32FromBytePtr(byte* raw, uint idx)
|
||||
{
|
||||
return (uint)((int)raw[idx] + ((int)raw[idx + 1U] << 8) + ((int)raw[idx + 2U] << 16) + ((int)raw[idx + 3U] << 24));
|
||||
}
|
||||
|
||||
// Token: 0x060007B0 RID: 1968 RVA: 0x00018D14 File Offset: 0x00016F14
|
||||
public unsafe static void FillCJK(string culture, ref CodePointIndexer cjkIndexer, ref byte* catTable, ref byte* lv1Table, ref CodePointIndexer lv2Indexer, ref byte* lv2Table)
|
||||
{
|
||||
object obj = MSCompatUnicodeTable.forLock;
|
||||
lock (obj)
|
||||
{
|
||||
MSCompatUnicodeTable.FillCJKCore(culture, ref cjkIndexer, ref catTable, ref lv1Table, ref lv2Indexer, ref lv2Table);
|
||||
MSCompatUnicodeTable.SetCJKReferences(culture, ref cjkIndexer, ref catTable, ref lv1Table, ref lv2Indexer, ref lv2Table);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060007B1 RID: 1969 RVA: 0x00018D70 File Offset: 0x00016F70
|
||||
private unsafe static void FillCJKCore(string culture, ref CodePointIndexer cjkIndexer, ref byte* catTable, ref byte* lv1Table, ref CodePointIndexer cjkLv2Indexer, ref byte* lv2Table)
|
||||
{
|
||||
if (!MSCompatUnicodeTable.IsReady)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string text = null;
|
||||
switch (culture)
|
||||
{
|
||||
case "zh-CHS":
|
||||
text = "cjkCHS";
|
||||
catTable = MSCompatUnicodeTable.cjkCHScategory;
|
||||
lv1Table = MSCompatUnicodeTable.cjkCHSlv1;
|
||||
break;
|
||||
case "zh-CHT":
|
||||
text = "cjkCHT";
|
||||
catTable = MSCompatUnicodeTable.cjkCHTcategory;
|
||||
lv1Table = MSCompatUnicodeTable.cjkCHTlv1;
|
||||
break;
|
||||
case "ja":
|
||||
text = "cjkJA";
|
||||
catTable = MSCompatUnicodeTable.cjkJAcategory;
|
||||
lv1Table = MSCompatUnicodeTable.cjkJAlv1;
|
||||
break;
|
||||
case "ko":
|
||||
text = "cjkKO";
|
||||
catTable = MSCompatUnicodeTable.cjkKOcategory;
|
||||
lv1Table = MSCompatUnicodeTable.cjkKOlv1;
|
||||
break;
|
||||
}
|
||||
if (text == null || lv1Table != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
uint num2 = 0U;
|
||||
string text2 = string.Format("collation.{0}.bin", text);
|
||||
IntPtr intPtr = MSCompatUnicodeTable.GetResource(text2);
|
||||
if (intPtr == IntPtr.Zero)
|
||||
{
|
||||
return;
|
||||
}
|
||||
byte* ptr = (byte*)(void*)intPtr;
|
||||
num2 += 1U;
|
||||
uint num3 = MSCompatUnicodeTable.UInt32FromBytePtr(ptr, num2);
|
||||
num2 += 4U;
|
||||
catTable = ptr + num2;
|
||||
lv1Table = ptr + num2 + num3;
|
||||
switch (culture)
|
||||
{
|
||||
case "zh-CHS":
|
||||
MSCompatUnicodeTable.cjkCHScategory = catTable;
|
||||
MSCompatUnicodeTable.cjkCHSlv1 = lv1Table;
|
||||
break;
|
||||
case "zh-CHT":
|
||||
MSCompatUnicodeTable.cjkCHTcategory = catTable;
|
||||
MSCompatUnicodeTable.cjkCHTlv1 = lv1Table;
|
||||
break;
|
||||
case "ja":
|
||||
MSCompatUnicodeTable.cjkJAcategory = catTable;
|
||||
MSCompatUnicodeTable.cjkJAlv1 = lv1Table;
|
||||
break;
|
||||
case "ko":
|
||||
MSCompatUnicodeTable.cjkKOcategory = catTable;
|
||||
MSCompatUnicodeTable.cjkKOlv1 = lv1Table;
|
||||
break;
|
||||
}
|
||||
if (text != "cjkKO")
|
||||
{
|
||||
return;
|
||||
}
|
||||
intPtr = MSCompatUnicodeTable.GetResource("collation.cjkKOlv2.bin");
|
||||
if (intPtr == IntPtr.Zero)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ptr = (byte*)(void*)intPtr;
|
||||
num2 = 5U;
|
||||
MSCompatUnicodeTable.cjkKOlv2 = ptr + num2;
|
||||
lv2Table = MSCompatUnicodeTable.cjkKOlv2;
|
||||
}
|
||||
|
||||
// Token: 0x0400012A RID: 298
|
||||
private const int ResourceVersionSize = 1;
|
||||
|
||||
// Token: 0x0400012B RID: 299
|
||||
public static int MaxExpansionLength = 3;
|
||||
|
||||
// Token: 0x0400012C RID: 300
|
||||
private unsafe static readonly byte* ignorableFlags;
|
||||
|
||||
// Token: 0x0400012D RID: 301
|
||||
private unsafe static readonly byte* categories;
|
||||
|
||||
// Token: 0x0400012E RID: 302
|
||||
private unsafe static readonly byte* level1;
|
||||
|
||||
// Token: 0x0400012F RID: 303
|
||||
private unsafe static readonly byte* level2;
|
||||
|
||||
// Token: 0x04000130 RID: 304
|
||||
private unsafe static readonly byte* level3;
|
||||
|
||||
// Token: 0x04000131 RID: 305
|
||||
private unsafe static byte* cjkCHScategory;
|
||||
|
||||
// Token: 0x04000132 RID: 306
|
||||
private unsafe static byte* cjkCHTcategory;
|
||||
|
||||
// Token: 0x04000133 RID: 307
|
||||
private unsafe static byte* cjkJAcategory;
|
||||
|
||||
// Token: 0x04000134 RID: 308
|
||||
private unsafe static byte* cjkKOcategory;
|
||||
|
||||
// Token: 0x04000135 RID: 309
|
||||
private unsafe static byte* cjkCHSlv1;
|
||||
|
||||
// Token: 0x04000136 RID: 310
|
||||
private unsafe static byte* cjkCHTlv1;
|
||||
|
||||
// Token: 0x04000137 RID: 311
|
||||
private unsafe static byte* cjkJAlv1;
|
||||
|
||||
// Token: 0x04000138 RID: 312
|
||||
private unsafe static byte* cjkKOlv1;
|
||||
|
||||
// Token: 0x04000139 RID: 313
|
||||
private unsafe static byte* cjkKOlv2;
|
||||
|
||||
// Token: 0x0400013A RID: 314
|
||||
private static readonly char[] tailoringArr;
|
||||
|
||||
// Token: 0x0400013B RID: 315
|
||||
private static readonly TailoringInfo[] tailoringInfos;
|
||||
|
||||
// Token: 0x0400013C RID: 316
|
||||
private static object forLock = new object();
|
||||
|
||||
// Token: 0x0400013D RID: 317
|
||||
public static readonly bool isReady;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Globalization.Unicode
|
||||
{
|
||||
// Token: 0x02000086 RID: 134
|
||||
internal class MSCompatUnicodeTableUtil
|
||||
{
|
||||
// Token: 0x060007B3 RID: 1971 RVA: 0x00018FF8 File Offset: 0x000171F8
|
||||
static MSCompatUnicodeTableUtil()
|
||||
{
|
||||
int[] array = new int[] { 0, 40960, 63744 };
|
||||
int[] array2 = new int[] { 13312, 42240, 65536 };
|
||||
int[] array3 = new int[] { 0, 7680, 12288, 19968, 44032, 63744 };
|
||||
int[] array4 = new int[] { 4608, 10240, 13312, 40960, 55216, 65536 };
|
||||
int[] array5 = new int[] { 0, 7680, 12288, 19968, 44032, 63744 };
|
||||
int[] array6 = new int[] { 4608, 10240, 13312, 40960, 55216, 65536 };
|
||||
int[] array7 = new int[] { 0, 7680, 12288, 64256 };
|
||||
int[] array8 = new int[] { 3840, 10240, 13312, 65536 };
|
||||
int[] array9 = new int[] { 0, 7680, 12288, 64256 };
|
||||
int[] array10 = new int[] { 4608, 10240, 13312, 65536 };
|
||||
int[] array11 = new int[] { 12544, 19968, 59392 };
|
||||
int[] array12 = new int[] { 13312, 40960, 65536 };
|
||||
int[] array13 = new int[] { 12544, 19968, 63744 };
|
||||
int[] array14 = new int[] { 13312, 40960, 64256 };
|
||||
MSCompatUnicodeTableUtil.Ignorable = new CodePointIndexer(array, array2, -1, -1);
|
||||
MSCompatUnicodeTableUtil.Category = new CodePointIndexer(array3, array4, 0, 0);
|
||||
MSCompatUnicodeTableUtil.Level1 = new CodePointIndexer(array5, array6, 0, 0);
|
||||
MSCompatUnicodeTableUtil.Level2 = new CodePointIndexer(array7, array8, 0, 0);
|
||||
MSCompatUnicodeTableUtil.Level3 = new CodePointIndexer(array9, array10, 0, 0);
|
||||
MSCompatUnicodeTableUtil.CjkCHS = new CodePointIndexer(array11, array12, -1, -1);
|
||||
MSCompatUnicodeTableUtil.Cjk = new CodePointIndexer(array13, array14, -1, -1);
|
||||
}
|
||||
|
||||
// Token: 0x04000141 RID: 321
|
||||
public const byte ResourceVersion = 3;
|
||||
|
||||
// Token: 0x04000142 RID: 322
|
||||
public static readonly CodePointIndexer Ignorable;
|
||||
|
||||
// Token: 0x04000143 RID: 323
|
||||
public static readonly CodePointIndexer Category;
|
||||
|
||||
// Token: 0x04000144 RID: 324
|
||||
public static readonly CodePointIndexer Level1;
|
||||
|
||||
// Token: 0x04000145 RID: 325
|
||||
public static readonly CodePointIndexer Level2;
|
||||
|
||||
// Token: 0x04000146 RID: 326
|
||||
public static readonly CodePointIndexer Level3;
|
||||
|
||||
// Token: 0x04000147 RID: 327
|
||||
public static readonly CodePointIndexer CjkCHS;
|
||||
|
||||
// Token: 0x04000148 RID: 328
|
||||
public static readonly CodePointIndexer Cjk;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,572 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
|
||||
namespace Mono.Globalization.Unicode
|
||||
{
|
||||
// Token: 0x02000088 RID: 136
|
||||
internal class Normalization
|
||||
{
|
||||
// Token: 0x060007B5 RID: 1973 RVA: 0x000191E0 File Offset: 0x000173E0
|
||||
unsafe static Normalization()
|
||||
{
|
||||
object obj = Normalization.forLock;
|
||||
lock (obj)
|
||||
{
|
||||
IntPtr intPtr;
|
||||
IntPtr intPtr2;
|
||||
IntPtr intPtr3;
|
||||
IntPtr intPtr4;
|
||||
IntPtr intPtr5;
|
||||
IntPtr intPtr6;
|
||||
Normalization.load_normalization_resource(out intPtr, out intPtr2, out intPtr3, out intPtr4, out intPtr5, out intPtr6);
|
||||
Normalization.props = (byte*)(void*)intPtr;
|
||||
Normalization.mappedChars = (int*)(void*)intPtr2;
|
||||
Normalization.charMapIndex = (short*)(void*)intPtr3;
|
||||
Normalization.helperIndex = (short*)(void*)intPtr4;
|
||||
Normalization.mapIdxToComposite = (ushort*)(void*)intPtr5;
|
||||
Normalization.combiningClass = (byte*)(void*)intPtr6;
|
||||
}
|
||||
Normalization.isReady = true;
|
||||
}
|
||||
|
||||
// Token: 0x060007B6 RID: 1974 RVA: 0x0001928C File Offset: 0x0001748C
|
||||
private unsafe static uint PropValue(int cp)
|
||||
{
|
||||
return (uint)Normalization.props[NormalizationTableUtil.PropIdx(cp)];
|
||||
}
|
||||
|
||||
// Token: 0x060007B7 RID: 1975 RVA: 0x0001929C File Offset: 0x0001749C
|
||||
private unsafe static int CharMapIdx(int cp)
|
||||
{
|
||||
return (int)Normalization.charMapIndex[NormalizationTableUtil.MapIdx(cp)];
|
||||
}
|
||||
|
||||
// Token: 0x060007B8 RID: 1976 RVA: 0x000192B0 File Offset: 0x000174B0
|
||||
private unsafe static int GetNormalizedStringLength(int ch)
|
||||
{
|
||||
int num = (int)Normalization.charMapIndex[NormalizationTableUtil.MapIdx(ch)];
|
||||
int num2 = num;
|
||||
while (Normalization.mappedChars[num2] != 0)
|
||||
{
|
||||
num2++;
|
||||
}
|
||||
return num2 - num;
|
||||
}
|
||||
|
||||
// Token: 0x060007B9 RID: 1977 RVA: 0x000192EC File Offset: 0x000174EC
|
||||
private unsafe static byte GetCombiningClass(int c)
|
||||
{
|
||||
return Normalization.combiningClass[NormalizationTableUtil.Combining.ToIndex(c)];
|
||||
}
|
||||
|
||||
// Token: 0x060007BA RID: 1978 RVA: 0x00019300 File Offset: 0x00017500
|
||||
private unsafe static int GetPrimaryCompositeFromMapIndex(int src)
|
||||
{
|
||||
return (int)Normalization.mapIdxToComposite[NormalizationTableUtil.Composite.ToIndex(src)];
|
||||
}
|
||||
|
||||
// Token: 0x060007BB RID: 1979 RVA: 0x00019318 File Offset: 0x00017518
|
||||
private unsafe static int GetPrimaryCompositeHelperIndex(int cp)
|
||||
{
|
||||
return (int)Normalization.helperIndex[NormalizationTableUtil.Helper.ToIndex(cp)];
|
||||
}
|
||||
|
||||
// Token: 0x060007BC RID: 1980 RVA: 0x00019330 File Offset: 0x00017530
|
||||
private unsafe static int GetPrimaryCompositeCharIndex(object chars, int start)
|
||||
{
|
||||
string text = chars as string;
|
||||
StringBuilder stringBuilder = chars as StringBuilder;
|
||||
char c = ((text == null) ? stringBuilder[start] : text[start]);
|
||||
int num = ((stringBuilder == null) ? text.Length : stringBuilder.Length);
|
||||
int num2 = Normalization.GetPrimaryCompositeHelperIndex((int)c);
|
||||
if (num2 == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
while (Normalization.mappedChars[num2] == (int)c)
|
||||
{
|
||||
int num3 = 0;
|
||||
int num4 = 1;
|
||||
int num5 = 1;
|
||||
for (;;)
|
||||
{
|
||||
int num6 = num3;
|
||||
if (Normalization.mappedChars[num2 + num4] == 0)
|
||||
{
|
||||
return num2;
|
||||
}
|
||||
if (start + num4 >= num)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
bool flag = false;
|
||||
char c2;
|
||||
do
|
||||
{
|
||||
c2 = ((text == null) ? stringBuilder[start + num5] : text[start + num5]);
|
||||
num3 = (int)Normalization.GetCombiningClass((int)c2);
|
||||
if (Normalization.mappedChars[num2 + num4] == (int)c2)
|
||||
{
|
||||
goto Block_7;
|
||||
}
|
||||
if (num3 < num6)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (++num5 + start < num && num3 != 0);
|
||||
IL_105:
|
||||
if (!flag)
|
||||
{
|
||||
if (num6 >= num3)
|
||||
{
|
||||
break;
|
||||
}
|
||||
num5--;
|
||||
if (Normalization.mappedChars[num2 + num4] != (int)c2)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
num4++;
|
||||
num5++;
|
||||
continue;
|
||||
Block_7:
|
||||
flag = true;
|
||||
goto IL_105;
|
||||
}
|
||||
while (Normalization.mappedChars[num4] != 0)
|
||||
{
|
||||
num4++;
|
||||
}
|
||||
num2 += num4 + 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Token: 0x060007BD RID: 1981 RVA: 0x000194C4 File Offset: 0x000176C4
|
||||
private static string Compose(string source, int checkType)
|
||||
{
|
||||
StringBuilder stringBuilder = null;
|
||||
Normalization.Decompose(source, ref stringBuilder, checkType);
|
||||
if (stringBuilder == null)
|
||||
{
|
||||
stringBuilder = Normalization.Combine(source, 0, checkType);
|
||||
}
|
||||
else
|
||||
{
|
||||
Normalization.Combine(stringBuilder, 0, checkType);
|
||||
}
|
||||
return (stringBuilder == null) ? source : stringBuilder.ToString();
|
||||
}
|
||||
|
||||
// Token: 0x060007BE RID: 1982 RVA: 0x0001950C File Offset: 0x0001770C
|
||||
private static StringBuilder Combine(string source, int start, int checkType)
|
||||
{
|
||||
for (int i = 0; i < source.Length; i++)
|
||||
{
|
||||
if (Normalization.QuickCheck(source[i], checkType) != NormalizationCheck.Yes)
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder(source.Length + source.Length / 10);
|
||||
stringBuilder.Append(source);
|
||||
Normalization.Combine(stringBuilder, i, checkType);
|
||||
return stringBuilder;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x060007BF RID: 1983 RVA: 0x00019570 File Offset: 0x00017770
|
||||
private static bool CanBePrimaryComposite(int i)
|
||||
{
|
||||
if (i >= 13312 && i <= 40891)
|
||||
{
|
||||
return Normalization.GetPrimaryCompositeHelperIndex(i) != 0;
|
||||
}
|
||||
return (Normalization.PropValue(i) & 128U) != 0U;
|
||||
}
|
||||
|
||||
// Token: 0x060007C0 RID: 1984 RVA: 0x000195A8 File Offset: 0x000177A8
|
||||
private unsafe static void Combine(StringBuilder sb, int start, int checkType)
|
||||
{
|
||||
for (int i = start; i < sb.Length; i++)
|
||||
{
|
||||
if (Normalization.QuickCheck(sb[i], checkType) != NormalizationCheck.Yes)
|
||||
{
|
||||
int num = i;
|
||||
while (i > 0)
|
||||
{
|
||||
if (Normalization.GetCombiningClass((int)sb[i]) == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
i--;
|
||||
}
|
||||
int num2 = 0;
|
||||
while (i < num)
|
||||
{
|
||||
num2 = Normalization.GetPrimaryCompositeMapIndex(sb, (int)sb[i], i);
|
||||
if (num2 > 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (num2 == 0)
|
||||
{
|
||||
i = num;
|
||||
}
|
||||
else
|
||||
{
|
||||
int primaryCompositeFromMapIndex = Normalization.GetPrimaryCompositeFromMapIndex(num2);
|
||||
int normalizedStringLength = Normalization.GetNormalizedStringLength(primaryCompositeFromMapIndex);
|
||||
if (primaryCompositeFromMapIndex == 0 || normalizedStringLength == 0)
|
||||
{
|
||||
throw new SystemException("Internal error: should not happen. Input: " + sb);
|
||||
}
|
||||
int j = 0;
|
||||
sb.Insert(i++, (char)primaryCompositeFromMapIndex);
|
||||
while (j < normalizedStringLength)
|
||||
{
|
||||
if ((int)sb[i] == Normalization.mappedChars[num2 + j])
|
||||
{
|
||||
sb.Remove(i, 1);
|
||||
j++;
|
||||
}
|
||||
else
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
i = num - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060007C1 RID: 1985 RVA: 0x000196C8 File Offset: 0x000178C8
|
||||
private static int GetPrimaryCompositeMapIndex(object o, int cur, int bufferPos)
|
||||
{
|
||||
if ((Normalization.PropValue(cur) & 64U) != 0U)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (Normalization.GetCombiningClass(cur) != 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return Normalization.GetPrimaryCompositeCharIndex(o, bufferPos);
|
||||
}
|
||||
|
||||
// Token: 0x060007C2 RID: 1986 RVA: 0x000196FC File Offset: 0x000178FC
|
||||
private static string Decompose(string source, int checkType)
|
||||
{
|
||||
StringBuilder stringBuilder = null;
|
||||
Normalization.Decompose(source, ref stringBuilder, checkType);
|
||||
return (stringBuilder == null) ? source : stringBuilder.ToString();
|
||||
}
|
||||
|
||||
// Token: 0x060007C3 RID: 1987 RVA: 0x00019728 File Offset: 0x00017928
|
||||
private static void Decompose(string source, ref StringBuilder sb, int checkType)
|
||||
{
|
||||
int[] array = null;
|
||||
int num = 0;
|
||||
for (int i = 0; i < source.Length; i++)
|
||||
{
|
||||
if (Normalization.QuickCheck(source[i], checkType) == NormalizationCheck.No)
|
||||
{
|
||||
Normalization.DecomposeChar(ref sb, ref array, source, i, ref num);
|
||||
}
|
||||
}
|
||||
if (sb != null)
|
||||
{
|
||||
sb.Append(source, num, source.Length - num);
|
||||
}
|
||||
Normalization.ReorderCanonical(source, ref sb, 1);
|
||||
}
|
||||
|
||||
// Token: 0x060007C4 RID: 1988 RVA: 0x00019790 File Offset: 0x00017990
|
||||
private static void ReorderCanonical(string src, ref StringBuilder sb, int start)
|
||||
{
|
||||
if (sb == null)
|
||||
{
|
||||
for (int i = 1; i < src.Length; i++)
|
||||
{
|
||||
int num = (int)Normalization.GetCombiningClass((int)src[i]);
|
||||
if (num != 0)
|
||||
{
|
||||
if ((int)Normalization.GetCombiningClass((int)src[i - 1]) > num)
|
||||
{
|
||||
sb = new StringBuilder(src.Length);
|
||||
sb.Append(src, 0, src.Length);
|
||||
Normalization.ReorderCanonical(src, ref sb, i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
for (int j = start; j < sb.Length; j++)
|
||||
{
|
||||
int num2 = (int)Normalization.GetCombiningClass((int)sb[j]);
|
||||
if (num2 != 0)
|
||||
{
|
||||
if ((int)Normalization.GetCombiningClass((int)sb[j - 1]) > num2)
|
||||
{
|
||||
char c = sb[j - 1];
|
||||
sb[j - 1] = sb[j];
|
||||
sb[j] = c;
|
||||
j--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060007C5 RID: 1989 RVA: 0x00019880 File Offset: 0x00017A80
|
||||
private static void DecomposeChar(ref StringBuilder sb, ref int[] buf, string s, int i, ref int start)
|
||||
{
|
||||
if (sb == null)
|
||||
{
|
||||
sb = new StringBuilder(s.Length + 100);
|
||||
}
|
||||
sb.Append(s, start, i - start);
|
||||
if (buf == null)
|
||||
{
|
||||
buf = new int[19];
|
||||
}
|
||||
Normalization.GetCanonical((int)s[i], buf, 0);
|
||||
int num = 0;
|
||||
while (buf[num] != 0)
|
||||
{
|
||||
if (buf[num] < 65535)
|
||||
{
|
||||
sb.Append((char)buf[num]);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append((char)(buf[num] >> 10));
|
||||
sb.Append((char)((buf[num] & 4095) + 56320));
|
||||
}
|
||||
num++;
|
||||
}
|
||||
start = i + 1;
|
||||
}
|
||||
|
||||
// Token: 0x060007C6 RID: 1990 RVA: 0x00019944 File Offset: 0x00017B44
|
||||
public static NormalizationCheck QuickCheck(char c, int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case 1:
|
||||
if ('가' <= c && c <= '힣')
|
||||
{
|
||||
return NormalizationCheck.No;
|
||||
}
|
||||
return ((Normalization.PropValue((int)c) & 1U) == 0U) ? NormalizationCheck.Yes : NormalizationCheck.No;
|
||||
case 2:
|
||||
{
|
||||
uint num = Normalization.PropValue((int)c);
|
||||
return ((num & 16U) == 0U) ? (((num & 32U) == 0U) ? NormalizationCheck.Yes : NormalizationCheck.Maybe) : NormalizationCheck.No;
|
||||
}
|
||||
case 3:
|
||||
if ('가' <= c && c <= '힣')
|
||||
{
|
||||
return NormalizationCheck.No;
|
||||
}
|
||||
return ((Normalization.PropValue((int)c) & 2U) == 0U) ? NormalizationCheck.Yes : NormalizationCheck.No;
|
||||
default:
|
||||
{
|
||||
uint num = Normalization.PropValue((int)c);
|
||||
return ((num & 4U) != 0U) ? NormalizationCheck.No : (((num & 8U) != 0U) ? NormalizationCheck.Maybe : NormalizationCheck.Yes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060007C7 RID: 1991 RVA: 0x00019A14 File Offset: 0x00017C14
|
||||
private static bool GetCanonicalHangul(int s, int[] buf, int bufIdx)
|
||||
{
|
||||
int num = s - 44032;
|
||||
if (num < 0 || num >= 11172)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int num2 = 4352 + num / 588;
|
||||
int num3 = 4449 + num % 588 / 28;
|
||||
int num4 = 4519 + num % 28;
|
||||
buf[bufIdx++] = num2;
|
||||
buf[bufIdx++] = num3;
|
||||
if (num4 != 4519)
|
||||
{
|
||||
buf[bufIdx++] = num4;
|
||||
}
|
||||
buf[bufIdx] = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x060007C8 RID: 1992 RVA: 0x00019A94 File Offset: 0x00017C94
|
||||
public unsafe static void GetCanonical(int c, int[] buf, int bufIdx)
|
||||
{
|
||||
if (!Normalization.GetCanonicalHangul(c, buf, bufIdx))
|
||||
{
|
||||
int num = Normalization.CharMapIdx(c);
|
||||
while (Normalization.mappedChars[num] != 0)
|
||||
{
|
||||
buf[bufIdx++] = Normalization.mappedChars[num];
|
||||
num++;
|
||||
}
|
||||
buf[bufIdx] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060007C9 RID: 1993 RVA: 0x00019AE4 File Offset: 0x00017CE4
|
||||
public static bool IsNormalized(string source, int type)
|
||||
{
|
||||
int num = -1;
|
||||
for (int i = 0; i < source.Length; i++)
|
||||
{
|
||||
int num2 = (int)Normalization.GetCombiningClass((int)source[i]);
|
||||
if (num2 != 0 && num2 < num)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
num = num2;
|
||||
switch (Normalization.QuickCheck(source[i], type))
|
||||
{
|
||||
case NormalizationCheck.No:
|
||||
return false;
|
||||
case NormalizationCheck.Maybe:
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
case 2:
|
||||
return source == Normalization.Normalize(source, type);
|
||||
}
|
||||
int num3 = i;
|
||||
while (i > 0)
|
||||
{
|
||||
if (Normalization.GetCombiningClass((int)source[i]) == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
i--;
|
||||
}
|
||||
while (i < num3)
|
||||
{
|
||||
if (Normalization.GetPrimaryCompositeCharIndex(source, i) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x060007CA RID: 1994 RVA: 0x00019BCC File Offset: 0x00017DCC
|
||||
public static string Normalize(string source, int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case 1:
|
||||
case 3:
|
||||
return Normalization.Decompose(source, type);
|
||||
default:
|
||||
return Normalization.Compose(source, type);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000DD RID: 221
|
||||
// (get) Token: 0x060007CB RID: 1995 RVA: 0x00019C04 File Offset: 0x00017E04
|
||||
public static bool IsReady
|
||||
{
|
||||
get
|
||||
{
|
||||
return Normalization.isReady;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060007CC RID: 1996
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
private static extern void load_normalization_resource(out IntPtr props, out IntPtr mappedChars, out IntPtr charMapIndex, out IntPtr helperIndex, out IntPtr mapIdxToComposite, out IntPtr combiningClass);
|
||||
|
||||
// Token: 0x0400014D RID: 333
|
||||
public const int NoNfd = 1;
|
||||
|
||||
// Token: 0x0400014E RID: 334
|
||||
public const int NoNfkd = 2;
|
||||
|
||||
// Token: 0x0400014F RID: 335
|
||||
public const int NoNfc = 4;
|
||||
|
||||
// Token: 0x04000150 RID: 336
|
||||
public const int MaybeNfc = 8;
|
||||
|
||||
// Token: 0x04000151 RID: 337
|
||||
public const int NoNfkc = 16;
|
||||
|
||||
// Token: 0x04000152 RID: 338
|
||||
public const int MaybeNfkc = 32;
|
||||
|
||||
// Token: 0x04000153 RID: 339
|
||||
public const int FullCompositionExclusion = 64;
|
||||
|
||||
// Token: 0x04000154 RID: 340
|
||||
public const int IsUnsafe = 128;
|
||||
|
||||
// Token: 0x04000155 RID: 341
|
||||
private const int HangulSBase = 44032;
|
||||
|
||||
// Token: 0x04000156 RID: 342
|
||||
private const int HangulLBase = 4352;
|
||||
|
||||
// Token: 0x04000157 RID: 343
|
||||
private const int HangulVBase = 4449;
|
||||
|
||||
// Token: 0x04000158 RID: 344
|
||||
private const int HangulTBase = 4519;
|
||||
|
||||
// Token: 0x04000159 RID: 345
|
||||
private const int HangulLCount = 19;
|
||||
|
||||
// Token: 0x0400015A RID: 346
|
||||
private const int HangulVCount = 21;
|
||||
|
||||
// Token: 0x0400015B RID: 347
|
||||
private const int HangulTCount = 28;
|
||||
|
||||
// Token: 0x0400015C RID: 348
|
||||
private const int HangulNCount = 588;
|
||||
|
||||
// Token: 0x0400015D RID: 349
|
||||
private const int HangulSCount = 11172;
|
||||
|
||||
// Token: 0x0400015E RID: 350
|
||||
private unsafe static byte* props;
|
||||
|
||||
// Token: 0x0400015F RID: 351
|
||||
private unsafe static int* mappedChars;
|
||||
|
||||
// Token: 0x04000160 RID: 352
|
||||
private unsafe static short* charMapIndex;
|
||||
|
||||
// Token: 0x04000161 RID: 353
|
||||
private unsafe static short* helperIndex;
|
||||
|
||||
// Token: 0x04000162 RID: 354
|
||||
private unsafe static ushort* mapIdxToComposite;
|
||||
|
||||
// Token: 0x04000163 RID: 355
|
||||
private unsafe static byte* combiningClass;
|
||||
|
||||
// Token: 0x04000164 RID: 356
|
||||
private static object forLock = new object();
|
||||
|
||||
// Token: 0x04000165 RID: 357
|
||||
public static readonly bool isReady;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Globalization.Unicode
|
||||
{
|
||||
// Token: 0x02000087 RID: 135
|
||||
internal enum NormalizationCheck
|
||||
{
|
||||
// Token: 0x0400014A RID: 330
|
||||
Yes,
|
||||
// Token: 0x0400014B RID: 331
|
||||
No,
|
||||
// Token: 0x0400014C RID: 332
|
||||
Maybe
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Globalization.Unicode
|
||||
{
|
||||
// Token: 0x02000089 RID: 137
|
||||
internal class NormalizationTableUtil
|
||||
{
|
||||
// Token: 0x060007CE RID: 1998 RVA: 0x00019C14 File Offset: 0x00017E14
|
||||
static NormalizationTableUtil()
|
||||
{
|
||||
int[] array = new int[] { 0, 2320, 6912, 9312, 10624, 11376, 11616, 11920, 42864, 63744 };
|
||||
int[] array2 = new int[] { 1760, 4608, 9008, 9728, 10976, 11392, 11632, 13312, 42880, 65536 };
|
||||
int[] array3 = new int[] { 144, 2336, 7456, 9312, 9376, 10752, 11616, 11920, 63744 };
|
||||
int[] array4 = new int[] { 1760, 4352, 9008, 9376, 9456, 10976, 11632, 13312, 65536 };
|
||||
int[] array5 = new int[]
|
||||
{
|
||||
752, 1152, 1424, 2352, 2480, 2608, 2736, 2864, 3008, 3136,
|
||||
3248, 3392, 3520, 3632, 3760, 3840, 4144, 4944, 5904, 6096,
|
||||
6304, 6448, 6672, 7616, 8400, 12320, 12432, 43008, 64272, 65056
|
||||
};
|
||||
int[] array6 = new int[]
|
||||
{
|
||||
864, 1168, 1872, 2400, 2512, 2640, 2768, 2896, 3024, 3168,
|
||||
3280, 3408, 3536, 3664, 3792, 4048, 4160, 4960, 5952, 6112,
|
||||
6320, 6464, 6688, 7632, 8432, 12336, 12448, 43024, 64288, 65072
|
||||
};
|
||||
int[] array7 = new int[] { 1152, 5136, 5744 };
|
||||
int[] array8 = new int[] { 4224, 5504, 8624 };
|
||||
int[] array9 = new int[] { 0, 2304, 7424, 9472, 12288, 15248, 16400, 19968, 64320 };
|
||||
int[] array10 = new int[] { 1792, 4608, 8960, 9728, 12640, 15264, 16432, 40960, 64336 };
|
||||
NormalizationTableUtil.Prop = new CodePointIndexer(array, array2, 0, 0);
|
||||
NormalizationTableUtil.Map = new CodePointIndexer(array3, array4, 0, 0);
|
||||
NormalizationTableUtil.Combining = new CodePointIndexer(array5, array6, 0, 0);
|
||||
NormalizationTableUtil.Composite = new CodePointIndexer(array7, array8, 0, 0);
|
||||
NormalizationTableUtil.Helper = new CodePointIndexer(array9, array10, 0, 0);
|
||||
}
|
||||
|
||||
// Token: 0x060007CF RID: 1999 RVA: 0x00019D4C File Offset: 0x00017F4C
|
||||
public static int PropIdx(int cp)
|
||||
{
|
||||
return NormalizationTableUtil.Prop.ToIndex(cp);
|
||||
}
|
||||
|
||||
// Token: 0x060007D0 RID: 2000 RVA: 0x00019D5C File Offset: 0x00017F5C
|
||||
public static int PropCP(int index)
|
||||
{
|
||||
return NormalizationTableUtil.Prop.ToCodePoint(index);
|
||||
}
|
||||
|
||||
// Token: 0x170000DE RID: 222
|
||||
// (get) Token: 0x060007D1 RID: 2001 RVA: 0x00019D6C File Offset: 0x00017F6C
|
||||
public static int PropCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return NormalizationTableUtil.Prop.TotalCount;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060007D2 RID: 2002 RVA: 0x00019D78 File Offset: 0x00017F78
|
||||
public static int MapIdx(int cp)
|
||||
{
|
||||
return NormalizationTableUtil.Map.ToIndex(cp);
|
||||
}
|
||||
|
||||
// Token: 0x060007D3 RID: 2003 RVA: 0x00019D88 File Offset: 0x00017F88
|
||||
public static int MapCP(int index)
|
||||
{
|
||||
return NormalizationTableUtil.Map.ToCodePoint(index);
|
||||
}
|
||||
|
||||
// Token: 0x060007D4 RID: 2004 RVA: 0x00019D98 File Offset: 0x00017F98
|
||||
public static int CbIdx(int cp)
|
||||
{
|
||||
return NormalizationTableUtil.Combining.ToIndex(cp);
|
||||
}
|
||||
|
||||
// Token: 0x060007D5 RID: 2005 RVA: 0x00019DA8 File Offset: 0x00017FA8
|
||||
public static int CbCP(int index)
|
||||
{
|
||||
return NormalizationTableUtil.Combining.ToCodePoint(index);
|
||||
}
|
||||
|
||||
// Token: 0x170000DF RID: 223
|
||||
// (get) Token: 0x060007D6 RID: 2006 RVA: 0x00019DB8 File Offset: 0x00017FB8
|
||||
public static int MapCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return NormalizationTableUtil.Map.TotalCount;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x04000166 RID: 358
|
||||
public static readonly CodePointIndexer Prop;
|
||||
|
||||
// Token: 0x04000167 RID: 359
|
||||
public static readonly CodePointIndexer Map;
|
||||
|
||||
// Token: 0x04000168 RID: 360
|
||||
public static readonly CodePointIndexer Combining;
|
||||
|
||||
// Token: 0x04000169 RID: 361
|
||||
public static readonly CodePointIndexer Composite;
|
||||
|
||||
// Token: 0x0400016A RID: 362
|
||||
public static readonly CodePointIndexer Helper;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2416 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Mono.Globalization.Unicode
|
||||
{
|
||||
// Token: 0x0200008A RID: 138
|
||||
internal class SimpleCollator
|
||||
{
|
||||
// Token: 0x060007D7 RID: 2007 RVA: 0x00019DC4 File Offset: 0x00017FC4
|
||||
public SimpleCollator(CultureInfo culture)
|
||||
{
|
||||
this.lcid = culture.LCID;
|
||||
this.textInfo = culture.TextInfo;
|
||||
this.SetCJKTable(culture, ref this.cjkIndexer, ref this.cjkCatTable, ref this.cjkLv1Table, ref this.cjkLv2Indexer, ref this.cjkLv2Table);
|
||||
TailoringInfo tailoringInfo = null;
|
||||
CultureInfo cultureInfo = culture;
|
||||
while (cultureInfo.LCID != 127)
|
||||
{
|
||||
tailoringInfo = MSCompatUnicodeTable.GetTailoringInfo(cultureInfo.LCID);
|
||||
if (tailoringInfo != null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
cultureInfo = cultureInfo.Parent;
|
||||
}
|
||||
if (tailoringInfo == null)
|
||||
{
|
||||
tailoringInfo = MSCompatUnicodeTable.GetTailoringInfo(127);
|
||||
}
|
||||
this.frenchSort = tailoringInfo.FrenchSort;
|
||||
MSCompatUnicodeTable.BuildTailoringTables(culture, tailoringInfo, ref this.contractions, ref this.level2Maps);
|
||||
this.unsafeFlags = new byte[96];
|
||||
foreach (Contraction contraction in this.contractions)
|
||||
{
|
||||
if (contraction.Source.Length > 1)
|
||||
{
|
||||
foreach (char c in contraction.Source)
|
||||
{
|
||||
byte[] array2 = this.unsafeFlags;
|
||||
char c2 = c / '\b';
|
||||
array2[(int)c2] = array2[(int)c2] | (byte)(1 << (int)(c & '\a'));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.lcid != 127)
|
||||
{
|
||||
foreach (Contraction contraction2 in SimpleCollator.invariant.contractions)
|
||||
{
|
||||
if (contraction2.Source.Length > 1)
|
||||
{
|
||||
foreach (char c3 in contraction2.Source)
|
||||
{
|
||||
byte[] array4 = this.unsafeFlags;
|
||||
char c4 = c3 / '\b';
|
||||
array4[(int)c4] = array4[(int)c4] | (byte)(1 << (int)(c3 & '\a'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060007D9 RID: 2009 RVA: 0x00019FC4 File Offset: 0x000181C4
|
||||
private unsafe void SetCJKTable(CultureInfo culture, ref CodePointIndexer cjkIndexer, ref byte* catTable, ref byte* lv1Table, ref CodePointIndexer lv2Indexer, ref byte* lv2Table)
|
||||
{
|
||||
string name = SimpleCollator.GetNeutralCulture(culture).Name;
|
||||
MSCompatUnicodeTable.FillCJK(name, ref cjkIndexer, ref catTable, ref lv1Table, ref lv2Indexer, ref lv2Table);
|
||||
}
|
||||
|
||||
// Token: 0x060007DA RID: 2010 RVA: 0x00019FEC File Offset: 0x000181EC
|
||||
private static CultureInfo GetNeutralCulture(CultureInfo info)
|
||||
{
|
||||
CultureInfo cultureInfo = info;
|
||||
while (cultureInfo.Parent != null && cultureInfo.Parent.LCID != 127)
|
||||
{
|
||||
cultureInfo = cultureInfo.Parent;
|
||||
}
|
||||
return cultureInfo;
|
||||
}
|
||||
|
||||
// Token: 0x060007DB RID: 2011 RVA: 0x0001A028 File Offset: 0x00018228
|
||||
private unsafe byte Category(int cp)
|
||||
{
|
||||
if (cp < 12288 || this.cjkCatTable == null)
|
||||
{
|
||||
return MSCompatUnicodeTable.Category(cp);
|
||||
}
|
||||
int num = this.cjkIndexer.ToIndex(cp);
|
||||
return (num >= 0) ? this.cjkCatTable[num] : MSCompatUnicodeTable.Category(cp);
|
||||
}
|
||||
|
||||
// Token: 0x060007DC RID: 2012 RVA: 0x0001A07C File Offset: 0x0001827C
|
||||
private unsafe byte Level1(int cp)
|
||||
{
|
||||
if (cp < 12288 || this.cjkLv1Table == null)
|
||||
{
|
||||
return MSCompatUnicodeTable.Level1(cp);
|
||||
}
|
||||
int num = this.cjkIndexer.ToIndex(cp);
|
||||
return (num >= 0) ? this.cjkLv1Table[num] : MSCompatUnicodeTable.Level1(cp);
|
||||
}
|
||||
|
||||
// Token: 0x060007DD RID: 2013 RVA: 0x0001A0D0 File Offset: 0x000182D0
|
||||
private unsafe byte Level2(int cp, SimpleCollator.ExtenderType ext)
|
||||
{
|
||||
if (ext == SimpleCollator.ExtenderType.Buggy)
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
if (ext == SimpleCollator.ExtenderType.Conditional)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (cp < 12288 || this.cjkLv2Table == null)
|
||||
{
|
||||
return MSCompatUnicodeTable.Level2(cp);
|
||||
}
|
||||
int num = this.cjkLv2Indexer.ToIndex(cp);
|
||||
byte b = ((num >= 0) ? this.cjkLv2Table[num] : 0);
|
||||
if (b != 0)
|
||||
{
|
||||
return b;
|
||||
}
|
||||
b = MSCompatUnicodeTable.Level2(cp);
|
||||
if (this.level2Maps.Length == 0)
|
||||
{
|
||||
return b;
|
||||
}
|
||||
for (int i = 0; i < this.level2Maps.Length; i++)
|
||||
{
|
||||
if (this.level2Maps[i].Source == b)
|
||||
{
|
||||
return this.level2Maps[i].Replace;
|
||||
}
|
||||
if (this.level2Maps[i].Source > b)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
// Token: 0x060007DE RID: 2014 RVA: 0x0001A1A4 File Offset: 0x000183A4
|
||||
private static bool IsHalfKana(int cp, CompareOptions opt)
|
||||
{
|
||||
return (opt & CompareOptions.IgnoreWidth) != CompareOptions.None || MSCompatUnicodeTable.IsHalfWidthKana((char)cp);
|
||||
}
|
||||
|
||||
// Token: 0x060007DF RID: 2015 RVA: 0x0001A1BC File Offset: 0x000183BC
|
||||
private Contraction GetContraction(string s, int start, int end)
|
||||
{
|
||||
Contraction contraction = this.GetContraction(s, start, end, this.contractions);
|
||||
if (contraction != null || this.lcid == 127)
|
||||
{
|
||||
return contraction;
|
||||
}
|
||||
return this.GetContraction(s, start, end, SimpleCollator.invariant.contractions);
|
||||
}
|
||||
|
||||
// Token: 0x060007E0 RID: 2016 RVA: 0x0001A204 File Offset: 0x00018404
|
||||
private Contraction GetContraction(string s, int start, int end, Contraction[] clist)
|
||||
{
|
||||
foreach (Contraction contraction in clist)
|
||||
{
|
||||
int num = (int)(contraction.Source[0] - s[start]);
|
||||
if (num > 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (num >= 0)
|
||||
{
|
||||
char[] source = contraction.Source;
|
||||
if (end - start >= source.Length)
|
||||
{
|
||||
bool flag = true;
|
||||
for (int j = 0; j < source.Length; j++)
|
||||
{
|
||||
if (s[start + j] != source[j])
|
||||
{
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
return contraction;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x060007E1 RID: 2017 RVA: 0x0001A2A8 File Offset: 0x000184A8
|
||||
private Contraction GetTailContraction(string s, int start, int end)
|
||||
{
|
||||
Contraction tailContraction = this.GetTailContraction(s, start, end, this.contractions);
|
||||
if (tailContraction != null || this.lcid == 127)
|
||||
{
|
||||
return tailContraction;
|
||||
}
|
||||
return this.GetTailContraction(s, start, end, SimpleCollator.invariant.contractions);
|
||||
}
|
||||
|
||||
// Token: 0x060007E2 RID: 2018 RVA: 0x0001A2F0 File Offset: 0x000184F0
|
||||
private Contraction GetTailContraction(string s, int start, int end, Contraction[] clist)
|
||||
{
|
||||
if (start == end || end < -1 || start >= s.Length || s.Length <= end + 1)
|
||||
{
|
||||
throw new SystemException(string.Format("MONO internal error. Failed to get TailContraction. start = {0} end = {1} string = '{2}'", start, end, s));
|
||||
}
|
||||
foreach (Contraction contraction in clist)
|
||||
{
|
||||
char[] source = contraction.Source;
|
||||
if (source.Length <= start - end)
|
||||
{
|
||||
if (source[source.Length - 1] == s[start])
|
||||
{
|
||||
bool flag = true;
|
||||
int j = 0;
|
||||
int num = start - source.Length + 1;
|
||||
while (j < source.Length)
|
||||
{
|
||||
if (s[num] != source[j])
|
||||
{
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
j++;
|
||||
num++;
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
return contraction;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x060007E3 RID: 2019 RVA: 0x0001A3D8 File Offset: 0x000185D8
|
||||
private Contraction GetContraction(char c)
|
||||
{
|
||||
Contraction contraction = this.GetContraction(c, this.contractions);
|
||||
if (contraction != null || this.lcid == 127)
|
||||
{
|
||||
return contraction;
|
||||
}
|
||||
return this.GetContraction(c, SimpleCollator.invariant.contractions);
|
||||
}
|
||||
|
||||
// Token: 0x060007E4 RID: 2020 RVA: 0x0001A41C File Offset: 0x0001861C
|
||||
private Contraction GetContraction(char c, Contraction[] clist)
|
||||
{
|
||||
foreach (Contraction contraction in clist)
|
||||
{
|
||||
if (contraction.Source[0] > c)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (contraction.Source[0] == c && contraction.Source.Length == 1)
|
||||
{
|
||||
return contraction;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x060007E5 RID: 2021 RVA: 0x0001A470 File Offset: 0x00018670
|
||||
private int FilterOptions(int i, CompareOptions opt)
|
||||
{
|
||||
if ((opt & CompareOptions.IgnoreWidth) != CompareOptions.None)
|
||||
{
|
||||
int num = MSCompatUnicodeTable.ToWidthCompat(i);
|
||||
if (num != 0)
|
||||
{
|
||||
i = num;
|
||||
}
|
||||
}
|
||||
if ((opt & CompareOptions.OrdinalIgnoreCase) != CompareOptions.None)
|
||||
{
|
||||
i = (int)this.textInfo.ToLower((char)i);
|
||||
}
|
||||
if ((opt & CompareOptions.IgnoreCase) != CompareOptions.None)
|
||||
{
|
||||
i = (int)this.textInfo.ToLower((char)i);
|
||||
}
|
||||
if ((opt & CompareOptions.IgnoreKanaType) != CompareOptions.None)
|
||||
{
|
||||
i = MSCompatUnicodeTable.ToKanaTypeInsensitive(i);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
// Token: 0x060007E6 RID: 2022 RVA: 0x0001A4DC File Offset: 0x000186DC
|
||||
private SimpleCollator.ExtenderType GetExtenderType(int i)
|
||||
{
|
||||
if (i == 8213)
|
||||
{
|
||||
return (this.lcid != 16) ? SimpleCollator.ExtenderType.None : SimpleCollator.ExtenderType.Conditional;
|
||||
}
|
||||
if (i < 12293 || i > 65392)
|
||||
{
|
||||
return SimpleCollator.ExtenderType.None;
|
||||
}
|
||||
if (i >= 65148)
|
||||
{
|
||||
if (i == 65148 || i == 65149)
|
||||
{
|
||||
return SimpleCollator.ExtenderType.Simple;
|
||||
}
|
||||
if (i == 65438 || i == 65439)
|
||||
{
|
||||
return SimpleCollator.ExtenderType.Voiced;
|
||||
}
|
||||
if (i == 65392)
|
||||
{
|
||||
return SimpleCollator.ExtenderType.Conditional;
|
||||
}
|
||||
}
|
||||
if (i > 12542)
|
||||
{
|
||||
return SimpleCollator.ExtenderType.None;
|
||||
}
|
||||
switch (i)
|
||||
{
|
||||
case 12540:
|
||||
return SimpleCollator.ExtenderType.Conditional;
|
||||
case 12541:
|
||||
break;
|
||||
case 12542:
|
||||
return SimpleCollator.ExtenderType.Voiced;
|
||||
default:
|
||||
if (i != 12337 && i != 12338 && i != 12445)
|
||||
{
|
||||
if (i == 12446)
|
||||
{
|
||||
return SimpleCollator.ExtenderType.Voiced;
|
||||
}
|
||||
if (i != 12293)
|
||||
{
|
||||
return SimpleCollator.ExtenderType.None;
|
||||
}
|
||||
return SimpleCollator.ExtenderType.Buggy;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return SimpleCollator.ExtenderType.Simple;
|
||||
}
|
||||
|
||||
// Token: 0x060007E7 RID: 2023 RVA: 0x0001A5DC File Offset: 0x000187DC
|
||||
private static byte ToDashTypeValue(SimpleCollator.ExtenderType ext, CompareOptions opt)
|
||||
{
|
||||
if ((opt & CompareOptions.IgnoreNonSpace) != CompareOptions.None)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
switch (ext)
|
||||
{
|
||||
case SimpleCollator.ExtenderType.None:
|
||||
return 3;
|
||||
case SimpleCollator.ExtenderType.Conditional:
|
||||
return 5;
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
|
||||
// Token: 0x060007E8 RID: 2024 RVA: 0x0001A618 File Offset: 0x00018818
|
||||
private int FilterExtender(int i, SimpleCollator.ExtenderType ext, CompareOptions opt)
|
||||
{
|
||||
if (ext == SimpleCollator.ExtenderType.Conditional && MSCompatUnicodeTable.HasSpecialWeight((char)i))
|
||||
{
|
||||
bool flag = SimpleCollator.IsHalfKana((int)((ushort)i), opt);
|
||||
bool flag2 = !MSCompatUnicodeTable.IsHiragana((char)i);
|
||||
switch (this.Level1(i) & 7)
|
||||
{
|
||||
case 2:
|
||||
return (!flag) ? ((!flag2) ? 12354 : 12450) : 65393;
|
||||
case 3:
|
||||
return (!flag) ? ((!flag2) ? 12356 : 12452) : 65394;
|
||||
case 4:
|
||||
return (!flag) ? ((!flag2) ? 12358 : 12454) : 65395;
|
||||
case 5:
|
||||
return (!flag) ? ((!flag2) ? 12360 : 12456) : 65396;
|
||||
case 6:
|
||||
return (!flag) ? ((!flag2) ? 12362 : 12458) : 65397;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
// Token: 0x060007E9 RID: 2025 RVA: 0x0001A738 File Offset: 0x00018938
|
||||
private static bool IsIgnorable(int i, CompareOptions opt)
|
||||
{
|
||||
return MSCompatUnicodeTable.IsIgnorable(i, (byte)(1 + (((opt & CompareOptions.IgnoreSymbols) == CompareOptions.None) ? 0 : 2) + (((opt & CompareOptions.IgnoreNonSpace) == CompareOptions.None) ? 0 : 4)));
|
||||
}
|
||||
|
||||
// Token: 0x060007EA RID: 2026 RVA: 0x0001A770 File Offset: 0x00018970
|
||||
private bool IsSafe(int i)
|
||||
{
|
||||
return i / 8 >= this.unsafeFlags.Length || ((int)this.unsafeFlags[i / 8] & (1 << i % 8)) == 0;
|
||||
}
|
||||
|
||||
// Token: 0x060007EB RID: 2027 RVA: 0x0001A7AC File Offset: 0x000189AC
|
||||
public SortKey GetSortKey(string s)
|
||||
{
|
||||
return this.GetSortKey(s, CompareOptions.None);
|
||||
}
|
||||
|
||||
// Token: 0x060007EC RID: 2028 RVA: 0x0001A7B8 File Offset: 0x000189B8
|
||||
public SortKey GetSortKey(string s, CompareOptions options)
|
||||
{
|
||||
return this.GetSortKey(s, 0, s.Length, options);
|
||||
}
|
||||
|
||||
// Token: 0x060007ED RID: 2029 RVA: 0x0001A7CC File Offset: 0x000189CC
|
||||
public SortKey GetSortKey(string s, int start, int length, CompareOptions options)
|
||||
{
|
||||
SortKeyBuffer sortKeyBuffer = new SortKeyBuffer(this.lcid);
|
||||
sortKeyBuffer.Initialize(options, this.lcid, s, this.frenchSort);
|
||||
int num = start + length;
|
||||
this.GetSortKey(s, start, num, sortKeyBuffer, options);
|
||||
return sortKeyBuffer.GetResultAndReset();
|
||||
}
|
||||
|
||||
// Token: 0x060007EE RID: 2030 RVA: 0x0001A810 File Offset: 0x00018A10
|
||||
private unsafe void GetSortKey(string s, int start, int end, SortKeyBuffer buf, CompareOptions opt)
|
||||
{
|
||||
byte* ptr = stackalloc byte[checked(4 * 1)];
|
||||
this.ClearBuffer(ptr, 4);
|
||||
SimpleCollator.Context context = new SimpleCollator.Context(opt, null, null, null, null, ptr, false);
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
int num = (int)s[i];
|
||||
SimpleCollator.ExtenderType extenderType = this.GetExtenderType(num);
|
||||
if (extenderType != SimpleCollator.ExtenderType.None)
|
||||
{
|
||||
num = this.FilterExtender(context.PrevCode, extenderType, opt);
|
||||
if (num >= 0)
|
||||
{
|
||||
this.FillSortKeyRaw(num, extenderType, buf, opt);
|
||||
}
|
||||
else if (context.PrevSortKey != null)
|
||||
{
|
||||
byte* prevSortKey = context.PrevSortKey;
|
||||
buf.AppendNormal(*prevSortKey, prevSortKey[1], (prevSortKey[2] == 1) ? this.Level2(num, extenderType) : prevSortKey[2], (prevSortKey[3] == 1) ? MSCompatUnicodeTable.Level3(num) : prevSortKey[3]);
|
||||
}
|
||||
}
|
||||
else if (!SimpleCollator.IsIgnorable(num, opt))
|
||||
{
|
||||
num = this.FilterOptions(num, opt);
|
||||
Contraction contraction = this.GetContraction(s, i, end);
|
||||
if (contraction != null)
|
||||
{
|
||||
if (contraction.Replacement != null)
|
||||
{
|
||||
this.GetSortKey(contraction.Replacement, 0, contraction.Replacement.Length, buf, opt);
|
||||
}
|
||||
else
|
||||
{
|
||||
byte* prevSortKey2 = context.PrevSortKey;
|
||||
for (int j = 0; j < contraction.SortKey.Length; j++)
|
||||
{
|
||||
prevSortKey2[j] = contraction.SortKey[j];
|
||||
}
|
||||
buf.AppendNormal(*prevSortKey2, prevSortKey2[1], (prevSortKey2[2] == 1) ? this.Level2(num, extenderType) : prevSortKey2[2], (prevSortKey2[3] == 1) ? MSCompatUnicodeTable.Level3(num) : prevSortKey2[3]);
|
||||
context.PrevCode = -1;
|
||||
}
|
||||
i += contraction.Source.Length - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!MSCompatUnicodeTable.IsIgnorableNonSpacing(num))
|
||||
{
|
||||
context.PrevCode = num;
|
||||
}
|
||||
this.FillSortKeyRaw(num, SimpleCollator.ExtenderType.None, buf, opt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060007EF RID: 2031 RVA: 0x0001AA0C File Offset: 0x00018C0C
|
||||
private void FillSortKeyRaw(int i, SimpleCollator.ExtenderType ext, SortKeyBuffer buf, CompareOptions opt)
|
||||
{
|
||||
if (13312 <= i && i <= 19893)
|
||||
{
|
||||
int num = i - 13312;
|
||||
buf.AppendCJKExtension((byte)(16 + num / 254), (byte)(num % 254 + 2));
|
||||
return;
|
||||
}
|
||||
UnicodeCategory unicodeCategory = char.GetUnicodeCategory((char)i);
|
||||
UnicodeCategory unicodeCategory2 = unicodeCategory;
|
||||
if (unicodeCategory2 == UnicodeCategory.Surrogate)
|
||||
{
|
||||
this.FillSurrogateSortKeyRaw(i, buf);
|
||||
return;
|
||||
}
|
||||
if (unicodeCategory2 != UnicodeCategory.PrivateUse)
|
||||
{
|
||||
byte b = this.Level2(i, ext);
|
||||
if (MSCompatUnicodeTable.HasSpecialWeight((char)i))
|
||||
{
|
||||
byte b2 = this.Level1(i);
|
||||
buf.AppendKana(this.Category(i), b2, b, MSCompatUnicodeTable.Level3(i), MSCompatUnicodeTable.IsJapaneseSmallLetter((char)i), SimpleCollator.ToDashTypeValue(ext, opt), !MSCompatUnicodeTable.IsHiragana((char)i), SimpleCollator.IsHalfKana((int)((ushort)i), opt));
|
||||
if ((opt & CompareOptions.IgnoreNonSpace) == CompareOptions.None && ext == SimpleCollator.ExtenderType.Voiced)
|
||||
{
|
||||
buf.AppendNormal(1, 1, 1, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
buf.AppendNormal(this.Category(i), this.Level1(i), b, MSCompatUnicodeTable.Level3(i));
|
||||
}
|
||||
return;
|
||||
}
|
||||
int num2 = i - 57344;
|
||||
buf.AppendNormal((byte)(229 + num2 / 254), (byte)(num2 % 254 + 2), 0, 0);
|
||||
}
|
||||
|
||||
// Token: 0x060007F0 RID: 2032 RVA: 0x0001AB38 File Offset: 0x00018D38
|
||||
private void FillSurrogateSortKeyRaw(int i, SortKeyBuffer buf)
|
||||
{
|
||||
int num;
|
||||
int num2;
|
||||
byte b;
|
||||
if (i < 55360)
|
||||
{
|
||||
num = 55296;
|
||||
num2 = 65;
|
||||
b = ((i != 55296) ? 63 : 62);
|
||||
}
|
||||
else if (55360 <= i && i < 55424)
|
||||
{
|
||||
num = 55360;
|
||||
num2 = 242;
|
||||
b = 62;
|
||||
}
|
||||
else if (56192 <= i && i < 56320)
|
||||
{
|
||||
num = 56128;
|
||||
num2 = 254;
|
||||
b = 62;
|
||||
}
|
||||
else
|
||||
{
|
||||
num = 56074;
|
||||
num2 = 65;
|
||||
b = 63;
|
||||
}
|
||||
int num3 = i - num;
|
||||
buf.AppendNormal((byte)(num2 + num3 / 254), (byte)(num3 % 254 + 2), b, b);
|
||||
}
|
||||
|
||||
// Token: 0x060007F1 RID: 2033 RVA: 0x0001ABFC File Offset: 0x00018DFC
|
||||
public int Compare(string s1, string s2)
|
||||
{
|
||||
return this.Compare(s1, s2, CompareOptions.None);
|
||||
}
|
||||
|
||||
// Token: 0x060007F2 RID: 2034 RVA: 0x0001AC08 File Offset: 0x00018E08
|
||||
public int Compare(string s1, string s2, CompareOptions options)
|
||||
{
|
||||
return this.Compare(s1, 0, s1.Length, s2, 0, s2.Length, options);
|
||||
}
|
||||
|
||||
// Token: 0x060007F3 RID: 2035 RVA: 0x0001AC2C File Offset: 0x00018E2C
|
||||
private int CompareOrdinal(string s1, int idx1, int len1, string s2, int idx2, int len2)
|
||||
{
|
||||
int num = ((len1 >= len2) ? len2 : len1);
|
||||
int num2 = idx1 + num;
|
||||
int num3 = idx2 + num;
|
||||
if (idx1 < 0 || idx2 < 0 || num2 > s1.Length || num3 > s2.Length)
|
||||
{
|
||||
throw new SystemException(string.Format("CompareInfo Internal Error: Should not happen. {0} {1} {2} {3} {4} {5}", new object[] { idx1, idx2, len1, len2, s1.Length, s2.Length }));
|
||||
}
|
||||
int num4 = idx1;
|
||||
int num5 = idx2;
|
||||
while (num4 < num2 && num5 < num3)
|
||||
{
|
||||
if (s1[num4] != s2[num5])
|
||||
{
|
||||
return (int)(s1[num4] - s2[num5]);
|
||||
}
|
||||
num4++;
|
||||
num5++;
|
||||
}
|
||||
return (len1 != len2) ? ((len1 != num) ? 1 : (-1)) : 0;
|
||||
}
|
||||
|
||||
// Token: 0x060007F4 RID: 2036 RVA: 0x0001AD3C File Offset: 0x00018F3C
|
||||
private int CompareQuick(string s1, int idx1, int len1, string s2, int idx2, int len2, out bool sourceConsumed, out bool targetConsumed, bool immediateBreakup)
|
||||
{
|
||||
sourceConsumed = false;
|
||||
targetConsumed = false;
|
||||
int num = ((len1 >= len2) ? len2 : len1);
|
||||
int num2 = idx1 + num;
|
||||
int num3 = idx2 + num;
|
||||
if (idx1 < 0 || idx2 < 0 || num2 > s1.Length || num3 > s2.Length)
|
||||
{
|
||||
throw new SystemException(string.Format("CompareInfo Internal Error: Should not happen. {0} {1} {2} {3} {4} {5}", new object[] { idx1, idx2, len1, len2, s1.Length, s2.Length }));
|
||||
}
|
||||
int num4 = idx1;
|
||||
int num5 = idx2;
|
||||
while (num4 < num2 && num5 < num3)
|
||||
{
|
||||
if (s1[num4] != s2[num5])
|
||||
{
|
||||
if (immediateBreakup)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int num6 = (int)(this.Category((int)s1[num4]) - this.Category((int)s2[num5]));
|
||||
if (num6 == 0)
|
||||
{
|
||||
num6 = (int)(this.Level1((int)s1[num4]) - this.Level1((int)s2[num5]));
|
||||
}
|
||||
if (num6 == 0)
|
||||
{
|
||||
num6 = (int)(MSCompatUnicodeTable.Level3((int)s1[num4]) - MSCompatUnicodeTable.Level3((int)s2[num5]));
|
||||
}
|
||||
if (num6 == 0)
|
||||
{
|
||||
throw new SystemException(string.Format("CompareInfo Internal Error: Should not happen. '{0}' {2} {3} '{1}' {4} {5}", new object[] { s1, s2, idx1, num2, idx2, num3 }));
|
||||
}
|
||||
return num6;
|
||||
}
|
||||
else
|
||||
{
|
||||
num4++;
|
||||
num5++;
|
||||
}
|
||||
}
|
||||
sourceConsumed = len1 <= len2;
|
||||
targetConsumed = len1 >= len2;
|
||||
return (len1 != len2) ? ((len1 != num) ? 1 : (-1)) : 0;
|
||||
}
|
||||
|
||||
// Token: 0x060007F5 RID: 2037 RVA: 0x0001AF18 File Offset: 0x00019118
|
||||
private int CompareOrdinalIgnoreCase(string s1, int idx1, int len1, string s2, int idx2, int len2)
|
||||
{
|
||||
int num = ((len1 >= len2) ? len2 : len1);
|
||||
int num2 = idx1 + num;
|
||||
int num3 = idx2 + num;
|
||||
if (idx1 < 0 || idx2 < 0 || num2 > s1.Length || num3 > s2.Length)
|
||||
{
|
||||
throw new SystemException(string.Format("CompareInfo Internal Error: Should not happen. {0} {1} {2} {3} {4} {5}", new object[] { idx1, idx2, len1, len2, s1.Length, s2.Length }));
|
||||
}
|
||||
TextInfo textInfo = SimpleCollator.invariant.textInfo;
|
||||
int num4 = idx1;
|
||||
int num5 = idx2;
|
||||
while (num4 < num2 && num5 < num3)
|
||||
{
|
||||
if (textInfo.ToLower(s1[num4]) != textInfo.ToLower(s2[num5]))
|
||||
{
|
||||
return (int)(textInfo.ToLower(s1[num4]) - textInfo.ToLower(s2[num5]));
|
||||
}
|
||||
num4++;
|
||||
num5++;
|
||||
}
|
||||
return (len1 != len2) ? ((len1 != num) ? 1 : (-1)) : 0;
|
||||
}
|
||||
|
||||
// Token: 0x060007F6 RID: 2038 RVA: 0x0001B050 File Offset: 0x00019250
|
||||
public unsafe int Compare(string s1, int idx1, int len1, string s2, int idx2, int len2, CompareOptions options)
|
||||
{
|
||||
if (idx1 == idx2 && len1 == len2 && object.ReferenceEquals(s1, s2))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (options == CompareOptions.Ordinal)
|
||||
{
|
||||
return this.CompareOrdinal(s1, idx1, len1, s2, idx2, len2);
|
||||
}
|
||||
if (options == CompareOptions.OrdinalIgnoreCase)
|
||||
{
|
||||
return this.CompareOrdinalIgnoreCase(s1, idx1, len1, s2, idx2, len2);
|
||||
}
|
||||
byte* ptr;
|
||||
byte* ptr2;
|
||||
checked
|
||||
{
|
||||
ptr = stackalloc byte[4 * 1];
|
||||
ptr2 = stackalloc byte[4 * 1];
|
||||
this.ClearBuffer(ptr, 4);
|
||||
this.ClearBuffer(ptr2, 4);
|
||||
}
|
||||
SimpleCollator.Context context = new SimpleCollator.Context(options, null, null, ptr, ptr2, null, this.QuickCheckPossible(s1, idx1, idx1 + len1, s2, idx2, idx2 + len2));
|
||||
bool flag;
|
||||
bool flag2;
|
||||
int num = this.CompareInternal(s1, idx1, len1, s2, idx2, len2, out flag, out flag2, true, false, ref context);
|
||||
return (num != 0) ? ((num >= 0) ? 1 : (-1)) : 0;
|
||||
}
|
||||
|
||||
// Token: 0x060007F7 RID: 2039 RVA: 0x0001B12C File Offset: 0x0001932C
|
||||
private unsafe void ClearBuffer(byte* buffer, int size)
|
||||
{
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
buffer[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060007F8 RID: 2040 RVA: 0x0001B150 File Offset: 0x00019350
|
||||
private bool QuickCheckPossible(string s1, int idx1, int end1, string s2, int idx2, int end2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Token: 0x060007F9 RID: 2041 RVA: 0x0001B154 File Offset: 0x00019354
|
||||
private unsafe int CompareInternal(string s1, int idx1, int len1, string s2, int idx2, int len2, out bool targetConsumed, out bool sourceConsumed, bool skipHeadingExtenders, bool immediateBreakup, ref SimpleCollator.Context ctx)
|
||||
{
|
||||
CompareOptions option = ctx.Option;
|
||||
int num = idx1;
|
||||
int num2 = idx2;
|
||||
int num3 = idx1 + len1;
|
||||
int num4 = idx2 + len2;
|
||||
targetConsumed = false;
|
||||
sourceConsumed = false;
|
||||
SimpleCollator.PreviousInfo previousInfo = new SimpleCollator.PreviousInfo(false);
|
||||
if (option == CompareOptions.None && ctx.QuickCheckPossible)
|
||||
{
|
||||
return this.CompareQuick(s1, idx1, len1, s2, idx2, len2, out sourceConsumed, out targetConsumed, immediateBreakup);
|
||||
}
|
||||
int num5 = 0;
|
||||
int num6 = 5;
|
||||
int num7 = -1;
|
||||
int num8 = -1;
|
||||
int num9 = 0;
|
||||
int num10 = 0;
|
||||
if (skipHeadingExtenders)
|
||||
{
|
||||
while (idx1 < num3)
|
||||
{
|
||||
if (this.GetExtenderType((int)s1[idx1]) == SimpleCollator.ExtenderType.None)
|
||||
{
|
||||
break;
|
||||
}
|
||||
idx1++;
|
||||
}
|
||||
while (idx2 < num4)
|
||||
{
|
||||
if (this.GetExtenderType((int)s2[idx2]) == SimpleCollator.ExtenderType.None)
|
||||
{
|
||||
break;
|
||||
}
|
||||
idx2++;
|
||||
}
|
||||
}
|
||||
SimpleCollator.ExtenderType extenderType = SimpleCollator.ExtenderType.None;
|
||||
SimpleCollator.ExtenderType extenderType2 = SimpleCollator.ExtenderType.None;
|
||||
int num11 = idx1;
|
||||
int num12 = idx2;
|
||||
bool flag = (option & CompareOptions.StringSort) != CompareOptions.None;
|
||||
bool flag2 = (option & CompareOptions.IgnoreNonSpace) != CompareOptions.None;
|
||||
SimpleCollator.Escape escape = default(SimpleCollator.Escape);
|
||||
SimpleCollator.Escape escape2 = default(SimpleCollator.Escape);
|
||||
for (;;)
|
||||
{
|
||||
while (idx1 < num3)
|
||||
{
|
||||
if (!SimpleCollator.IsIgnorable((int)s1[idx1], option))
|
||||
{
|
||||
break;
|
||||
}
|
||||
idx1++;
|
||||
}
|
||||
while (idx2 < num4)
|
||||
{
|
||||
if (!SimpleCollator.IsIgnorable((int)s2[idx2], option))
|
||||
{
|
||||
break;
|
||||
}
|
||||
idx2++;
|
||||
}
|
||||
if (idx1 >= num3)
|
||||
{
|
||||
if (escape.Source == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
s1 = escape.Source;
|
||||
num = escape.Start;
|
||||
idx1 = escape.Index;
|
||||
num3 = escape.End;
|
||||
num11 = escape.Optional;
|
||||
escape.Source = null;
|
||||
}
|
||||
else if (idx2 >= num4)
|
||||
{
|
||||
if (escape2.Source == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
s2 = escape2.Source;
|
||||
num2 = escape2.Start;
|
||||
idx2 = escape2.Index;
|
||||
num4 = escape2.End;
|
||||
num12 = escape2.Optional;
|
||||
escape2.Source = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (num11 < idx1 && num12 < idx2)
|
||||
{
|
||||
while (idx1 < num3 && idx2 < num4 && s1[idx1] == s2[idx2])
|
||||
{
|
||||
idx1++;
|
||||
idx2++;
|
||||
}
|
||||
if (idx1 == num3 || idx2 == num4)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int num13 = num11;
|
||||
int num14 = num12;
|
||||
num11 = idx1;
|
||||
num12 = idx2;
|
||||
idx1--;
|
||||
idx2--;
|
||||
while (idx1 > num13)
|
||||
{
|
||||
if (this.Category((int)s1[idx1]) != 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
idx1--;
|
||||
}
|
||||
while (idx2 > num14)
|
||||
{
|
||||
if (this.Category((int)s2[idx2]) != 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
idx2--;
|
||||
}
|
||||
while (idx1 > num13)
|
||||
{
|
||||
if (this.IsSafe((int)s1[idx1]))
|
||||
{
|
||||
break;
|
||||
}
|
||||
idx1--;
|
||||
}
|
||||
while (idx2 > num14)
|
||||
{
|
||||
if (this.IsSafe((int)s2[idx2]))
|
||||
{
|
||||
break;
|
||||
}
|
||||
idx2--;
|
||||
}
|
||||
}
|
||||
int num15 = idx1;
|
||||
int num16 = idx2;
|
||||
byte* ptr = null;
|
||||
byte* ptr2 = null;
|
||||
int num17 = this.FilterOptions((int)s1[idx1], option);
|
||||
int num18 = this.FilterOptions((int)s2[idx2], option);
|
||||
bool flag3 = false;
|
||||
bool flag4 = false;
|
||||
extenderType = this.GetExtenderType(num17);
|
||||
if (extenderType != SimpleCollator.ExtenderType.None)
|
||||
{
|
||||
if (ctx.PrevCode < 0)
|
||||
{
|
||||
if (ctx.PrevSortKey == null)
|
||||
{
|
||||
idx1++;
|
||||
continue;
|
||||
}
|
||||
ptr = ctx.PrevSortKey;
|
||||
}
|
||||
else
|
||||
{
|
||||
num17 = this.FilterExtender(ctx.PrevCode, extenderType, option);
|
||||
}
|
||||
}
|
||||
extenderType2 = this.GetExtenderType(num18);
|
||||
if (extenderType2 != SimpleCollator.ExtenderType.None)
|
||||
{
|
||||
if (previousInfo.Code < 0)
|
||||
{
|
||||
if (previousInfo.SortKey == null)
|
||||
{
|
||||
idx2++;
|
||||
continue;
|
||||
}
|
||||
ptr2 = previousInfo.SortKey;
|
||||
}
|
||||
else
|
||||
{
|
||||
num18 = this.FilterExtender(previousInfo.Code, extenderType2, option);
|
||||
}
|
||||
}
|
||||
byte b = this.Category(num17);
|
||||
byte b2 = this.Category(num18);
|
||||
if (b == 6)
|
||||
{
|
||||
if (!flag && num6 == 5)
|
||||
{
|
||||
num7 = ((escape.Source == null) ? (num15 - num) : (escape.Index - escape.Start));
|
||||
num9 = (int)this.Level1(num17) << (int)(8 + MSCompatUnicodeTable.Level3(num17));
|
||||
}
|
||||
ctx.PrevCode = num17;
|
||||
idx1++;
|
||||
}
|
||||
if (b2 == 6)
|
||||
{
|
||||
if (!flag && num6 == 5)
|
||||
{
|
||||
num8 = ((escape2.Source == null) ? (num16 - num2) : (escape2.Index - escape2.Start));
|
||||
num10 = (int)this.Level1(num18) << (int)(8 + MSCompatUnicodeTable.Level3(num18));
|
||||
}
|
||||
previousInfo.Code = num18;
|
||||
idx2++;
|
||||
}
|
||||
if (b == 6 || b2 == 6)
|
||||
{
|
||||
if (num6 == 5)
|
||||
{
|
||||
if (num9 == num10)
|
||||
{
|
||||
num8 = (num7 = -1);
|
||||
num10 = (num9 = 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
num6 = 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Contraction contraction = null;
|
||||
if (extenderType == SimpleCollator.ExtenderType.None)
|
||||
{
|
||||
contraction = this.GetContraction(s1, idx1, num3);
|
||||
}
|
||||
int num19 = 1;
|
||||
if (ptr != null)
|
||||
{
|
||||
num19 = 1;
|
||||
}
|
||||
else if (contraction != null)
|
||||
{
|
||||
num19 = contraction.Source.Length;
|
||||
if (contraction.SortKey != null)
|
||||
{
|
||||
ptr = ctx.Buffer1;
|
||||
for (int i = 0; i < contraction.SortKey.Length; i++)
|
||||
{
|
||||
ptr[i] = contraction.SortKey[i];
|
||||
}
|
||||
ctx.PrevCode = -1;
|
||||
ctx.PrevSortKey = ptr;
|
||||
}
|
||||
else if (escape.Source == null)
|
||||
{
|
||||
escape.Source = s1;
|
||||
escape.Start = num;
|
||||
escape.Index = num15 + contraction.Source.Length;
|
||||
escape.End = num3;
|
||||
escape.Optional = num11;
|
||||
s1 = contraction.Replacement;
|
||||
idx1 = 0;
|
||||
num = 0;
|
||||
num3 = s1.Length;
|
||||
num11 = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr = ctx.Buffer1;
|
||||
*ptr = b;
|
||||
ptr[1] = this.Level1(num17);
|
||||
if (!flag2 && num6 > 1)
|
||||
{
|
||||
ptr[2] = this.Level2(num17, extenderType);
|
||||
}
|
||||
if (num6 > 2)
|
||||
{
|
||||
ptr[3] = MSCompatUnicodeTable.Level3(num17);
|
||||
}
|
||||
if (num6 > 3)
|
||||
{
|
||||
flag3 = MSCompatUnicodeTable.HasSpecialWeight((char)num17);
|
||||
}
|
||||
if (b > 1)
|
||||
{
|
||||
ctx.PrevCode = num17;
|
||||
}
|
||||
}
|
||||
Contraction contraction2 = null;
|
||||
if (extenderType2 == SimpleCollator.ExtenderType.None)
|
||||
{
|
||||
contraction2 = this.GetContraction(s2, idx2, num4);
|
||||
}
|
||||
if (ptr2 != null)
|
||||
{
|
||||
idx2++;
|
||||
}
|
||||
else if (contraction2 != null)
|
||||
{
|
||||
idx2 += contraction2.Source.Length;
|
||||
if (contraction2.SortKey != null)
|
||||
{
|
||||
ptr2 = ctx.Buffer2;
|
||||
for (int j = 0; j < contraction2.SortKey.Length; j++)
|
||||
{
|
||||
ptr2[j] = contraction2.SortKey[j];
|
||||
}
|
||||
previousInfo.Code = -1;
|
||||
previousInfo.SortKey = ptr2;
|
||||
}
|
||||
else if (escape2.Source == null)
|
||||
{
|
||||
escape2.Source = s2;
|
||||
escape2.Start = num2;
|
||||
escape2.Index = num16 + contraction2.Source.Length;
|
||||
escape2.End = num4;
|
||||
escape2.Optional = num12;
|
||||
s2 = contraction2.Replacement;
|
||||
idx2 = 0;
|
||||
num2 = 0;
|
||||
num4 = s2.Length;
|
||||
num12 = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr2 = ctx.Buffer2;
|
||||
*ptr2 = b2;
|
||||
ptr2[1] = this.Level1(num18);
|
||||
if (!flag2 && num6 > 1)
|
||||
{
|
||||
ptr2[2] = this.Level2(num18, extenderType2);
|
||||
}
|
||||
if (num6 > 2)
|
||||
{
|
||||
ptr2[3] = MSCompatUnicodeTable.Level3(num18);
|
||||
}
|
||||
if (num6 > 3)
|
||||
{
|
||||
flag4 = MSCompatUnicodeTable.HasSpecialWeight((char)num18);
|
||||
}
|
||||
if (b2 > 1)
|
||||
{
|
||||
previousInfo.Code = num18;
|
||||
}
|
||||
idx2++;
|
||||
}
|
||||
idx1 += num19;
|
||||
if (!flag2)
|
||||
{
|
||||
while (idx1 < num3)
|
||||
{
|
||||
if (this.Category((int)s1[idx1]) != 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (ptr[2] == 0)
|
||||
{
|
||||
ptr[2] = 2;
|
||||
}
|
||||
ptr[2] = ptr[2] + this.Level2((int)s1[idx1], SimpleCollator.ExtenderType.None);
|
||||
idx1++;
|
||||
}
|
||||
while (idx2 < num4)
|
||||
{
|
||||
if (this.Category((int)s2[idx2]) != 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (ptr2[2] == 0)
|
||||
{
|
||||
ptr2[2] = 2;
|
||||
}
|
||||
ptr2[2] = ptr2[2] + this.Level2((int)s2[idx2], SimpleCollator.ExtenderType.None);
|
||||
idx2++;
|
||||
}
|
||||
}
|
||||
int num20 = (int)(*ptr - *ptr2);
|
||||
num20 = ((num20 == 0) ? ((int)(ptr[1] - ptr2[1])) : num20);
|
||||
if (num20 != 0)
|
||||
{
|
||||
return num20;
|
||||
}
|
||||
if (num6 != 1)
|
||||
{
|
||||
if (!flag2)
|
||||
{
|
||||
num20 = (int)(ptr[2] - ptr2[2]);
|
||||
if (num20 != 0)
|
||||
{
|
||||
num5 = num20;
|
||||
if (immediateBreakup)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
num6 = ((!this.frenchSort) ? 1 : 2);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (num6 != 2)
|
||||
{
|
||||
num20 = (int)(ptr[3] - ptr2[3]);
|
||||
if (num20 != 0)
|
||||
{
|
||||
num5 = num20;
|
||||
if (immediateBreakup)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
num6 = 2;
|
||||
}
|
||||
else if (num6 != 3)
|
||||
{
|
||||
if (flag3 != flag4)
|
||||
{
|
||||
if (immediateBreakup)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
num5 = ((!flag3) ? (-1) : 1);
|
||||
num6 = 3;
|
||||
}
|
||||
else if (flag3)
|
||||
{
|
||||
num20 = this.CompareFlagPair(!MSCompatUnicodeTable.IsJapaneseSmallLetter((char)num17), !MSCompatUnicodeTable.IsJapaneseSmallLetter((char)num18));
|
||||
num20 = ((num20 == 0) ? ((int)(SimpleCollator.ToDashTypeValue(extenderType, option) - SimpleCollator.ToDashTypeValue(extenderType2, option))) : num20);
|
||||
num20 = ((num20 == 0) ? this.CompareFlagPair(MSCompatUnicodeTable.IsHiragana((char)num17), MSCompatUnicodeTable.IsHiragana((char)num18)) : num20);
|
||||
num20 = ((num20 == 0) ? this.CompareFlagPair(!SimpleCollator.IsHalfKana((int)((ushort)num17), option), !SimpleCollator.IsHalfKana((int)((ushort)num18), option)) : num20);
|
||||
if (num20 != 0)
|
||||
{
|
||||
if (immediateBreakup)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
num5 = num20;
|
||||
num6 = 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!flag2 && num5 != 0 && num6 > 2)
|
||||
{
|
||||
while (idx1 < num3 && idx2 < num4)
|
||||
{
|
||||
if (!MSCompatUnicodeTable.IsIgnorableNonSpacing((int)s1[idx1]))
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (!MSCompatUnicodeTable.IsIgnorableNonSpacing((int)s2[idx2]))
|
||||
{
|
||||
break;
|
||||
}
|
||||
num5 = (int)(this.Level2(this.FilterOptions((int)s1[idx1], option), extenderType) - this.Level2(this.FilterOptions((int)s2[idx2], option), extenderType2));
|
||||
if (num5 != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
idx1++;
|
||||
idx2++;
|
||||
extenderType = SimpleCollator.ExtenderType.None;
|
||||
extenderType2 = SimpleCollator.ExtenderType.None;
|
||||
}
|
||||
}
|
||||
if (num6 == 1 && num5 != 0)
|
||||
{
|
||||
while (idx1 < num3)
|
||||
{
|
||||
if (!MSCompatUnicodeTable.IsIgnorableNonSpacing((int)s1[idx1]))
|
||||
{
|
||||
break;
|
||||
}
|
||||
idx1++;
|
||||
}
|
||||
while (idx2 < num4)
|
||||
{
|
||||
if (!MSCompatUnicodeTable.IsIgnorableNonSpacing((int)s2[idx2]))
|
||||
{
|
||||
break;
|
||||
}
|
||||
idx2++;
|
||||
}
|
||||
}
|
||||
if (num5 == 0)
|
||||
{
|
||||
if (num7 < 0 && num8 >= 0)
|
||||
{
|
||||
num5 = -1;
|
||||
}
|
||||
else if (num8 < 0 && num7 >= 0)
|
||||
{
|
||||
num5 = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
num5 = num7 - num8;
|
||||
if (num5 == 0)
|
||||
{
|
||||
num5 = num9 - num10;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (num5 == 0)
|
||||
{
|
||||
if (idx2 == num4)
|
||||
{
|
||||
targetConsumed = true;
|
||||
}
|
||||
if (idx1 == num3)
|
||||
{
|
||||
sourceConsumed = true;
|
||||
}
|
||||
}
|
||||
return (idx1 == num3) ? ((idx2 != num4) ? (-1) : num5) : 1;
|
||||
}
|
||||
|
||||
// Token: 0x060007FA RID: 2042 RVA: 0x0001BD38 File Offset: 0x00019F38
|
||||
private int CompareFlagPair(bool b1, bool b2)
|
||||
{
|
||||
return (b1 != b2) ? ((!b1) ? (-1) : 1) : 0;
|
||||
}
|
||||
|
||||
// Token: 0x060007FB RID: 2043 RVA: 0x0001BD54 File Offset: 0x00019F54
|
||||
public bool IsPrefix(string src, string target, CompareOptions opt)
|
||||
{
|
||||
return this.IsPrefix(src, target, 0, src.Length, opt);
|
||||
}
|
||||
|
||||
// Token: 0x060007FC RID: 2044 RVA: 0x0001BD74 File Offset: 0x00019F74
|
||||
public unsafe bool IsPrefix(string s, string target, int start, int length, CompareOptions opt)
|
||||
{
|
||||
if (target.Length == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
byte* ptr;
|
||||
byte* ptr2;
|
||||
checked
|
||||
{
|
||||
ptr = stackalloc byte[4 * 1];
|
||||
ptr2 = stackalloc byte[4 * 1];
|
||||
this.ClearBuffer(ptr, 4);
|
||||
this.ClearBuffer(ptr2, 4);
|
||||
}
|
||||
SimpleCollator.Context context = new SimpleCollator.Context(opt, null, null, ptr, ptr2, null, this.QuickCheckPossible(s, start, start + length, target, 0, target.Length));
|
||||
return this.IsPrefix(s, target, start, length, true, ref context);
|
||||
}
|
||||
|
||||
// Token: 0x060007FD RID: 2045 RVA: 0x0001BDE0 File Offset: 0x00019FE0
|
||||
private bool IsPrefix(string s, string target, int start, int length, bool skipHeadingExtenders, ref SimpleCollator.Context ctx)
|
||||
{
|
||||
bool flag;
|
||||
bool flag2;
|
||||
this.CompareInternal(s, start, length, target, 0, target.Length, out flag, out flag2, skipHeadingExtenders, true, ref ctx);
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x060007FE RID: 2046 RVA: 0x0001BE0C File Offset: 0x0001A00C
|
||||
public bool IsSuffix(string src, string target, CompareOptions opt)
|
||||
{
|
||||
return this.IsSuffix(src, target, src.Length - 1, src.Length, opt);
|
||||
}
|
||||
|
||||
// Token: 0x060007FF RID: 2047 RVA: 0x0001BE30 File Offset: 0x0001A030
|
||||
public bool IsSuffix(string s, string target, int start, int length, CompareOptions opt)
|
||||
{
|
||||
if (target.Length == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
int num = this.LastIndexOf(s, target, start, length, opt);
|
||||
return num >= 0 && this.Compare(s, num, s.Length - num, target, 0, target.Length, opt) == 0;
|
||||
}
|
||||
|
||||
// Token: 0x06000800 RID: 2048 RVA: 0x0001BE80 File Offset: 0x0001A080
|
||||
public int IndexOf(string s, string target, CompareOptions opt)
|
||||
{
|
||||
return this.IndexOf(s, target, 0, s.Length, opt);
|
||||
}
|
||||
|
||||
// Token: 0x06000801 RID: 2049 RVA: 0x0001BEA0 File Offset: 0x0001A0A0
|
||||
private int QuickIndexOf(string s, string target, int start, int length, out bool testWasUnable)
|
||||
{
|
||||
int num = -1;
|
||||
int num2 = -1;
|
||||
testWasUnable = true;
|
||||
if (target.Length == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (target.Length > length)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
testWasUnable = false;
|
||||
int num3 = start + length - target.Length + 1;
|
||||
for (int i = start; i < num3; i++)
|
||||
{
|
||||
bool flag = false;
|
||||
for (int j = 0; j < target.Length; j++)
|
||||
{
|
||||
if (num2 < j)
|
||||
{
|
||||
if (target[j] >= '\u0080')
|
||||
{
|
||||
testWasUnable = true;
|
||||
return -1;
|
||||
}
|
||||
num2 = j;
|
||||
}
|
||||
if (num < i + j)
|
||||
{
|
||||
if (s[i + j] >= '\u0080')
|
||||
{
|
||||
testWasUnable = true;
|
||||
return -1;
|
||||
}
|
||||
num = i + j;
|
||||
}
|
||||
if (s[i + j] != target[j])
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Token: 0x06000802 RID: 2050 RVA: 0x0001BF90 File Offset: 0x0001A190
|
||||
public unsafe int IndexOf(string s, string target, int start, int length, CompareOptions opt)
|
||||
{
|
||||
if (opt == CompareOptions.Ordinal)
|
||||
{
|
||||
return this.IndexOfOrdinal(s, target, start, length);
|
||||
}
|
||||
if (opt == CompareOptions.OrdinalIgnoreCase)
|
||||
{
|
||||
return this.IndexOfOrdinalIgnoreCase(s, target, start, length);
|
||||
}
|
||||
if (opt == CompareOptions.None)
|
||||
{
|
||||
bool flag;
|
||||
int num = this.QuickIndexOf(s, target, start, length, out flag);
|
||||
if (!flag)
|
||||
{
|
||||
return num;
|
||||
}
|
||||
}
|
||||
checked
|
||||
{
|
||||
byte* ptr = stackalloc byte[16 * 1];
|
||||
byte* ptr2 = stackalloc byte[16 * 1];
|
||||
byte* ptr3 = stackalloc byte[4 * 1];
|
||||
byte* ptr4 = stackalloc byte[4 * 1];
|
||||
byte* ptr5 = stackalloc byte[4 * 1];
|
||||
this.ClearBuffer(ptr, 16);
|
||||
this.ClearBuffer(ptr2, 16);
|
||||
this.ClearBuffer(ptr3, 4);
|
||||
this.ClearBuffer(ptr4, 4);
|
||||
this.ClearBuffer(ptr5, 4);
|
||||
SimpleCollator.Context context = new SimpleCollator.Context(opt, ptr, ptr2, ptr4, ptr5, null, false);
|
||||
return this.IndexOf(s, target, start, length, ptr3, ref context);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000803 RID: 2051 RVA: 0x0001C05C File Offset: 0x0001A25C
|
||||
private int IndexOfOrdinal(string s, string target, int start, int length)
|
||||
{
|
||||
if (target.Length == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (target.Length > length)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int num = start + length - target.Length + 1;
|
||||
for (int i = start; i < num; i++)
|
||||
{
|
||||
bool flag = false;
|
||||
for (int j = 0; j < target.Length; j++)
|
||||
{
|
||||
if (s[i + j] != target[j])
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Token: 0x06000804 RID: 2052 RVA: 0x0001C0E8 File Offset: 0x0001A2E8
|
||||
private int IndexOfOrdinalIgnoreCase(string s, string target, int start, int length)
|
||||
{
|
||||
if (target.Length == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (target.Length > length)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int num = start + length - target.Length + 1;
|
||||
for (int i = start; i < num; i++)
|
||||
{
|
||||
bool flag = false;
|
||||
for (int j = 0; j < target.Length; j++)
|
||||
{
|
||||
if (this.textInfo.ToLower(s[i + j]) != this.textInfo.ToLower(target[j]))
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Token: 0x06000805 RID: 2053 RVA: 0x0001C18C File Offset: 0x0001A38C
|
||||
public int IndexOf(string s, char target, CompareOptions opt)
|
||||
{
|
||||
return this.IndexOf(s, target, 0, s.Length, opt);
|
||||
}
|
||||
|
||||
// Token: 0x06000806 RID: 2054 RVA: 0x0001C1AC File Offset: 0x0001A3AC
|
||||
public unsafe int IndexOf(string s, char target, int start, int length, CompareOptions opt)
|
||||
{
|
||||
if (opt == CompareOptions.Ordinal)
|
||||
{
|
||||
return this.IndexOfOrdinal(s, target, start, length);
|
||||
}
|
||||
if (opt == CompareOptions.OrdinalIgnoreCase)
|
||||
{
|
||||
return this.IndexOfOrdinalIgnoreCase(s, target, start, length);
|
||||
}
|
||||
byte* ptr3;
|
||||
byte* ptr5;
|
||||
SimpleCollator.Context context;
|
||||
Contraction contraction;
|
||||
checked
|
||||
{
|
||||
byte* ptr = stackalloc byte[16 * 1];
|
||||
byte* ptr2 = stackalloc byte[16 * 1];
|
||||
ptr3 = stackalloc byte[4 * 1];
|
||||
byte* ptr4 = stackalloc byte[4 * 1];
|
||||
ptr5 = stackalloc byte[4 * 1];
|
||||
this.ClearBuffer(ptr, 16);
|
||||
this.ClearBuffer(ptr2, 16);
|
||||
this.ClearBuffer(ptr3, 4);
|
||||
this.ClearBuffer(ptr4, 4);
|
||||
this.ClearBuffer(ptr5, 4);
|
||||
context = new SimpleCollator.Context(opt, ptr, ptr2, ptr4, ptr5, null, false);
|
||||
contraction = this.GetContraction(target);
|
||||
}
|
||||
if (contraction == null)
|
||||
{
|
||||
int num = this.FilterOptions((int)target, opt);
|
||||
*ptr3 = this.Category(num);
|
||||
ptr3[1] = this.Level1(num);
|
||||
if ((opt & CompareOptions.IgnoreNonSpace) == CompareOptions.None)
|
||||
{
|
||||
ptr3[2] = this.Level2(num, SimpleCollator.ExtenderType.None);
|
||||
}
|
||||
ptr3[3] = MSCompatUnicodeTable.Level3(num);
|
||||
return this.IndexOfSortKey(s, start, length, ptr3, target, num, !MSCompatUnicodeTable.HasSpecialWeight((char)num), ref context);
|
||||
}
|
||||
if (contraction.Replacement != null)
|
||||
{
|
||||
return this.IndexOf(s, contraction.Replacement, start, length, ptr3, ref context);
|
||||
}
|
||||
for (int i = 0; i < contraction.SortKey.Length; i++)
|
||||
{
|
||||
ptr5[i] = contraction.SortKey[i];
|
||||
}
|
||||
return this.IndexOfSortKey(s, start, length, ptr5, '\0', -1, true, ref context);
|
||||
}
|
||||
|
||||
// Token: 0x06000807 RID: 2055 RVA: 0x0001C314 File Offset: 0x0001A514
|
||||
private int IndexOfOrdinal(string s, char target, int start, int length)
|
||||
{
|
||||
int num = start + length;
|
||||
for (int i = start; i < num; i++)
|
||||
{
|
||||
if (s[i] == target)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Token: 0x06000808 RID: 2056 RVA: 0x0001C348 File Offset: 0x0001A548
|
||||
private int IndexOfOrdinalIgnoreCase(string s, char target, int start, int length)
|
||||
{
|
||||
int num = start + length;
|
||||
target = this.textInfo.ToLower(target);
|
||||
for (int i = start; i < num; i++)
|
||||
{
|
||||
if (this.textInfo.ToLower(s[i]) == target)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Token: 0x06000809 RID: 2057 RVA: 0x0001C398 File Offset: 0x0001A598
|
||||
private unsafe int IndexOfSortKey(string s, int start, int length, byte* sortkey, char target, int ti, bool noLv4, ref SimpleCollator.Context ctx)
|
||||
{
|
||||
int num = start + length;
|
||||
int i = start;
|
||||
while (i < num)
|
||||
{
|
||||
int num2 = i;
|
||||
if (this.MatchesForward(s, ref i, num, ti, sortkey, noLv4, ref ctx))
|
||||
{
|
||||
return num2;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Token: 0x0600080A RID: 2058 RVA: 0x0001C3D4 File Offset: 0x0001A5D4
|
||||
private unsafe int IndexOf(string s, string target, int start, int length, byte* targetSortKey, ref SimpleCollator.Context ctx)
|
||||
{
|
||||
CompareOptions option = ctx.Option;
|
||||
int i;
|
||||
for (i = 0; i < target.Length; i++)
|
||||
{
|
||||
if (!SimpleCollator.IsIgnorable((int)target[i], option))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == target.Length)
|
||||
{
|
||||
return start;
|
||||
}
|
||||
Contraction contraction = this.GetContraction(target, i, target.Length - i);
|
||||
string text = ((contraction == null) ? null : contraction.Replacement);
|
||||
byte* ptr = ((text != null) ? null : targetSortKey);
|
||||
bool flag = true;
|
||||
char c = '\0';
|
||||
int num = -1;
|
||||
if (contraction != null && ptr != null)
|
||||
{
|
||||
for (int j = 0; j < contraction.SortKey.Length; j++)
|
||||
{
|
||||
ptr[j] = contraction.SortKey[j];
|
||||
}
|
||||
}
|
||||
else if (ptr != null)
|
||||
{
|
||||
c = target[i];
|
||||
num = this.FilterOptions((int)target[i], option);
|
||||
*ptr = this.Category(num);
|
||||
ptr[1] = this.Level1(num);
|
||||
if ((option & CompareOptions.IgnoreNonSpace) == CompareOptions.None)
|
||||
{
|
||||
ptr[2] = this.Level2(num, SimpleCollator.ExtenderType.None);
|
||||
}
|
||||
ptr[3] = MSCompatUnicodeTable.Level3(num);
|
||||
flag = !MSCompatUnicodeTable.HasSpecialWeight((char)num);
|
||||
}
|
||||
if (ptr != null)
|
||||
{
|
||||
for (i++; i < target.Length; i++)
|
||||
{
|
||||
if (this.Category((int)target[i]) != 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (ptr[2] == 0)
|
||||
{
|
||||
ptr[2] = 2;
|
||||
}
|
||||
ptr[2] = ptr[2] + this.Level2((int)target[i], SimpleCollator.ExtenderType.None);
|
||||
}
|
||||
}
|
||||
for (;;)
|
||||
{
|
||||
int num2;
|
||||
if (text != null)
|
||||
{
|
||||
num2 = this.IndexOf(s, text, start, length, targetSortKey, ref ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
num2 = this.IndexOfSortKey(s, start, length, ptr, c, num, flag, ref ctx);
|
||||
}
|
||||
if (num2 < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
length -= num2 - start;
|
||||
start = num2;
|
||||
if (this.IsPrefix(s, target, start, length, false, ref ctx))
|
||||
{
|
||||
return num2;
|
||||
}
|
||||
Contraction contraction2 = this.GetContraction(s, start, length);
|
||||
if (contraction2 != null)
|
||||
{
|
||||
start += contraction2.Source.Length;
|
||||
length -= contraction2.Source.Length;
|
||||
}
|
||||
else
|
||||
{
|
||||
start++;
|
||||
length--;
|
||||
}
|
||||
if (length <= 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Token: 0x0600080B RID: 2059 RVA: 0x0001C614 File Offset: 0x0001A814
|
||||
public int LastIndexOf(string s, string target, CompareOptions opt)
|
||||
{
|
||||
return this.LastIndexOf(s, target, s.Length - 1, s.Length, opt);
|
||||
}
|
||||
|
||||
// Token: 0x0600080C RID: 2060 RVA: 0x0001C638 File Offset: 0x0001A838
|
||||
public unsafe int LastIndexOf(string s, string target, int start, int length, CompareOptions opt)
|
||||
{
|
||||
if (opt == CompareOptions.Ordinal)
|
||||
{
|
||||
return this.LastIndexOfOrdinal(s, target, start, length);
|
||||
}
|
||||
if (opt == CompareOptions.OrdinalIgnoreCase)
|
||||
{
|
||||
return this.LastIndexOfOrdinalIgnoreCase(s, target, start, length);
|
||||
}
|
||||
checked
|
||||
{
|
||||
byte* ptr = stackalloc byte[16 * 1];
|
||||
byte* ptr2 = stackalloc byte[16 * 1];
|
||||
byte* ptr3 = stackalloc byte[4 * 1];
|
||||
byte* ptr4 = stackalloc byte[4 * 1];
|
||||
byte* ptr5 = stackalloc byte[4 * 1];
|
||||
this.ClearBuffer(ptr, 16);
|
||||
this.ClearBuffer(ptr2, 16);
|
||||
this.ClearBuffer(ptr3, 4);
|
||||
this.ClearBuffer(ptr4, 4);
|
||||
this.ClearBuffer(ptr5, 4);
|
||||
SimpleCollator.Context context = new SimpleCollator.Context(opt, ptr, ptr2, ptr4, ptr5, null, false);
|
||||
return this.LastIndexOf(s, target, start, length, ptr3, ref context);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600080D RID: 2061 RVA: 0x0001C6E0 File Offset: 0x0001A8E0
|
||||
private int LastIndexOfOrdinal(string s, string target, int start, int length)
|
||||
{
|
||||
if (target.Length == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (s.Length < target.Length || target.Length > length)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int num = start - length + target.Length - 1;
|
||||
char c = target[target.Length - 1];
|
||||
int i = start;
|
||||
while (i > num)
|
||||
{
|
||||
if (s[i] != c)
|
||||
{
|
||||
i--;
|
||||
}
|
||||
else
|
||||
{
|
||||
int num2 = i - target.Length + 1;
|
||||
i--;
|
||||
bool flag = false;
|
||||
for (int j = target.Length - 2; j >= 0; j--)
|
||||
{
|
||||
if (s[num2 + j] != target[j])
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
return num2;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Token: 0x0600080E RID: 2062 RVA: 0x0001C7B8 File Offset: 0x0001A9B8
|
||||
private int LastIndexOfOrdinalIgnoreCase(string s, string target, int start, int length)
|
||||
{
|
||||
if (target.Length == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (s.Length < length || target.Length > length)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int num = start - length + target.Length - 1;
|
||||
char c = this.textInfo.ToLower(target[target.Length - 1]);
|
||||
int i = start;
|
||||
while (i > num)
|
||||
{
|
||||
if (this.textInfo.ToLower(s[i]) != c)
|
||||
{
|
||||
i--;
|
||||
}
|
||||
else
|
||||
{
|
||||
int num2 = i - target.Length + 1;
|
||||
i--;
|
||||
bool flag = false;
|
||||
for (int j = target.Length - 2; j >= 0; j--)
|
||||
{
|
||||
if (this.textInfo.ToLower(s[num2 + j]) != this.textInfo.ToLower(target[j]))
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
return num2;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Token: 0x0600080F RID: 2063 RVA: 0x0001C8B8 File Offset: 0x0001AAB8
|
||||
public int LastIndexOf(string s, char target, CompareOptions opt)
|
||||
{
|
||||
return this.LastIndexOf(s, target, s.Length - 1, s.Length, opt);
|
||||
}
|
||||
|
||||
// Token: 0x06000810 RID: 2064 RVA: 0x0001C8DC File Offset: 0x0001AADC
|
||||
public unsafe int LastIndexOf(string s, char target, int start, int length, CompareOptions opt)
|
||||
{
|
||||
if (opt == CompareOptions.Ordinal)
|
||||
{
|
||||
return this.LastIndexOfOrdinal(s, target, start, length);
|
||||
}
|
||||
if (opt == CompareOptions.OrdinalIgnoreCase)
|
||||
{
|
||||
return this.LastIndexOfOrdinalIgnoreCase(s, target, start, length);
|
||||
}
|
||||
byte* ptr3;
|
||||
byte* ptr5;
|
||||
SimpleCollator.Context context;
|
||||
Contraction contraction;
|
||||
checked
|
||||
{
|
||||
byte* ptr = stackalloc byte[16 * 1];
|
||||
byte* ptr2 = stackalloc byte[16 * 1];
|
||||
ptr3 = stackalloc byte[4 * 1];
|
||||
byte* ptr4 = stackalloc byte[4 * 1];
|
||||
ptr5 = stackalloc byte[4 * 1];
|
||||
this.ClearBuffer(ptr, 16);
|
||||
this.ClearBuffer(ptr2, 16);
|
||||
this.ClearBuffer(ptr3, 4);
|
||||
this.ClearBuffer(ptr4, 4);
|
||||
this.ClearBuffer(ptr5, 4);
|
||||
context = new SimpleCollator.Context(opt, ptr, ptr2, ptr4, ptr5, null, false);
|
||||
contraction = this.GetContraction(target);
|
||||
}
|
||||
if (contraction == null)
|
||||
{
|
||||
int num = this.FilterOptions((int)target, opt);
|
||||
*ptr3 = this.Category(num);
|
||||
ptr3[1] = this.Level1(num);
|
||||
if ((opt & CompareOptions.IgnoreNonSpace) == CompareOptions.None)
|
||||
{
|
||||
ptr3[2] = this.Level2(num, SimpleCollator.ExtenderType.None);
|
||||
}
|
||||
ptr3[3] = MSCompatUnicodeTable.Level3(num);
|
||||
return this.LastIndexOfSortKey(s, start, start, length, ptr3, num, !MSCompatUnicodeTable.HasSpecialWeight((char)num), ref context);
|
||||
}
|
||||
if (contraction.Replacement != null)
|
||||
{
|
||||
return this.LastIndexOf(s, contraction.Replacement, start, length, ptr3, ref context);
|
||||
}
|
||||
for (int i = 0; i < contraction.SortKey.Length; i++)
|
||||
{
|
||||
ptr5[i] = contraction.SortKey[i];
|
||||
}
|
||||
return this.LastIndexOfSortKey(s, start, start, length, ptr5, -1, true, ref context);
|
||||
}
|
||||
|
||||
// Token: 0x06000811 RID: 2065 RVA: 0x0001CA44 File Offset: 0x0001AC44
|
||||
private int LastIndexOfOrdinal(string s, char target, int start, int length)
|
||||
{
|
||||
if (s.Length == 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int num = start - length;
|
||||
for (int i = start; i > num; i--)
|
||||
{
|
||||
if (s[i] == target)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Token: 0x06000812 RID: 2066 RVA: 0x0001CA88 File Offset: 0x0001AC88
|
||||
private int LastIndexOfOrdinalIgnoreCase(string s, char target, int start, int length)
|
||||
{
|
||||
if (s.Length == 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int num = start - length;
|
||||
char c = this.textInfo.ToUpper(target);
|
||||
for (int i = start; i > num; i--)
|
||||
{
|
||||
if (this.textInfo.ToUpper(s[i]) == c)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Token: 0x06000813 RID: 2067 RVA: 0x0001CAE4 File Offset: 0x0001ACE4
|
||||
private unsafe int LastIndexOfSortKey(string s, int start, int orgStart, int length, byte* sortkey, int ti, bool noLv4, ref SimpleCollator.Context ctx)
|
||||
{
|
||||
int num = start - length;
|
||||
int i = start;
|
||||
while (i > num)
|
||||
{
|
||||
int num2 = i;
|
||||
if (this.MatchesBackward(s, ref i, num, orgStart, ti, sortkey, noLv4, ref ctx))
|
||||
{
|
||||
return num2;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Token: 0x06000814 RID: 2068 RVA: 0x0001CB24 File Offset: 0x0001AD24
|
||||
private unsafe int LastIndexOf(string s, string target, int start, int length, byte* targetSortKey, ref SimpleCollator.Context ctx)
|
||||
{
|
||||
CompareOptions option = ctx.Option;
|
||||
int num = start;
|
||||
int i;
|
||||
for (i = 0; i < target.Length; i++)
|
||||
{
|
||||
if (!SimpleCollator.IsIgnorable((int)target[i], option))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == target.Length)
|
||||
{
|
||||
return start;
|
||||
}
|
||||
Contraction contraction = this.GetContraction(target, i, target.Length - i);
|
||||
string text = ((contraction == null) ? null : contraction.Replacement);
|
||||
byte* ptr = ((text != null) ? null : targetSortKey);
|
||||
bool flag = true;
|
||||
int num2 = -1;
|
||||
if (contraction != null && ptr != null)
|
||||
{
|
||||
for (int j = 0; j < contraction.SortKey.Length; j++)
|
||||
{
|
||||
ptr[j] = contraction.SortKey[j];
|
||||
}
|
||||
}
|
||||
else if (ptr != null)
|
||||
{
|
||||
num2 = this.FilterOptions((int)target[i], option);
|
||||
*ptr = this.Category(num2);
|
||||
ptr[1] = this.Level1(num2);
|
||||
if ((option & CompareOptions.IgnoreNonSpace) == CompareOptions.None)
|
||||
{
|
||||
ptr[2] = this.Level2(num2, SimpleCollator.ExtenderType.None);
|
||||
}
|
||||
ptr[3] = MSCompatUnicodeTable.Level3(num2);
|
||||
flag = !MSCompatUnicodeTable.HasSpecialWeight((char)num2);
|
||||
}
|
||||
if (ptr != null)
|
||||
{
|
||||
for (i++; i < target.Length; i++)
|
||||
{
|
||||
if (this.Category((int)target[i]) != 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (ptr[2] == 0)
|
||||
{
|
||||
ptr[2] = 2;
|
||||
}
|
||||
ptr[2] = ptr[2] + this.Level2((int)target[i], SimpleCollator.ExtenderType.None);
|
||||
}
|
||||
}
|
||||
int k;
|
||||
for (;;)
|
||||
{
|
||||
if (text != null)
|
||||
{
|
||||
k = this.LastIndexOf(s, text, start, length, targetSortKey, ref ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
k = this.LastIndexOfSortKey(s, start, num, length, ptr, num2, flag, ref ctx);
|
||||
}
|
||||
if (k < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
length -= start - k;
|
||||
start = k;
|
||||
if (this.IsPrefix(s, target, k, num - k + 1, false, ref ctx))
|
||||
{
|
||||
goto Block_15;
|
||||
}
|
||||
Contraction contraction2 = this.GetContraction(s, k, num - k + 1);
|
||||
if (contraction2 != null)
|
||||
{
|
||||
start -= contraction2.Source.Length;
|
||||
length -= contraction2.Source.Length;
|
||||
}
|
||||
else
|
||||
{
|
||||
start--;
|
||||
length--;
|
||||
}
|
||||
if (length <= 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
Block_15:
|
||||
while (k < num)
|
||||
{
|
||||
if (!SimpleCollator.IsIgnorable((int)s[k], option))
|
||||
{
|
||||
break;
|
||||
}
|
||||
k++;
|
||||
}
|
||||
return k;
|
||||
}
|
||||
|
||||
// Token: 0x06000815 RID: 2069 RVA: 0x0001CD94 File Offset: 0x0001AF94
|
||||
private unsafe bool MatchesForward(string s, ref int idx, int end, int ti, byte* sortkey, bool noLv4, ref SimpleCollator.Context ctx)
|
||||
{
|
||||
int num = (int)s[idx];
|
||||
if (ctx.AlwaysMatchFlags != null && num < 128 && ((int)ctx.AlwaysMatchFlags[num / 8] & (1 << num % 8)) != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (ctx.NeverMatchFlags != null && num < 128 && ((int)ctx.NeverMatchFlags[num / 8] & (1 << num % 8)) != 0)
|
||||
{
|
||||
idx++;
|
||||
return false;
|
||||
}
|
||||
SimpleCollator.ExtenderType extenderType = this.GetExtenderType((int)s[idx]);
|
||||
Contraction contraction = null;
|
||||
if (this.MatchesForwardCore(s, ref idx, end, ti, sortkey, noLv4, extenderType, ref contraction, ref ctx))
|
||||
{
|
||||
if (ctx.AlwaysMatchFlags != null && contraction == null && extenderType == SimpleCollator.ExtenderType.None && num < 128)
|
||||
{
|
||||
byte* ptr = ctx.AlwaysMatchFlags + num / 8;
|
||||
*ptr |= (byte)(1 << num % 8);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (ctx.NeverMatchFlags != null && contraction == null && extenderType == SimpleCollator.ExtenderType.None && num < 128)
|
||||
{
|
||||
byte* ptr2 = ctx.NeverMatchFlags + num / 8;
|
||||
*ptr2 |= (byte)(1 << num % 8);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Token: 0x06000816 RID: 2070 RVA: 0x0001CEBC File Offset: 0x0001B0BC
|
||||
private unsafe bool MatchesForwardCore(string s, ref int idx, int end, int ti, byte* sortkey, bool noLv4, SimpleCollator.ExtenderType ext, ref Contraction ct, ref SimpleCollator.Context ctx)
|
||||
{
|
||||
CompareOptions option = ctx.Option;
|
||||
byte* ptr = ctx.Buffer1;
|
||||
bool flag = (option & CompareOptions.IgnoreNonSpace) != CompareOptions.None;
|
||||
int num = -1;
|
||||
if (ext == SimpleCollator.ExtenderType.None)
|
||||
{
|
||||
ct = this.GetContraction(s, idx, end);
|
||||
}
|
||||
else if (ctx.PrevCode < 0)
|
||||
{
|
||||
if (ctx.PrevSortKey == null)
|
||||
{
|
||||
idx++;
|
||||
return false;
|
||||
}
|
||||
ptr = ctx.PrevSortKey;
|
||||
}
|
||||
else
|
||||
{
|
||||
num = this.FilterExtender(ctx.PrevCode, ext, option);
|
||||
}
|
||||
if (ct != null)
|
||||
{
|
||||
idx += ct.Source.Length;
|
||||
if (!noLv4)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (ct.SortKey == null)
|
||||
{
|
||||
int num2 = 0;
|
||||
return this.MatchesForward(ct.Replacement, ref num2, ct.Replacement.Length, ti, sortkey, noLv4, ref ctx);
|
||||
}
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
ptr[i] = sortkey[i];
|
||||
}
|
||||
ctx.PrevCode = -1;
|
||||
ctx.PrevSortKey = ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (num < 0)
|
||||
{
|
||||
num = this.FilterOptions((int)s[idx], option);
|
||||
}
|
||||
idx++;
|
||||
*ptr = this.Category(num);
|
||||
bool flag2 = false;
|
||||
if (*sortkey == *ptr)
|
||||
{
|
||||
ptr[1] = this.Level1(num);
|
||||
}
|
||||
else
|
||||
{
|
||||
flag2 = true;
|
||||
}
|
||||
if (!flag && sortkey[1] == ptr[1])
|
||||
{
|
||||
ptr[2] = this.Level2(num, ext);
|
||||
}
|
||||
else if (!flag)
|
||||
{
|
||||
flag2 = true;
|
||||
}
|
||||
if (flag2)
|
||||
{
|
||||
while (idx < end)
|
||||
{
|
||||
if (this.Category((int)s[idx]) != 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
ptr[3] = MSCompatUnicodeTable.Level3(num);
|
||||
if (*ptr != 1)
|
||||
{
|
||||
ctx.PrevCode = num;
|
||||
}
|
||||
}
|
||||
while (idx < end)
|
||||
{
|
||||
if (this.Category((int)s[idx]) != 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
if (ptr[2] == 0)
|
||||
{
|
||||
ptr[2] = 2;
|
||||
}
|
||||
ptr[2] = ptr[2] + this.Level2((int)s[idx], SimpleCollator.ExtenderType.None);
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
return this.MatchesPrimitive(option, ptr, num, ext, sortkey, ti, noLv4);
|
||||
}
|
||||
|
||||
// Token: 0x06000817 RID: 2071 RVA: 0x0001D104 File Offset: 0x0001B304
|
||||
private unsafe bool MatchesPrimitive(CompareOptions opt, byte* source, int si, SimpleCollator.ExtenderType ext, byte* target, int ti, bool noLv4)
|
||||
{
|
||||
bool flag = (opt & CompareOptions.IgnoreNonSpace) != CompareOptions.None;
|
||||
return *source == *target && source[1] == target[1] && (flag || source[2] == target[2]) && source[3] == target[3] && ((noLv4 && (si < 0 || !MSCompatUnicodeTable.HasSpecialWeight((char)si))) || (!noLv4 && (flag || ext != SimpleCollator.ExtenderType.Conditional) && MSCompatUnicodeTable.IsJapaneseSmallLetter((char)si) == MSCompatUnicodeTable.IsJapaneseSmallLetter((char)ti) && SimpleCollator.ToDashTypeValue(ext, opt) == SimpleCollator.ToDashTypeValue(SimpleCollator.ExtenderType.None, opt) && !MSCompatUnicodeTable.IsHiragana((char)si) == !MSCompatUnicodeTable.IsHiragana((char)ti) && SimpleCollator.IsHalfKana((int)((ushort)si), opt) == SimpleCollator.IsHalfKana((int)((ushort)ti), opt)));
|
||||
}
|
||||
|
||||
// Token: 0x06000818 RID: 2072 RVA: 0x0001D1E8 File Offset: 0x0001B3E8
|
||||
private unsafe bool MatchesBackward(string s, ref int idx, int end, int orgStart, int ti, byte* sortkey, bool noLv4, ref SimpleCollator.Context ctx)
|
||||
{
|
||||
int num = (int)s[idx];
|
||||
if (ctx.AlwaysMatchFlags != null && num < 128 && ((int)ctx.AlwaysMatchFlags[num / 8] & (1 << num % 8)) != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (ctx.NeverMatchFlags != null && num < 128 && ((int)ctx.NeverMatchFlags[num / 8] & (1 << num % 8)) != 0)
|
||||
{
|
||||
idx--;
|
||||
return false;
|
||||
}
|
||||
SimpleCollator.ExtenderType extenderType = this.GetExtenderType((int)s[idx]);
|
||||
Contraction contraction = null;
|
||||
if (this.MatchesBackwardCore(s, ref idx, end, orgStart, ti, sortkey, noLv4, extenderType, ref contraction, ref ctx))
|
||||
{
|
||||
if (ctx.AlwaysMatchFlags != null && contraction == null && extenderType == SimpleCollator.ExtenderType.None && num < 128)
|
||||
{
|
||||
byte* ptr = ctx.AlwaysMatchFlags + num / 8;
|
||||
*ptr |= (byte)(1 << num % 8);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (ctx.NeverMatchFlags != null && contraction == null && extenderType == SimpleCollator.ExtenderType.None && num < 128)
|
||||
{
|
||||
byte* ptr2 = ctx.NeverMatchFlags + num / 8;
|
||||
*ptr2 |= (byte)(1 << num % 8);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Token: 0x06000819 RID: 2073 RVA: 0x0001D314 File Offset: 0x0001B514
|
||||
private unsafe bool MatchesBackwardCore(string s, ref int idx, int end, int orgStart, int ti, byte* sortkey, bool noLv4, SimpleCollator.ExtenderType ext, ref Contraction ct, ref SimpleCollator.Context ctx)
|
||||
{
|
||||
CompareOptions option = ctx.Option;
|
||||
byte* buffer = ctx.Buffer1;
|
||||
bool flag = (option & CompareOptions.IgnoreNonSpace) != CompareOptions.None;
|
||||
int num = idx;
|
||||
int num2 = -1;
|
||||
if (ext != SimpleCollator.ExtenderType.None)
|
||||
{
|
||||
byte b = 0;
|
||||
for (int i = 0; i >= 0; i--)
|
||||
{
|
||||
if (!SimpleCollator.IsIgnorable((int)s[i], option))
|
||||
{
|
||||
int num3 = this.FilterOptions((int)s[i], option);
|
||||
byte b2 = this.Category(num3);
|
||||
if (b2 != 1)
|
||||
{
|
||||
num2 = this.FilterExtender(num3, ext, option);
|
||||
*buffer = b2;
|
||||
buffer[1] = this.Level1(num2);
|
||||
if (!flag)
|
||||
{
|
||||
buffer[2] = this.Level2(num2, ext);
|
||||
}
|
||||
buffer[3] = MSCompatUnicodeTable.Level3(num2);
|
||||
if (ext != SimpleCollator.ExtenderType.Conditional && b != 0)
|
||||
{
|
||||
buffer[2] = ((buffer[2] != 0) ? b : (b + 2));
|
||||
}
|
||||
idx--;
|
||||
goto IL_101;
|
||||
}
|
||||
b = this.Level2(num3, SimpleCollator.ExtenderType.None);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
IL_101:
|
||||
if (ext == SimpleCollator.ExtenderType.None)
|
||||
{
|
||||
ct = this.GetTailContraction(s, idx, end);
|
||||
}
|
||||
if (ct != null)
|
||||
{
|
||||
idx -= ct.Source.Length;
|
||||
if (!noLv4)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (ct.SortKey == null)
|
||||
{
|
||||
int num4 = ct.Replacement.Length - 1;
|
||||
return 0 <= this.LastIndexOfSortKey(ct.Replacement, num4, num4, ct.Replacement.Length, sortkey, ti, noLv4, ref ctx);
|
||||
}
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
buffer[j] = sortkey[j];
|
||||
}
|
||||
ctx.PrevCode = -1;
|
||||
ctx.PrevSortKey = buffer;
|
||||
}
|
||||
else if (ext == SimpleCollator.ExtenderType.None)
|
||||
{
|
||||
if (num2 < 0)
|
||||
{
|
||||
num2 = this.FilterOptions((int)s[idx], option);
|
||||
}
|
||||
idx--;
|
||||
bool flag2 = false;
|
||||
*buffer = this.Category(num2);
|
||||
if (*buffer == *sortkey)
|
||||
{
|
||||
buffer[1] = this.Level1(num2);
|
||||
}
|
||||
else
|
||||
{
|
||||
flag2 = true;
|
||||
}
|
||||
if (!flag && buffer[1] == sortkey[1])
|
||||
{
|
||||
buffer[2] = this.Level2(num2, ext);
|
||||
}
|
||||
else if (!flag)
|
||||
{
|
||||
flag2 = true;
|
||||
}
|
||||
if (flag2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
buffer[3] = MSCompatUnicodeTable.Level3(num2);
|
||||
if (*buffer != 1)
|
||||
{
|
||||
ctx.PrevCode = num2;
|
||||
}
|
||||
}
|
||||
if (ext == SimpleCollator.ExtenderType.None)
|
||||
{
|
||||
for (int k = num + 1; k < orgStart; k++)
|
||||
{
|
||||
if (this.Category((int)s[k]) != 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
if (buffer[2] == 0)
|
||||
{
|
||||
buffer[2] = 2;
|
||||
}
|
||||
buffer[2] = buffer[2] + this.Level2((int)s[k], SimpleCollator.ExtenderType.None);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.MatchesPrimitive(option, buffer, num2, ext, sortkey, ti, noLv4);
|
||||
}
|
||||
|
||||
// Token: 0x0400016B RID: 363
|
||||
private const int UnsafeFlagLength = 96;
|
||||
|
||||
// Token: 0x0400016C RID: 364
|
||||
private static bool QuickCheckDisabled = Environment.internalGetEnvironmentVariable("MONO_COLLATION_QUICK_CHECK_DISABLED") == "yes";
|
||||
|
||||
// Token: 0x0400016D RID: 365
|
||||
private static SimpleCollator invariant = new SimpleCollator(CultureInfo.InvariantCulture);
|
||||
|
||||
// Token: 0x0400016E RID: 366
|
||||
private readonly TextInfo textInfo;
|
||||
|
||||
// Token: 0x0400016F RID: 367
|
||||
private readonly bool frenchSort;
|
||||
|
||||
// Token: 0x04000170 RID: 368
|
||||
private unsafe readonly byte* cjkCatTable;
|
||||
|
||||
// Token: 0x04000171 RID: 369
|
||||
private unsafe readonly byte* cjkLv1Table;
|
||||
|
||||
// Token: 0x04000172 RID: 370
|
||||
private readonly CodePointIndexer cjkIndexer;
|
||||
|
||||
// Token: 0x04000173 RID: 371
|
||||
private unsafe readonly byte* cjkLv2Table;
|
||||
|
||||
// Token: 0x04000174 RID: 372
|
||||
private readonly CodePointIndexer cjkLv2Indexer;
|
||||
|
||||
// Token: 0x04000175 RID: 373
|
||||
private readonly int lcid;
|
||||
|
||||
// Token: 0x04000176 RID: 374
|
||||
private readonly Contraction[] contractions;
|
||||
|
||||
// Token: 0x04000177 RID: 375
|
||||
private readonly Level2Map[] level2Maps;
|
||||
|
||||
// Token: 0x04000178 RID: 376
|
||||
private readonly byte[] unsafeFlags;
|
||||
|
||||
// Token: 0x0200008B RID: 139
|
||||
internal struct Context
|
||||
{
|
||||
// Token: 0x0600081A RID: 2074 RVA: 0x0001D600 File Offset: 0x0001B800
|
||||
public unsafe Context(CompareOptions opt, byte* alwaysMatchFlags, byte* neverMatchFlags, byte* buffer1, byte* buffer2, byte* prev1, bool quickCheckPossible)
|
||||
{
|
||||
this.Option = opt;
|
||||
this.AlwaysMatchFlags = alwaysMatchFlags;
|
||||
this.NeverMatchFlags = neverMatchFlags;
|
||||
this.Buffer1 = buffer1;
|
||||
this.Buffer2 = buffer2;
|
||||
this.PrevSortKey = prev1;
|
||||
this.PrevCode = -1;
|
||||
this.QuickCheckPossible = quickCheckPossible;
|
||||
}
|
||||
|
||||
// Token: 0x0600081B RID: 2075 RVA: 0x0001D64C File Offset: 0x0001B84C
|
||||
public void ClearPrevInfo()
|
||||
{
|
||||
this.PrevCode = -1;
|
||||
this.PrevSortKey = null;
|
||||
}
|
||||
|
||||
// Token: 0x04000179 RID: 377
|
||||
public readonly CompareOptions Option;
|
||||
|
||||
// Token: 0x0400017A RID: 378
|
||||
public unsafe readonly byte* NeverMatchFlags;
|
||||
|
||||
// Token: 0x0400017B RID: 379
|
||||
public unsafe readonly byte* AlwaysMatchFlags;
|
||||
|
||||
// Token: 0x0400017C RID: 380
|
||||
public unsafe byte* Buffer1;
|
||||
|
||||
// Token: 0x0400017D RID: 381
|
||||
public unsafe byte* Buffer2;
|
||||
|
||||
// Token: 0x0400017E RID: 382
|
||||
public int PrevCode;
|
||||
|
||||
// Token: 0x0400017F RID: 383
|
||||
public unsafe byte* PrevSortKey;
|
||||
|
||||
// Token: 0x04000180 RID: 384
|
||||
public readonly bool QuickCheckPossible;
|
||||
}
|
||||
|
||||
// Token: 0x0200008C RID: 140
|
||||
private struct PreviousInfo
|
||||
{
|
||||
// Token: 0x0600081C RID: 2076 RVA: 0x0001D660 File Offset: 0x0001B860
|
||||
public PreviousInfo(bool dummy)
|
||||
{
|
||||
this.Code = -1;
|
||||
this.SortKey = null;
|
||||
}
|
||||
|
||||
// Token: 0x04000181 RID: 385
|
||||
public int Code;
|
||||
|
||||
// Token: 0x04000182 RID: 386
|
||||
public unsafe byte* SortKey;
|
||||
}
|
||||
|
||||
// Token: 0x0200008D RID: 141
|
||||
private struct Escape
|
||||
{
|
||||
// Token: 0x04000183 RID: 387
|
||||
public string Source;
|
||||
|
||||
// Token: 0x04000184 RID: 388
|
||||
public int Index;
|
||||
|
||||
// Token: 0x04000185 RID: 389
|
||||
public int Start;
|
||||
|
||||
// Token: 0x04000186 RID: 390
|
||||
public int End;
|
||||
|
||||
// Token: 0x04000187 RID: 391
|
||||
public int Optional;
|
||||
}
|
||||
|
||||
// Token: 0x0200008E RID: 142
|
||||
private enum ExtenderType
|
||||
{
|
||||
// Token: 0x04000189 RID: 393
|
||||
None,
|
||||
// Token: 0x0400018A RID: 394
|
||||
Simple,
|
||||
// Token: 0x0400018B RID: 395
|
||||
Voiced,
|
||||
// Token: 0x0400018C RID: 396
|
||||
Conditional,
|
||||
// Token: 0x0400018D RID: 397
|
||||
Buggy
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,308 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Mono.Globalization.Unicode
|
||||
{
|
||||
// Token: 0x02000090 RID: 144
|
||||
internal class SortKeyBuffer
|
||||
{
|
||||
// Token: 0x06000825 RID: 2085 RVA: 0x0001D890 File Offset: 0x0001BA90
|
||||
public SortKeyBuffer(int lcid)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000826 RID: 2086 RVA: 0x0001D898 File Offset: 0x0001BA98
|
||||
public void Reset()
|
||||
{
|
||||
this.l1 = (this.l2 = (this.l3 = (this.l4s = (this.l4t = (this.l4k = (this.l4w = (this.l5 = 0)))))));
|
||||
this.frenchSorted = false;
|
||||
}
|
||||
|
||||
// Token: 0x06000827 RID: 2087 RVA: 0x0001D8F4 File Offset: 0x0001BAF4
|
||||
internal void ClearBuffer()
|
||||
{
|
||||
this.l1b = (this.l2b = (this.l3b = (this.l4sb = (this.l4tb = (this.l4kb = (this.l4wb = (this.l5b = null)))))));
|
||||
}
|
||||
|
||||
// Token: 0x06000828 RID: 2088 RVA: 0x0001D948 File Offset: 0x0001BB48
|
||||
internal void Initialize(CompareOptions options, int lcid, string s, bool frenchSort)
|
||||
{
|
||||
this.source = s;
|
||||
this.lcid = lcid;
|
||||
this.options = options;
|
||||
int length = s.Length;
|
||||
this.processLevel2 = (options & CompareOptions.IgnoreNonSpace) == CompareOptions.None;
|
||||
this.frenchSort = frenchSort;
|
||||
if (this.l1b == null || this.l1b.Length < length)
|
||||
{
|
||||
this.l1b = new byte[length * 2 + 10];
|
||||
}
|
||||
if (this.processLevel2 && (this.l2b == null || this.l2b.Length < length))
|
||||
{
|
||||
this.l2b = new byte[length + 10];
|
||||
}
|
||||
if (this.l3b == null || this.l3b.Length < length)
|
||||
{
|
||||
this.l3b = new byte[length + 10];
|
||||
}
|
||||
if (this.l4sb == null)
|
||||
{
|
||||
this.l4sb = new byte[10];
|
||||
}
|
||||
if (this.l4tb == null)
|
||||
{
|
||||
this.l4tb = new byte[10];
|
||||
}
|
||||
if (this.l4kb == null)
|
||||
{
|
||||
this.l4kb = new byte[10];
|
||||
}
|
||||
if (this.l4wb == null)
|
||||
{
|
||||
this.l4wb = new byte[10];
|
||||
}
|
||||
if (this.l5b == null)
|
||||
{
|
||||
this.l5b = new byte[10];
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000829 RID: 2089 RVA: 0x0001DA84 File Offset: 0x0001BC84
|
||||
internal void AppendCJKExtension(byte lv1msb, byte lv1lsb)
|
||||
{
|
||||
this.AppendBufferPrimitive(254, ref this.l1b, ref this.l1);
|
||||
this.AppendBufferPrimitive(byte.MaxValue, ref this.l1b, ref this.l1);
|
||||
this.AppendBufferPrimitive(lv1msb, ref this.l1b, ref this.l1);
|
||||
this.AppendBufferPrimitive(lv1lsb, ref this.l1b, ref this.l1);
|
||||
if (this.processLevel2)
|
||||
{
|
||||
this.AppendBufferPrimitive(2, ref this.l2b, ref this.l2);
|
||||
}
|
||||
this.AppendBufferPrimitive(2, ref this.l3b, ref this.l3);
|
||||
}
|
||||
|
||||
// Token: 0x0600082A RID: 2090 RVA: 0x0001DB18 File Offset: 0x0001BD18
|
||||
internal void AppendKana(byte category, byte lv1, byte lv2, byte lv3, bool isSmallKana, byte markType, bool isKatakana, bool isHalfWidth)
|
||||
{
|
||||
this.AppendNormal(category, lv1, lv2, lv3);
|
||||
this.AppendBufferPrimitive((!isSmallKana) ? 228 : 196, ref this.l4sb, ref this.l4s);
|
||||
this.AppendBufferPrimitive(markType, ref this.l4tb, ref this.l4t);
|
||||
this.AppendBufferPrimitive((!isKatakana) ? 228 : 196, ref this.l4kb, ref this.l4k);
|
||||
this.AppendBufferPrimitive((!isHalfWidth) ? 228 : 196, ref this.l4wb, ref this.l4w);
|
||||
}
|
||||
|
||||
// Token: 0x0600082B RID: 2091 RVA: 0x0001DBC0 File Offset: 0x0001BDC0
|
||||
internal void AppendNormal(byte category, byte lv1, byte lv2, byte lv3)
|
||||
{
|
||||
if (lv2 == 0)
|
||||
{
|
||||
lv2 = 2;
|
||||
}
|
||||
if (lv3 == 0)
|
||||
{
|
||||
lv3 = 2;
|
||||
}
|
||||
if (category == 6 && (this.options & CompareOptions.StringSort) == CompareOptions.None)
|
||||
{
|
||||
this.AppendLevel5(category, lv1);
|
||||
return;
|
||||
}
|
||||
if (this.processLevel2 && category == 1 && this.l1 > 0)
|
||||
{
|
||||
lv2 += this.l2b[--this.l2];
|
||||
lv3 = this.l3b[--this.l3];
|
||||
}
|
||||
if (category != 1)
|
||||
{
|
||||
this.AppendBufferPrimitive(category, ref this.l1b, ref this.l1);
|
||||
this.AppendBufferPrimitive(lv1, ref this.l1b, ref this.l1);
|
||||
}
|
||||
if (this.processLevel2)
|
||||
{
|
||||
this.AppendBufferPrimitive(lv2, ref this.l2b, ref this.l2);
|
||||
}
|
||||
this.AppendBufferPrimitive(lv3, ref this.l3b, ref this.l3);
|
||||
}
|
||||
|
||||
// Token: 0x0600082C RID: 2092 RVA: 0x0001DCB8 File Offset: 0x0001BEB8
|
||||
private void AppendLevel5(byte category, byte lv1)
|
||||
{
|
||||
int num = (this.l2 + 1) % 8192;
|
||||
this.AppendBufferPrimitive((byte)(num / 64 + 128), ref this.l5b, ref this.l5);
|
||||
this.AppendBufferPrimitive((byte)(num % 64 * 4 + 3), ref this.l5b, ref this.l5);
|
||||
this.AppendBufferPrimitive(category, ref this.l5b, ref this.l5);
|
||||
this.AppendBufferPrimitive(lv1, ref this.l5b, ref this.l5);
|
||||
}
|
||||
|
||||
// Token: 0x0600082D RID: 2093 RVA: 0x0001DD34 File Offset: 0x0001BF34
|
||||
private void AppendBufferPrimitive(byte value, ref byte[] buf, ref int bidx)
|
||||
{
|
||||
buf[bidx++] = value;
|
||||
if (bidx == buf.Length)
|
||||
{
|
||||
byte[] array = new byte[bidx * 2];
|
||||
Array.Copy(buf, array, buf.Length);
|
||||
buf = array;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600082E RID: 2094 RVA: 0x0001DD74 File Offset: 0x0001BF74
|
||||
public SortKey GetResultAndReset()
|
||||
{
|
||||
SortKey result = this.GetResult();
|
||||
this.Reset();
|
||||
return result;
|
||||
}
|
||||
|
||||
// Token: 0x0600082F RID: 2095 RVA: 0x0001DD90 File Offset: 0x0001BF90
|
||||
private int GetOptimizedLength(byte[] data, int len, byte defaultValue)
|
||||
{
|
||||
int num = -1;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
if (data[i] != defaultValue)
|
||||
{
|
||||
num = i;
|
||||
}
|
||||
}
|
||||
return num + 1;
|
||||
}
|
||||
|
||||
// Token: 0x06000830 RID: 2096 RVA: 0x0001DDC0 File Offset: 0x0001BFC0
|
||||
public SortKey GetResult()
|
||||
{
|
||||
if (this.frenchSort && !this.frenchSorted && this.l2b != null)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < this.l2b.Length; i++)
|
||||
{
|
||||
if (this.l2b[i] == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
Array.Reverse(this.l2b, 0, i);
|
||||
this.frenchSorted = true;
|
||||
}
|
||||
this.l2 = this.GetOptimizedLength(this.l2b, this.l2, 2);
|
||||
this.l3 = this.GetOptimizedLength(this.l3b, this.l3, 2);
|
||||
bool flag = this.l4s > 0;
|
||||
this.l4s = this.GetOptimizedLength(this.l4sb, this.l4s, 228);
|
||||
this.l4t = this.GetOptimizedLength(this.l4tb, this.l4t, 3);
|
||||
this.l4k = this.GetOptimizedLength(this.l4kb, this.l4k, 228);
|
||||
this.l4w = this.GetOptimizedLength(this.l4wb, this.l4w, 228);
|
||||
this.l5 = this.GetOptimizedLength(this.l5b, this.l5, 2);
|
||||
int num = this.l1 + this.l2 + this.l3 + this.l5 + 5;
|
||||
int num2 = this.l4s + this.l4t + this.l4k + this.l4w;
|
||||
if (flag)
|
||||
{
|
||||
num += num2 + 4;
|
||||
}
|
||||
byte[] array = new byte[num];
|
||||
Array.Copy(this.l1b, array, this.l1);
|
||||
array[this.l1] = 1;
|
||||
int num3 = this.l1 + 1;
|
||||
if (this.l2 > 0)
|
||||
{
|
||||
Array.Copy(this.l2b, 0, array, num3, this.l2);
|
||||
}
|
||||
num3 += this.l2;
|
||||
array[num3++] = 1;
|
||||
if (this.l3 > 0)
|
||||
{
|
||||
Array.Copy(this.l3b, 0, array, num3, this.l3);
|
||||
}
|
||||
num3 += this.l3;
|
||||
array[num3++] = 1;
|
||||
if (flag)
|
||||
{
|
||||
Array.Copy(this.l4sb, 0, array, num3, this.l4s);
|
||||
num3 += this.l4s;
|
||||
array[num3++] = byte.MaxValue;
|
||||
Array.Copy(this.l4tb, 0, array, num3, this.l4t);
|
||||
num3 += this.l4t;
|
||||
array[num3++] = 2;
|
||||
Array.Copy(this.l4kb, 0, array, num3, this.l4k);
|
||||
num3 += this.l4k;
|
||||
array[num3++] = byte.MaxValue;
|
||||
Array.Copy(this.l4wb, 0, array, num3, this.l4w);
|
||||
num3 += this.l4w;
|
||||
array[num3++] = byte.MaxValue;
|
||||
}
|
||||
array[num3++] = 1;
|
||||
if (this.l5 > 0)
|
||||
{
|
||||
Array.Copy(this.l5b, 0, array, num3, this.l5);
|
||||
}
|
||||
num3 += this.l5;
|
||||
array[num3++] = 0;
|
||||
return new SortKey(this.lcid, this.source, array, this.options, this.l1, this.l2, this.l3, this.l4s, this.l4t, this.l4k, this.l4w, this.l5);
|
||||
}
|
||||
|
||||
// Token: 0x04000192 RID: 402
|
||||
private int l1;
|
||||
|
||||
// Token: 0x04000193 RID: 403
|
||||
private int l2;
|
||||
|
||||
// Token: 0x04000194 RID: 404
|
||||
private int l3;
|
||||
|
||||
// Token: 0x04000195 RID: 405
|
||||
private int l4s;
|
||||
|
||||
// Token: 0x04000196 RID: 406
|
||||
private int l4t;
|
||||
|
||||
// Token: 0x04000197 RID: 407
|
||||
private int l4k;
|
||||
|
||||
// Token: 0x04000198 RID: 408
|
||||
private int l4w;
|
||||
|
||||
// Token: 0x04000199 RID: 409
|
||||
private int l5;
|
||||
|
||||
// Token: 0x0400019A RID: 410
|
||||
private byte[] l1b;
|
||||
|
||||
// Token: 0x0400019B RID: 411
|
||||
private byte[] l2b;
|
||||
|
||||
// Token: 0x0400019C RID: 412
|
||||
private byte[] l3b;
|
||||
|
||||
// Token: 0x0400019D RID: 413
|
||||
private byte[] l4sb;
|
||||
|
||||
// Token: 0x0400019E RID: 414
|
||||
private byte[] l4tb;
|
||||
|
||||
// Token: 0x0400019F RID: 415
|
||||
private byte[] l4kb;
|
||||
|
||||
// Token: 0x040001A0 RID: 416
|
||||
private byte[] l4wb;
|
||||
|
||||
// Token: 0x040001A1 RID: 417
|
||||
private byte[] l5b;
|
||||
|
||||
// Token: 0x040001A2 RID: 418
|
||||
private string source;
|
||||
|
||||
// Token: 0x040001A3 RID: 419
|
||||
private bool processLevel2;
|
||||
|
||||
// Token: 0x040001A4 RID: 420
|
||||
private bool frenchSort;
|
||||
|
||||
// Token: 0x040001A5 RID: 421
|
||||
private bool frenchSorted;
|
||||
|
||||
// Token: 0x040001A6 RID: 422
|
||||
private int lcid;
|
||||
|
||||
// Token: 0x040001A7 RID: 423
|
||||
private CompareOptions options;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Globalization.Unicode
|
||||
{
|
||||
// Token: 0x02000080 RID: 128
|
||||
internal class TailoringInfo
|
||||
{
|
||||
// Token: 0x0600078E RID: 1934 RVA: 0x00018038 File Offset: 0x00016238
|
||||
public TailoringInfo(int lcid, int tailoringIndex, int tailoringCount, bool frenchSort)
|
||||
{
|
||||
this.LCID = lcid;
|
||||
this.TailoringIndex = tailoringIndex;
|
||||
this.TailoringCount = tailoringCount;
|
||||
this.FrenchSort = frenchSort;
|
||||
}
|
||||
|
||||
// Token: 0x0400011F RID: 287
|
||||
public readonly int LCID;
|
||||
|
||||
// Token: 0x04000120 RID: 288
|
||||
public readonly int TailoringIndex;
|
||||
|
||||
// Token: 0x04000121 RID: 289
|
||||
public readonly int TailoringCount;
|
||||
|
||||
// Token: 0x04000122 RID: 290
|
||||
public readonly bool FrenchSort;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Remoting;
|
||||
using System.Runtime.Remoting.Messaging;
|
||||
using System.Runtime.Remoting.Proxies;
|
||||
using System.Threading;
|
||||
|
||||
namespace Mono.Interop
|
||||
{
|
||||
// Token: 0x02000091 RID: 145
|
||||
internal class ComInteropProxy : RealProxy, IRemotingTypeInfo
|
||||
{
|
||||
// Token: 0x06000831 RID: 2097 RVA: 0x0001E128 File Offset: 0x0001C328
|
||||
private ComInteropProxy(Type t)
|
||||
: base(t)
|
||||
{
|
||||
this.com_object = __ComObject.CreateRCW(t);
|
||||
}
|
||||
|
||||
// Token: 0x06000832 RID: 2098 RVA: 0x0001E144 File Offset: 0x0001C344
|
||||
private ComInteropProxy(IntPtr pUnk)
|
||||
: this(pUnk, typeof(__ComObject))
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000833 RID: 2099 RVA: 0x0001E158 File Offset: 0x0001C358
|
||||
internal ComInteropProxy(IntPtr pUnk, Type t)
|
||||
: base(t)
|
||||
{
|
||||
this.com_object = new __ComObject(pUnk);
|
||||
this.CacheProxy();
|
||||
}
|
||||
|
||||
// Token: 0x06000834 RID: 2100
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
private static extern void AddProxy(IntPtr pItf, ComInteropProxy proxy);
|
||||
|
||||
// Token: 0x06000835 RID: 2101
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern ComInteropProxy FindProxy(IntPtr pItf);
|
||||
|
||||
// Token: 0x06000836 RID: 2102 RVA: 0x0001E188 File Offset: 0x0001C388
|
||||
private void CacheProxy()
|
||||
{
|
||||
ComInteropProxy.AddProxy(this.com_object.IUnknown, this);
|
||||
}
|
||||
|
||||
// Token: 0x06000837 RID: 2103 RVA: 0x0001E19C File Offset: 0x0001C39C
|
||||
internal static ComInteropProxy GetProxy(IntPtr pItf, Type t)
|
||||
{
|
||||
Guid iid_IUnknown = __ComObject.IID_IUnknown;
|
||||
IntPtr intPtr;
|
||||
int num = Marshal.QueryInterface(pItf, ref iid_IUnknown, out intPtr);
|
||||
Marshal.ThrowExceptionForHR(num);
|
||||
ComInteropProxy comInteropProxy = ComInteropProxy.FindProxy(intPtr);
|
||||
if (comInteropProxy == null)
|
||||
{
|
||||
Marshal.Release(pItf);
|
||||
return new ComInteropProxy(intPtr);
|
||||
}
|
||||
Marshal.Release(pItf);
|
||||
Interlocked.Increment(ref comInteropProxy.ref_count);
|
||||
return comInteropProxy;
|
||||
}
|
||||
|
||||
// Token: 0x06000838 RID: 2104 RVA: 0x0001E1F0 File Offset: 0x0001C3F0
|
||||
internal static ComInteropProxy CreateProxy(Type t)
|
||||
{
|
||||
ComInteropProxy comInteropProxy = new ComInteropProxy(t);
|
||||
comInteropProxy.com_object.Initialize(t);
|
||||
ComInteropProxy comInteropProxy2 = ComInteropProxy.FindProxy(comInteropProxy.com_object.IUnknown);
|
||||
if (comInteropProxy2 == null)
|
||||
{
|
||||
return comInteropProxy;
|
||||
}
|
||||
Type type = comInteropProxy2.com_object.GetType();
|
||||
if (type != t)
|
||||
{
|
||||
throw new InvalidCastException(string.Format("Unable to cast object of type '{0}' to type '{1}'.", type, t));
|
||||
}
|
||||
return comInteropProxy2;
|
||||
}
|
||||
|
||||
// Token: 0x06000839 RID: 2105 RVA: 0x0001E250 File Offset: 0x0001C450
|
||||
public override IMessage Invoke(IMessage msg)
|
||||
{
|
||||
Console.WriteLine("Invoke");
|
||||
Console.WriteLine(Environment.StackTrace);
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
}
|
||||
|
||||
// Token: 0x170000E2 RID: 226
|
||||
// (get) Token: 0x0600083A RID: 2106 RVA: 0x0001E270 File Offset: 0x0001C470
|
||||
// (set) Token: 0x0600083B RID: 2107 RVA: 0x0001E278 File Offset: 0x0001C478
|
||||
public string TypeName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.type_name;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.type_name = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600083C RID: 2108 RVA: 0x0001E284 File Offset: 0x0001C484
|
||||
public bool CanCastTo(Type fromType, object o)
|
||||
{
|
||||
__ComObject _ComObject = o as __ComObject;
|
||||
if (_ComObject == null)
|
||||
{
|
||||
throw new NotSupportedException("Only RCWs are currently supported");
|
||||
}
|
||||
return (fromType.Attributes & TypeAttributes.Import) != TypeAttributes.NotPublic && !(_ComObject.GetInterface(fromType, false) == IntPtr.Zero);
|
||||
}
|
||||
|
||||
// Token: 0x040001A8 RID: 424
|
||||
private __ComObject com_object;
|
||||
|
||||
// Token: 0x040001A9 RID: 425
|
||||
private int ref_count = 1;
|
||||
|
||||
// Token: 0x040001AA RID: 426
|
||||
private string type_name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Mono.Interop
|
||||
{
|
||||
// Token: 0x02000092 RID: 146
|
||||
[Guid("00020400-0000-0000-C000-000000000046")]
|
||||
internal interface IDispatch
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Mono.Interop
|
||||
{
|
||||
// Token: 0x02000093 RID: 147
|
||||
[Guid("00000000-0000-0000-C000-000000000046")]
|
||||
internal interface IUnknown
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,1930 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using Mono.Math.Prime;
|
||||
using Mono.Math.Prime.Generator;
|
||||
|
||||
namespace Mono.Math
|
||||
{
|
||||
// Token: 0x02000099 RID: 153
|
||||
internal class BigInteger
|
||||
{
|
||||
// Token: 0x0600084F RID: 2127 RVA: 0x0001E80C File Offset: 0x0001CA0C
|
||||
public BigInteger()
|
||||
{
|
||||
this.data = new uint[20];
|
||||
this.length = 20U;
|
||||
}
|
||||
|
||||
// Token: 0x06000850 RID: 2128 RVA: 0x0001E834 File Offset: 0x0001CA34
|
||||
public BigInteger(BigInteger.Sign sign, uint len)
|
||||
{
|
||||
this.data = new uint[len];
|
||||
this.length = len;
|
||||
}
|
||||
|
||||
// Token: 0x06000851 RID: 2129 RVA: 0x0001E858 File Offset: 0x0001CA58
|
||||
public BigInteger(BigInteger bi)
|
||||
{
|
||||
this.data = (uint[])bi.data.Clone();
|
||||
this.length = bi.length;
|
||||
}
|
||||
|
||||
// Token: 0x06000852 RID: 2130 RVA: 0x0001E88C File Offset: 0x0001CA8C
|
||||
public BigInteger(BigInteger bi, uint len)
|
||||
{
|
||||
this.data = new uint[len];
|
||||
for (uint num = 0U; num < bi.length; num += 1U)
|
||||
{
|
||||
this.data[(int)((UIntPtr)num)] = bi.data[(int)((UIntPtr)num)];
|
||||
}
|
||||
this.length = bi.length;
|
||||
}
|
||||
|
||||
// Token: 0x06000853 RID: 2131 RVA: 0x0001E8E8 File Offset: 0x0001CAE8
|
||||
public BigInteger(byte[] inData)
|
||||
{
|
||||
this.length = (uint)inData.Length >> 2;
|
||||
int num = inData.Length & 3;
|
||||
if (num != 0)
|
||||
{
|
||||
this.length += 1U;
|
||||
}
|
||||
this.data = new uint[this.length];
|
||||
int i = inData.Length - 1;
|
||||
int num2 = 0;
|
||||
while (i >= 3)
|
||||
{
|
||||
this.data[num2] = (uint)(((int)inData[i - 3] << 24) | ((int)inData[i - 2] << 16) | ((int)inData[i - 1] << 8) | (int)inData[i]);
|
||||
i -= 4;
|
||||
num2++;
|
||||
}
|
||||
switch (num)
|
||||
{
|
||||
case 1:
|
||||
this.data[(int)((UIntPtr)(this.length - 1U))] = (uint)inData[0];
|
||||
break;
|
||||
case 2:
|
||||
this.data[(int)((UIntPtr)(this.length - 1U))] = (uint)(((int)inData[0] << 8) | (int)inData[1]);
|
||||
break;
|
||||
case 3:
|
||||
this.data[(int)((UIntPtr)(this.length - 1U))] = (uint)(((int)inData[0] << 16) | ((int)inData[1] << 8) | (int)inData[2]);
|
||||
break;
|
||||
}
|
||||
this.Normalize();
|
||||
}
|
||||
|
||||
// Token: 0x06000854 RID: 2132 RVA: 0x0001E9F8 File Offset: 0x0001CBF8
|
||||
public BigInteger(uint[] inData)
|
||||
{
|
||||
this.length = (uint)inData.Length;
|
||||
this.data = new uint[this.length];
|
||||
int i = (int)(this.length - 1U);
|
||||
int num = 0;
|
||||
while (i >= 0)
|
||||
{
|
||||
this.data[num] = inData[i];
|
||||
i--;
|
||||
num++;
|
||||
}
|
||||
this.Normalize();
|
||||
}
|
||||
|
||||
// Token: 0x06000855 RID: 2133 RVA: 0x0001EA60 File Offset: 0x0001CC60
|
||||
public BigInteger(uint ui)
|
||||
{
|
||||
this.data = new uint[] { ui };
|
||||
}
|
||||
|
||||
// Token: 0x06000856 RID: 2134 RVA: 0x0001EA80 File Offset: 0x0001CC80
|
||||
public BigInteger(ulong ul)
|
||||
{
|
||||
this.data = new uint[]
|
||||
{
|
||||
(uint)ul,
|
||||
(uint)(ul >> 32)
|
||||
};
|
||||
this.length = 2U;
|
||||
this.Normalize();
|
||||
}
|
||||
|
||||
// Token: 0x06000858 RID: 2136 RVA: 0x0001EADC File Offset: 0x0001CCDC
|
||||
public static BigInteger Parse(string number)
|
||||
{
|
||||
if (number == null)
|
||||
{
|
||||
throw new ArgumentNullException("number");
|
||||
}
|
||||
int i = 0;
|
||||
int num = number.Length;
|
||||
bool flag = false;
|
||||
BigInteger bigInteger = new BigInteger(0U);
|
||||
if (number[i] == '+')
|
||||
{
|
||||
i++;
|
||||
}
|
||||
else if (number[i] == '-')
|
||||
{
|
||||
throw new FormatException("Operation would return a negative value");
|
||||
}
|
||||
while (i < num)
|
||||
{
|
||||
char c = number[i];
|
||||
if (c == '\0')
|
||||
{
|
||||
i = num;
|
||||
}
|
||||
else if (c >= '0' && c <= '9')
|
||||
{
|
||||
bigInteger = bigInteger * 10 + (int)(c - '0');
|
||||
flag = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (char.IsWhiteSpace(c))
|
||||
{
|
||||
for (i++; i < num; i++)
|
||||
{
|
||||
if (!char.IsWhiteSpace(number[i]))
|
||||
{
|
||||
throw new FormatException();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
throw new FormatException();
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
throw new FormatException();
|
||||
}
|
||||
return bigInteger;
|
||||
}
|
||||
|
||||
// Token: 0x06000859 RID: 2137 RVA: 0x0001EBE4 File Offset: 0x0001CDE4
|
||||
public static BigInteger Add(BigInteger bi1, BigInteger bi2)
|
||||
{
|
||||
return bi1 + bi2;
|
||||
}
|
||||
|
||||
// Token: 0x0600085A RID: 2138 RVA: 0x0001EBF0 File Offset: 0x0001CDF0
|
||||
public static BigInteger Subtract(BigInteger bi1, BigInteger bi2)
|
||||
{
|
||||
return bi1 - bi2;
|
||||
}
|
||||
|
||||
// Token: 0x0600085B RID: 2139 RVA: 0x0001EBFC File Offset: 0x0001CDFC
|
||||
public static int Modulus(BigInteger bi, int i)
|
||||
{
|
||||
return bi % i;
|
||||
}
|
||||
|
||||
// Token: 0x0600085C RID: 2140 RVA: 0x0001EC08 File Offset: 0x0001CE08
|
||||
public static uint Modulus(BigInteger bi, uint ui)
|
||||
{
|
||||
return bi % ui;
|
||||
}
|
||||
|
||||
// Token: 0x0600085D RID: 2141 RVA: 0x0001EC14 File Offset: 0x0001CE14
|
||||
public static BigInteger Modulus(BigInteger bi1, BigInteger bi2)
|
||||
{
|
||||
return bi1 % bi2;
|
||||
}
|
||||
|
||||
// Token: 0x0600085E RID: 2142 RVA: 0x0001EC20 File Offset: 0x0001CE20
|
||||
public static BigInteger Divid(BigInteger bi, int i)
|
||||
{
|
||||
return bi / i;
|
||||
}
|
||||
|
||||
// Token: 0x0600085F RID: 2143 RVA: 0x0001EC2C File Offset: 0x0001CE2C
|
||||
public static BigInteger Divid(BigInteger bi1, BigInteger bi2)
|
||||
{
|
||||
return bi1 / bi2;
|
||||
}
|
||||
|
||||
// Token: 0x06000860 RID: 2144 RVA: 0x0001EC38 File Offset: 0x0001CE38
|
||||
public static BigInteger Multiply(BigInteger bi1, BigInteger bi2)
|
||||
{
|
||||
return bi1 * bi2;
|
||||
}
|
||||
|
||||
// Token: 0x06000861 RID: 2145 RVA: 0x0001EC44 File Offset: 0x0001CE44
|
||||
public static BigInteger Multiply(BigInteger bi, int i)
|
||||
{
|
||||
return bi * i;
|
||||
}
|
||||
|
||||
// Token: 0x170000E6 RID: 230
|
||||
// (get) Token: 0x06000862 RID: 2146 RVA: 0x0001EC50 File Offset: 0x0001CE50
|
||||
private static RandomNumberGenerator Rng
|
||||
{
|
||||
get
|
||||
{
|
||||
if (BigInteger.rng == null)
|
||||
{
|
||||
BigInteger.rng = RandomNumberGenerator.Create();
|
||||
}
|
||||
return BigInteger.rng;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000863 RID: 2147 RVA: 0x0001EC6C File Offset: 0x0001CE6C
|
||||
public static BigInteger GenerateRandom(int bits, RandomNumberGenerator rng)
|
||||
{
|
||||
int num = bits >> 5;
|
||||
int num2 = bits & 31;
|
||||
if (num2 != 0)
|
||||
{
|
||||
num++;
|
||||
}
|
||||
BigInteger bigInteger = new BigInteger(BigInteger.Sign.Positive, (uint)(num + 1));
|
||||
byte[] array = new byte[num << 2];
|
||||
rng.GetBytes(array);
|
||||
Buffer.BlockCopy(array, 0, bigInteger.data, 0, num << 2);
|
||||
if (num2 != 0)
|
||||
{
|
||||
uint num3 = 1U << num2 - 1;
|
||||
bigInteger.data[num - 1] |= num3;
|
||||
num3 = uint.MaxValue >> 32 - num2;
|
||||
bigInteger.data[num - 1] &= num3;
|
||||
}
|
||||
else
|
||||
{
|
||||
bigInteger.data[num - 1] |= 2147483648U;
|
||||
}
|
||||
bigInteger.Normalize();
|
||||
return bigInteger;
|
||||
}
|
||||
|
||||
// Token: 0x06000864 RID: 2148 RVA: 0x0001ED20 File Offset: 0x0001CF20
|
||||
public static BigInteger GenerateRandom(int bits)
|
||||
{
|
||||
return BigInteger.GenerateRandom(bits, BigInteger.Rng);
|
||||
}
|
||||
|
||||
// Token: 0x06000865 RID: 2149 RVA: 0x0001ED30 File Offset: 0x0001CF30
|
||||
public void Randomize(RandomNumberGenerator rng)
|
||||
{
|
||||
if (this == 0U)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int num = this.BitCount();
|
||||
int num2 = num >> 5;
|
||||
int num3 = num & 31;
|
||||
if (num3 != 0)
|
||||
{
|
||||
num2++;
|
||||
}
|
||||
byte[] array = new byte[num2 << 2];
|
||||
rng.GetBytes(array);
|
||||
Buffer.BlockCopy(array, 0, this.data, 0, num2 << 2);
|
||||
if (num3 != 0)
|
||||
{
|
||||
uint num4 = 1U << num3 - 1;
|
||||
this.data[num2 - 1] |= num4;
|
||||
num4 = uint.MaxValue >> 32 - num3;
|
||||
this.data[num2 - 1] &= num4;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.data[num2 - 1] |= 2147483648U;
|
||||
}
|
||||
this.Normalize();
|
||||
}
|
||||
|
||||
// Token: 0x06000866 RID: 2150 RVA: 0x0001EDEC File Offset: 0x0001CFEC
|
||||
public void Randomize()
|
||||
{
|
||||
this.Randomize(BigInteger.Rng);
|
||||
}
|
||||
|
||||
// Token: 0x06000867 RID: 2151 RVA: 0x0001EDFC File Offset: 0x0001CFFC
|
||||
public int BitCount()
|
||||
{
|
||||
this.Normalize();
|
||||
uint num = this.data[(int)((UIntPtr)(this.length - 1U))];
|
||||
uint num2 = 2147483648U;
|
||||
uint num3 = 32U;
|
||||
while (num3 > 0U && (num & num2) == 0U)
|
||||
{
|
||||
num3 -= 1U;
|
||||
num2 >>= 1;
|
||||
}
|
||||
return (int)(num3 + (this.length - 1U << 5));
|
||||
}
|
||||
|
||||
// Token: 0x06000868 RID: 2152 RVA: 0x0001EE54 File Offset: 0x0001D054
|
||||
public bool TestBit(uint bitNum)
|
||||
{
|
||||
uint num = bitNum >> 5;
|
||||
byte b = (byte)(bitNum & 31U);
|
||||
uint num2 = 1U << (int)b;
|
||||
return (this.data[(int)((UIntPtr)num)] & num2) != 0U;
|
||||
}
|
||||
|
||||
// Token: 0x06000869 RID: 2153 RVA: 0x0001EE84 File Offset: 0x0001D084
|
||||
public bool TestBit(int bitNum)
|
||||
{
|
||||
if (bitNum < 0)
|
||||
{
|
||||
throw new IndexOutOfRangeException("bitNum out of range");
|
||||
}
|
||||
uint num = (uint)bitNum >> 5;
|
||||
byte b = (byte)(bitNum & 31);
|
||||
uint num2 = 1U << (int)b;
|
||||
return (this.data[(int)((UIntPtr)num)] | num2) == this.data[(int)((UIntPtr)num)];
|
||||
}
|
||||
|
||||
// Token: 0x0600086A RID: 2154 RVA: 0x0001EECC File Offset: 0x0001D0CC
|
||||
public void SetBit(uint bitNum)
|
||||
{
|
||||
this.SetBit(bitNum, true);
|
||||
}
|
||||
|
||||
// Token: 0x0600086B RID: 2155 RVA: 0x0001EED8 File Offset: 0x0001D0D8
|
||||
public void ClearBit(uint bitNum)
|
||||
{
|
||||
this.SetBit(bitNum, false);
|
||||
}
|
||||
|
||||
// Token: 0x0600086C RID: 2156 RVA: 0x0001EEE4 File Offset: 0x0001D0E4
|
||||
public void SetBit(uint bitNum, bool value)
|
||||
{
|
||||
uint num = bitNum >> 5;
|
||||
if (num < this.length)
|
||||
{
|
||||
uint num2 = 1U << (int)bitNum;
|
||||
if (value)
|
||||
{
|
||||
this.data[(int)((UIntPtr)num)] |= num2;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.data[(int)((UIntPtr)num)] &= ~num2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600086D RID: 2157 RVA: 0x0001EF3C File Offset: 0x0001D13C
|
||||
public int LowestSetBit()
|
||||
{
|
||||
if (this == 0U)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int num = 0;
|
||||
while (!this.TestBit(num))
|
||||
{
|
||||
num++;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x0600086E RID: 2158 RVA: 0x0001EF70 File Offset: 0x0001D170
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
if (this == 0U)
|
||||
{
|
||||
return new byte[1];
|
||||
}
|
||||
int num = this.BitCount();
|
||||
int num2 = num >> 3;
|
||||
if ((num & 7) != 0)
|
||||
{
|
||||
num2++;
|
||||
}
|
||||
byte[] array = new byte[num2];
|
||||
int num3 = num2 & 3;
|
||||
if (num3 == 0)
|
||||
{
|
||||
num3 = 4;
|
||||
}
|
||||
int num4 = 0;
|
||||
for (int i = (int)(this.length - 1U); i >= 0; i--)
|
||||
{
|
||||
uint num5 = this.data[i];
|
||||
for (int j = num3 - 1; j >= 0; j--)
|
||||
{
|
||||
array[num4 + j] = (byte)(num5 & 255U);
|
||||
num5 >>= 8;
|
||||
}
|
||||
num4 += num3;
|
||||
num3 = 4;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x0600086F RID: 2159 RVA: 0x0001F01C File Offset: 0x0001D21C
|
||||
public BigInteger.Sign Compare(BigInteger bi)
|
||||
{
|
||||
return BigInteger.Kernel.Compare(this, bi);
|
||||
}
|
||||
|
||||
// Token: 0x06000870 RID: 2160 RVA: 0x0001F028 File Offset: 0x0001D228
|
||||
public string ToString(uint radix)
|
||||
{
|
||||
return this.ToString(radix, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
}
|
||||
|
||||
// Token: 0x06000871 RID: 2161 RVA: 0x0001F038 File Offset: 0x0001D238
|
||||
public string ToString(uint radix, string characterSet)
|
||||
{
|
||||
if ((long)characterSet.Length < (long)((ulong)radix))
|
||||
{
|
||||
throw new ArgumentException("charSet length less than radix", "characterSet");
|
||||
}
|
||||
if (radix == 1U)
|
||||
{
|
||||
throw new ArgumentException("There is no such thing as radix one notation", "radix");
|
||||
}
|
||||
if (this == 0U)
|
||||
{
|
||||
return "0";
|
||||
}
|
||||
if (this == 1U)
|
||||
{
|
||||
return "1";
|
||||
}
|
||||
string text = string.Empty;
|
||||
BigInteger bigInteger = new BigInteger(this);
|
||||
while (bigInteger != 0U)
|
||||
{
|
||||
uint num = BigInteger.Kernel.SingleByteDivideInPlace(bigInteger, radix);
|
||||
text = characterSet[(int)num] + text;
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
// Token: 0x06000872 RID: 2162 RVA: 0x0001F0D8 File Offset: 0x0001D2D8
|
||||
private void Normalize()
|
||||
{
|
||||
while (this.length > 0U && this.data[(int)((UIntPtr)(this.length - 1U))] == 0U)
|
||||
{
|
||||
this.length -= 1U;
|
||||
}
|
||||
if (this.length == 0U)
|
||||
{
|
||||
this.length += 1U;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000873 RID: 2163 RVA: 0x0001F134 File Offset: 0x0001D334
|
||||
public void Clear()
|
||||
{
|
||||
int num = 0;
|
||||
while ((long)num < (long)((ulong)this.length))
|
||||
{
|
||||
this.data[num] = 0U;
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000874 RID: 2164 RVA: 0x0001F164 File Offset: 0x0001D364
|
||||
public override int GetHashCode()
|
||||
{
|
||||
uint num = 0U;
|
||||
for (uint num2 = 0U; num2 < this.length; num2 += 1U)
|
||||
{
|
||||
num ^= this.data[(int)((UIntPtr)num2)];
|
||||
}
|
||||
return (int)num;
|
||||
}
|
||||
|
||||
// Token: 0x06000875 RID: 2165 RVA: 0x0001F198 File Offset: 0x0001D398
|
||||
public override string ToString()
|
||||
{
|
||||
return this.ToString(10U);
|
||||
}
|
||||
|
||||
// Token: 0x06000876 RID: 2166 RVA: 0x0001F1A4 File Offset: 0x0001D3A4
|
||||
public override bool Equals(object o)
|
||||
{
|
||||
if (o == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (o is int)
|
||||
{
|
||||
return (int)o >= 0 && this == (uint)o;
|
||||
}
|
||||
BigInteger bigInteger = o as BigInteger;
|
||||
return !(bigInteger == null) && BigInteger.Kernel.Compare(this, bigInteger) == BigInteger.Sign.Zero;
|
||||
}
|
||||
|
||||
// Token: 0x06000877 RID: 2167 RVA: 0x0001F200 File Offset: 0x0001D400
|
||||
public BigInteger GCD(BigInteger bi)
|
||||
{
|
||||
return BigInteger.Kernel.gcd(this, bi);
|
||||
}
|
||||
|
||||
// Token: 0x06000878 RID: 2168 RVA: 0x0001F20C File Offset: 0x0001D40C
|
||||
public BigInteger ModInverse(BigInteger modulus)
|
||||
{
|
||||
return BigInteger.Kernel.modInverse(this, modulus);
|
||||
}
|
||||
|
||||
// Token: 0x06000879 RID: 2169 RVA: 0x0001F218 File Offset: 0x0001D418
|
||||
public BigInteger ModPow(BigInteger exp, BigInteger n)
|
||||
{
|
||||
BigInteger.ModulusRing modulusRing = new BigInteger.ModulusRing(n);
|
||||
return modulusRing.Pow(this, exp);
|
||||
}
|
||||
|
||||
// Token: 0x0600087A RID: 2170 RVA: 0x0001F234 File Offset: 0x0001D434
|
||||
public bool IsProbablePrime()
|
||||
{
|
||||
if (this <= BigInteger.smallPrimes[BigInteger.smallPrimes.Length - 1])
|
||||
{
|
||||
for (int i = 0; i < BigInteger.smallPrimes.Length; i++)
|
||||
{
|
||||
if (this == BigInteger.smallPrimes[i])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
for (int j = 0; j < BigInteger.smallPrimes.Length; j++)
|
||||
{
|
||||
if (this % BigInteger.smallPrimes[j] == 0U)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return PrimalityTests.Test(this, ConfidenceFactor.Medium);
|
||||
}
|
||||
|
||||
// Token: 0x0600087B RID: 2171 RVA: 0x0001F2C4 File Offset: 0x0001D4C4
|
||||
public static BigInteger NextHighestPrime(BigInteger bi)
|
||||
{
|
||||
NextPrimeFinder nextPrimeFinder = new NextPrimeFinder();
|
||||
return nextPrimeFinder.GenerateNewPrime(0, bi);
|
||||
}
|
||||
|
||||
// Token: 0x0600087C RID: 2172 RVA: 0x0001F2E0 File Offset: 0x0001D4E0
|
||||
public static BigInteger GeneratePseudoPrime(int bits)
|
||||
{
|
||||
SequentialSearchPrimeGeneratorBase sequentialSearchPrimeGeneratorBase = new SequentialSearchPrimeGeneratorBase();
|
||||
return sequentialSearchPrimeGeneratorBase.GenerateNewPrime(bits);
|
||||
}
|
||||
|
||||
// Token: 0x0600087D RID: 2173 RVA: 0x0001F2FC File Offset: 0x0001D4FC
|
||||
public void Incr2()
|
||||
{
|
||||
int num = 0;
|
||||
this.data[0] += 2U;
|
||||
if (this.data[0] < 2U)
|
||||
{
|
||||
this.data[++num] += 1U;
|
||||
while (this.data[num++] == 0U)
|
||||
{
|
||||
this.data[num] += 1U;
|
||||
}
|
||||
if (this.length == (uint)num)
|
||||
{
|
||||
this.length += 1U;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600087E RID: 2174 RVA: 0x0001F380 File Offset: 0x0001D580
|
||||
public static implicit operator BigInteger(uint value)
|
||||
{
|
||||
return new BigInteger(value);
|
||||
}
|
||||
|
||||
// Token: 0x0600087F RID: 2175 RVA: 0x0001F388 File Offset: 0x0001D588
|
||||
public static implicit operator BigInteger(int value)
|
||||
{
|
||||
if (value < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("value");
|
||||
}
|
||||
return new BigInteger((uint)value);
|
||||
}
|
||||
|
||||
// Token: 0x06000880 RID: 2176 RVA: 0x0001F3A4 File Offset: 0x0001D5A4
|
||||
public static implicit operator BigInteger(ulong value)
|
||||
{
|
||||
return new BigInteger(value);
|
||||
}
|
||||
|
||||
// Token: 0x06000881 RID: 2177 RVA: 0x0001F3AC File Offset: 0x0001D5AC
|
||||
public static BigInteger operator +(BigInteger bi1, BigInteger bi2)
|
||||
{
|
||||
if (bi1 == 0U)
|
||||
{
|
||||
return new BigInteger(bi2);
|
||||
}
|
||||
if (bi2 == 0U)
|
||||
{
|
||||
return new BigInteger(bi1);
|
||||
}
|
||||
return BigInteger.Kernel.AddSameSign(bi1, bi2);
|
||||
}
|
||||
|
||||
// Token: 0x06000882 RID: 2178 RVA: 0x0001F3DC File Offset: 0x0001D5DC
|
||||
public static BigInteger operator -(BigInteger bi1, BigInteger bi2)
|
||||
{
|
||||
if (bi2 == 0U)
|
||||
{
|
||||
return new BigInteger(bi1);
|
||||
}
|
||||
if (bi1 == 0U)
|
||||
{
|
||||
throw new ArithmeticException("Operation would return a negative value");
|
||||
}
|
||||
BigInteger.Sign sign = BigInteger.Kernel.Compare(bi1, bi2);
|
||||
switch (sign + 1)
|
||||
{
|
||||
case BigInteger.Sign.Zero:
|
||||
throw new ArithmeticException("Operation would return a negative value");
|
||||
case BigInteger.Sign.Positive:
|
||||
return 0;
|
||||
case (BigInteger.Sign)2:
|
||||
return BigInteger.Kernel.Subtract(bi1, bi2);
|
||||
default:
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000883 RID: 2179 RVA: 0x0001F454 File Offset: 0x0001D654
|
||||
public static int operator %(BigInteger bi, int i)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
return (int)BigInteger.Kernel.DwordMod(bi, (uint)i);
|
||||
}
|
||||
return (int)(-(int)BigInteger.Kernel.DwordMod(bi, (uint)(-(uint)i)));
|
||||
}
|
||||
|
||||
// Token: 0x06000884 RID: 2180 RVA: 0x0001F470 File Offset: 0x0001D670
|
||||
public static uint operator %(BigInteger bi, uint ui)
|
||||
{
|
||||
return BigInteger.Kernel.DwordMod(bi, ui);
|
||||
}
|
||||
|
||||
// Token: 0x06000885 RID: 2181 RVA: 0x0001F47C File Offset: 0x0001D67C
|
||||
public static BigInteger operator %(BigInteger bi1, BigInteger bi2)
|
||||
{
|
||||
return BigInteger.Kernel.multiByteDivide(bi1, bi2)[1];
|
||||
}
|
||||
|
||||
// Token: 0x06000886 RID: 2182 RVA: 0x0001F488 File Offset: 0x0001D688
|
||||
public static BigInteger operator /(BigInteger bi, int i)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
return BigInteger.Kernel.DwordDiv(bi, (uint)i);
|
||||
}
|
||||
throw new ArithmeticException("Operation would return a negative value");
|
||||
}
|
||||
|
||||
// Token: 0x06000887 RID: 2183 RVA: 0x0001F4A4 File Offset: 0x0001D6A4
|
||||
public static BigInteger operator /(BigInteger bi1, BigInteger bi2)
|
||||
{
|
||||
return BigInteger.Kernel.multiByteDivide(bi1, bi2)[0];
|
||||
}
|
||||
|
||||
// Token: 0x06000888 RID: 2184 RVA: 0x0001F4B0 File Offset: 0x0001D6B0
|
||||
public static BigInteger operator *(BigInteger bi1, BigInteger bi2)
|
||||
{
|
||||
if (bi1 == 0U || bi2 == 0U)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if ((long)bi1.data.Length < (long)((ulong)bi1.length))
|
||||
{
|
||||
throw new IndexOutOfRangeException("bi1 out of range");
|
||||
}
|
||||
if ((long)bi2.data.Length < (long)((ulong)bi2.length))
|
||||
{
|
||||
throw new IndexOutOfRangeException("bi2 out of range");
|
||||
}
|
||||
BigInteger bigInteger = new BigInteger(BigInteger.Sign.Positive, bi1.length + bi2.length);
|
||||
BigInteger.Kernel.Multiply(bi1.data, 0U, bi1.length, bi2.data, 0U, bi2.length, bigInteger.data, 0U);
|
||||
bigInteger.Normalize();
|
||||
return bigInteger;
|
||||
}
|
||||
|
||||
// Token: 0x06000889 RID: 2185 RVA: 0x0001F560 File Offset: 0x0001D760
|
||||
public static BigInteger operator *(BigInteger bi, int i)
|
||||
{
|
||||
if (i < 0)
|
||||
{
|
||||
throw new ArithmeticException("Operation would return a negative value");
|
||||
}
|
||||
if (i == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (i == 1)
|
||||
{
|
||||
return new BigInteger(bi);
|
||||
}
|
||||
return BigInteger.Kernel.MultiplyByDword(bi, (uint)i);
|
||||
}
|
||||
|
||||
// Token: 0x0600088A RID: 2186 RVA: 0x0001F5A4 File Offset: 0x0001D7A4
|
||||
public static BigInteger operator <<(BigInteger bi1, int shiftVal)
|
||||
{
|
||||
return BigInteger.Kernel.LeftShift(bi1, shiftVal);
|
||||
}
|
||||
|
||||
// Token: 0x0600088B RID: 2187 RVA: 0x0001F5B0 File Offset: 0x0001D7B0
|
||||
public static BigInteger operator >>(BigInteger bi1, int shiftVal)
|
||||
{
|
||||
return BigInteger.Kernel.RightShift(bi1, shiftVal);
|
||||
}
|
||||
|
||||
// Token: 0x0600088C RID: 2188 RVA: 0x0001F5BC File Offset: 0x0001D7BC
|
||||
public static bool operator ==(BigInteger bi1, uint ui)
|
||||
{
|
||||
if (bi1.length != 1U)
|
||||
{
|
||||
bi1.Normalize();
|
||||
}
|
||||
return bi1.length == 1U && bi1.data[0] == ui;
|
||||
}
|
||||
|
||||
// Token: 0x0600088D RID: 2189 RVA: 0x0001F5F8 File Offset: 0x0001D7F8
|
||||
public static bool operator !=(BigInteger bi1, uint ui)
|
||||
{
|
||||
if (bi1.length != 1U)
|
||||
{
|
||||
bi1.Normalize();
|
||||
}
|
||||
return bi1.length != 1U || bi1.data[0] != ui;
|
||||
}
|
||||
|
||||
// Token: 0x0600088E RID: 2190 RVA: 0x0001F62C File Offset: 0x0001D82C
|
||||
public static bool operator ==(BigInteger bi1, BigInteger bi2)
|
||||
{
|
||||
return bi1 == bi2 || (!(null == bi1) && !(null == bi2) && BigInteger.Kernel.Compare(bi1, bi2) == BigInteger.Sign.Zero);
|
||||
}
|
||||
|
||||
// Token: 0x0600088F RID: 2191 RVA: 0x0001F65C File Offset: 0x0001D85C
|
||||
public static bool operator !=(BigInteger bi1, BigInteger bi2)
|
||||
{
|
||||
return bi1 != bi2 && (null == bi1 || null == bi2 || BigInteger.Kernel.Compare(bi1, bi2) != BigInteger.Sign.Zero);
|
||||
}
|
||||
|
||||
// Token: 0x06000890 RID: 2192 RVA: 0x0001F69C File Offset: 0x0001D89C
|
||||
public static bool operator >(BigInteger bi1, BigInteger bi2)
|
||||
{
|
||||
return BigInteger.Kernel.Compare(bi1, bi2) > BigInteger.Sign.Zero;
|
||||
}
|
||||
|
||||
// Token: 0x06000891 RID: 2193 RVA: 0x0001F6A8 File Offset: 0x0001D8A8
|
||||
public static bool operator <(BigInteger bi1, BigInteger bi2)
|
||||
{
|
||||
return BigInteger.Kernel.Compare(bi1, bi2) < BigInteger.Sign.Zero;
|
||||
}
|
||||
|
||||
// Token: 0x06000892 RID: 2194 RVA: 0x0001F6B4 File Offset: 0x0001D8B4
|
||||
public static bool operator >=(BigInteger bi1, BigInteger bi2)
|
||||
{
|
||||
return BigInteger.Kernel.Compare(bi1, bi2) >= BigInteger.Sign.Zero;
|
||||
}
|
||||
|
||||
// Token: 0x06000893 RID: 2195 RVA: 0x0001F6C4 File Offset: 0x0001D8C4
|
||||
public static bool operator <=(BigInteger bi1, BigInteger bi2)
|
||||
{
|
||||
return BigInteger.Kernel.Compare(bi1, bi2) <= BigInteger.Sign.Zero;
|
||||
}
|
||||
|
||||
// Token: 0x040001B2 RID: 434
|
||||
private const uint DEFAULT_LEN = 20U;
|
||||
|
||||
// Token: 0x040001B3 RID: 435
|
||||
private const string WouldReturnNegVal = "Operation would return a negative value";
|
||||
|
||||
// Token: 0x040001B4 RID: 436
|
||||
private uint length = 1U;
|
||||
|
||||
// Token: 0x040001B5 RID: 437
|
||||
private uint[] data;
|
||||
|
||||
// Token: 0x040001B6 RID: 438
|
||||
internal static readonly uint[] smallPrimes = new uint[]
|
||||
{
|
||||
2U, 3U, 5U, 7U, 11U, 13U, 17U, 19U, 23U, 29U,
|
||||
31U, 37U, 41U, 43U, 47U, 53U, 59U, 61U, 67U, 71U,
|
||||
73U, 79U, 83U, 89U, 97U, 101U, 103U, 107U, 109U, 113U,
|
||||
127U, 131U, 137U, 139U, 149U, 151U, 157U, 163U, 167U, 173U,
|
||||
179U, 181U, 191U, 193U, 197U, 199U, 211U, 223U, 227U, 229U,
|
||||
233U, 239U, 241U, 251U, 257U, 263U, 269U, 271U, 277U, 281U,
|
||||
283U, 293U, 307U, 311U, 313U, 317U, 331U, 337U, 347U, 349U,
|
||||
353U, 359U, 367U, 373U, 379U, 383U, 389U, 397U, 401U, 409U,
|
||||
419U, 421U, 431U, 433U, 439U, 443U, 449U, 457U, 461U, 463U,
|
||||
467U, 479U, 487U, 491U, 499U, 503U, 509U, 521U, 523U, 541U,
|
||||
547U, 557U, 563U, 569U, 571U, 577U, 587U, 593U, 599U, 601U,
|
||||
607U, 613U, 617U, 619U, 631U, 641U, 643U, 647U, 653U, 659U,
|
||||
661U, 673U, 677U, 683U, 691U, 701U, 709U, 719U, 727U, 733U,
|
||||
739U, 743U, 751U, 757U, 761U, 769U, 773U, 787U, 797U, 809U,
|
||||
811U, 821U, 823U, 827U, 829U, 839U, 853U, 857U, 859U, 863U,
|
||||
877U, 881U, 883U, 887U, 907U, 911U, 919U, 929U, 937U, 941U,
|
||||
947U, 953U, 967U, 971U, 977U, 983U, 991U, 997U, 1009U, 1013U,
|
||||
1019U, 1021U, 1031U, 1033U, 1039U, 1049U, 1051U, 1061U, 1063U, 1069U,
|
||||
1087U, 1091U, 1093U, 1097U, 1103U, 1109U, 1117U, 1123U, 1129U, 1151U,
|
||||
1153U, 1163U, 1171U, 1181U, 1187U, 1193U, 1201U, 1213U, 1217U, 1223U,
|
||||
1229U, 1231U, 1237U, 1249U, 1259U, 1277U, 1279U, 1283U, 1289U, 1291U,
|
||||
1297U, 1301U, 1303U, 1307U, 1319U, 1321U, 1327U, 1361U, 1367U, 1373U,
|
||||
1381U, 1399U, 1409U, 1423U, 1427U, 1429U, 1433U, 1439U, 1447U, 1451U,
|
||||
1453U, 1459U, 1471U, 1481U, 1483U, 1487U, 1489U, 1493U, 1499U, 1511U,
|
||||
1523U, 1531U, 1543U, 1549U, 1553U, 1559U, 1567U, 1571U, 1579U, 1583U,
|
||||
1597U, 1601U, 1607U, 1609U, 1613U, 1619U, 1621U, 1627U, 1637U, 1657U,
|
||||
1663U, 1667U, 1669U, 1693U, 1697U, 1699U, 1709U, 1721U, 1723U, 1733U,
|
||||
1741U, 1747U, 1753U, 1759U, 1777U, 1783U, 1787U, 1789U, 1801U, 1811U,
|
||||
1823U, 1831U, 1847U, 1861U, 1867U, 1871U, 1873U, 1877U, 1879U, 1889U,
|
||||
1901U, 1907U, 1913U, 1931U, 1933U, 1949U, 1951U, 1973U, 1979U, 1987U,
|
||||
1993U, 1997U, 1999U, 2003U, 2011U, 2017U, 2027U, 2029U, 2039U, 2053U,
|
||||
2063U, 2069U, 2081U, 2083U, 2087U, 2089U, 2099U, 2111U, 2113U, 2129U,
|
||||
2131U, 2137U, 2141U, 2143U, 2153U, 2161U, 2179U, 2203U, 2207U, 2213U,
|
||||
2221U, 2237U, 2239U, 2243U, 2251U, 2267U, 2269U, 2273U, 2281U, 2287U,
|
||||
2293U, 2297U, 2309U, 2311U, 2333U, 2339U, 2341U, 2347U, 2351U, 2357U,
|
||||
2371U, 2377U, 2381U, 2383U, 2389U, 2393U, 2399U, 2411U, 2417U, 2423U,
|
||||
2437U, 2441U, 2447U, 2459U, 2467U, 2473U, 2477U, 2503U, 2521U, 2531U,
|
||||
2539U, 2543U, 2549U, 2551U, 2557U, 2579U, 2591U, 2593U, 2609U, 2617U,
|
||||
2621U, 2633U, 2647U, 2657U, 2659U, 2663U, 2671U, 2677U, 2683U, 2687U,
|
||||
2689U, 2693U, 2699U, 2707U, 2711U, 2713U, 2719U, 2729U, 2731U, 2741U,
|
||||
2749U, 2753U, 2767U, 2777U, 2789U, 2791U, 2797U, 2801U, 2803U, 2819U,
|
||||
2833U, 2837U, 2843U, 2851U, 2857U, 2861U, 2879U, 2887U, 2897U, 2903U,
|
||||
2909U, 2917U, 2927U, 2939U, 2953U, 2957U, 2963U, 2969U, 2971U, 2999U,
|
||||
3001U, 3011U, 3019U, 3023U, 3037U, 3041U, 3049U, 3061U, 3067U, 3079U,
|
||||
3083U, 3089U, 3109U, 3119U, 3121U, 3137U, 3163U, 3167U, 3169U, 3181U,
|
||||
3187U, 3191U, 3203U, 3209U, 3217U, 3221U, 3229U, 3251U, 3253U, 3257U,
|
||||
3259U, 3271U, 3299U, 3301U, 3307U, 3313U, 3319U, 3323U, 3329U, 3331U,
|
||||
3343U, 3347U, 3359U, 3361U, 3371U, 3373U, 3389U, 3391U, 3407U, 3413U,
|
||||
3433U, 3449U, 3457U, 3461U, 3463U, 3467U, 3469U, 3491U, 3499U, 3511U,
|
||||
3517U, 3527U, 3529U, 3533U, 3539U, 3541U, 3547U, 3557U, 3559U, 3571U,
|
||||
3581U, 3583U, 3593U, 3607U, 3613U, 3617U, 3623U, 3631U, 3637U, 3643U,
|
||||
3659U, 3671U, 3673U, 3677U, 3691U, 3697U, 3701U, 3709U, 3719U, 3727U,
|
||||
3733U, 3739U, 3761U, 3767U, 3769U, 3779U, 3793U, 3797U, 3803U, 3821U,
|
||||
3823U, 3833U, 3847U, 3851U, 3853U, 3863U, 3877U, 3881U, 3889U, 3907U,
|
||||
3911U, 3917U, 3919U, 3923U, 3929U, 3931U, 3943U, 3947U, 3967U, 3989U,
|
||||
4001U, 4003U, 4007U, 4013U, 4019U, 4021U, 4027U, 4049U, 4051U, 4057U,
|
||||
4073U, 4079U, 4091U, 4093U, 4099U, 4111U, 4127U, 4129U, 4133U, 4139U,
|
||||
4153U, 4157U, 4159U, 4177U, 4201U, 4211U, 4217U, 4219U, 4229U, 4231U,
|
||||
4241U, 4243U, 4253U, 4259U, 4261U, 4271U, 4273U, 4283U, 4289U, 4297U,
|
||||
4327U, 4337U, 4339U, 4349U, 4357U, 4363U, 4373U, 4391U, 4397U, 4409U,
|
||||
4421U, 4423U, 4441U, 4447U, 4451U, 4457U, 4463U, 4481U, 4483U, 4493U,
|
||||
4507U, 4513U, 4517U, 4519U, 4523U, 4547U, 4549U, 4561U, 4567U, 4583U,
|
||||
4591U, 4597U, 4603U, 4621U, 4637U, 4639U, 4643U, 4649U, 4651U, 4657U,
|
||||
4663U, 4673U, 4679U, 4691U, 4703U, 4721U, 4723U, 4729U, 4733U, 4751U,
|
||||
4759U, 4783U, 4787U, 4789U, 4793U, 4799U, 4801U, 4813U, 4817U, 4831U,
|
||||
4861U, 4871U, 4877U, 4889U, 4903U, 4909U, 4919U, 4931U, 4933U, 4937U,
|
||||
4943U, 4951U, 4957U, 4967U, 4969U, 4973U, 4987U, 4993U, 4999U, 5003U,
|
||||
5009U, 5011U, 5021U, 5023U, 5039U, 5051U, 5059U, 5077U, 5081U, 5087U,
|
||||
5099U, 5101U, 5107U, 5113U, 5119U, 5147U, 5153U, 5167U, 5171U, 5179U,
|
||||
5189U, 5197U, 5209U, 5227U, 5231U, 5233U, 5237U, 5261U, 5273U, 5279U,
|
||||
5281U, 5297U, 5303U, 5309U, 5323U, 5333U, 5347U, 5351U, 5381U, 5387U,
|
||||
5393U, 5399U, 5407U, 5413U, 5417U, 5419U, 5431U, 5437U, 5441U, 5443U,
|
||||
5449U, 5471U, 5477U, 5479U, 5483U, 5501U, 5503U, 5507U, 5519U, 5521U,
|
||||
5527U, 5531U, 5557U, 5563U, 5569U, 5573U, 5581U, 5591U, 5623U, 5639U,
|
||||
5641U, 5647U, 5651U, 5653U, 5657U, 5659U, 5669U, 5683U, 5689U, 5693U,
|
||||
5701U, 5711U, 5717U, 5737U, 5741U, 5743U, 5749U, 5779U, 5783U, 5791U,
|
||||
5801U, 5807U, 5813U, 5821U, 5827U, 5839U, 5843U, 5849U, 5851U, 5857U,
|
||||
5861U, 5867U, 5869U, 5879U, 5881U, 5897U, 5903U, 5923U, 5927U, 5939U,
|
||||
5953U, 5981U, 5987U
|
||||
};
|
||||
|
||||
// Token: 0x040001B7 RID: 439
|
||||
private static RandomNumberGenerator rng;
|
||||
|
||||
// Token: 0x0200009A RID: 154
|
||||
public enum Sign
|
||||
{
|
||||
// Token: 0x040001B9 RID: 441
|
||||
Negative = -1,
|
||||
// Token: 0x040001BA RID: 442
|
||||
Zero,
|
||||
// Token: 0x040001BB RID: 443
|
||||
Positive
|
||||
}
|
||||
|
||||
// Token: 0x0200009B RID: 155
|
||||
internal sealed class ModulusRing
|
||||
{
|
||||
// Token: 0x06000894 RID: 2196 RVA: 0x0001F6D4 File Offset: 0x0001D8D4
|
||||
public ModulusRing(BigInteger modulus)
|
||||
{
|
||||
this.mod = modulus;
|
||||
uint num = this.mod.length << 1;
|
||||
this.constant = new BigInteger(BigInteger.Sign.Positive, num + 1U);
|
||||
this.constant.data[(int)((UIntPtr)num)] = 1U;
|
||||
this.constant /= this.mod;
|
||||
}
|
||||
|
||||
// Token: 0x06000895 RID: 2197 RVA: 0x0001F734 File Offset: 0x0001D934
|
||||
public void BarrettReduction(BigInteger x)
|
||||
{
|
||||
BigInteger bigInteger = this.mod;
|
||||
uint length = bigInteger.length;
|
||||
uint num = length + 1U;
|
||||
uint num2 = length - 1U;
|
||||
if (x.length < length)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ((long)x.data.Length < (long)((ulong)x.length))
|
||||
{
|
||||
throw new IndexOutOfRangeException("x out of range");
|
||||
}
|
||||
BigInteger bigInteger2 = new BigInteger(BigInteger.Sign.Positive, x.length - num2 + this.constant.length);
|
||||
BigInteger.Kernel.Multiply(x.data, num2, x.length - num2, this.constant.data, 0U, this.constant.length, bigInteger2.data, 0U);
|
||||
uint num3 = ((x.length <= num) ? x.length : num);
|
||||
x.length = num3;
|
||||
x.Normalize();
|
||||
BigInteger bigInteger3 = new BigInteger(BigInteger.Sign.Positive, num);
|
||||
BigInteger.Kernel.MultiplyMod2p32pmod(bigInteger2.data, (int)num, (int)(bigInteger2.length - num), bigInteger.data, 0, (int)bigInteger.length, bigInteger3.data, 0, (int)num);
|
||||
bigInteger3.Normalize();
|
||||
if (bigInteger3 <= x)
|
||||
{
|
||||
BigInteger.Kernel.MinusEq(x, bigInteger3);
|
||||
}
|
||||
else
|
||||
{
|
||||
BigInteger bigInteger4 = new BigInteger(BigInteger.Sign.Positive, num + 1U);
|
||||
bigInteger4.data[(int)((UIntPtr)num)] = 1U;
|
||||
BigInteger.Kernel.MinusEq(bigInteger4, bigInteger3);
|
||||
BigInteger.Kernel.PlusEq(x, bigInteger4);
|
||||
}
|
||||
while (x >= bigInteger)
|
||||
{
|
||||
BigInteger.Kernel.MinusEq(x, bigInteger);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000896 RID: 2198 RVA: 0x0001F890 File Offset: 0x0001DA90
|
||||
public BigInteger Multiply(BigInteger a, BigInteger b)
|
||||
{
|
||||
if (a == 0U || b == 0U)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (a > this.mod)
|
||||
{
|
||||
a %= this.mod;
|
||||
}
|
||||
if (b > this.mod)
|
||||
{
|
||||
b %= this.mod;
|
||||
}
|
||||
BigInteger bigInteger = a * b;
|
||||
this.BarrettReduction(bigInteger);
|
||||
return bigInteger;
|
||||
}
|
||||
|
||||
// Token: 0x06000897 RID: 2199 RVA: 0x0001F90C File Offset: 0x0001DB0C
|
||||
public BigInteger Difference(BigInteger a, BigInteger b)
|
||||
{
|
||||
BigInteger.Sign sign = BigInteger.Kernel.Compare(a, b);
|
||||
BigInteger.Sign sign2 = sign;
|
||||
BigInteger bigInteger;
|
||||
switch (sign2 + 1)
|
||||
{
|
||||
case BigInteger.Sign.Zero:
|
||||
bigInteger = b - a;
|
||||
break;
|
||||
case BigInteger.Sign.Positive:
|
||||
return 0;
|
||||
case (BigInteger.Sign)2:
|
||||
bigInteger = a - b;
|
||||
break;
|
||||
default:
|
||||
throw new Exception();
|
||||
}
|
||||
if (bigInteger >= this.mod)
|
||||
{
|
||||
if (bigInteger.length >= this.mod.length << 1)
|
||||
{
|
||||
bigInteger %= this.mod;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.BarrettReduction(bigInteger);
|
||||
}
|
||||
}
|
||||
if (sign == BigInteger.Sign.Negative)
|
||||
{
|
||||
bigInteger = this.mod - bigInteger;
|
||||
}
|
||||
return bigInteger;
|
||||
}
|
||||
|
||||
// Token: 0x06000898 RID: 2200 RVA: 0x0001F9BC File Offset: 0x0001DBBC
|
||||
public BigInteger Pow(BigInteger a, BigInteger k)
|
||||
{
|
||||
BigInteger bigInteger = new BigInteger(1U);
|
||||
if (k == 0U)
|
||||
{
|
||||
return bigInteger;
|
||||
}
|
||||
BigInteger bigInteger2 = a;
|
||||
if (k.TestBit(0))
|
||||
{
|
||||
bigInteger = a;
|
||||
}
|
||||
for (int i = 1; i < k.BitCount(); i++)
|
||||
{
|
||||
bigInteger2 = this.Multiply(bigInteger2, bigInteger2);
|
||||
if (k.TestBit(i))
|
||||
{
|
||||
bigInteger = this.Multiply(bigInteger2, bigInteger);
|
||||
}
|
||||
}
|
||||
return bigInteger;
|
||||
}
|
||||
|
||||
// Token: 0x06000899 RID: 2201 RVA: 0x0001FA24 File Offset: 0x0001DC24
|
||||
public BigInteger Pow(uint b, BigInteger exp)
|
||||
{
|
||||
return this.Pow(new BigInteger(b), exp);
|
||||
}
|
||||
|
||||
// Token: 0x040001BC RID: 444
|
||||
private BigInteger mod;
|
||||
|
||||
// Token: 0x040001BD RID: 445
|
||||
private BigInteger constant;
|
||||
}
|
||||
|
||||
// Token: 0x0200009C RID: 156
|
||||
internal sealed class Montgomery
|
||||
{
|
||||
// Token: 0x0600089A RID: 2202 RVA: 0x0001FA34 File Offset: 0x0001DC34
|
||||
private Montgomery()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600089B RID: 2203 RVA: 0x0001FA3C File Offset: 0x0001DC3C
|
||||
public static uint Inverse(uint n)
|
||||
{
|
||||
uint num = n;
|
||||
uint num2;
|
||||
while ((num2 = n * num) != 1U)
|
||||
{
|
||||
num *= 2U - num2;
|
||||
}
|
||||
return (uint)(-(uint)((ulong)num));
|
||||
}
|
||||
|
||||
// Token: 0x0600089C RID: 2204 RVA: 0x0001FA68 File Offset: 0x0001DC68
|
||||
public static BigInteger ToMont(BigInteger n, BigInteger m)
|
||||
{
|
||||
n.Normalize();
|
||||
m.Normalize();
|
||||
n <<= (int)(m.length * 32U);
|
||||
n %= m;
|
||||
return n;
|
||||
}
|
||||
|
||||
// Token: 0x0600089D RID: 2205 RVA: 0x0001FA9C File Offset: 0x0001DC9C
|
||||
public unsafe static BigInteger Reduce(BigInteger n, BigInteger m, uint mPrime)
|
||||
{
|
||||
fixed (uint* ptr = (ref n.data != null && n.data.Length != 0 ? ref n.data[0] : ref *null), ptr2 = (ref m.data != null && m.data.Length != 0 ? ref m.data[0] : ref *null))
|
||||
{
|
||||
for (uint num = 0U; num < m.length; num += 1U)
|
||||
{
|
||||
uint num2 = *ptr * mPrime;
|
||||
uint* ptr3 = ptr2;
|
||||
uint* ptr4 = ptr;
|
||||
uint* ptr5 = ptr;
|
||||
ulong num3 = (ulong)num2 * (ulong)(*(ptr3++)) + (ulong)(*(ptr4++));
|
||||
num3 >>= 32;
|
||||
uint num4;
|
||||
for (num4 = 1U; num4 < m.length; num4 += 1U)
|
||||
{
|
||||
num3 += (ulong)num2 * (ulong)(*(ptr3++)) + (ulong)(*(ptr4++));
|
||||
*(ptr5++) = (uint)num3;
|
||||
num3 >>= 32;
|
||||
}
|
||||
while (num4 < n.length)
|
||||
{
|
||||
num3 += (ulong)(*(ptr4++));
|
||||
*(ptr5++) = (uint)num3;
|
||||
num3 >>= 32;
|
||||
if (num3 == 0UL)
|
||||
{
|
||||
num4 += 1U;
|
||||
break;
|
||||
}
|
||||
num4 += 1U;
|
||||
}
|
||||
while (num4 < n.length)
|
||||
{
|
||||
*(ptr5++) = *(ptr4++);
|
||||
num4 += 1U;
|
||||
}
|
||||
*(ptr5++) = (uint)num3;
|
||||
}
|
||||
while (n.length > 1U && ptr[n.length - 1U] == 0U)
|
||||
{
|
||||
n.length -= 1U;
|
||||
}
|
||||
}
|
||||
if (n >= m)
|
||||
{
|
||||
BigInteger.Kernel.MinusEq(n, m);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0200009D RID: 157
|
||||
private sealed class Kernel
|
||||
{
|
||||
// Token: 0x0600089F RID: 2207 RVA: 0x0001FC70 File Offset: 0x0001DE70
|
||||
public static BigInteger AddSameSign(BigInteger bi1, BigInteger bi2)
|
||||
{
|
||||
uint num = 0U;
|
||||
uint[] array;
|
||||
uint num2;
|
||||
uint[] array2;
|
||||
uint num3;
|
||||
if (bi1.length < bi2.length)
|
||||
{
|
||||
array = bi2.data;
|
||||
num2 = bi2.length;
|
||||
array2 = bi1.data;
|
||||
num3 = bi1.length;
|
||||
}
|
||||
else
|
||||
{
|
||||
array = bi1.data;
|
||||
num2 = bi1.length;
|
||||
array2 = bi2.data;
|
||||
num3 = bi2.length;
|
||||
}
|
||||
BigInteger bigInteger = new BigInteger(BigInteger.Sign.Positive, num2 + 1U);
|
||||
uint[] data = bigInteger.data;
|
||||
ulong num4 = 0UL;
|
||||
do
|
||||
{
|
||||
num4 = (ulong)array[(int)((UIntPtr)num)] + (ulong)array2[(int)((UIntPtr)num)] + num4;
|
||||
data[(int)((UIntPtr)num)] = (uint)num4;
|
||||
num4 >>= 32;
|
||||
}
|
||||
while ((num += 1U) < num3);
|
||||
bool flag = num4 != 0UL;
|
||||
if (flag)
|
||||
{
|
||||
if (num < num2)
|
||||
{
|
||||
do
|
||||
{
|
||||
flag = (data[(int)((UIntPtr)num)] = array[(int)((UIntPtr)num)] + 1U) == 0U;
|
||||
}
|
||||
while ((num += 1U) < num2 && flag);
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
data[(int)((UIntPtr)num)] = 1U;
|
||||
bigInteger.length = num + 1U;
|
||||
return bigInteger;
|
||||
}
|
||||
}
|
||||
if (num < num2)
|
||||
{
|
||||
do
|
||||
{
|
||||
data[(int)((UIntPtr)num)] = array[(int)((UIntPtr)num)];
|
||||
}
|
||||
while ((num += 1U) < num2);
|
||||
}
|
||||
bigInteger.Normalize();
|
||||
return bigInteger;
|
||||
}
|
||||
|
||||
// Token: 0x060008A0 RID: 2208 RVA: 0x0001FDA4 File Offset: 0x0001DFA4
|
||||
public static BigInteger Subtract(BigInteger big, BigInteger small)
|
||||
{
|
||||
BigInteger bigInteger = new BigInteger(BigInteger.Sign.Positive, big.length);
|
||||
uint[] data = bigInteger.data;
|
||||
uint[] data2 = big.data;
|
||||
uint[] data3 = small.data;
|
||||
uint num = 0U;
|
||||
uint num2 = 0U;
|
||||
do
|
||||
{
|
||||
uint num3 = data3[(int)((UIntPtr)num)];
|
||||
if (((num3 += num2) < num2) | ((data[(int)((UIntPtr)num)] = data2[(int)((UIntPtr)num)] - num3) > ~num3))
|
||||
{
|
||||
num2 = 1U;
|
||||
}
|
||||
else
|
||||
{
|
||||
num2 = 0U;
|
||||
}
|
||||
}
|
||||
while ((num += 1U) < small.length);
|
||||
if (num != big.length)
|
||||
{
|
||||
if (num2 == 1U)
|
||||
{
|
||||
do
|
||||
{
|
||||
data[(int)((UIntPtr)num)] = data2[(int)((UIntPtr)num)] - 1U;
|
||||
}
|
||||
while (data2[(int)((UIntPtr)(num++))] == 0U && num < big.length);
|
||||
if (num == big.length)
|
||||
{
|
||||
goto IL_E5;
|
||||
}
|
||||
}
|
||||
do
|
||||
{
|
||||
data[(int)((UIntPtr)num)] = data2[(int)((UIntPtr)num)];
|
||||
}
|
||||
while ((num += 1U) < big.length);
|
||||
}
|
||||
IL_E5:
|
||||
bigInteger.Normalize();
|
||||
return bigInteger;
|
||||
}
|
||||
|
||||
// Token: 0x060008A1 RID: 2209 RVA: 0x0001FEA0 File Offset: 0x0001E0A0
|
||||
public static void MinusEq(BigInteger big, BigInteger small)
|
||||
{
|
||||
uint[] data = big.data;
|
||||
uint[] data2 = small.data;
|
||||
uint num = 0U;
|
||||
uint num2 = 0U;
|
||||
do
|
||||
{
|
||||
uint num3 = data2[(int)((UIntPtr)num)];
|
||||
if (((num3 += num2) < num2) | ((data[(int)((UIntPtr)num)] -= num3) > ~num3))
|
||||
{
|
||||
num2 = 1U;
|
||||
}
|
||||
else
|
||||
{
|
||||
num2 = 0U;
|
||||
}
|
||||
}
|
||||
while ((num += 1U) < small.length);
|
||||
if (num != big.length)
|
||||
{
|
||||
if (num2 == 1U)
|
||||
{
|
||||
do
|
||||
{
|
||||
data[(int)((UIntPtr)num)] -= 1U;
|
||||
}
|
||||
while (data[(int)((UIntPtr)(num++))] == 0U && num < big.length);
|
||||
}
|
||||
}
|
||||
while (big.length > 0U && big.data[(int)((UIntPtr)(big.length - 1U))] == 0U)
|
||||
{
|
||||
big.length -= 1U;
|
||||
}
|
||||
if (big.length == 0U)
|
||||
{
|
||||
big.length += 1U;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060008A2 RID: 2210 RVA: 0x0001FF94 File Offset: 0x0001E194
|
||||
public static void PlusEq(BigInteger bi1, BigInteger bi2)
|
||||
{
|
||||
uint num = 0U;
|
||||
bool flag = false;
|
||||
uint[] array;
|
||||
uint num2;
|
||||
uint[] array2;
|
||||
uint num3;
|
||||
if (bi1.length < bi2.length)
|
||||
{
|
||||
flag = true;
|
||||
array = bi2.data;
|
||||
num2 = bi2.length;
|
||||
array2 = bi1.data;
|
||||
num3 = bi1.length;
|
||||
}
|
||||
else
|
||||
{
|
||||
array = bi1.data;
|
||||
num2 = bi1.length;
|
||||
array2 = bi2.data;
|
||||
num3 = bi2.length;
|
||||
}
|
||||
uint[] data = bi1.data;
|
||||
ulong num4 = 0UL;
|
||||
do
|
||||
{
|
||||
num4 += (ulong)array[(int)((UIntPtr)num)] + (ulong)array2[(int)((UIntPtr)num)];
|
||||
data[(int)((UIntPtr)num)] = (uint)num4;
|
||||
num4 >>= 32;
|
||||
}
|
||||
while ((num += 1U) < num3);
|
||||
bool flag2 = num4 != 0UL;
|
||||
if (flag2)
|
||||
{
|
||||
if (num < num2)
|
||||
{
|
||||
do
|
||||
{
|
||||
flag2 = (data[(int)((UIntPtr)num)] = array[(int)((UIntPtr)num)] + 1U) == 0U;
|
||||
}
|
||||
while ((num += 1U) < num2 && flag2);
|
||||
}
|
||||
if (flag2)
|
||||
{
|
||||
data[(int)((UIntPtr)num)] = 1U;
|
||||
bi1.length = num + 1U;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (flag && num < num2 - 1U)
|
||||
{
|
||||
do
|
||||
{
|
||||
data[(int)((UIntPtr)num)] = array[(int)((UIntPtr)num)];
|
||||
}
|
||||
while ((num += 1U) < num2);
|
||||
}
|
||||
bi1.length = num2 + 1U;
|
||||
bi1.Normalize();
|
||||
}
|
||||
|
||||
// Token: 0x060008A3 RID: 2211 RVA: 0x000200CC File Offset: 0x0001E2CC
|
||||
public static BigInteger.Sign Compare(BigInteger bi1, BigInteger bi2)
|
||||
{
|
||||
uint num = bi1.length;
|
||||
uint num2 = bi2.length;
|
||||
while (num > 0U && bi1.data[(int)((UIntPtr)(num - 1U))] == 0U)
|
||||
{
|
||||
num -= 1U;
|
||||
}
|
||||
while (num2 > 0U && bi2.data[(int)((UIntPtr)(num2 - 1U))] == 0U)
|
||||
{
|
||||
num2 -= 1U;
|
||||
}
|
||||
if (num == 0U && num2 == 0U)
|
||||
{
|
||||
return BigInteger.Sign.Zero;
|
||||
}
|
||||
if (num < num2)
|
||||
{
|
||||
return BigInteger.Sign.Negative;
|
||||
}
|
||||
if (num > num2)
|
||||
{
|
||||
return BigInteger.Sign.Positive;
|
||||
}
|
||||
uint num3 = num - 1U;
|
||||
while (num3 != 0U && bi1.data[(int)((UIntPtr)num3)] == bi2.data[(int)((UIntPtr)num3)])
|
||||
{
|
||||
num3 -= 1U;
|
||||
}
|
||||
if (bi1.data[(int)((UIntPtr)num3)] < bi2.data[(int)((UIntPtr)num3)])
|
||||
{
|
||||
return BigInteger.Sign.Negative;
|
||||
}
|
||||
if (bi1.data[(int)((UIntPtr)num3)] > bi2.data[(int)((UIntPtr)num3)])
|
||||
{
|
||||
return BigInteger.Sign.Positive;
|
||||
}
|
||||
return BigInteger.Sign.Zero;
|
||||
}
|
||||
|
||||
// Token: 0x060008A4 RID: 2212 RVA: 0x000201A4 File Offset: 0x0001E3A4
|
||||
public static uint SingleByteDivideInPlace(BigInteger n, uint d)
|
||||
{
|
||||
ulong num = 0UL;
|
||||
uint length = n.length;
|
||||
while (length-- > 0U)
|
||||
{
|
||||
num <<= 32;
|
||||
num |= (ulong)n.data[(int)((UIntPtr)length)];
|
||||
n.data[(int)((UIntPtr)length)] = (uint)(num / (ulong)d);
|
||||
num %= (ulong)d;
|
||||
}
|
||||
n.Normalize();
|
||||
return (uint)num;
|
||||
}
|
||||
|
||||
// Token: 0x060008A5 RID: 2213 RVA: 0x000201F8 File Offset: 0x0001E3F8
|
||||
public static uint DwordMod(BigInteger n, uint d)
|
||||
{
|
||||
ulong num = 0UL;
|
||||
uint length = n.length;
|
||||
while (length-- > 0U)
|
||||
{
|
||||
num <<= 32;
|
||||
num |= (ulong)n.data[(int)((UIntPtr)length)];
|
||||
num %= (ulong)d;
|
||||
}
|
||||
return (uint)num;
|
||||
}
|
||||
|
||||
// Token: 0x060008A6 RID: 2214 RVA: 0x00020238 File Offset: 0x0001E438
|
||||
public static BigInteger DwordDiv(BigInteger n, uint d)
|
||||
{
|
||||
BigInteger bigInteger = new BigInteger(BigInteger.Sign.Positive, n.length);
|
||||
ulong num = 0UL;
|
||||
uint length = n.length;
|
||||
while (length-- > 0U)
|
||||
{
|
||||
num <<= 32;
|
||||
num |= (ulong)n.data[(int)((UIntPtr)length)];
|
||||
bigInteger.data[(int)((UIntPtr)length)] = (uint)(num / (ulong)d);
|
||||
num %= (ulong)d;
|
||||
}
|
||||
bigInteger.Normalize();
|
||||
return bigInteger;
|
||||
}
|
||||
|
||||
// Token: 0x060008A7 RID: 2215 RVA: 0x00020298 File Offset: 0x0001E498
|
||||
public static BigInteger[] DwordDivMod(BigInteger n, uint d)
|
||||
{
|
||||
BigInteger bigInteger = new BigInteger(BigInteger.Sign.Positive, n.length);
|
||||
ulong num = 0UL;
|
||||
uint length = n.length;
|
||||
while (length-- > 0U)
|
||||
{
|
||||
num <<= 32;
|
||||
num |= (ulong)n.data[(int)((UIntPtr)length)];
|
||||
bigInteger.data[(int)((UIntPtr)length)] = (uint)(num / (ulong)d);
|
||||
num %= (ulong)d;
|
||||
}
|
||||
bigInteger.Normalize();
|
||||
BigInteger bigInteger2 = (uint)num;
|
||||
return new BigInteger[] { bigInteger, bigInteger2 };
|
||||
}
|
||||
|
||||
// Token: 0x060008A8 RID: 2216 RVA: 0x00020310 File Offset: 0x0001E510
|
||||
public static BigInteger[] multiByteDivide(BigInteger bi1, BigInteger bi2)
|
||||
{
|
||||
if (BigInteger.Kernel.Compare(bi1, bi2) == BigInteger.Sign.Negative)
|
||||
{
|
||||
return new BigInteger[]
|
||||
{
|
||||
0,
|
||||
new BigInteger(bi1)
|
||||
};
|
||||
}
|
||||
bi1.Normalize();
|
||||
bi2.Normalize();
|
||||
if (bi2.length == 1U)
|
||||
{
|
||||
return BigInteger.Kernel.DwordDivMod(bi1, bi2.data[0]);
|
||||
}
|
||||
uint num = bi1.length + 1U;
|
||||
int num2 = (int)(bi2.length + 1U);
|
||||
uint num3 = 2147483648U;
|
||||
uint num4 = bi2.data[(int)((UIntPtr)(bi2.length - 1U))];
|
||||
int num5 = 0;
|
||||
int num6 = (int)(bi1.length - bi2.length);
|
||||
while (num3 != 0U && (num4 & num3) == 0U)
|
||||
{
|
||||
num5++;
|
||||
num3 >>= 1;
|
||||
}
|
||||
BigInteger bigInteger = new BigInteger(BigInteger.Sign.Positive, bi1.length - bi2.length + 1U);
|
||||
BigInteger bigInteger2 = bi1 << num5;
|
||||
uint[] data = bigInteger2.data;
|
||||
bi2 <<= num5;
|
||||
int i = (int)(num - bi2.length);
|
||||
int num7 = (int)(num - 1U);
|
||||
uint num8 = bi2.data[(int)((UIntPtr)(bi2.length - 1U))];
|
||||
ulong num9 = (ulong)bi2.data[(int)((UIntPtr)(bi2.length - 2U))];
|
||||
while (i > 0)
|
||||
{
|
||||
ulong num10 = ((ulong)data[num7] << 32) + (ulong)data[num7 - 1];
|
||||
ulong num11 = num10 / (ulong)num8;
|
||||
ulong num12 = num10 % (ulong)num8;
|
||||
while (num11 == 4294967296UL || num11 * num9 > (num12 << 32) + (ulong)data[num7 - 2])
|
||||
{
|
||||
num11 -= 1UL;
|
||||
num12 += (ulong)num8;
|
||||
if (num12 >= 4294967296UL)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
uint num13 = 0U;
|
||||
int num14 = num7 - num2 + 1;
|
||||
ulong num15 = 0UL;
|
||||
uint num16 = (uint)num11;
|
||||
do
|
||||
{
|
||||
num15 += (ulong)bi2.data[(int)((UIntPtr)num13)] * (ulong)num16;
|
||||
uint num17 = data[num14];
|
||||
data[num14] -= (uint)num15;
|
||||
num15 >>= 32;
|
||||
if (data[num14] > num17)
|
||||
{
|
||||
num15 += 1UL;
|
||||
}
|
||||
num13 += 1U;
|
||||
num14++;
|
||||
}
|
||||
while ((ulong)num13 < (ulong)((long)num2));
|
||||
num14 = num7 - num2 + 1;
|
||||
num13 = 0U;
|
||||
if (num15 != 0UL)
|
||||
{
|
||||
num16 -= 1U;
|
||||
ulong num18 = 0UL;
|
||||
do
|
||||
{
|
||||
num18 = (ulong)data[num14] + (ulong)bi2.data[(int)((UIntPtr)num13)] + num18;
|
||||
data[num14] = (uint)num18;
|
||||
num18 >>= 32;
|
||||
num13 += 1U;
|
||||
num14++;
|
||||
}
|
||||
while ((ulong)num13 < (ulong)((long)num2));
|
||||
}
|
||||
bigInteger.data[num6--] = num16;
|
||||
num7--;
|
||||
i--;
|
||||
}
|
||||
bigInteger.Normalize();
|
||||
bigInteger2.Normalize();
|
||||
BigInteger[] array = new BigInteger[] { bigInteger, bigInteger2 };
|
||||
if (num5 != 0)
|
||||
{
|
||||
BigInteger[] array2 = array;
|
||||
int num19 = 1;
|
||||
array2[num19] >>= num5;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x060008A9 RID: 2217 RVA: 0x000205D0 File Offset: 0x0001E7D0
|
||||
public static BigInteger LeftShift(BigInteger bi, int n)
|
||||
{
|
||||
if (n == 0)
|
||||
{
|
||||
return new BigInteger(bi, bi.length + 1U);
|
||||
}
|
||||
int num = n >> 5;
|
||||
n &= 31;
|
||||
BigInteger bigInteger = new BigInteger(BigInteger.Sign.Positive, bi.length + 1U + (uint)num);
|
||||
uint num2 = 0U;
|
||||
uint length = bi.length;
|
||||
if (n != 0)
|
||||
{
|
||||
uint num3 = 0U;
|
||||
while (num2 < length)
|
||||
{
|
||||
uint num4 = bi.data[(int)((UIntPtr)num2)];
|
||||
checked
|
||||
{
|
||||
bigInteger.data[(int)((IntPtr)(unchecked((ulong)num2 + (ulong)((long)num))))] = (num4 << n) | num3;
|
||||
}
|
||||
num3 = num4 >> 32 - n;
|
||||
num2 += 1U;
|
||||
}
|
||||
checked
|
||||
{
|
||||
bigInteger.data[(int)((IntPtr)(unchecked((ulong)num2 + (ulong)((long)num))))] = num3;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (num2 < length)
|
||||
{
|
||||
bigInteger.data[(int)(checked((IntPtr)(unchecked((ulong)num2 + (ulong)((long)num)))))] = bi.data[(int)((UIntPtr)num2)];
|
||||
num2 += 1U;
|
||||
}
|
||||
}
|
||||
bigInteger.Normalize();
|
||||
return bigInteger;
|
||||
}
|
||||
|
||||
// Token: 0x060008AA RID: 2218 RVA: 0x000206A0 File Offset: 0x0001E8A0
|
||||
public static BigInteger RightShift(BigInteger bi, int n)
|
||||
{
|
||||
if (n == 0)
|
||||
{
|
||||
return new BigInteger(bi);
|
||||
}
|
||||
int num = n >> 5;
|
||||
int num2 = n & 31;
|
||||
BigInteger bigInteger = new BigInteger(BigInteger.Sign.Positive, bi.length - (uint)num + 1U);
|
||||
uint num3 = (uint)(bigInteger.data.Length - 1);
|
||||
if (num2 != 0)
|
||||
{
|
||||
uint num4 = 0U;
|
||||
while (num3-- > 0U)
|
||||
{
|
||||
uint num5;
|
||||
checked
|
||||
{
|
||||
num5 = bi.data[(int)((IntPtr)(unchecked((ulong)num3 + (ulong)((long)num))))];
|
||||
}
|
||||
bigInteger.data[(int)((UIntPtr)num3)] = (num5 >> n) | num4;
|
||||
num4 = num5 << 32 - n;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (num3-- > 0U)
|
||||
{
|
||||
bigInteger.data[(int)((UIntPtr)num3)] = bi.data[(int)(checked((IntPtr)(unchecked((ulong)num3 + (ulong)((long)num)))))];
|
||||
}
|
||||
}
|
||||
bigInteger.Normalize();
|
||||
return bigInteger;
|
||||
}
|
||||
|
||||
// Token: 0x060008AB RID: 2219 RVA: 0x00020758 File Offset: 0x0001E958
|
||||
public static BigInteger MultiplyByDword(BigInteger n, uint f)
|
||||
{
|
||||
BigInteger bigInteger = new BigInteger(BigInteger.Sign.Positive, n.length + 1U);
|
||||
uint num = 0U;
|
||||
ulong num2 = 0UL;
|
||||
do
|
||||
{
|
||||
num2 += (ulong)n.data[(int)((UIntPtr)num)] * (ulong)f;
|
||||
bigInteger.data[(int)((UIntPtr)num)] = (uint)num2;
|
||||
num2 >>= 32;
|
||||
}
|
||||
while ((num += 1U) < n.length);
|
||||
bigInteger.data[(int)((UIntPtr)num)] = (uint)num2;
|
||||
bigInteger.Normalize();
|
||||
return bigInteger;
|
||||
}
|
||||
|
||||
// Token: 0x060008AC RID: 2220 RVA: 0x000207BC File Offset: 0x0001E9BC
|
||||
public unsafe static void Multiply(uint[] x, uint xOffset, uint xLen, uint[] y, uint yOffset, uint yLen, uint[] d, uint dOffset)
|
||||
{
|
||||
fixed (uint* ptr = (ref x != null && x.Length != 0 ? ref x[0] : ref *null), ptr2 = (ref y != null && y.Length != 0 ? ref y[0] : ref *null), ptr3 = (ref d != null && d.Length != 0 ? ref d[0] : ref *null))
|
||||
{
|
||||
uint* ptr4 = ptr + xOffset;
|
||||
uint* ptr5 = ptr4 + xLen;
|
||||
uint* ptr6 = ptr2 + yOffset;
|
||||
uint* ptr7 = ptr6 + yLen;
|
||||
uint* ptr8 = ptr3 + dOffset;
|
||||
while (ptr4 < ptr5)
|
||||
{
|
||||
if (*ptr4 != 0U)
|
||||
{
|
||||
ulong num = 0UL;
|
||||
uint* ptr9 = ptr8;
|
||||
uint* ptr10 = ptr6;
|
||||
while (ptr10 < ptr7)
|
||||
{
|
||||
num += (ulong)(*ptr4) * (ulong)(*ptr10) + (ulong)(*ptr9);
|
||||
*ptr9 = (uint)num;
|
||||
num >>= 32;
|
||||
ptr10++;
|
||||
ptr9++;
|
||||
}
|
||||
if (num != 0UL)
|
||||
{
|
||||
*ptr9 = (uint)num;
|
||||
}
|
||||
}
|
||||
ptr4++;
|
||||
ptr8++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060008AD RID: 2221 RVA: 0x000208D0 File Offset: 0x0001EAD0
|
||||
public unsafe static void MultiplyMod2p32pmod(uint[] x, int xOffset, int xLen, uint[] y, int yOffest, int yLen, uint[] d, int dOffset, int mod)
|
||||
{
|
||||
fixed (uint* ptr = (ref x != null && x.Length != 0 ? ref x[0] : ref *null), ptr2 = (ref y != null && y.Length != 0 ? ref y[0] : ref *null), ptr3 = (ref d != null && d.Length != 0 ? ref d[0] : ref *null))
|
||||
{
|
||||
uint* ptr4 = ptr + xOffset;
|
||||
uint* ptr5 = ptr4 + xLen;
|
||||
uint* ptr6 = ptr2 + yOffest;
|
||||
uint* ptr7 = ptr6 + yLen;
|
||||
uint* ptr8 = ptr3 + dOffset;
|
||||
uint* ptr9 = ptr8 + mod;
|
||||
while (ptr4 < ptr5)
|
||||
{
|
||||
if (*ptr4 != 0U)
|
||||
{
|
||||
ulong num = 0UL;
|
||||
uint* ptr10 = ptr8;
|
||||
uint* ptr11 = ptr6;
|
||||
while (ptr11 < ptr7 && ptr10 < ptr9)
|
||||
{
|
||||
num += (ulong)(*ptr4) * (ulong)(*ptr11) + (ulong)(*ptr10);
|
||||
*ptr10 = (uint)num;
|
||||
num >>= 32;
|
||||
ptr11++;
|
||||
ptr10++;
|
||||
}
|
||||
if (num != 0UL && ptr10 < ptr9)
|
||||
{
|
||||
*ptr10 = (uint)num;
|
||||
}
|
||||
}
|
||||
ptr4++;
|
||||
ptr8++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060008AE RID: 2222 RVA: 0x000209FC File Offset: 0x0001EBFC
|
||||
public unsafe static void SquarePositive(BigInteger bi, ref uint[] wkSpace)
|
||||
{
|
||||
uint[] array = wkSpace;
|
||||
wkSpace = bi.data;
|
||||
uint[] data = bi.data;
|
||||
uint length = bi.length;
|
||||
bi.data = array;
|
||||
fixed (uint* ptr = (ref data != null && data.Length != 0 ? ref data[0] : ref *null), ptr2 = (ref array != null && array.Length != 0 ? ref array[0] : ref *null))
|
||||
{
|
||||
uint* ptr3 = ptr2 + array.Length;
|
||||
for (uint* ptr4 = ptr2; ptr4 < ptr3; ptr4++)
|
||||
{
|
||||
*ptr4 = 0U;
|
||||
}
|
||||
uint* ptr5 = ptr;
|
||||
uint* ptr6 = ptr2;
|
||||
uint num = 0U;
|
||||
while (num < length)
|
||||
{
|
||||
if (*ptr5 != 0U)
|
||||
{
|
||||
ulong num2 = 0UL;
|
||||
uint num3 = *ptr5;
|
||||
uint* ptr7 = ptr5 + 1;
|
||||
uint* ptr8 = ptr6 + 2U * num + 1;
|
||||
uint num4 = num + 1U;
|
||||
while (num4 < length)
|
||||
{
|
||||
num2 += (ulong)num3 * (ulong)(*ptr7) + (ulong)(*ptr8);
|
||||
*ptr8 = (uint)num2;
|
||||
num2 >>= 32;
|
||||
num4 += 1U;
|
||||
ptr8++;
|
||||
ptr7++;
|
||||
}
|
||||
if (num2 != 0UL)
|
||||
{
|
||||
*ptr8 = (uint)num2;
|
||||
}
|
||||
}
|
||||
num += 1U;
|
||||
ptr5++;
|
||||
}
|
||||
ptr6 = ptr2;
|
||||
uint num5 = 0U;
|
||||
while (ptr6 < ptr3)
|
||||
{
|
||||
uint num6 = *ptr6;
|
||||
*ptr6 = (num6 << 1) | num5;
|
||||
num5 = num6 >> 31;
|
||||
ptr6++;
|
||||
}
|
||||
if (num5 != 0U)
|
||||
{
|
||||
*ptr6 = num5;
|
||||
}
|
||||
ptr5 = ptr;
|
||||
ptr6 = ptr2;
|
||||
uint* ptr9 = ptr5 + length;
|
||||
while (ptr5 < ptr9)
|
||||
{
|
||||
ulong num7 = (ulong)(*ptr5) * (ulong)(*ptr5) + (ulong)(*ptr6);
|
||||
*ptr6 = (uint)num7;
|
||||
num7 >>= 32;
|
||||
*(++ptr6) += (uint)num7;
|
||||
if (*ptr6 < (uint)num7)
|
||||
{
|
||||
uint* ptr10 = ptr6;
|
||||
*(++ptr10) += 1U;
|
||||
while (*(ptr10++) == 0U)
|
||||
{
|
||||
*ptr10 += 1U;
|
||||
}
|
||||
}
|
||||
ptr5++;
|
||||
ptr6++;
|
||||
}
|
||||
bi.length <<= 1;
|
||||
while (ptr2[bi.length - 1U] == 0U && bi.length > 1U)
|
||||
{
|
||||
bi.length -= 1U;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060008AF RID: 2223 RVA: 0x00020C40 File Offset: 0x0001EE40
|
||||
public static BigInteger gcd(BigInteger a, BigInteger b)
|
||||
{
|
||||
BigInteger bigInteger = a;
|
||||
BigInteger bigInteger2 = b;
|
||||
BigInteger bigInteger3 = bigInteger2;
|
||||
while (bigInteger.length > 1U)
|
||||
{
|
||||
bigInteger3 = bigInteger;
|
||||
bigInteger = bigInteger2 % bigInteger;
|
||||
bigInteger2 = bigInteger3;
|
||||
}
|
||||
if (bigInteger == 0U)
|
||||
{
|
||||
return bigInteger3;
|
||||
}
|
||||
uint num = bigInteger.data[0];
|
||||
uint num2 = bigInteger2 % num;
|
||||
int num3 = 0;
|
||||
while (((num2 | num) & 1U) == 0U)
|
||||
{
|
||||
num2 >>= 1;
|
||||
num >>= 1;
|
||||
num3++;
|
||||
}
|
||||
while (num2 != 0U)
|
||||
{
|
||||
while ((num2 & 1U) == 0U)
|
||||
{
|
||||
num2 >>= 1;
|
||||
}
|
||||
while ((num & 1U) == 0U)
|
||||
{
|
||||
num >>= 1;
|
||||
}
|
||||
if (num2 >= num)
|
||||
{
|
||||
num2 = num2 - num >> 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
num = num - num2 >> 1;
|
||||
}
|
||||
}
|
||||
return num << num3;
|
||||
}
|
||||
|
||||
// Token: 0x060008B0 RID: 2224 RVA: 0x00020D0C File Offset: 0x0001EF0C
|
||||
public static uint modInverse(BigInteger bi, uint modulus)
|
||||
{
|
||||
uint num = modulus;
|
||||
uint num2 = bi % modulus;
|
||||
uint num3 = 0U;
|
||||
uint num4 = 1U;
|
||||
while (num2 != 0U)
|
||||
{
|
||||
if (num2 == 1U)
|
||||
{
|
||||
return num4;
|
||||
}
|
||||
num3 += num / num2 * num4;
|
||||
num %= num2;
|
||||
if (num == 0U)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (num == 1U)
|
||||
{
|
||||
return modulus - num3;
|
||||
}
|
||||
num4 += num2 / num * num3;
|
||||
num2 %= num;
|
||||
}
|
||||
return 0U;
|
||||
}
|
||||
|
||||
// Token: 0x060008B1 RID: 2225 RVA: 0x00020D6C File Offset: 0x0001EF6C
|
||||
public static BigInteger modInverse(BigInteger bi, BigInteger modulus)
|
||||
{
|
||||
if (modulus.length == 1U)
|
||||
{
|
||||
return BigInteger.Kernel.modInverse(bi, modulus.data[0]);
|
||||
}
|
||||
BigInteger[] array = new BigInteger[] { 0, 1 };
|
||||
BigInteger[] array2 = new BigInteger[2];
|
||||
BigInteger[] array3 = new BigInteger[] { 0, 0 };
|
||||
int num = 0;
|
||||
BigInteger bigInteger = modulus;
|
||||
BigInteger bigInteger2 = bi;
|
||||
BigInteger.ModulusRing modulusRing = new BigInteger.ModulusRing(modulus);
|
||||
while (bigInteger2 != 0U)
|
||||
{
|
||||
if (num > 1)
|
||||
{
|
||||
BigInteger bigInteger3 = modulusRing.Difference(array[0], array[1] * array2[0]);
|
||||
array[0] = array[1];
|
||||
array[1] = bigInteger3;
|
||||
}
|
||||
BigInteger[] array4 = BigInteger.Kernel.multiByteDivide(bigInteger, bigInteger2);
|
||||
array2[0] = array2[1];
|
||||
array2[1] = array4[0];
|
||||
array3[0] = array3[1];
|
||||
array3[1] = array4[1];
|
||||
bigInteger = bigInteger2;
|
||||
bigInteger2 = array4[1];
|
||||
num++;
|
||||
}
|
||||
if (array3[0] != 1U)
|
||||
{
|
||||
throw new ArithmeticException("No inverse!");
|
||||
}
|
||||
return modulusRing.Difference(array[0], array[1] * array2[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Math.Prime
|
||||
{
|
||||
// Token: 0x02000097 RID: 151
|
||||
internal enum ConfidenceFactor
|
||||
{
|
||||
// Token: 0x040001AC RID: 428
|
||||
ExtraLow,
|
||||
// Token: 0x040001AD RID: 429
|
||||
Low,
|
||||
// Token: 0x040001AE RID: 430
|
||||
Medium,
|
||||
// Token: 0x040001AF RID: 431
|
||||
High,
|
||||
// Token: 0x040001B0 RID: 432
|
||||
ExtraHigh,
|
||||
// Token: 0x040001B1 RID: 433
|
||||
Provable
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Math.Prime.Generator
|
||||
{
|
||||
// Token: 0x02000094 RID: 148
|
||||
internal class NextPrimeFinder : SequentialSearchPrimeGeneratorBase
|
||||
{
|
||||
// Token: 0x0600083E RID: 2110 RVA: 0x0001E2E0 File Offset: 0x0001C4E0
|
||||
protected override BigInteger GenerateSearchBase(int bits, object Context)
|
||||
{
|
||||
if (Context == null)
|
||||
{
|
||||
throw new ArgumentNullException("Context");
|
||||
}
|
||||
BigInteger bigInteger = new BigInteger((BigInteger)Context);
|
||||
bigInteger.SetBit(0U);
|
||||
return bigInteger;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Math.Prime.Generator
|
||||
{
|
||||
// Token: 0x02000095 RID: 149
|
||||
internal abstract class PrimeGeneratorBase
|
||||
{
|
||||
// Token: 0x170000E3 RID: 227
|
||||
// (get) Token: 0x06000840 RID: 2112 RVA: 0x0001E31C File Offset: 0x0001C51C
|
||||
public virtual ConfidenceFactor Confidence
|
||||
{
|
||||
get
|
||||
{
|
||||
return ConfidenceFactor.Medium;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000E4 RID: 228
|
||||
// (get) Token: 0x06000841 RID: 2113 RVA: 0x0001E320 File Offset: 0x0001C520
|
||||
public virtual PrimalityTest PrimalityTest
|
||||
{
|
||||
get
|
||||
{
|
||||
return new PrimalityTest(PrimalityTests.RabinMillerTest);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000E5 RID: 229
|
||||
// (get) Token: 0x06000842 RID: 2114 RVA: 0x0001E330 File Offset: 0x0001C530
|
||||
public virtual int TrialDivisionBounds
|
||||
{
|
||||
get
|
||||
{
|
||||
return 4000;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000843 RID: 2115 RVA: 0x0001E338 File Offset: 0x0001C538
|
||||
protected bool PostTrialDivisionTests(BigInteger bi)
|
||||
{
|
||||
return this.PrimalityTest(bi, this.Confidence);
|
||||
}
|
||||
|
||||
// Token: 0x06000844 RID: 2116
|
||||
public abstract BigInteger GenerateNewPrime(int bits);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Math.Prime.Generator
|
||||
{
|
||||
// Token: 0x02000096 RID: 150
|
||||
internal class SequentialSearchPrimeGeneratorBase : PrimeGeneratorBase
|
||||
{
|
||||
// Token: 0x06000846 RID: 2118 RVA: 0x0001E354 File Offset: 0x0001C554
|
||||
protected virtual BigInteger GenerateSearchBase(int bits, object context)
|
||||
{
|
||||
BigInteger bigInteger = BigInteger.GenerateRandom(bits);
|
||||
bigInteger.SetBit(0U);
|
||||
return bigInteger;
|
||||
}
|
||||
|
||||
// Token: 0x06000847 RID: 2119 RVA: 0x0001E370 File Offset: 0x0001C570
|
||||
public override BigInteger GenerateNewPrime(int bits)
|
||||
{
|
||||
return this.GenerateNewPrime(bits, null);
|
||||
}
|
||||
|
||||
// Token: 0x06000848 RID: 2120 RVA: 0x0001E37C File Offset: 0x0001C57C
|
||||
public virtual BigInteger GenerateNewPrime(int bits, object context)
|
||||
{
|
||||
BigInteger bigInteger = this.GenerateSearchBase(bits, context);
|
||||
uint num = bigInteger % 3234846615U;
|
||||
int trialDivisionBounds = this.TrialDivisionBounds;
|
||||
uint[] smallPrimes = BigInteger.smallPrimes;
|
||||
for (;;)
|
||||
{
|
||||
if (num % 3U != 0U)
|
||||
{
|
||||
if (num % 5U != 0U)
|
||||
{
|
||||
if (num % 7U != 0U)
|
||||
{
|
||||
if (num % 11U != 0U)
|
||||
{
|
||||
if (num % 13U != 0U)
|
||||
{
|
||||
if (num % 17U != 0U)
|
||||
{
|
||||
if (num % 19U != 0U)
|
||||
{
|
||||
if (num % 23U != 0U)
|
||||
{
|
||||
if (num % 29U != 0U)
|
||||
{
|
||||
int num2 = 10;
|
||||
while (num2 < smallPrimes.Length && (ulong)smallPrimes[num2] <= (ulong)((long)trialDivisionBounds))
|
||||
{
|
||||
if (bigInteger % smallPrimes[num2] == 0U)
|
||||
{
|
||||
goto IL_105;
|
||||
}
|
||||
num2++;
|
||||
}
|
||||
if (this.IsPrimeAcceptable(bigInteger, context))
|
||||
{
|
||||
if (this.PrimalityTest(bigInteger, this.Confidence))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
IL_105:
|
||||
num += 2U;
|
||||
if (num >= 3234846615U)
|
||||
{
|
||||
num -= 3234846615U;
|
||||
}
|
||||
bigInteger.Incr2();
|
||||
}
|
||||
return bigInteger;
|
||||
}
|
||||
|
||||
// Token: 0x06000849 RID: 2121 RVA: 0x0001E4B0 File Offset: 0x0001C6B0
|
||||
protected virtual bool IsPrimeAcceptable(BigInteger bi, object context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Math.Prime
|
||||
{
|
||||
// Token: 0x020006D2 RID: 1746
|
||||
// (Invoke) Token: 0x060041D0 RID: 16848
|
||||
internal delegate bool PrimalityTest(BigInteger bi, ConfidenceFactor confidence);
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Math.Prime
|
||||
{
|
||||
// Token: 0x02000098 RID: 152
|
||||
internal sealed class PrimalityTests
|
||||
{
|
||||
// Token: 0x0600084A RID: 2122 RVA: 0x0001E4B4 File Offset: 0x0001C6B4
|
||||
private PrimalityTests()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600084B RID: 2123 RVA: 0x0001E4BC File Offset: 0x0001C6BC
|
||||
private static int GetSPPRounds(BigInteger bi, ConfidenceFactor confidence)
|
||||
{
|
||||
int num = bi.BitCount();
|
||||
int num2;
|
||||
if (num <= 100)
|
||||
{
|
||||
num2 = 27;
|
||||
}
|
||||
else if (num <= 150)
|
||||
{
|
||||
num2 = 18;
|
||||
}
|
||||
else if (num <= 200)
|
||||
{
|
||||
num2 = 15;
|
||||
}
|
||||
else if (num <= 250)
|
||||
{
|
||||
num2 = 12;
|
||||
}
|
||||
else if (num <= 300)
|
||||
{
|
||||
num2 = 9;
|
||||
}
|
||||
else if (num <= 350)
|
||||
{
|
||||
num2 = 8;
|
||||
}
|
||||
else if (num <= 400)
|
||||
{
|
||||
num2 = 7;
|
||||
}
|
||||
else if (num <= 500)
|
||||
{
|
||||
num2 = 6;
|
||||
}
|
||||
else if (num <= 600)
|
||||
{
|
||||
num2 = 5;
|
||||
}
|
||||
else if (num <= 800)
|
||||
{
|
||||
num2 = 4;
|
||||
}
|
||||
else if (num <= 1250)
|
||||
{
|
||||
num2 = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
num2 = 2;
|
||||
}
|
||||
switch (confidence)
|
||||
{
|
||||
case ConfidenceFactor.ExtraLow:
|
||||
num2 >>= 2;
|
||||
return (num2 == 0) ? 1 : num2;
|
||||
case ConfidenceFactor.Low:
|
||||
num2 >>= 1;
|
||||
return (num2 == 0) ? 1 : num2;
|
||||
case ConfidenceFactor.Medium:
|
||||
return num2;
|
||||
case ConfidenceFactor.High:
|
||||
return num2 << 1;
|
||||
case ConfidenceFactor.ExtraHigh:
|
||||
return num2 << 2;
|
||||
case ConfidenceFactor.Provable:
|
||||
throw new Exception("The Rabin-Miller test can not be executed in a way such that its results are provable");
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException("confidence");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600084C RID: 2124 RVA: 0x0001E604 File Offset: 0x0001C804
|
||||
public static bool Test(BigInteger n, ConfidenceFactor confidence)
|
||||
{
|
||||
if (n.BitCount() < 33)
|
||||
{
|
||||
return PrimalityTests.SmallPrimeSppTest(n, confidence);
|
||||
}
|
||||
return PrimalityTests.RabinMillerTest(n, confidence);
|
||||
}
|
||||
|
||||
// Token: 0x0600084D RID: 2125 RVA: 0x0001E624 File Offset: 0x0001C824
|
||||
public static bool RabinMillerTest(BigInteger n, ConfidenceFactor confidence)
|
||||
{
|
||||
int num = n.BitCount();
|
||||
int spprounds = PrimalityTests.GetSPPRounds(num, confidence);
|
||||
BigInteger bigInteger = n - 1;
|
||||
int num2 = bigInteger.LowestSetBit();
|
||||
BigInteger bigInteger2 = bigInteger >> num2;
|
||||
BigInteger.ModulusRing modulusRing = new BigInteger.ModulusRing(n);
|
||||
BigInteger bigInteger3 = null;
|
||||
if (n.BitCount() > 100)
|
||||
{
|
||||
bigInteger3 = modulusRing.Pow(2U, bigInteger2);
|
||||
}
|
||||
for (int i = 0; i < spprounds; i++)
|
||||
{
|
||||
if (i > 0 || bigInteger3 == null)
|
||||
{
|
||||
BigInteger bigInteger4;
|
||||
do
|
||||
{
|
||||
bigInteger4 = BigInteger.GenerateRandom(num);
|
||||
}
|
||||
while (bigInteger4 <= 2 && bigInteger4 >= bigInteger);
|
||||
bigInteger3 = modulusRing.Pow(bigInteger4, bigInteger2);
|
||||
}
|
||||
if (!(bigInteger3 == 1U))
|
||||
{
|
||||
int num3 = 0;
|
||||
while (num3 < num2 && bigInteger3 != bigInteger)
|
||||
{
|
||||
bigInteger3 = modulusRing.Pow(bigInteger3, 2);
|
||||
if (bigInteger3 == 1U)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
num3++;
|
||||
}
|
||||
if (bigInteger3 != bigInteger)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x0600084E RID: 2126 RVA: 0x0001E750 File Offset: 0x0001C950
|
||||
public static bool SmallPrimeSppTest(BigInteger bi, ConfidenceFactor confidence)
|
||||
{
|
||||
int spprounds = PrimalityTests.GetSPPRounds(bi, confidence);
|
||||
BigInteger bigInteger = bi - 1;
|
||||
int num = bigInteger.LowestSetBit();
|
||||
BigInteger bigInteger2 = bigInteger >> num;
|
||||
BigInteger.ModulusRing modulusRing = new BigInteger.ModulusRing(bi);
|
||||
for (int i = 0; i < spprounds; i++)
|
||||
{
|
||||
BigInteger bigInteger3 = modulusRing.Pow(BigInteger.smallPrimes[i], bigInteger2);
|
||||
if (!(bigInteger3 == 1U))
|
||||
{
|
||||
bool flag = false;
|
||||
for (int j = 0; j < num; j++)
|
||||
{
|
||||
if (bigInteger3 == bigInteger)
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
bigInteger3 = bigInteger3 * bigInteger3 % bi;
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Mono
|
||||
{
|
||||
// Token: 0x020000F8 RID: 248
|
||||
internal class Runtime
|
||||
{
|
||||
// Token: 0x06000C5F RID: 3167
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
private static extern void mono_runtime_install_handlers();
|
||||
|
||||
// Token: 0x06000C60 RID: 3168 RVA: 0x000383E8 File Offset: 0x000365E8
|
||||
internal static void InstallSignalHandlers()
|
||||
{
|
||||
Runtime.mono_runtime_install_handlers();
|
||||
}
|
||||
|
||||
// Token: 0x06000C61 RID: 3169
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern string GetDisplayName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,389 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Mono.Security
|
||||
{
|
||||
// Token: 0x020000DA RID: 218
|
||||
internal class ASN1
|
||||
{
|
||||
// Token: 0x06000ADA RID: 2778 RVA: 0x0002FF08 File Offset: 0x0002E108
|
||||
public ASN1()
|
||||
: this(0, null)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000ADB RID: 2779 RVA: 0x0002FF14 File Offset: 0x0002E114
|
||||
public ASN1(byte tag)
|
||||
: this(tag, null)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000ADC RID: 2780 RVA: 0x0002FF20 File Offset: 0x0002E120
|
||||
public ASN1(byte tag, byte[] data)
|
||||
{
|
||||
this.m_nTag = tag;
|
||||
this.m_aValue = data;
|
||||
}
|
||||
|
||||
// Token: 0x06000ADD RID: 2781 RVA: 0x0002FF38 File Offset: 0x0002E138
|
||||
public ASN1(byte[] data)
|
||||
{
|
||||
this.m_nTag = data[0];
|
||||
int num = 0;
|
||||
int num2 = (int)data[1];
|
||||
if (num2 > 128)
|
||||
{
|
||||
num = num2 - 128;
|
||||
num2 = 0;
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
num2 *= 256;
|
||||
num2 += (int)data[i + 2];
|
||||
}
|
||||
}
|
||||
else if (num2 == 128)
|
||||
{
|
||||
throw new NotSupportedException("Undefined length encoding.");
|
||||
}
|
||||
this.m_aValue = new byte[num2];
|
||||
Buffer.BlockCopy(data, 2 + num, this.m_aValue, 0, num2);
|
||||
if ((this.m_nTag & 32) == 32)
|
||||
{
|
||||
int num3 = 2 + num;
|
||||
this.Decode(data, ref num3, data.Length);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700016E RID: 366
|
||||
// (get) Token: 0x06000ADE RID: 2782 RVA: 0x0002FFEC File Offset: 0x0002E1EC
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.elist == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return this.elist.Count;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700016F RID: 367
|
||||
// (get) Token: 0x06000ADF RID: 2783 RVA: 0x00030008 File Offset: 0x0002E208
|
||||
public byte Tag
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_nTag;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000170 RID: 368
|
||||
// (get) Token: 0x06000AE0 RID: 2784 RVA: 0x00030010 File Offset: 0x0002E210
|
||||
public int Length
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.m_aValue != null)
|
||||
{
|
||||
return this.m_aValue.Length;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000171 RID: 369
|
||||
// (get) Token: 0x06000AE1 RID: 2785 RVA: 0x00030028 File Offset: 0x0002E228
|
||||
// (set) Token: 0x06000AE2 RID: 2786 RVA: 0x00030058 File Offset: 0x0002E258
|
||||
public byte[] Value
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.m_aValue == null)
|
||||
{
|
||||
this.GetBytes();
|
||||
}
|
||||
return (byte[])this.m_aValue.Clone();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
this.m_aValue = (byte[])value.Clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000AE3 RID: 2787 RVA: 0x00030074 File Offset: 0x0002E274
|
||||
private bool CompareArray(byte[] array1, byte[] array2)
|
||||
{
|
||||
bool flag = array1.Length == array2.Length;
|
||||
if (flag)
|
||||
{
|
||||
for (int i = 0; i < array1.Length; i++)
|
||||
{
|
||||
if (array1[i] != array2[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x06000AE4 RID: 2788 RVA: 0x000300B4 File Offset: 0x0002E2B4
|
||||
public bool Equals(byte[] asn1)
|
||||
{
|
||||
return this.CompareArray(this.GetBytes(), asn1);
|
||||
}
|
||||
|
||||
// Token: 0x06000AE5 RID: 2789 RVA: 0x000300C4 File Offset: 0x0002E2C4
|
||||
public bool CompareValue(byte[] value)
|
||||
{
|
||||
return this.CompareArray(this.m_aValue, value);
|
||||
}
|
||||
|
||||
// Token: 0x06000AE6 RID: 2790 RVA: 0x000300D4 File Offset: 0x0002E2D4
|
||||
public ASN1 Add(ASN1 asn1)
|
||||
{
|
||||
if (asn1 != null)
|
||||
{
|
||||
if (this.elist == null)
|
||||
{
|
||||
this.elist = new ArrayList();
|
||||
}
|
||||
this.elist.Add(asn1);
|
||||
}
|
||||
return asn1;
|
||||
}
|
||||
|
||||
// Token: 0x06000AE7 RID: 2791 RVA: 0x0003010C File Offset: 0x0002E30C
|
||||
public virtual byte[] GetBytes()
|
||||
{
|
||||
byte[] array = null;
|
||||
if (this.Count > 0)
|
||||
{
|
||||
int num = 0;
|
||||
ArrayList arrayList = new ArrayList();
|
||||
foreach (object obj in this.elist)
|
||||
{
|
||||
ASN1 asn = (ASN1)obj;
|
||||
byte[] bytes = asn.GetBytes();
|
||||
arrayList.Add(bytes);
|
||||
num += bytes.Length;
|
||||
}
|
||||
array = new byte[num];
|
||||
int num2 = 0;
|
||||
for (int i = 0; i < this.elist.Count; i++)
|
||||
{
|
||||
byte[] array2 = (byte[])arrayList[i];
|
||||
Buffer.BlockCopy(array2, 0, array, num2, array2.Length);
|
||||
num2 += array2.Length;
|
||||
}
|
||||
}
|
||||
else if (this.m_aValue != null)
|
||||
{
|
||||
array = this.m_aValue;
|
||||
}
|
||||
int num3 = 0;
|
||||
byte[] array3;
|
||||
if (array != null)
|
||||
{
|
||||
int num4 = array.Length;
|
||||
if (num4 > 127)
|
||||
{
|
||||
if (num4 <= 255)
|
||||
{
|
||||
array3 = new byte[3 + num4];
|
||||
Buffer.BlockCopy(array, 0, array3, 3, num4);
|
||||
num3 = 129;
|
||||
array3[2] = (byte)num4;
|
||||
}
|
||||
else if (num4 <= 65535)
|
||||
{
|
||||
array3 = new byte[4 + num4];
|
||||
Buffer.BlockCopy(array, 0, array3, 4, num4);
|
||||
num3 = 130;
|
||||
array3[2] = (byte)(num4 >> 8);
|
||||
array3[3] = (byte)num4;
|
||||
}
|
||||
else if (num4 <= 16777215)
|
||||
{
|
||||
array3 = new byte[5 + num4];
|
||||
Buffer.BlockCopy(array, 0, array3, 5, num4);
|
||||
num3 = 131;
|
||||
array3[2] = (byte)(num4 >> 16);
|
||||
array3[3] = (byte)(num4 >> 8);
|
||||
array3[4] = (byte)num4;
|
||||
}
|
||||
else
|
||||
{
|
||||
array3 = new byte[6 + num4];
|
||||
Buffer.BlockCopy(array, 0, array3, 6, num4);
|
||||
num3 = 132;
|
||||
array3[2] = (byte)(num4 >> 24);
|
||||
array3[3] = (byte)(num4 >> 16);
|
||||
array3[4] = (byte)(num4 >> 8);
|
||||
array3[5] = (byte)num4;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
array3 = new byte[2 + num4];
|
||||
Buffer.BlockCopy(array, 0, array3, 2, num4);
|
||||
num3 = num4;
|
||||
}
|
||||
if (this.m_aValue == null)
|
||||
{
|
||||
this.m_aValue = array;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
array3 = new byte[2];
|
||||
}
|
||||
array3[0] = this.m_nTag;
|
||||
array3[1] = (byte)num3;
|
||||
return array3;
|
||||
}
|
||||
|
||||
// Token: 0x06000AE8 RID: 2792 RVA: 0x0003037C File Offset: 0x0002E57C
|
||||
protected void Decode(byte[] asn1, ref int anPos, int anLength)
|
||||
{
|
||||
while (anPos < anLength - 1)
|
||||
{
|
||||
byte b;
|
||||
int num;
|
||||
byte[] array;
|
||||
this.DecodeTLV(asn1, ref anPos, out b, out num, out array);
|
||||
if (b != 0)
|
||||
{
|
||||
ASN1 asn2 = this.Add(new ASN1(b, array));
|
||||
if ((b & 32) == 32)
|
||||
{
|
||||
int num2 = anPos;
|
||||
asn2.Decode(asn1, ref num2, num2 + num);
|
||||
}
|
||||
anPos += num;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000AE9 RID: 2793 RVA: 0x000303E4 File Offset: 0x0002E5E4
|
||||
protected void DecodeTLV(byte[] asn1, ref int pos, out byte tag, out int length, out byte[] content)
|
||||
{
|
||||
tag = asn1[pos++];
|
||||
length = (int)asn1[pos++];
|
||||
if ((length & 128) == 128)
|
||||
{
|
||||
int num = length & 127;
|
||||
length = 0;
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
length = length * 256 + (int)asn1[pos++];
|
||||
}
|
||||
}
|
||||
content = new byte[length];
|
||||
Buffer.BlockCopy(asn1, pos, content, 0, length);
|
||||
}
|
||||
|
||||
// Token: 0x17000172 RID: 370
|
||||
public ASN1 this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
ASN1 asn;
|
||||
try
|
||||
{
|
||||
if (this.elist == null || index >= this.elist.Count)
|
||||
{
|
||||
asn = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
asn = (ASN1)this.elist[index];
|
||||
}
|
||||
}
|
||||
catch (ArgumentOutOfRangeException)
|
||||
{
|
||||
asn = null;
|
||||
}
|
||||
return asn;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000AEB RID: 2795 RVA: 0x000304E8 File Offset: 0x0002E6E8
|
||||
public ASN1 Element(int index, byte anTag)
|
||||
{
|
||||
ASN1 asn;
|
||||
try
|
||||
{
|
||||
if (this.elist == null || index >= this.elist.Count)
|
||||
{
|
||||
asn = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
ASN1 asn2 = (ASN1)this.elist[index];
|
||||
if (asn2.Tag == anTag)
|
||||
{
|
||||
asn = asn2;
|
||||
}
|
||||
else
|
||||
{
|
||||
asn = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (ArgumentOutOfRangeException)
|
||||
{
|
||||
asn = null;
|
||||
}
|
||||
return asn;
|
||||
}
|
||||
|
||||
// Token: 0x06000AEC RID: 2796 RVA: 0x00030574 File Offset: 0x0002E774
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.AppendFormat("Tag: {0} {1}", this.m_nTag.ToString("X2"), Environment.NewLine);
|
||||
stringBuilder.AppendFormat("Length: {0} {1}", this.Value.Length, Environment.NewLine);
|
||||
stringBuilder.Append("Value: ");
|
||||
stringBuilder.Append(Environment.NewLine);
|
||||
for (int i = 0; i < this.Value.Length; i++)
|
||||
{
|
||||
stringBuilder.AppendFormat("{0} ", this.Value[i].ToString("X2"));
|
||||
if ((i + 1) % 16 == 0)
|
||||
{
|
||||
stringBuilder.AppendFormat(Environment.NewLine, new object[0]);
|
||||
}
|
||||
}
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
// Token: 0x06000AED RID: 2797 RVA: 0x0003063C File Offset: 0x0002E83C
|
||||
public void SaveToFile(string filename)
|
||||
{
|
||||
if (filename == null)
|
||||
{
|
||||
throw new ArgumentNullException("filename");
|
||||
}
|
||||
using (FileStream fileStream = File.Create(filename))
|
||||
{
|
||||
byte[] bytes = this.GetBytes();
|
||||
fileStream.Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x040002D4 RID: 724
|
||||
private byte m_nTag;
|
||||
|
||||
// Token: 0x040002D5 RID: 725
|
||||
private byte[] m_aValue;
|
||||
|
||||
// Token: 0x040002D6 RID: 726
|
||||
private ArrayList elist;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Mono.Security
|
||||
{
|
||||
// Token: 0x020000DB RID: 219
|
||||
internal static class ASN1Convert
|
||||
{
|
||||
// Token: 0x06000AEE RID: 2798 RVA: 0x000306A4 File Offset: 0x0002E8A4
|
||||
public static ASN1 FromDateTime(DateTime dt)
|
||||
{
|
||||
if (dt.Year < 2050)
|
||||
{
|
||||
return new ASN1(23, Encoding.ASCII.GetBytes(dt.ToUniversalTime().ToString("yyMMddHHmmss", CultureInfo.InvariantCulture) + "Z"));
|
||||
}
|
||||
return new ASN1(24, Encoding.ASCII.GetBytes(dt.ToUniversalTime().ToString("yyyyMMddHHmmss", CultureInfo.InvariantCulture) + "Z"));
|
||||
}
|
||||
|
||||
// Token: 0x06000AEF RID: 2799 RVA: 0x0003072C File Offset: 0x0002E92C
|
||||
public static ASN1 FromInt32(int value)
|
||||
{
|
||||
byte[] bytes = BitConverterLE.GetBytes(value);
|
||||
Array.Reverse(bytes);
|
||||
int num = 0;
|
||||
while (num < bytes.Length && bytes[num] == 0)
|
||||
{
|
||||
num++;
|
||||
}
|
||||
ASN1 asn = new ASN1(2);
|
||||
int num2 = num;
|
||||
if (num2 != 0)
|
||||
{
|
||||
if (num2 != 4)
|
||||
{
|
||||
byte[] array = new byte[4 - num];
|
||||
Buffer.BlockCopy(bytes, num, array, 0, array.Length);
|
||||
asn.Value = array;
|
||||
}
|
||||
else
|
||||
{
|
||||
asn.Value = new byte[1];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
asn.Value = bytes;
|
||||
}
|
||||
return asn;
|
||||
}
|
||||
|
||||
// Token: 0x06000AF0 RID: 2800 RVA: 0x000307C0 File Offset: 0x0002E9C0
|
||||
public static ASN1 FromOid(string oid)
|
||||
{
|
||||
if (oid == null)
|
||||
{
|
||||
throw new ArgumentNullException("oid");
|
||||
}
|
||||
return new ASN1(CryptoConfig.EncodeOID(oid));
|
||||
}
|
||||
|
||||
// Token: 0x06000AF1 RID: 2801 RVA: 0x000307E0 File Offset: 0x0002E9E0
|
||||
public static ASN1 FromUnsignedBigInteger(byte[] big)
|
||||
{
|
||||
if (big == null)
|
||||
{
|
||||
throw new ArgumentNullException("big");
|
||||
}
|
||||
if (big[0] >= 128)
|
||||
{
|
||||
int num = big.Length + 1;
|
||||
byte[] array = new byte[num];
|
||||
Buffer.BlockCopy(big, 0, array, 1, num - 1);
|
||||
big = array;
|
||||
}
|
||||
return new ASN1(2, big);
|
||||
}
|
||||
|
||||
// Token: 0x06000AF2 RID: 2802 RVA: 0x00030830 File Offset: 0x0002EA30
|
||||
public static int ToInt32(ASN1 asn1)
|
||||
{
|
||||
if (asn1 == null)
|
||||
{
|
||||
throw new ArgumentNullException("asn1");
|
||||
}
|
||||
if (asn1.Tag != 2)
|
||||
{
|
||||
throw new FormatException("Only integer can be converted");
|
||||
}
|
||||
int num = 0;
|
||||
for (int i = 0; i < asn1.Value.Length; i++)
|
||||
{
|
||||
num = (num << 8) + (int)asn1.Value[i];
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x06000AF3 RID: 2803 RVA: 0x00030890 File Offset: 0x0002EA90
|
||||
public static string ToOid(ASN1 asn1)
|
||||
{
|
||||
if (asn1 == null)
|
||||
{
|
||||
throw new ArgumentNullException("asn1");
|
||||
}
|
||||
byte[] value = asn1.Value;
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
byte b = value[0] / 40;
|
||||
byte b2 = value[0] % 40;
|
||||
if (b > 2)
|
||||
{
|
||||
b2 += (b - 2) * 40;
|
||||
b = 2;
|
||||
}
|
||||
stringBuilder.Append(b.ToString(CultureInfo.InvariantCulture));
|
||||
stringBuilder.Append(".");
|
||||
stringBuilder.Append(b2.ToString(CultureInfo.InvariantCulture));
|
||||
ulong num = 0UL;
|
||||
b = 1;
|
||||
while ((int)b < value.Length)
|
||||
{
|
||||
num = (num << 7) | (ulong)(value[(int)b] & 127);
|
||||
if ((value[(int)b] & 128) != 128)
|
||||
{
|
||||
stringBuilder.Append(".");
|
||||
stringBuilder.Append(num.ToString(CultureInfo.InvariantCulture));
|
||||
num = 0UL;
|
||||
}
|
||||
b += 1;
|
||||
}
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
// Token: 0x06000AF4 RID: 2804 RVA: 0x00030978 File Offset: 0x0002EB78
|
||||
public static DateTime ToDateTime(ASN1 time)
|
||||
{
|
||||
if (time == null)
|
||||
{
|
||||
throw new ArgumentNullException("time");
|
||||
}
|
||||
string text = Encoding.ASCII.GetString(time.Value);
|
||||
string text2 = null;
|
||||
switch (text.Length)
|
||||
{
|
||||
case 11:
|
||||
text2 = "yyMMddHHmmZ";
|
||||
break;
|
||||
case 13:
|
||||
{
|
||||
int num = (int)Convert.ToInt16(text.Substring(0, 2), CultureInfo.InvariantCulture);
|
||||
if (num >= 50)
|
||||
{
|
||||
text = "19" + text;
|
||||
}
|
||||
else
|
||||
{
|
||||
text = "20" + text;
|
||||
}
|
||||
text2 = "yyyyMMddHHmmssZ";
|
||||
break;
|
||||
}
|
||||
case 15:
|
||||
text2 = "yyyyMMddHHmmssZ";
|
||||
break;
|
||||
case 17:
|
||||
{
|
||||
int num = (int)Convert.ToInt16(text.Substring(0, 2), CultureInfo.InvariantCulture);
|
||||
string text3 = ((num < 50) ? "20" : "19");
|
||||
char c = ((text[12] != '+') ? '+' : '-');
|
||||
text = string.Format("{0}{1}{2}{3}{4}:{5}{6}", new object[]
|
||||
{
|
||||
text3,
|
||||
text.Substring(0, 12),
|
||||
c,
|
||||
text[13],
|
||||
text[14],
|
||||
text[15],
|
||||
text[16]
|
||||
});
|
||||
text2 = "yyyyMMddHHmmsszzz";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return DateTime.ParseExact(text, text2, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,278 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Mono.Security.Authenticode
|
||||
{
|
||||
// Token: 0x0200009F RID: 159
|
||||
internal class AuthenticodeBase
|
||||
{
|
||||
// Token: 0x060008B2 RID: 2226 RVA: 0x00020E80 File Offset: 0x0001F080
|
||||
public AuthenticodeBase()
|
||||
{
|
||||
this.fileblock = new byte[4096];
|
||||
}
|
||||
|
||||
// Token: 0x170000E7 RID: 231
|
||||
// (get) Token: 0x060008B3 RID: 2227 RVA: 0x00020E98 File Offset: 0x0001F098
|
||||
internal int PEOffset
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.blockNo < 1)
|
||||
{
|
||||
this.ReadFirstBlock();
|
||||
}
|
||||
return this.peOffset;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000E8 RID: 232
|
||||
// (get) Token: 0x060008B4 RID: 2228 RVA: 0x00020EB4 File Offset: 0x0001F0B4
|
||||
internal int CoffSymbolTableOffset
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.blockNo < 1)
|
||||
{
|
||||
this.ReadFirstBlock();
|
||||
}
|
||||
return this.coffSymbolTableOffset;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000E9 RID: 233
|
||||
// (get) Token: 0x060008B5 RID: 2229 RVA: 0x00020ED0 File Offset: 0x0001F0D0
|
||||
internal int SecurityOffset
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.blockNo < 1)
|
||||
{
|
||||
this.ReadFirstBlock();
|
||||
}
|
||||
return this.dirSecurityOffset;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060008B6 RID: 2230 RVA: 0x00020EEC File Offset: 0x0001F0EC
|
||||
internal void Open(string filename)
|
||||
{
|
||||
if (this.fs != null)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
this.fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
}
|
||||
|
||||
// Token: 0x060008B7 RID: 2231 RVA: 0x00020F1C File Offset: 0x0001F11C
|
||||
internal void Close()
|
||||
{
|
||||
if (this.fs != null)
|
||||
{
|
||||
this.fs.Close();
|
||||
this.fs = null;
|
||||
this.blockNo = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060008B8 RID: 2232 RVA: 0x00020F50 File Offset: 0x0001F150
|
||||
internal bool ReadFirstBlock()
|
||||
{
|
||||
if (this.fs == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.fs.Position = 0L;
|
||||
this.blockLength = this.fs.Read(this.fileblock, 0, this.fileblock.Length);
|
||||
this.blockNo = 1;
|
||||
if (this.blockLength < 64)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (BitConverterLE.ToUInt16(this.fileblock, 0) != 23117)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.peOffset = BitConverterLE.ToInt32(this.fileblock, 60);
|
||||
if (this.peOffset > this.fileblock.Length)
|
||||
{
|
||||
string text = string.Format(Locale.GetText("Header size too big (> {0} bytes)."), this.fileblock.Length);
|
||||
throw new NotSupportedException(text);
|
||||
}
|
||||
if ((long)this.peOffset > this.fs.Length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (BitConverterLE.ToUInt32(this.fileblock, this.peOffset) != 17744U)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.dirSecurityOffset = BitConverterLE.ToInt32(this.fileblock, this.peOffset + 152);
|
||||
this.dirSecuritySize = BitConverterLE.ToInt32(this.fileblock, this.peOffset + 156);
|
||||
this.coffSymbolTableOffset = BitConverterLE.ToInt32(this.fileblock, this.peOffset + 12);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x060008B9 RID: 2233 RVA: 0x0002109C File Offset: 0x0001F29C
|
||||
internal byte[] GetSecurityEntry()
|
||||
{
|
||||
if (this.blockNo < 1)
|
||||
{
|
||||
this.ReadFirstBlock();
|
||||
}
|
||||
if (this.dirSecuritySize > 8)
|
||||
{
|
||||
byte[] array = new byte[this.dirSecuritySize - 8];
|
||||
this.fs.Position = (long)(this.dirSecurityOffset + 8);
|
||||
this.fs.Read(array, 0, array.Length);
|
||||
return array;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x060008BA RID: 2234 RVA: 0x00021100 File Offset: 0x0001F300
|
||||
internal byte[] GetHash(HashAlgorithm hash)
|
||||
{
|
||||
if (this.blockNo < 1)
|
||||
{
|
||||
this.ReadFirstBlock();
|
||||
}
|
||||
this.fs.Position = (long)this.blockLength;
|
||||
int num = 0;
|
||||
long num2;
|
||||
if (this.dirSecurityOffset > 0)
|
||||
{
|
||||
if (this.dirSecurityOffset < this.blockLength)
|
||||
{
|
||||
this.blockLength = this.dirSecurityOffset;
|
||||
num2 = 0L;
|
||||
}
|
||||
else
|
||||
{
|
||||
num2 = (long)(this.dirSecurityOffset - this.blockLength);
|
||||
}
|
||||
}
|
||||
else if (this.coffSymbolTableOffset > 0)
|
||||
{
|
||||
this.fileblock[this.PEOffset + 12] = 0;
|
||||
this.fileblock[this.PEOffset + 13] = 0;
|
||||
this.fileblock[this.PEOffset + 14] = 0;
|
||||
this.fileblock[this.PEOffset + 15] = 0;
|
||||
this.fileblock[this.PEOffset + 16] = 0;
|
||||
this.fileblock[this.PEOffset + 17] = 0;
|
||||
this.fileblock[this.PEOffset + 18] = 0;
|
||||
this.fileblock[this.PEOffset + 19] = 0;
|
||||
if (this.coffSymbolTableOffset < this.blockLength)
|
||||
{
|
||||
this.blockLength = this.coffSymbolTableOffset;
|
||||
num2 = 0L;
|
||||
}
|
||||
else
|
||||
{
|
||||
num2 = (long)(this.coffSymbolTableOffset - this.blockLength);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
num = (int)(this.fs.Length & 7L);
|
||||
if (num > 0)
|
||||
{
|
||||
num = 8 - num;
|
||||
}
|
||||
num2 = this.fs.Length - (long)this.blockLength;
|
||||
}
|
||||
int num3 = this.peOffset + 88;
|
||||
hash.TransformBlock(this.fileblock, 0, num3, this.fileblock, 0);
|
||||
num3 += 4;
|
||||
hash.TransformBlock(this.fileblock, num3, 60, this.fileblock, num3);
|
||||
num3 += 68;
|
||||
if (num2 == 0L)
|
||||
{
|
||||
hash.TransformFinalBlock(this.fileblock, num3, this.blockLength - num3);
|
||||
}
|
||||
else
|
||||
{
|
||||
hash.TransformBlock(this.fileblock, num3, this.blockLength - num3, this.fileblock, num3);
|
||||
long num4 = num2 >> 12;
|
||||
int num5 = (int)(num2 - (num4 << 12));
|
||||
if (num5 == 0)
|
||||
{
|
||||
num4 -= 1L;
|
||||
num5 = 4096;
|
||||
}
|
||||
for (;;)
|
||||
{
|
||||
long num6 = num4;
|
||||
num4 = num6 - 1L;
|
||||
if (num6 <= 0L)
|
||||
{
|
||||
break;
|
||||
}
|
||||
this.fs.Read(this.fileblock, 0, this.fileblock.Length);
|
||||
hash.TransformBlock(this.fileblock, 0, this.fileblock.Length, this.fileblock, 0);
|
||||
}
|
||||
if (this.fs.Read(this.fileblock, 0, num5) != num5)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (num > 0)
|
||||
{
|
||||
hash.TransformBlock(this.fileblock, 0, num5, this.fileblock, 0);
|
||||
hash.TransformFinalBlock(new byte[num], 0, num);
|
||||
}
|
||||
else
|
||||
{
|
||||
hash.TransformFinalBlock(this.fileblock, 0, num5);
|
||||
}
|
||||
}
|
||||
return hash.Hash;
|
||||
}
|
||||
|
||||
// Token: 0x060008BB RID: 2235 RVA: 0x000213C4 File Offset: 0x0001F5C4
|
||||
protected byte[] HashFile(string fileName, string hashName)
|
||||
{
|
||||
byte[] array;
|
||||
try
|
||||
{
|
||||
this.Open(fileName);
|
||||
HashAlgorithm hashAlgorithm = HashAlgorithm.Create(hashName);
|
||||
byte[] hash = this.GetHash(hashAlgorithm);
|
||||
this.Close();
|
||||
array = hash;
|
||||
}
|
||||
catch
|
||||
{
|
||||
array = null;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x040001C2 RID: 450
|
||||
public const string spcIndirectDataContext = "1.3.6.1.4.1.311.2.1.4";
|
||||
|
||||
// Token: 0x040001C3 RID: 451
|
||||
private byte[] fileblock;
|
||||
|
||||
// Token: 0x040001C4 RID: 452
|
||||
private FileStream fs;
|
||||
|
||||
// Token: 0x040001C5 RID: 453
|
||||
private int blockNo;
|
||||
|
||||
// Token: 0x040001C6 RID: 454
|
||||
private int blockLength;
|
||||
|
||||
// Token: 0x040001C7 RID: 455
|
||||
private int peOffset;
|
||||
|
||||
// Token: 0x040001C8 RID: 456
|
||||
private int dirSecurityOffset;
|
||||
|
||||
// Token: 0x040001C9 RID: 457
|
||||
private int dirSecuritySize;
|
||||
|
||||
// Token: 0x040001CA RID: 458
|
||||
private int coffSymbolTableOffset;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,486 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security;
|
||||
using System.Security.Cryptography;
|
||||
using Mono.Security.Cryptography;
|
||||
using Mono.Security.X509;
|
||||
|
||||
namespace Mono.Security.Authenticode
|
||||
{
|
||||
// Token: 0x020000A0 RID: 160
|
||||
internal class AuthenticodeDeformatter : AuthenticodeBase
|
||||
{
|
||||
// Token: 0x060008BC RID: 2236 RVA: 0x00021424 File Offset: 0x0001F624
|
||||
public AuthenticodeDeformatter()
|
||||
{
|
||||
this.reason = -1;
|
||||
this.signerChain = new X509Chain();
|
||||
this.timestampChain = new X509Chain();
|
||||
}
|
||||
|
||||
// Token: 0x060008BD RID: 2237 RVA: 0x0002144C File Offset: 0x0001F64C
|
||||
public AuthenticodeDeformatter(string fileName)
|
||||
: this()
|
||||
{
|
||||
this.FileName = fileName;
|
||||
}
|
||||
|
||||
// Token: 0x170000EA RID: 234
|
||||
// (get) Token: 0x060008BE RID: 2238 RVA: 0x0002145C File Offset: 0x0001F65C
|
||||
// (set) Token: 0x060008BF RID: 2239 RVA: 0x00021464 File Offset: 0x0001F664
|
||||
public string FileName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.filename;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.Reset();
|
||||
try
|
||||
{
|
||||
this.CheckSignature(value);
|
||||
}
|
||||
catch (SecurityException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
this.reason = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000EB RID: 235
|
||||
// (get) Token: 0x060008C0 RID: 2240 RVA: 0x000214D0 File Offset: 0x0001F6D0
|
||||
public byte[] Hash
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.signedHash == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (byte[])this.signedHash.Value.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000EC RID: 236
|
||||
// (get) Token: 0x060008C1 RID: 2241 RVA: 0x00021500 File Offset: 0x0001F700
|
||||
public int Reason
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.reason == -1)
|
||||
{
|
||||
this.IsTrusted();
|
||||
}
|
||||
return this.reason;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060008C2 RID: 2242 RVA: 0x0002151C File Offset: 0x0001F71C
|
||||
public bool IsTrusted()
|
||||
{
|
||||
if (this.entry == null)
|
||||
{
|
||||
this.reason = 1;
|
||||
return false;
|
||||
}
|
||||
if (this.signingCertificate == null)
|
||||
{
|
||||
this.reason = 7;
|
||||
return false;
|
||||
}
|
||||
if (this.signerChain.Root == null || !this.trustedRoot)
|
||||
{
|
||||
this.reason = 6;
|
||||
return false;
|
||||
}
|
||||
if (this.timestamp != DateTime.MinValue)
|
||||
{
|
||||
if (this.timestampChain.Root == null || !this.trustedTimestampRoot)
|
||||
{
|
||||
this.reason = 6;
|
||||
return false;
|
||||
}
|
||||
if (!this.signingCertificate.WasCurrent(this.Timestamp))
|
||||
{
|
||||
this.reason = 4;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (!this.signingCertificate.IsCurrent)
|
||||
{
|
||||
this.reason = 8;
|
||||
return false;
|
||||
}
|
||||
if (this.reason == -1)
|
||||
{
|
||||
this.reason = 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x170000ED RID: 237
|
||||
// (get) Token: 0x060008C3 RID: 2243 RVA: 0x00021600 File Offset: 0x0001F800
|
||||
public byte[] Signature
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.entry == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (byte[])this.entry.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000EE RID: 238
|
||||
// (get) Token: 0x060008C4 RID: 2244 RVA: 0x00021620 File Offset: 0x0001F820
|
||||
public DateTime Timestamp
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000EF RID: 239
|
||||
// (get) Token: 0x060008C5 RID: 2245 RVA: 0x00021628 File Offset: 0x0001F828
|
||||
public X509CertificateCollection Certificates
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.coll;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000F0 RID: 240
|
||||
// (get) Token: 0x060008C6 RID: 2246 RVA: 0x00021630 File Offset: 0x0001F830
|
||||
public X509Certificate SigningCertificate
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.signingCertificate;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060008C7 RID: 2247 RVA: 0x00021638 File Offset: 0x0001F838
|
||||
private bool CheckSignature(string fileName)
|
||||
{
|
||||
this.filename = fileName;
|
||||
base.Open(this.filename);
|
||||
this.entry = base.GetSecurityEntry();
|
||||
if (this.entry == null)
|
||||
{
|
||||
this.reason = 1;
|
||||
base.Close();
|
||||
return false;
|
||||
}
|
||||
PKCS7.ContentInfo contentInfo = new PKCS7.ContentInfo(this.entry);
|
||||
if (contentInfo.ContentType != "1.2.840.113549.1.7.2")
|
||||
{
|
||||
base.Close();
|
||||
return false;
|
||||
}
|
||||
PKCS7.SignedData signedData = new PKCS7.SignedData(contentInfo.Content);
|
||||
if (signedData.ContentInfo.ContentType != "1.3.6.1.4.1.311.2.1.4")
|
||||
{
|
||||
base.Close();
|
||||
return false;
|
||||
}
|
||||
this.coll = signedData.Certificates;
|
||||
ASN1 content = signedData.ContentInfo.Content;
|
||||
this.signedHash = content[0][1][1];
|
||||
int length = this.signedHash.Length;
|
||||
HashAlgorithm hashAlgorithm;
|
||||
if (length != 16)
|
||||
{
|
||||
if (length != 20)
|
||||
{
|
||||
this.reason = 5;
|
||||
base.Close();
|
||||
return false;
|
||||
}
|
||||
hashAlgorithm = HashAlgorithm.Create("SHA1");
|
||||
this.hash = base.GetHash(hashAlgorithm);
|
||||
}
|
||||
else
|
||||
{
|
||||
hashAlgorithm = HashAlgorithm.Create("MD5");
|
||||
this.hash = base.GetHash(hashAlgorithm);
|
||||
}
|
||||
base.Close();
|
||||
if (!this.signedHash.CompareValue(this.hash))
|
||||
{
|
||||
this.reason = 2;
|
||||
}
|
||||
byte[] value = content[0].Value;
|
||||
hashAlgorithm.Initialize();
|
||||
byte[] array = hashAlgorithm.ComputeHash(value);
|
||||
bool flag = this.VerifySignature(signedData, array, hashAlgorithm);
|
||||
return flag && this.reason == 0;
|
||||
}
|
||||
|
||||
// Token: 0x060008C8 RID: 2248 RVA: 0x000217D8 File Offset: 0x0001F9D8
|
||||
private bool CompareIssuerSerial(string issuer, byte[] serial, X509Certificate x509)
|
||||
{
|
||||
if (issuer != x509.IssuerName)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (serial.Length != x509.SerialNumber.Length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int num = serial.Length;
|
||||
for (int i = 0; i < serial.Length; i++)
|
||||
{
|
||||
if (serial[i] != x509.SerialNumber[--num])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x060008C9 RID: 2249 RVA: 0x0002183C File Offset: 0x0001FA3C
|
||||
private bool VerifySignature(PKCS7.SignedData sd, byte[] calculatedMessageDigest, HashAlgorithm ha)
|
||||
{
|
||||
string text = null;
|
||||
ASN1 asn = null;
|
||||
int i = 0;
|
||||
while (i < sd.SignerInfo.AuthenticatedAttributes.Count)
|
||||
{
|
||||
ASN1 asn2 = (ASN1)sd.SignerInfo.AuthenticatedAttributes[i];
|
||||
string text2 = ASN1Convert.ToOid(asn2[0]);
|
||||
string text3 = text2;
|
||||
switch (text3)
|
||||
{
|
||||
case "1.2.840.113549.1.9.3":
|
||||
text = ASN1Convert.ToOid(asn2[1][0]);
|
||||
break;
|
||||
case "1.2.840.113549.1.9.4":
|
||||
asn = asn2[1][0];
|
||||
break;
|
||||
}
|
||||
IL_F1:
|
||||
i++;
|
||||
continue;
|
||||
goto IL_F1;
|
||||
}
|
||||
if (text != "1.3.6.1.4.1.311.2.1.4")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (asn == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!asn.CompareValue(calculatedMessageDigest))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
string text4 = CryptoConfig.MapNameToOID(ha.ToString());
|
||||
ASN1 asn3 = new ASN1(49);
|
||||
foreach (object obj in sd.SignerInfo.AuthenticatedAttributes)
|
||||
{
|
||||
ASN1 asn4 = (ASN1)obj;
|
||||
asn3.Add(asn4);
|
||||
}
|
||||
ha.Initialize();
|
||||
byte[] array = ha.ComputeHash(asn3.GetBytes());
|
||||
byte[] signature = sd.SignerInfo.Signature;
|
||||
string issuerName = sd.SignerInfo.IssuerName;
|
||||
byte[] serialNumber = sd.SignerInfo.SerialNumber;
|
||||
foreach (X509Certificate x509Certificate in this.coll)
|
||||
{
|
||||
if (this.CompareIssuerSerial(issuerName, serialNumber, x509Certificate) && x509Certificate.PublicKey.Length > signature.Length >> 3)
|
||||
{
|
||||
this.signingCertificate = x509Certificate;
|
||||
RSACryptoServiceProvider rsacryptoServiceProvider = (RSACryptoServiceProvider)x509Certificate.RSA;
|
||||
if (rsacryptoServiceProvider.VerifyHash(array, text4, signature))
|
||||
{
|
||||
this.signerChain.LoadCertificates(this.coll);
|
||||
this.trustedRoot = this.signerChain.Build(x509Certificate);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sd.SignerInfo.UnauthenticatedAttributes.Count == 0)
|
||||
{
|
||||
this.trustedTimestampRoot = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
int j = 0;
|
||||
while (j < sd.SignerInfo.UnauthenticatedAttributes.Count)
|
||||
{
|
||||
ASN1 asn5 = (ASN1)sd.SignerInfo.UnauthenticatedAttributes[j];
|
||||
string text5 = ASN1Convert.ToOid(asn5[0]);
|
||||
string text3 = text5;
|
||||
if (text3 != null)
|
||||
{
|
||||
if (AuthenticodeDeformatter.<>f__switch$map6 == null)
|
||||
{
|
||||
AuthenticodeDeformatter.<>f__switch$map6 = new Dictionary<string, int>(1) { { "1.2.840.113549.1.9.6", 0 } };
|
||||
}
|
||||
int num;
|
||||
if (AuthenticodeDeformatter.<>f__switch$map6.TryGetValue(text3, out num))
|
||||
{
|
||||
if (num == 0)
|
||||
{
|
||||
PKCS7.SignerInfo signerInfo = new PKCS7.SignerInfo(asn5[1]);
|
||||
this.trustedTimestampRoot = this.VerifyCounterSignature(signerInfo, signature);
|
||||
}
|
||||
}
|
||||
}
|
||||
IL_35D:
|
||||
j++;
|
||||
continue;
|
||||
goto IL_35D;
|
||||
}
|
||||
}
|
||||
return this.trustedRoot && this.trustedTimestampRoot;
|
||||
}
|
||||
|
||||
// Token: 0x060008CA RID: 2250 RVA: 0x00021C0C File Offset: 0x0001FE0C
|
||||
private bool VerifyCounterSignature(PKCS7.SignerInfo cs, byte[] signature)
|
||||
{
|
||||
if (cs.Version != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
string text = null;
|
||||
ASN1 asn = null;
|
||||
int i = 0;
|
||||
while (i < cs.AuthenticatedAttributes.Count)
|
||||
{
|
||||
ASN1 asn2 = (ASN1)cs.AuthenticatedAttributes[i];
|
||||
string text2 = ASN1Convert.ToOid(asn2[0]);
|
||||
string text3 = text2;
|
||||
switch (text3)
|
||||
{
|
||||
case "1.2.840.113549.1.9.3":
|
||||
text = ASN1Convert.ToOid(asn2[1][0]);
|
||||
break;
|
||||
case "1.2.840.113549.1.9.4":
|
||||
asn = asn2[1][0];
|
||||
break;
|
||||
case "1.2.840.113549.1.9.5":
|
||||
this.timestamp = ASN1Convert.ToDateTime(asn2[1][0]);
|
||||
break;
|
||||
}
|
||||
IL_FC:
|
||||
i++;
|
||||
continue;
|
||||
goto IL_FC;
|
||||
}
|
||||
if (text != "1.2.840.113549.1.7.1")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (asn == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
string text4 = null;
|
||||
int length = asn.Length;
|
||||
if (length != 16)
|
||||
{
|
||||
if (length == 20)
|
||||
{
|
||||
text4 = "SHA1";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
text4 = "MD5";
|
||||
}
|
||||
HashAlgorithm hashAlgorithm = HashAlgorithm.Create(text4);
|
||||
if (!asn.CompareValue(hashAlgorithm.ComputeHash(signature)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
byte[] signature2 = cs.Signature;
|
||||
ASN1 asn3 = new ASN1(49);
|
||||
foreach (object obj in cs.AuthenticatedAttributes)
|
||||
{
|
||||
ASN1 asn4 = (ASN1)obj;
|
||||
asn3.Add(asn4);
|
||||
}
|
||||
byte[] array = hashAlgorithm.ComputeHash(asn3.GetBytes());
|
||||
string issuerName = cs.IssuerName;
|
||||
byte[] serialNumber = cs.SerialNumber;
|
||||
foreach (X509Certificate x509Certificate in this.coll)
|
||||
{
|
||||
if (this.CompareIssuerSerial(issuerName, serialNumber, x509Certificate) && x509Certificate.PublicKey.Length > signature2.Length)
|
||||
{
|
||||
RSACryptoServiceProvider rsacryptoServiceProvider = (RSACryptoServiceProvider)x509Certificate.RSA;
|
||||
RSAManaged rsamanaged = new RSAManaged();
|
||||
rsamanaged.ImportParameters(rsacryptoServiceProvider.ExportParameters(false));
|
||||
if (PKCS1.Verify_v15(rsamanaged, hashAlgorithm, array, signature2, true))
|
||||
{
|
||||
this.timestampChain.LoadCertificates(this.coll);
|
||||
return this.timestampChain.Build(x509Certificate);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Token: 0x060008CB RID: 2251 RVA: 0x00021F18 File Offset: 0x00020118
|
||||
private void Reset()
|
||||
{
|
||||
this.filename = null;
|
||||
this.entry = null;
|
||||
this.hash = null;
|
||||
this.signedHash = null;
|
||||
this.signingCertificate = null;
|
||||
this.reason = -1;
|
||||
this.trustedRoot = false;
|
||||
this.trustedTimestampRoot = false;
|
||||
this.signerChain.Reset();
|
||||
this.timestampChain.Reset();
|
||||
this.timestamp = DateTime.MinValue;
|
||||
}
|
||||
|
||||
// Token: 0x040001CB RID: 459
|
||||
private string filename;
|
||||
|
||||
// Token: 0x040001CC RID: 460
|
||||
private byte[] hash;
|
||||
|
||||
// Token: 0x040001CD RID: 461
|
||||
private X509CertificateCollection coll;
|
||||
|
||||
// Token: 0x040001CE RID: 462
|
||||
private ASN1 signedHash;
|
||||
|
||||
// Token: 0x040001CF RID: 463
|
||||
private DateTime timestamp;
|
||||
|
||||
// Token: 0x040001D0 RID: 464
|
||||
private X509Certificate signingCertificate;
|
||||
|
||||
// Token: 0x040001D1 RID: 465
|
||||
private int reason;
|
||||
|
||||
// Token: 0x040001D2 RID: 466
|
||||
private bool trustedRoot;
|
||||
|
||||
// Token: 0x040001D3 RID: 467
|
||||
private bool trustedTimestampRoot;
|
||||
|
||||
// Token: 0x040001D4 RID: 468
|
||||
private byte[] entry;
|
||||
|
||||
// Token: 0x040001D5 RID: 469
|
||||
private X509Chain signerChain;
|
||||
|
||||
// Token: 0x040001D6 RID: 470
|
||||
private X509Chain timestampChain;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.Authenticode
|
||||
{
|
||||
// Token: 0x0200009E RID: 158
|
||||
internal enum Authority
|
||||
{
|
||||
// Token: 0x040001BF RID: 447
|
||||
Individual,
|
||||
// Token: 0x040001C0 RID: 448
|
||||
Commercial,
|
||||
// Token: 0x040001C1 RID: 449
|
||||
Maximum
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,274 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security
|
||||
{
|
||||
// Token: 0x020000DC RID: 220
|
||||
internal sealed class BitConverterLE
|
||||
{
|
||||
// Token: 0x06000AF5 RID: 2805 RVA: 0x00030B00 File Offset: 0x0002ED00
|
||||
private BitConverterLE()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000AF6 RID: 2806 RVA: 0x00030B08 File Offset: 0x0002ED08
|
||||
private unsafe static byte[] GetUShortBytes(byte* bytes)
|
||||
{
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
return new byte[]
|
||||
{
|
||||
*bytes,
|
||||
bytes[1]
|
||||
};
|
||||
}
|
||||
return new byte[]
|
||||
{
|
||||
bytes[1],
|
||||
*bytes
|
||||
};
|
||||
}
|
||||
|
||||
// Token: 0x06000AF7 RID: 2807 RVA: 0x00030B3C File Offset: 0x0002ED3C
|
||||
private unsafe static byte[] GetUIntBytes(byte* bytes)
|
||||
{
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
return new byte[]
|
||||
{
|
||||
*bytes,
|
||||
bytes[1],
|
||||
bytes[2],
|
||||
bytes[3]
|
||||
};
|
||||
}
|
||||
return new byte[]
|
||||
{
|
||||
bytes[3],
|
||||
bytes[2],
|
||||
bytes[1],
|
||||
*bytes
|
||||
};
|
||||
}
|
||||
|
||||
// Token: 0x06000AF8 RID: 2808 RVA: 0x00030B94 File Offset: 0x0002ED94
|
||||
private unsafe static byte[] GetULongBytes(byte* bytes)
|
||||
{
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
return new byte[]
|
||||
{
|
||||
*bytes,
|
||||
bytes[1],
|
||||
bytes[2],
|
||||
bytes[3],
|
||||
bytes[4],
|
||||
bytes[5],
|
||||
bytes[6],
|
||||
bytes[7]
|
||||
};
|
||||
}
|
||||
return new byte[]
|
||||
{
|
||||
bytes[7],
|
||||
bytes[6],
|
||||
bytes[5],
|
||||
bytes[4],
|
||||
bytes[3],
|
||||
bytes[2],
|
||||
bytes[1],
|
||||
*bytes
|
||||
};
|
||||
}
|
||||
|
||||
// Token: 0x06000AF9 RID: 2809 RVA: 0x00030C24 File Offset: 0x0002EE24
|
||||
internal static byte[] GetBytes(bool value)
|
||||
{
|
||||
return new byte[] { (!value) ? 0 : 1 };
|
||||
}
|
||||
|
||||
// Token: 0x06000AFA RID: 2810 RVA: 0x00030C3C File Offset: 0x0002EE3C
|
||||
internal unsafe static byte[] GetBytes(char value)
|
||||
{
|
||||
return BitConverterLE.GetUShortBytes((byte*)(&value));
|
||||
}
|
||||
|
||||
// Token: 0x06000AFB RID: 2811 RVA: 0x00030C48 File Offset: 0x0002EE48
|
||||
internal unsafe static byte[] GetBytes(short value)
|
||||
{
|
||||
return BitConverterLE.GetUShortBytes((byte*)(&value));
|
||||
}
|
||||
|
||||
// Token: 0x06000AFC RID: 2812 RVA: 0x00030C54 File Offset: 0x0002EE54
|
||||
internal unsafe static byte[] GetBytes(int value)
|
||||
{
|
||||
return BitConverterLE.GetUIntBytes((byte*)(&value));
|
||||
}
|
||||
|
||||
// Token: 0x06000AFD RID: 2813 RVA: 0x00030C60 File Offset: 0x0002EE60
|
||||
internal unsafe static byte[] GetBytes(long value)
|
||||
{
|
||||
return BitConverterLE.GetULongBytes((byte*)(&value));
|
||||
}
|
||||
|
||||
// Token: 0x06000AFE RID: 2814 RVA: 0x00030C6C File Offset: 0x0002EE6C
|
||||
internal unsafe static byte[] GetBytes(ushort value)
|
||||
{
|
||||
return BitConverterLE.GetUShortBytes((byte*)(&value));
|
||||
}
|
||||
|
||||
// Token: 0x06000AFF RID: 2815 RVA: 0x00030C78 File Offset: 0x0002EE78
|
||||
internal unsafe static byte[] GetBytes(uint value)
|
||||
{
|
||||
return BitConverterLE.GetUIntBytes((byte*)(&value));
|
||||
}
|
||||
|
||||
// Token: 0x06000B00 RID: 2816 RVA: 0x00030C84 File Offset: 0x0002EE84
|
||||
internal unsafe static byte[] GetBytes(ulong value)
|
||||
{
|
||||
return BitConverterLE.GetULongBytes((byte*)(&value));
|
||||
}
|
||||
|
||||
// Token: 0x06000B01 RID: 2817 RVA: 0x00030C90 File Offset: 0x0002EE90
|
||||
internal unsafe static byte[] GetBytes(float value)
|
||||
{
|
||||
return BitConverterLE.GetUIntBytes((byte*)(&value));
|
||||
}
|
||||
|
||||
// Token: 0x06000B02 RID: 2818 RVA: 0x00030C9C File Offset: 0x0002EE9C
|
||||
internal unsafe static byte[] GetBytes(double value)
|
||||
{
|
||||
return BitConverterLE.GetULongBytes((byte*)(&value));
|
||||
}
|
||||
|
||||
// Token: 0x06000B03 RID: 2819 RVA: 0x00030CA8 File Offset: 0x0002EEA8
|
||||
private unsafe static void UShortFromBytes(byte* dst, byte[] src, int startIndex)
|
||||
{
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
*dst = src[startIndex];
|
||||
dst[1] = src[startIndex + 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
*dst = src[startIndex + 1];
|
||||
dst[1] = src[startIndex];
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000B04 RID: 2820 RVA: 0x00030CD8 File Offset: 0x0002EED8
|
||||
private unsafe static void UIntFromBytes(byte* dst, byte[] src, int startIndex)
|
||||
{
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
*dst = src[startIndex];
|
||||
dst[1] = src[startIndex + 1];
|
||||
dst[2] = src[startIndex + 2];
|
||||
dst[3] = src[startIndex + 3];
|
||||
}
|
||||
else
|
||||
{
|
||||
*dst = src[startIndex + 3];
|
||||
dst[1] = src[startIndex + 2];
|
||||
dst[2] = src[startIndex + 1];
|
||||
dst[3] = src[startIndex];
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000B05 RID: 2821 RVA: 0x00030D34 File Offset: 0x0002EF34
|
||||
private unsafe static void ULongFromBytes(byte* dst, byte[] src, int startIndex)
|
||||
{
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
dst[i] = src[startIndex + i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int j = 0; j < 8; j++)
|
||||
{
|
||||
dst[j] = src[startIndex + (7 - j)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000B06 RID: 2822 RVA: 0x00030D88 File Offset: 0x0002EF88
|
||||
internal static bool ToBoolean(byte[] value, int startIndex)
|
||||
{
|
||||
return value[startIndex] != 0;
|
||||
}
|
||||
|
||||
// Token: 0x06000B07 RID: 2823 RVA: 0x00030D94 File Offset: 0x0002EF94
|
||||
internal unsafe static char ToChar(byte[] value, int startIndex)
|
||||
{
|
||||
char c;
|
||||
BitConverterLE.UShortFromBytes((byte*)(&c), value, startIndex);
|
||||
return c;
|
||||
}
|
||||
|
||||
// Token: 0x06000B08 RID: 2824 RVA: 0x00030DAC File Offset: 0x0002EFAC
|
||||
internal unsafe static short ToInt16(byte[] value, int startIndex)
|
||||
{
|
||||
short num;
|
||||
BitConverterLE.UShortFromBytes((byte*)(&num), value, startIndex);
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x06000B09 RID: 2825 RVA: 0x00030DC4 File Offset: 0x0002EFC4
|
||||
internal unsafe static int ToInt32(byte[] value, int startIndex)
|
||||
{
|
||||
int num;
|
||||
BitConverterLE.UIntFromBytes((byte*)(&num), value, startIndex);
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x06000B0A RID: 2826 RVA: 0x00030DDC File Offset: 0x0002EFDC
|
||||
internal unsafe static long ToInt64(byte[] value, int startIndex)
|
||||
{
|
||||
long num;
|
||||
BitConverterLE.ULongFromBytes((byte*)(&num), value, startIndex);
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x06000B0B RID: 2827 RVA: 0x00030DF4 File Offset: 0x0002EFF4
|
||||
internal unsafe static ushort ToUInt16(byte[] value, int startIndex)
|
||||
{
|
||||
ushort num;
|
||||
BitConverterLE.UShortFromBytes((byte*)(&num), value, startIndex);
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x06000B0C RID: 2828 RVA: 0x00030E0C File Offset: 0x0002F00C
|
||||
internal unsafe static uint ToUInt32(byte[] value, int startIndex)
|
||||
{
|
||||
uint num;
|
||||
BitConverterLE.UIntFromBytes((byte*)(&num), value, startIndex);
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x06000B0D RID: 2829 RVA: 0x00030E24 File Offset: 0x0002F024
|
||||
internal unsafe static ulong ToUInt64(byte[] value, int startIndex)
|
||||
{
|
||||
ulong num;
|
||||
BitConverterLE.ULongFromBytes((byte*)(&num), value, startIndex);
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x06000B0E RID: 2830 RVA: 0x00030E3C File Offset: 0x0002F03C
|
||||
internal unsafe static float ToSingle(byte[] value, int startIndex)
|
||||
{
|
||||
float num;
|
||||
BitConverterLE.UIntFromBytes((byte*)(&num), value, startIndex);
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x06000B0F RID: 2831 RVA: 0x00030E54 File Offset: 0x0002F054
|
||||
internal unsafe static double ToDouble(byte[] value, int startIndex)
|
||||
{
|
||||
double num;
|
||||
BitConverterLE.ULongFromBytes((byte*)(&num), value, startIndex);
|
||||
return num;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Mono.Security.Cryptography
|
||||
{
|
||||
// Token: 0x020000A3 RID: 163
|
||||
internal class BlockProcessor
|
||||
{
|
||||
// Token: 0x060008EB RID: 2283 RVA: 0x00023098 File Offset: 0x00021298
|
||||
public BlockProcessor(ICryptoTransform transform)
|
||||
: this(transform, transform.InputBlockSize)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060008EC RID: 2284 RVA: 0x000230A8 File Offset: 0x000212A8
|
||||
public BlockProcessor(ICryptoTransform transform, int blockSize)
|
||||
{
|
||||
this.transform = transform;
|
||||
this.blockSize = blockSize;
|
||||
this.block = new byte[blockSize];
|
||||
}
|
||||
|
||||
// Token: 0x060008ED RID: 2285 RVA: 0x000230D8 File Offset: 0x000212D8
|
||||
~BlockProcessor()
|
||||
{
|
||||
Array.Clear(this.block, 0, this.blockSize);
|
||||
}
|
||||
|
||||
// Token: 0x060008EE RID: 2286 RVA: 0x00023120 File Offset: 0x00021320
|
||||
public void Initialize()
|
||||
{
|
||||
Array.Clear(this.block, 0, this.blockSize);
|
||||
this.blockCount = 0;
|
||||
}
|
||||
|
||||
// Token: 0x060008EF RID: 2287 RVA: 0x0002313C File Offset: 0x0002133C
|
||||
public void Core(byte[] rgb)
|
||||
{
|
||||
this.Core(rgb, 0, rgb.Length);
|
||||
}
|
||||
|
||||
// Token: 0x060008F0 RID: 2288 RVA: 0x0002314C File Offset: 0x0002134C
|
||||
public void Core(byte[] rgb, int ib, int cb)
|
||||
{
|
||||
int num = Math.Min(this.blockSize - this.blockCount, cb);
|
||||
Buffer.BlockCopy(rgb, ib, this.block, this.blockCount, num);
|
||||
this.blockCount += num;
|
||||
if (this.blockCount == this.blockSize)
|
||||
{
|
||||
this.transform.TransformBlock(this.block, 0, this.blockSize, this.block, 0);
|
||||
int num2 = (cb - num) / this.blockSize;
|
||||
for (int i = 0; i < num2; i++)
|
||||
{
|
||||
this.transform.TransformBlock(rgb, num + ib, this.blockSize, this.block, 0);
|
||||
num += this.blockSize;
|
||||
}
|
||||
this.blockCount = cb - num;
|
||||
if (this.blockCount > 0)
|
||||
{
|
||||
Buffer.BlockCopy(rgb, num + ib, this.block, 0, this.blockCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060008F1 RID: 2289 RVA: 0x00023230 File Offset: 0x00021430
|
||||
public byte[] Final()
|
||||
{
|
||||
return this.transform.TransformFinalBlock(this.block, 0, this.blockCount);
|
||||
}
|
||||
|
||||
// Token: 0x040001DB RID: 475
|
||||
private ICryptoTransform transform;
|
||||
|
||||
// Token: 0x040001DC RID: 476
|
||||
private byte[] block;
|
||||
|
||||
// Token: 0x040001DD RID: 477
|
||||
private int blockSize;
|
||||
|
||||
// Token: 0x040001DE RID: 478
|
||||
private int blockCount;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,642 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Mono.Security.Cryptography
|
||||
{
|
||||
// Token: 0x020000A1 RID: 161
|
||||
internal sealed class CryptoConvert
|
||||
{
|
||||
// Token: 0x060008CC RID: 2252 RVA: 0x00021F80 File Offset: 0x00020180
|
||||
private CryptoConvert()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060008CD RID: 2253 RVA: 0x00021F88 File Offset: 0x00020188
|
||||
private static int ToInt32LE(byte[] bytes, int offset)
|
||||
{
|
||||
return ((int)bytes[offset + 3] << 24) | ((int)bytes[offset + 2] << 16) | ((int)bytes[offset + 1] << 8) | (int)bytes[offset];
|
||||
}
|
||||
|
||||
// Token: 0x060008CE RID: 2254 RVA: 0x00021FA8 File Offset: 0x000201A8
|
||||
private static uint ToUInt32LE(byte[] bytes, int offset)
|
||||
{
|
||||
return (uint)(((int)bytes[offset + 3] << 24) | ((int)bytes[offset + 2] << 16) | ((int)bytes[offset + 1] << 8) | (int)bytes[offset]);
|
||||
}
|
||||
|
||||
// Token: 0x060008CF RID: 2255 RVA: 0x00021FC8 File Offset: 0x000201C8
|
||||
private static byte[] GetBytesLE(int val)
|
||||
{
|
||||
return new byte[]
|
||||
{
|
||||
(byte)(val & 255),
|
||||
(byte)((val >> 8) & 255),
|
||||
(byte)((val >> 16) & 255),
|
||||
(byte)((val >> 24) & 255)
|
||||
};
|
||||
}
|
||||
|
||||
// Token: 0x060008D0 RID: 2256 RVA: 0x00022010 File Offset: 0x00020210
|
||||
private static byte[] Trim(byte[] array)
|
||||
{
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
if (array[i] != 0)
|
||||
{
|
||||
byte[] array2 = new byte[array.Length - i];
|
||||
Buffer.BlockCopy(array, i, array2, 0, array2.Length);
|
||||
return array2;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x060008D1 RID: 2257 RVA: 0x00022054 File Offset: 0x00020254
|
||||
public static RSA FromCapiPrivateKeyBlob(byte[] blob)
|
||||
{
|
||||
return CryptoConvert.FromCapiPrivateKeyBlob(blob, 0);
|
||||
}
|
||||
|
||||
// Token: 0x060008D2 RID: 2258 RVA: 0x00022060 File Offset: 0x00020260
|
||||
public static RSA FromCapiPrivateKeyBlob(byte[] blob, int offset)
|
||||
{
|
||||
if (blob == null)
|
||||
{
|
||||
throw new ArgumentNullException("blob");
|
||||
}
|
||||
if (offset >= blob.Length)
|
||||
{
|
||||
throw new ArgumentException("blob is too small.");
|
||||
}
|
||||
RSAParameters rsaparameters = default(RSAParameters);
|
||||
try
|
||||
{
|
||||
if (blob[offset] != 7 || blob[offset + 1] != 2 || blob[offset + 2] != 0 || blob[offset + 3] != 0 || CryptoConvert.ToUInt32LE(blob, offset + 8) != 843141970U)
|
||||
{
|
||||
throw new CryptographicException("Invalid blob header");
|
||||
}
|
||||
int num = CryptoConvert.ToInt32LE(blob, offset + 12);
|
||||
byte[] array = new byte[4];
|
||||
Buffer.BlockCopy(blob, offset + 16, array, 0, 4);
|
||||
Array.Reverse(array);
|
||||
rsaparameters.Exponent = CryptoConvert.Trim(array);
|
||||
int num2 = offset + 20;
|
||||
int num3 = num >> 3;
|
||||
rsaparameters.Modulus = new byte[num3];
|
||||
Buffer.BlockCopy(blob, num2, rsaparameters.Modulus, 0, num3);
|
||||
Array.Reverse(rsaparameters.Modulus);
|
||||
num2 += num3;
|
||||
int num4 = num3 >> 1;
|
||||
rsaparameters.P = new byte[num4];
|
||||
Buffer.BlockCopy(blob, num2, rsaparameters.P, 0, num4);
|
||||
Array.Reverse(rsaparameters.P);
|
||||
num2 += num4;
|
||||
rsaparameters.Q = new byte[num4];
|
||||
Buffer.BlockCopy(blob, num2, rsaparameters.Q, 0, num4);
|
||||
Array.Reverse(rsaparameters.Q);
|
||||
num2 += num4;
|
||||
rsaparameters.DP = new byte[num4];
|
||||
Buffer.BlockCopy(blob, num2, rsaparameters.DP, 0, num4);
|
||||
Array.Reverse(rsaparameters.DP);
|
||||
num2 += num4;
|
||||
rsaparameters.DQ = new byte[num4];
|
||||
Buffer.BlockCopy(blob, num2, rsaparameters.DQ, 0, num4);
|
||||
Array.Reverse(rsaparameters.DQ);
|
||||
num2 += num4;
|
||||
rsaparameters.InverseQ = new byte[num4];
|
||||
Buffer.BlockCopy(blob, num2, rsaparameters.InverseQ, 0, num4);
|
||||
Array.Reverse(rsaparameters.InverseQ);
|
||||
num2 += num4;
|
||||
rsaparameters.D = new byte[num3];
|
||||
if (num2 + num3 + offset <= blob.Length)
|
||||
{
|
||||
Buffer.BlockCopy(blob, num2, rsaparameters.D, 0, num3);
|
||||
Array.Reverse(rsaparameters.D);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new CryptographicException("Invalid blob.", ex);
|
||||
}
|
||||
RSA rsa = RSA.Create();
|
||||
rsa.ImportParameters(rsaparameters);
|
||||
return rsa;
|
||||
}
|
||||
|
||||
// Token: 0x060008D3 RID: 2259 RVA: 0x000222C4 File Offset: 0x000204C4
|
||||
public static DSA FromCapiPrivateKeyBlobDSA(byte[] blob)
|
||||
{
|
||||
return CryptoConvert.FromCapiPrivateKeyBlobDSA(blob, 0);
|
||||
}
|
||||
|
||||
// Token: 0x060008D4 RID: 2260 RVA: 0x000222D0 File Offset: 0x000204D0
|
||||
public static DSA FromCapiPrivateKeyBlobDSA(byte[] blob, int offset)
|
||||
{
|
||||
if (blob == null)
|
||||
{
|
||||
throw new ArgumentNullException("blob");
|
||||
}
|
||||
if (offset >= blob.Length)
|
||||
{
|
||||
throw new ArgumentException("blob is too small.");
|
||||
}
|
||||
DSAParameters dsaparameters = default(DSAParameters);
|
||||
try
|
||||
{
|
||||
if (blob[offset] != 7 || blob[offset + 1] != 2 || blob[offset + 2] != 0 || blob[offset + 3] != 0 || CryptoConvert.ToUInt32LE(blob, offset + 8) != 844321604U)
|
||||
{
|
||||
throw new CryptographicException("Invalid blob header");
|
||||
}
|
||||
int num = CryptoConvert.ToInt32LE(blob, offset + 12);
|
||||
int num2 = num >> 3;
|
||||
int num3 = offset + 16;
|
||||
dsaparameters.P = new byte[num2];
|
||||
Buffer.BlockCopy(blob, num3, dsaparameters.P, 0, num2);
|
||||
Array.Reverse(dsaparameters.P);
|
||||
num3 += num2;
|
||||
dsaparameters.Q = new byte[20];
|
||||
Buffer.BlockCopy(blob, num3, dsaparameters.Q, 0, 20);
|
||||
Array.Reverse(dsaparameters.Q);
|
||||
num3 += 20;
|
||||
dsaparameters.G = new byte[num2];
|
||||
Buffer.BlockCopy(blob, num3, dsaparameters.G, 0, num2);
|
||||
Array.Reverse(dsaparameters.G);
|
||||
num3 += num2;
|
||||
dsaparameters.X = new byte[20];
|
||||
Buffer.BlockCopy(blob, num3, dsaparameters.X, 0, 20);
|
||||
Array.Reverse(dsaparameters.X);
|
||||
num3 += 20;
|
||||
dsaparameters.Counter = CryptoConvert.ToInt32LE(blob, num3);
|
||||
num3 += 4;
|
||||
dsaparameters.Seed = new byte[20];
|
||||
Buffer.BlockCopy(blob, num3, dsaparameters.Seed, 0, 20);
|
||||
Array.Reverse(dsaparameters.Seed);
|
||||
num3 += 20;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new CryptographicException("Invalid blob.", ex);
|
||||
}
|
||||
DSA dsa = DSA.Create();
|
||||
dsa.ImportParameters(dsaparameters);
|
||||
return dsa;
|
||||
}
|
||||
|
||||
// Token: 0x060008D5 RID: 2261 RVA: 0x000224A8 File Offset: 0x000206A8
|
||||
public static byte[] ToCapiPrivateKeyBlob(RSA rsa)
|
||||
{
|
||||
RSAParameters rsaparameters = rsa.ExportParameters(true);
|
||||
int num = rsaparameters.Modulus.Length;
|
||||
byte[] array = new byte[20 + (num << 2) + (num >> 1)];
|
||||
array[0] = 7;
|
||||
array[1] = 2;
|
||||
array[5] = 36;
|
||||
array[8] = 82;
|
||||
array[9] = 83;
|
||||
array[10] = 65;
|
||||
array[11] = 50;
|
||||
byte[] bytesLE = CryptoConvert.GetBytesLE(num << 3);
|
||||
array[12] = bytesLE[0];
|
||||
array[13] = bytesLE[1];
|
||||
array[14] = bytesLE[2];
|
||||
array[15] = bytesLE[3];
|
||||
int num2 = 16;
|
||||
int i = rsaparameters.Exponent.Length;
|
||||
while (i > 0)
|
||||
{
|
||||
array[num2++] = rsaparameters.Exponent[--i];
|
||||
}
|
||||
num2 = 20;
|
||||
byte[] array2 = rsaparameters.Modulus;
|
||||
int num3 = array2.Length;
|
||||
Array.Reverse(array2, 0, num3);
|
||||
Buffer.BlockCopy(array2, 0, array, num2, num3);
|
||||
num2 += num3;
|
||||
array2 = rsaparameters.P;
|
||||
num3 = array2.Length;
|
||||
Array.Reverse(array2, 0, num3);
|
||||
Buffer.BlockCopy(array2, 0, array, num2, num3);
|
||||
num2 += num3;
|
||||
array2 = rsaparameters.Q;
|
||||
num3 = array2.Length;
|
||||
Array.Reverse(array2, 0, num3);
|
||||
Buffer.BlockCopy(array2, 0, array, num2, num3);
|
||||
num2 += num3;
|
||||
array2 = rsaparameters.DP;
|
||||
num3 = array2.Length;
|
||||
Array.Reverse(array2, 0, num3);
|
||||
Buffer.BlockCopy(array2, 0, array, num2, num3);
|
||||
num2 += num3;
|
||||
array2 = rsaparameters.DQ;
|
||||
num3 = array2.Length;
|
||||
Array.Reverse(array2, 0, num3);
|
||||
Buffer.BlockCopy(array2, 0, array, num2, num3);
|
||||
num2 += num3;
|
||||
array2 = rsaparameters.InverseQ;
|
||||
num3 = array2.Length;
|
||||
Array.Reverse(array2, 0, num3);
|
||||
Buffer.BlockCopy(array2, 0, array, num2, num3);
|
||||
num2 += num3;
|
||||
array2 = rsaparameters.D;
|
||||
num3 = array2.Length;
|
||||
Array.Reverse(array2, 0, num3);
|
||||
Buffer.BlockCopy(array2, 0, array, num2, num3);
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x060008D6 RID: 2262 RVA: 0x00022690 File Offset: 0x00020890
|
||||
public static byte[] ToCapiPrivateKeyBlob(DSA dsa)
|
||||
{
|
||||
DSAParameters dsaparameters = dsa.ExportParameters(true);
|
||||
int num = dsaparameters.P.Length;
|
||||
byte[] array = new byte[16 + num + 20 + num + 20 + 4 + 20];
|
||||
array[0] = 7;
|
||||
array[1] = 2;
|
||||
array[5] = 34;
|
||||
array[8] = 68;
|
||||
array[9] = 83;
|
||||
array[10] = 83;
|
||||
array[11] = 50;
|
||||
byte[] bytesLE = CryptoConvert.GetBytesLE(num << 3);
|
||||
array[12] = bytesLE[0];
|
||||
array[13] = bytesLE[1];
|
||||
array[14] = bytesLE[2];
|
||||
array[15] = bytesLE[3];
|
||||
int num2 = 16;
|
||||
byte[] array2 = dsaparameters.P;
|
||||
Array.Reverse(array2);
|
||||
Buffer.BlockCopy(array2, 0, array, num2, num);
|
||||
num2 += num;
|
||||
array2 = dsaparameters.Q;
|
||||
Array.Reverse(array2);
|
||||
Buffer.BlockCopy(array2, 0, array, num2, 20);
|
||||
num2 += 20;
|
||||
array2 = dsaparameters.G;
|
||||
Array.Reverse(array2);
|
||||
Buffer.BlockCopy(array2, 0, array, num2, num);
|
||||
num2 += num;
|
||||
array2 = dsaparameters.X;
|
||||
Array.Reverse(array2);
|
||||
Buffer.BlockCopy(array2, 0, array, num2, 20);
|
||||
num2 += 20;
|
||||
Buffer.BlockCopy(CryptoConvert.GetBytesLE(dsaparameters.Counter), 0, array, num2, 4);
|
||||
num2 += 4;
|
||||
array2 = dsaparameters.Seed;
|
||||
Array.Reverse(array2);
|
||||
Buffer.BlockCopy(array2, 0, array, num2, 20);
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x060008D7 RID: 2263 RVA: 0x000227DC File Offset: 0x000209DC
|
||||
public static RSA FromCapiPublicKeyBlob(byte[] blob)
|
||||
{
|
||||
return CryptoConvert.FromCapiPublicKeyBlob(blob, 0);
|
||||
}
|
||||
|
||||
// Token: 0x060008D8 RID: 2264 RVA: 0x000227E8 File Offset: 0x000209E8
|
||||
public static RSA FromCapiPublicKeyBlob(byte[] blob, int offset)
|
||||
{
|
||||
if (blob == null)
|
||||
{
|
||||
throw new ArgumentNullException("blob");
|
||||
}
|
||||
if (offset >= blob.Length)
|
||||
{
|
||||
throw new ArgumentException("blob is too small.");
|
||||
}
|
||||
RSA rsa2;
|
||||
try
|
||||
{
|
||||
if (blob[offset] != 6 || blob[offset + 1] != 2 || blob[offset + 2] != 0 || blob[offset + 3] != 0 || CryptoConvert.ToUInt32LE(blob, offset + 8) != 826364754U)
|
||||
{
|
||||
throw new CryptographicException("Invalid blob header");
|
||||
}
|
||||
int num = CryptoConvert.ToInt32LE(blob, offset + 12);
|
||||
RSAParameters rsaparameters = default(RSAParameters);
|
||||
rsaparameters.Exponent = new byte[3];
|
||||
rsaparameters.Exponent[0] = blob[offset + 18];
|
||||
rsaparameters.Exponent[1] = blob[offset + 17];
|
||||
rsaparameters.Exponent[2] = blob[offset + 16];
|
||||
int num2 = offset + 20;
|
||||
int num3 = num >> 3;
|
||||
rsaparameters.Modulus = new byte[num3];
|
||||
Buffer.BlockCopy(blob, num2, rsaparameters.Modulus, 0, num3);
|
||||
Array.Reverse(rsaparameters.Modulus);
|
||||
RSA rsa = RSA.Create();
|
||||
rsa.ImportParameters(rsaparameters);
|
||||
rsa2 = rsa;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new CryptographicException("Invalid blob.", ex);
|
||||
}
|
||||
return rsa2;
|
||||
}
|
||||
|
||||
// Token: 0x060008D9 RID: 2265 RVA: 0x00022930 File Offset: 0x00020B30
|
||||
public static DSA FromCapiPublicKeyBlobDSA(byte[] blob)
|
||||
{
|
||||
return CryptoConvert.FromCapiPublicKeyBlobDSA(blob, 0);
|
||||
}
|
||||
|
||||
// Token: 0x060008DA RID: 2266 RVA: 0x0002293C File Offset: 0x00020B3C
|
||||
public static DSA FromCapiPublicKeyBlobDSA(byte[] blob, int offset)
|
||||
{
|
||||
if (blob == null)
|
||||
{
|
||||
throw new ArgumentNullException("blob");
|
||||
}
|
||||
if (offset >= blob.Length)
|
||||
{
|
||||
throw new ArgumentException("blob is too small.");
|
||||
}
|
||||
DSA dsa2;
|
||||
try
|
||||
{
|
||||
if (blob[offset] != 6 || blob[offset + 1] != 2 || blob[offset + 2] != 0 || blob[offset + 3] != 0 || CryptoConvert.ToUInt32LE(blob, offset + 8) != 827544388U)
|
||||
{
|
||||
throw new CryptographicException("Invalid blob header");
|
||||
}
|
||||
int num = CryptoConvert.ToInt32LE(blob, offset + 12);
|
||||
DSAParameters dsaparameters = default(DSAParameters);
|
||||
int num2 = num >> 3;
|
||||
int num3 = offset + 16;
|
||||
dsaparameters.P = new byte[num2];
|
||||
Buffer.BlockCopy(blob, num3, dsaparameters.P, 0, num2);
|
||||
Array.Reverse(dsaparameters.P);
|
||||
num3 += num2;
|
||||
dsaparameters.Q = new byte[20];
|
||||
Buffer.BlockCopy(blob, num3, dsaparameters.Q, 0, 20);
|
||||
Array.Reverse(dsaparameters.Q);
|
||||
num3 += 20;
|
||||
dsaparameters.G = new byte[num2];
|
||||
Buffer.BlockCopy(blob, num3, dsaparameters.G, 0, num2);
|
||||
Array.Reverse(dsaparameters.G);
|
||||
num3 += num2;
|
||||
dsaparameters.Y = new byte[num2];
|
||||
Buffer.BlockCopy(blob, num3, dsaparameters.Y, 0, num2);
|
||||
Array.Reverse(dsaparameters.Y);
|
||||
num3 += num2;
|
||||
dsaparameters.Counter = CryptoConvert.ToInt32LE(blob, num3);
|
||||
num3 += 4;
|
||||
dsaparameters.Seed = new byte[20];
|
||||
Buffer.BlockCopy(blob, num3, dsaparameters.Seed, 0, 20);
|
||||
Array.Reverse(dsaparameters.Seed);
|
||||
num3 += 20;
|
||||
DSA dsa = DSA.Create();
|
||||
dsa.ImportParameters(dsaparameters);
|
||||
dsa2 = dsa;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new CryptographicException("Invalid blob.", ex);
|
||||
}
|
||||
return dsa2;
|
||||
}
|
||||
|
||||
// Token: 0x060008DB RID: 2267 RVA: 0x00022B18 File Offset: 0x00020D18
|
||||
public static byte[] ToCapiPublicKeyBlob(RSA rsa)
|
||||
{
|
||||
RSAParameters rsaparameters = rsa.ExportParameters(false);
|
||||
int num = rsaparameters.Modulus.Length;
|
||||
byte[] array = new byte[20 + num];
|
||||
array[0] = 6;
|
||||
array[1] = 2;
|
||||
array[5] = 36;
|
||||
array[8] = 82;
|
||||
array[9] = 83;
|
||||
array[10] = 65;
|
||||
array[11] = 49;
|
||||
byte[] bytesLE = CryptoConvert.GetBytesLE(num << 3);
|
||||
array[12] = bytesLE[0];
|
||||
array[13] = bytesLE[1];
|
||||
array[14] = bytesLE[2];
|
||||
array[15] = bytesLE[3];
|
||||
int num2 = 16;
|
||||
int i = rsaparameters.Exponent.Length;
|
||||
while (i > 0)
|
||||
{
|
||||
array[num2++] = rsaparameters.Exponent[--i];
|
||||
}
|
||||
num2 = 20;
|
||||
byte[] modulus = rsaparameters.Modulus;
|
||||
int num3 = modulus.Length;
|
||||
Array.Reverse(modulus, 0, num3);
|
||||
Buffer.BlockCopy(modulus, 0, array, num2, num3);
|
||||
num2 += num3;
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x060008DC RID: 2268 RVA: 0x00022BF0 File Offset: 0x00020DF0
|
||||
public static byte[] ToCapiPublicKeyBlob(DSA dsa)
|
||||
{
|
||||
DSAParameters dsaparameters = dsa.ExportParameters(false);
|
||||
int num = dsaparameters.P.Length;
|
||||
byte[] array = new byte[16 + num + 20 + num + num + 4 + 20];
|
||||
array[0] = 6;
|
||||
array[1] = 2;
|
||||
array[5] = 34;
|
||||
array[8] = 68;
|
||||
array[9] = 83;
|
||||
array[10] = 83;
|
||||
array[11] = 49;
|
||||
byte[] bytesLE = CryptoConvert.GetBytesLE(num << 3);
|
||||
array[12] = bytesLE[0];
|
||||
array[13] = bytesLE[1];
|
||||
array[14] = bytesLE[2];
|
||||
array[15] = bytesLE[3];
|
||||
int num2 = 16;
|
||||
byte[] array2 = dsaparameters.P;
|
||||
Array.Reverse(array2);
|
||||
Buffer.BlockCopy(array2, 0, array, num2, num);
|
||||
num2 += num;
|
||||
array2 = dsaparameters.Q;
|
||||
Array.Reverse(array2);
|
||||
Buffer.BlockCopy(array2, 0, array, num2, 20);
|
||||
num2 += 20;
|
||||
array2 = dsaparameters.G;
|
||||
Array.Reverse(array2);
|
||||
Buffer.BlockCopy(array2, 0, array, num2, num);
|
||||
num2 += num;
|
||||
array2 = dsaparameters.Y;
|
||||
Array.Reverse(array2);
|
||||
Buffer.BlockCopy(array2, 0, array, num2, num);
|
||||
num2 += num;
|
||||
Buffer.BlockCopy(CryptoConvert.GetBytesLE(dsaparameters.Counter), 0, array, num2, 4);
|
||||
num2 += 4;
|
||||
array2 = dsaparameters.Seed;
|
||||
Array.Reverse(array2);
|
||||
Buffer.BlockCopy(array2, 0, array, num2, 20);
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x060008DD RID: 2269 RVA: 0x00022D38 File Offset: 0x00020F38
|
||||
public static RSA FromCapiKeyBlob(byte[] blob)
|
||||
{
|
||||
return CryptoConvert.FromCapiKeyBlob(blob, 0);
|
||||
}
|
||||
|
||||
// Token: 0x060008DE RID: 2270 RVA: 0x00022D44 File Offset: 0x00020F44
|
||||
public static RSA FromCapiKeyBlob(byte[] blob, int offset)
|
||||
{
|
||||
if (blob == null)
|
||||
{
|
||||
throw new ArgumentNullException("blob");
|
||||
}
|
||||
if (offset >= blob.Length)
|
||||
{
|
||||
throw new ArgumentException("blob is too small.");
|
||||
}
|
||||
byte b = blob[offset];
|
||||
if (b == 6)
|
||||
{
|
||||
return CryptoConvert.FromCapiPublicKeyBlob(blob, offset);
|
||||
}
|
||||
if (b != 7)
|
||||
{
|
||||
if (b == 0)
|
||||
{
|
||||
if (blob[offset + 12] == 6)
|
||||
{
|
||||
return CryptoConvert.FromCapiPublicKeyBlob(blob, offset + 12);
|
||||
}
|
||||
}
|
||||
throw new CryptographicException("Unknown blob format.");
|
||||
}
|
||||
return CryptoConvert.FromCapiPrivateKeyBlob(blob, offset);
|
||||
}
|
||||
|
||||
// Token: 0x060008DF RID: 2271 RVA: 0x00022DCC File Offset: 0x00020FCC
|
||||
public static DSA FromCapiKeyBlobDSA(byte[] blob)
|
||||
{
|
||||
return CryptoConvert.FromCapiKeyBlobDSA(blob, 0);
|
||||
}
|
||||
|
||||
// Token: 0x060008E0 RID: 2272 RVA: 0x00022DD8 File Offset: 0x00020FD8
|
||||
public static DSA FromCapiKeyBlobDSA(byte[] blob, int offset)
|
||||
{
|
||||
if (blob == null)
|
||||
{
|
||||
throw new ArgumentNullException("blob");
|
||||
}
|
||||
if (offset >= blob.Length)
|
||||
{
|
||||
throw new ArgumentException("blob is too small.");
|
||||
}
|
||||
byte b = blob[offset];
|
||||
if (b == 6)
|
||||
{
|
||||
return CryptoConvert.FromCapiPublicKeyBlobDSA(blob, offset);
|
||||
}
|
||||
if (b != 7)
|
||||
{
|
||||
throw new CryptographicException("Unknown blob format.");
|
||||
}
|
||||
return CryptoConvert.FromCapiPrivateKeyBlobDSA(blob, offset);
|
||||
}
|
||||
|
||||
// Token: 0x060008E1 RID: 2273 RVA: 0x00022E3C File Offset: 0x0002103C
|
||||
public static byte[] ToCapiKeyBlob(AsymmetricAlgorithm keypair, bool includePrivateKey)
|
||||
{
|
||||
if (keypair == null)
|
||||
{
|
||||
throw new ArgumentNullException("keypair");
|
||||
}
|
||||
if (keypair is RSA)
|
||||
{
|
||||
return CryptoConvert.ToCapiKeyBlob((RSA)keypair, includePrivateKey);
|
||||
}
|
||||
if (keypair is DSA)
|
||||
{
|
||||
return CryptoConvert.ToCapiKeyBlob((DSA)keypair, includePrivateKey);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x060008E2 RID: 2274 RVA: 0x00022E8C File Offset: 0x0002108C
|
||||
public static byte[] ToCapiKeyBlob(RSA rsa, bool includePrivateKey)
|
||||
{
|
||||
if (rsa == null)
|
||||
{
|
||||
throw new ArgumentNullException("rsa");
|
||||
}
|
||||
if (includePrivateKey)
|
||||
{
|
||||
return CryptoConvert.ToCapiPrivateKeyBlob(rsa);
|
||||
}
|
||||
return CryptoConvert.ToCapiPublicKeyBlob(rsa);
|
||||
}
|
||||
|
||||
// Token: 0x060008E3 RID: 2275 RVA: 0x00022EC0 File Offset: 0x000210C0
|
||||
public static byte[] ToCapiKeyBlob(DSA dsa, bool includePrivateKey)
|
||||
{
|
||||
if (dsa == null)
|
||||
{
|
||||
throw new ArgumentNullException("dsa");
|
||||
}
|
||||
if (includePrivateKey)
|
||||
{
|
||||
return CryptoConvert.ToCapiPrivateKeyBlob(dsa);
|
||||
}
|
||||
return CryptoConvert.ToCapiPublicKeyBlob(dsa);
|
||||
}
|
||||
|
||||
// Token: 0x060008E4 RID: 2276 RVA: 0x00022EF4 File Offset: 0x000210F4
|
||||
public static string ToHex(byte[] input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
StringBuilder stringBuilder = new StringBuilder(input.Length * 2);
|
||||
foreach (byte b in input)
|
||||
{
|
||||
stringBuilder.Append(b.ToString("X2", CultureInfo.InvariantCulture));
|
||||
}
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
// Token: 0x060008E5 RID: 2277 RVA: 0x00022F4C File Offset: 0x0002114C
|
||||
private static byte FromHexChar(char c)
|
||||
{
|
||||
if (c >= 'a' && c <= 'f')
|
||||
{
|
||||
return (byte)(c - 'a' + '\n');
|
||||
}
|
||||
if (c >= 'A' && c <= 'F')
|
||||
{
|
||||
return (byte)(c - 'A' + '\n');
|
||||
}
|
||||
if (c >= '0' && c <= '9')
|
||||
{
|
||||
return (byte)(c - '0');
|
||||
}
|
||||
throw new ArgumentException("invalid hex char");
|
||||
}
|
||||
|
||||
// Token: 0x060008E6 RID: 2278 RVA: 0x00022FAC File Offset: 0x000211AC
|
||||
public static byte[] FromHex(string hex)
|
||||
{
|
||||
if (hex == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if ((hex.Length & 1) == 1)
|
||||
{
|
||||
throw new ArgumentException("Length must be a multiple of 2");
|
||||
}
|
||||
byte[] array = new byte[hex.Length >> 1];
|
||||
int i = 0;
|
||||
int num = 0;
|
||||
while (i < array.Length)
|
||||
{
|
||||
array[i] = (byte)(CryptoConvert.FromHexChar(hex[num++]) << 4);
|
||||
byte[] array2 = array;
|
||||
int num2 = i++;
|
||||
array2[num2] += CryptoConvert.FromHexChar(hex[num++]);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,509 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using Mono.Math;
|
||||
|
||||
namespace Mono.Security.Cryptography
|
||||
{
|
||||
// Token: 0x020000A4 RID: 164
|
||||
internal class DSAManaged : DSA
|
||||
{
|
||||
// Token: 0x060008F2 RID: 2290 RVA: 0x0002324C File Offset: 0x0002144C
|
||||
public DSAManaged()
|
||||
: this(1024)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060008F3 RID: 2291 RVA: 0x0002325C File Offset: 0x0002145C
|
||||
public DSAManaged(int dwKeySize)
|
||||
{
|
||||
this.KeySizeValue = dwKeySize;
|
||||
this.LegalKeySizesValue = new KeySizes[1];
|
||||
this.LegalKeySizesValue[0] = new KeySizes(512, 1024, 64);
|
||||
}
|
||||
|
||||
// Token: 0x14000001 RID: 1
|
||||
// (add) Token: 0x060008F4 RID: 2292 RVA: 0x0002329C File Offset: 0x0002149C
|
||||
// (remove) Token: 0x060008F5 RID: 2293 RVA: 0x000232B8 File Offset: 0x000214B8
|
||||
public event DSAManaged.KeyGeneratedEventHandler KeyGenerated;
|
||||
|
||||
// Token: 0x060008F6 RID: 2294 RVA: 0x000232D4 File Offset: 0x000214D4
|
||||
~DSAManaged()
|
||||
{
|
||||
this.Dispose(false);
|
||||
}
|
||||
|
||||
// Token: 0x060008F7 RID: 2295 RVA: 0x00023310 File Offset: 0x00021510
|
||||
private void Generate()
|
||||
{
|
||||
this.GenerateParams(base.KeySize);
|
||||
this.GenerateKeyPair();
|
||||
this.keypairGenerated = true;
|
||||
if (this.KeyGenerated != null)
|
||||
{
|
||||
this.KeyGenerated(this, null);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060008F8 RID: 2296 RVA: 0x00023350 File Offset: 0x00021550
|
||||
private void GenerateKeyPair()
|
||||
{
|
||||
this.x = BigInteger.GenerateRandom(160);
|
||||
while (this.x == 0U || this.x >= this.q)
|
||||
{
|
||||
this.x.Randomize();
|
||||
}
|
||||
this.y = this.g.ModPow(this.x, this.p);
|
||||
}
|
||||
|
||||
// Token: 0x060008F9 RID: 2297 RVA: 0x000233C4 File Offset: 0x000215C4
|
||||
private void add(byte[] a, byte[] b, int value)
|
||||
{
|
||||
uint num = (uint)((int)(b[b.Length - 1] & byte.MaxValue) + value);
|
||||
a[b.Length - 1] = (byte)num;
|
||||
num >>= 8;
|
||||
for (int i = b.Length - 2; i >= 0; i--)
|
||||
{
|
||||
num += (uint)(b[i] & byte.MaxValue);
|
||||
a[i] = (byte)num;
|
||||
num >>= 8;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060008FA RID: 2298 RVA: 0x0002341C File Offset: 0x0002161C
|
||||
private void GenerateParams(int keyLength)
|
||||
{
|
||||
byte[] array = new byte[20];
|
||||
byte[] array2 = new byte[20];
|
||||
byte[] array3 = new byte[20];
|
||||
byte[] array4 = new byte[20];
|
||||
SHA1 sha = SHA1.Create();
|
||||
int num = (keyLength - 1) / 160;
|
||||
byte[] array5 = new byte[keyLength / 8];
|
||||
bool flag = false;
|
||||
while (!flag)
|
||||
{
|
||||
do
|
||||
{
|
||||
this.Random.GetBytes(array);
|
||||
array2 = sha.ComputeHash(array);
|
||||
Array.Copy(array, 0, array3, 0, array.Length);
|
||||
this.add(array3, array, 1);
|
||||
array3 = sha.ComputeHash(array3);
|
||||
for (int num2 = 0; num2 != array4.Length; num2++)
|
||||
{
|
||||
array4[num2] = array2[num2] ^ array3[num2];
|
||||
}
|
||||
byte[] array6 = array4;
|
||||
int num3 = 0;
|
||||
array6[num3] |= 128;
|
||||
byte[] array7 = array4;
|
||||
int num4 = 19;
|
||||
array7[num4] |= 1;
|
||||
this.q = new BigInteger(array4);
|
||||
}
|
||||
while (!this.q.IsProbablePrime());
|
||||
this.counter = 0;
|
||||
int num5 = 2;
|
||||
while (this.counter < 4096)
|
||||
{
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
this.add(array2, array, num5 + i);
|
||||
array2 = sha.ComputeHash(array2);
|
||||
Array.Copy(array2, 0, array5, array5.Length - (i + 1) * array2.Length, array2.Length);
|
||||
}
|
||||
this.add(array2, array, num5 + num);
|
||||
array2 = sha.ComputeHash(array2);
|
||||
Array.Copy(array2, array2.Length - (array5.Length - num * array2.Length), array5, 0, array5.Length - num * array2.Length);
|
||||
byte[] array8 = array5;
|
||||
int num6 = 0;
|
||||
array8[num6] |= 128;
|
||||
BigInteger bigInteger = new BigInteger(array5);
|
||||
BigInteger bigInteger2 = bigInteger % (this.q * 2);
|
||||
this.p = bigInteger - (bigInteger2 - 1);
|
||||
if (this.p.TestBit((uint)(keyLength - 1)) && this.p.IsProbablePrime())
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
this.counter++;
|
||||
num5 += num + 1;
|
||||
}
|
||||
}
|
||||
BigInteger bigInteger3 = (this.p - 1) / this.q;
|
||||
for (;;)
|
||||
{
|
||||
BigInteger bigInteger4 = BigInteger.GenerateRandom(keyLength);
|
||||
if (!(bigInteger4 <= 1) && !(bigInteger4 >= this.p - 1))
|
||||
{
|
||||
this.g = bigInteger4.ModPow(bigInteger3, this.p);
|
||||
if (!(this.g <= 1))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.seed = new BigInteger(array);
|
||||
this.j = (this.p - 1) / this.q;
|
||||
}
|
||||
|
||||
// Token: 0x170000F2 RID: 242
|
||||
// (get) Token: 0x060008FB RID: 2299 RVA: 0x000236FC File Offset: 0x000218FC
|
||||
private RandomNumberGenerator Random
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.rng == null)
|
||||
{
|
||||
this.rng = RandomNumberGenerator.Create();
|
||||
}
|
||||
return this.rng;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000F3 RID: 243
|
||||
// (get) Token: 0x060008FC RID: 2300 RVA: 0x0002371C File Offset: 0x0002191C
|
||||
public override int KeySize
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.keypairGenerated)
|
||||
{
|
||||
return this.p.BitCount();
|
||||
}
|
||||
return base.KeySize;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000F4 RID: 244
|
||||
// (get) Token: 0x060008FD RID: 2301 RVA: 0x0002373C File Offset: 0x0002193C
|
||||
public override string KeyExchangeAlgorithm
|
||||
{
|
||||
get
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000F5 RID: 245
|
||||
// (get) Token: 0x060008FE RID: 2302 RVA: 0x00023740 File Offset: 0x00021940
|
||||
public bool PublicOnly
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.keypairGenerated && this.x == null;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000F6 RID: 246
|
||||
// (get) Token: 0x060008FF RID: 2303 RVA: 0x0002375C File Offset: 0x0002195C
|
||||
public override string SignatureAlgorithm
|
||||
{
|
||||
get
|
||||
{
|
||||
return "http://www.w3.org/2000/09/xmldsig#dsa-sha1";
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000900 RID: 2304 RVA: 0x00023764 File Offset: 0x00021964
|
||||
private byte[] NormalizeArray(byte[] array)
|
||||
{
|
||||
int num = array.Length % 4;
|
||||
if (num > 0)
|
||||
{
|
||||
byte[] array2 = new byte[array.Length + 4 - num];
|
||||
Array.Copy(array, 0, array2, 4 - num, array.Length);
|
||||
return array2;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x06000901 RID: 2305 RVA: 0x0002379C File Offset: 0x0002199C
|
||||
public override DSAParameters ExportParameters(bool includePrivateParameters)
|
||||
{
|
||||
if (this.m_disposed)
|
||||
{
|
||||
throw new ObjectDisposedException(Locale.GetText("Keypair was disposed"));
|
||||
}
|
||||
if (!this.keypairGenerated)
|
||||
{
|
||||
this.Generate();
|
||||
}
|
||||
if (includePrivateParameters && this.x == null)
|
||||
{
|
||||
throw new CryptographicException("no private key to export");
|
||||
}
|
||||
DSAParameters dsaparameters = default(DSAParameters);
|
||||
dsaparameters.P = this.NormalizeArray(this.p.GetBytes());
|
||||
dsaparameters.Q = this.NormalizeArray(this.q.GetBytes());
|
||||
dsaparameters.G = this.NormalizeArray(this.g.GetBytes());
|
||||
dsaparameters.Y = this.NormalizeArray(this.y.GetBytes());
|
||||
if (!this.j_missing)
|
||||
{
|
||||
dsaparameters.J = this.NormalizeArray(this.j.GetBytes());
|
||||
}
|
||||
if (this.seed != 0U)
|
||||
{
|
||||
dsaparameters.Seed = this.NormalizeArray(this.seed.GetBytes());
|
||||
dsaparameters.Counter = this.counter;
|
||||
}
|
||||
if (includePrivateParameters)
|
||||
{
|
||||
byte[] bytes = this.x.GetBytes();
|
||||
if (bytes.Length == 20)
|
||||
{
|
||||
dsaparameters.X = this.NormalizeArray(bytes);
|
||||
}
|
||||
}
|
||||
return dsaparameters;
|
||||
}
|
||||
|
||||
// Token: 0x06000902 RID: 2306 RVA: 0x000238E4 File Offset: 0x00021AE4
|
||||
public override void ImportParameters(DSAParameters parameters)
|
||||
{
|
||||
if (this.m_disposed)
|
||||
{
|
||||
throw new ObjectDisposedException(Locale.GetText("Keypair was disposed"));
|
||||
}
|
||||
if (parameters.P == null || parameters.Q == null || parameters.G == null)
|
||||
{
|
||||
throw new CryptographicException(Locale.GetText("Missing mandatory DSA parameters (P, Q or G)."));
|
||||
}
|
||||
if (parameters.X == null && parameters.Y == null)
|
||||
{
|
||||
throw new CryptographicException(Locale.GetText("Missing both public (Y) and private (X) keys."));
|
||||
}
|
||||
this.p = new BigInteger(parameters.P);
|
||||
this.q = new BigInteger(parameters.Q);
|
||||
this.g = new BigInteger(parameters.G);
|
||||
if (parameters.X != null)
|
||||
{
|
||||
this.x = new BigInteger(parameters.X);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.x = null;
|
||||
}
|
||||
if (parameters.Y != null)
|
||||
{
|
||||
this.y = new BigInteger(parameters.Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.y = this.g.ModPow(this.x, this.p);
|
||||
}
|
||||
if (parameters.J != null)
|
||||
{
|
||||
this.j = new BigInteger(parameters.J);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.j = (this.p - 1) / this.q;
|
||||
this.j_missing = true;
|
||||
}
|
||||
if (parameters.Seed != null)
|
||||
{
|
||||
this.seed = new BigInteger(parameters.Seed);
|
||||
this.counter = parameters.Counter;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.seed = 0;
|
||||
}
|
||||
this.keypairGenerated = true;
|
||||
}
|
||||
|
||||
// Token: 0x06000903 RID: 2307 RVA: 0x00023A98 File Offset: 0x00021C98
|
||||
public override byte[] CreateSignature(byte[] rgbHash)
|
||||
{
|
||||
if (this.m_disposed)
|
||||
{
|
||||
throw new ObjectDisposedException(Locale.GetText("Keypair was disposed"));
|
||||
}
|
||||
if (rgbHash == null)
|
||||
{
|
||||
throw new ArgumentNullException("rgbHash");
|
||||
}
|
||||
if (rgbHash.Length != 20)
|
||||
{
|
||||
throw new CryptographicException("invalid hash length");
|
||||
}
|
||||
if (!this.keypairGenerated)
|
||||
{
|
||||
this.Generate();
|
||||
}
|
||||
if (this.x == null)
|
||||
{
|
||||
throw new CryptographicException("no private key available for signature");
|
||||
}
|
||||
BigInteger bigInteger = new BigInteger(rgbHash);
|
||||
BigInteger bigInteger2 = BigInteger.GenerateRandom(160);
|
||||
while (bigInteger2 >= this.q)
|
||||
{
|
||||
bigInteger2.Randomize();
|
||||
}
|
||||
BigInteger bigInteger3 = this.g.ModPow(bigInteger2, this.p) % this.q;
|
||||
BigInteger bigInteger4 = bigInteger2.ModInverse(this.q) * (bigInteger + this.x * bigInteger3) % this.q;
|
||||
byte[] array = new byte[40];
|
||||
byte[] bytes = bigInteger3.GetBytes();
|
||||
byte[] bytes2 = bigInteger4.GetBytes();
|
||||
int num = 20 - bytes.Length;
|
||||
Array.Copy(bytes, 0, array, num, bytes.Length);
|
||||
num = 40 - bytes2.Length;
|
||||
Array.Copy(bytes2, 0, array, num, bytes2.Length);
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x06000904 RID: 2308 RVA: 0x00023BDC File Offset: 0x00021DDC
|
||||
public override bool VerifySignature(byte[] rgbHash, byte[] rgbSignature)
|
||||
{
|
||||
if (this.m_disposed)
|
||||
{
|
||||
throw new ObjectDisposedException(Locale.GetText("Keypair was disposed"));
|
||||
}
|
||||
if (rgbHash == null)
|
||||
{
|
||||
throw new ArgumentNullException("rgbHash");
|
||||
}
|
||||
if (rgbSignature == null)
|
||||
{
|
||||
throw new ArgumentNullException("rgbSignature");
|
||||
}
|
||||
if (rgbHash.Length != 20)
|
||||
{
|
||||
throw new CryptographicException("invalid hash length");
|
||||
}
|
||||
if (rgbSignature.Length != 40)
|
||||
{
|
||||
throw new CryptographicException("invalid signature length");
|
||||
}
|
||||
if (!this.keypairGenerated)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool flag;
|
||||
try
|
||||
{
|
||||
BigInteger bigInteger = new BigInteger(rgbHash);
|
||||
byte[] array = new byte[20];
|
||||
Array.Copy(rgbSignature, 0, array, 0, 20);
|
||||
BigInteger bigInteger2 = new BigInteger(array);
|
||||
Array.Copy(rgbSignature, 20, array, 0, 20);
|
||||
BigInteger bigInteger3 = new BigInteger(array);
|
||||
if (bigInteger2 < 0 || this.q <= bigInteger2)
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
else if (bigInteger3 < 0 || this.q <= bigInteger3)
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
BigInteger bigInteger4 = bigInteger3.ModInverse(this.q);
|
||||
BigInteger bigInteger5 = bigInteger * bigInteger4 % this.q;
|
||||
BigInteger bigInteger6 = bigInteger2 * bigInteger4 % this.q;
|
||||
bigInteger5 = this.g.ModPow(bigInteger5, this.p);
|
||||
bigInteger6 = this.y.ModPow(bigInteger6, this.p);
|
||||
BigInteger bigInteger7 = bigInteger5 * bigInteger6 % this.p % this.q;
|
||||
flag = bigInteger7 == bigInteger2;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw new CryptographicException("couldn't compute signature verification");
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x06000905 RID: 2309 RVA: 0x00023DAC File Offset: 0x00021FAC
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (!this.m_disposed)
|
||||
{
|
||||
if (this.x != null)
|
||||
{
|
||||
this.x.Clear();
|
||||
this.x = null;
|
||||
}
|
||||
if (disposing)
|
||||
{
|
||||
if (this.p != null)
|
||||
{
|
||||
this.p.Clear();
|
||||
this.p = null;
|
||||
}
|
||||
if (this.q != null)
|
||||
{
|
||||
this.q.Clear();
|
||||
this.q = null;
|
||||
}
|
||||
if (this.g != null)
|
||||
{
|
||||
this.g.Clear();
|
||||
this.g = null;
|
||||
}
|
||||
if (this.j != null)
|
||||
{
|
||||
this.j.Clear();
|
||||
this.j = null;
|
||||
}
|
||||
if (this.seed != null)
|
||||
{
|
||||
this.seed.Clear();
|
||||
this.seed = null;
|
||||
}
|
||||
if (this.y != null)
|
||||
{
|
||||
this.y.Clear();
|
||||
this.y = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.m_disposed = true;
|
||||
}
|
||||
|
||||
// Token: 0x040001DF RID: 479
|
||||
private const int defaultKeySize = 1024;
|
||||
|
||||
// Token: 0x040001E0 RID: 480
|
||||
private bool keypairGenerated;
|
||||
|
||||
// Token: 0x040001E1 RID: 481
|
||||
private bool m_disposed;
|
||||
|
||||
// Token: 0x040001E2 RID: 482
|
||||
private BigInteger p;
|
||||
|
||||
// Token: 0x040001E3 RID: 483
|
||||
private BigInteger q;
|
||||
|
||||
// Token: 0x040001E4 RID: 484
|
||||
private BigInteger g;
|
||||
|
||||
// Token: 0x040001E5 RID: 485
|
||||
private BigInteger x;
|
||||
|
||||
// Token: 0x040001E6 RID: 486
|
||||
private BigInteger y;
|
||||
|
||||
// Token: 0x040001E7 RID: 487
|
||||
private BigInteger j;
|
||||
|
||||
// Token: 0x040001E8 RID: 488
|
||||
private BigInteger seed;
|
||||
|
||||
// Token: 0x040001E9 RID: 489
|
||||
private int counter;
|
||||
|
||||
// Token: 0x040001EA RID: 490
|
||||
private bool j_missing;
|
||||
|
||||
// Token: 0x040001EB RID: 491
|
||||
private RandomNumberGenerator rng;
|
||||
|
||||
// Token: 0x020006C4 RID: 1732
|
||||
// (Invoke) Token: 0x06004198 RID: 16792
|
||||
public delegate void KeyGeneratedEventHandler(object sender, EventArgs e);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Mono.Security.Cryptography
|
||||
{
|
||||
// Token: 0x020000A5 RID: 165
|
||||
internal class HMACAlgorithm
|
||||
{
|
||||
// Token: 0x06000906 RID: 2310 RVA: 0x00023EC8 File Offset: 0x000220C8
|
||||
public HMACAlgorithm(string algoName)
|
||||
{
|
||||
this.CreateHash(algoName);
|
||||
}
|
||||
|
||||
// Token: 0x06000907 RID: 2311 RVA: 0x00023ED8 File Offset: 0x000220D8
|
||||
~HMACAlgorithm()
|
||||
{
|
||||
this.Dispose();
|
||||
}
|
||||
|
||||
// Token: 0x06000908 RID: 2312 RVA: 0x00023F14 File Offset: 0x00022114
|
||||
private void CreateHash(string algoName)
|
||||
{
|
||||
this.algo = HashAlgorithm.Create(algoName);
|
||||
this.hashName = algoName;
|
||||
this.block = new BlockProcessor(this.algo, 8);
|
||||
}
|
||||
|
||||
// Token: 0x06000909 RID: 2313 RVA: 0x00023F3C File Offset: 0x0002213C
|
||||
public void Dispose()
|
||||
{
|
||||
if (this.key != null)
|
||||
{
|
||||
Array.Clear(this.key, 0, this.key.Length);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000F7 RID: 247
|
||||
// (get) Token: 0x0600090A RID: 2314 RVA: 0x00023F60 File Offset: 0x00022160
|
||||
public HashAlgorithm Algo
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.algo;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000F8 RID: 248
|
||||
// (get) Token: 0x0600090B RID: 2315 RVA: 0x00023F68 File Offset: 0x00022168
|
||||
// (set) Token: 0x0600090C RID: 2316 RVA: 0x00023F70 File Offset: 0x00022170
|
||||
public string HashName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.hashName;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.CreateHash(value);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000F9 RID: 249
|
||||
// (get) Token: 0x0600090D RID: 2317 RVA: 0x00023F7C File Offset: 0x0002217C
|
||||
// (set) Token: 0x0600090E RID: 2318 RVA: 0x00023F84 File Offset: 0x00022184
|
||||
public byte[] Key
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.key;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null && value.Length > 64)
|
||||
{
|
||||
this.key = this.algo.ComputeHash(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.key = (byte[])value.Clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600090F RID: 2319 RVA: 0x00023FCC File Offset: 0x000221CC
|
||||
public void Initialize()
|
||||
{
|
||||
this.hash = null;
|
||||
this.block.Initialize();
|
||||
byte[] array = this.KeySetup(this.key, 54);
|
||||
this.algo.Initialize();
|
||||
this.block.Core(array);
|
||||
Array.Clear(array, 0, array.Length);
|
||||
}
|
||||
|
||||
// Token: 0x06000910 RID: 2320 RVA: 0x0002401C File Offset: 0x0002221C
|
||||
private byte[] KeySetup(byte[] key, byte padding)
|
||||
{
|
||||
byte[] array = new byte[64];
|
||||
for (int i = 0; i < key.Length; i++)
|
||||
{
|
||||
array[i] = key[i] ^ padding;
|
||||
}
|
||||
for (int j = key.Length; j < 64; j++)
|
||||
{
|
||||
array[j] = padding;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x06000911 RID: 2321 RVA: 0x00024068 File Offset: 0x00022268
|
||||
public void Core(byte[] rgb, int ib, int cb)
|
||||
{
|
||||
this.block.Core(rgb, ib, cb);
|
||||
}
|
||||
|
||||
// Token: 0x06000912 RID: 2322 RVA: 0x00024078 File Offset: 0x00022278
|
||||
public byte[] Final()
|
||||
{
|
||||
this.block.Final();
|
||||
byte[] array = this.algo.Hash;
|
||||
byte[] array2 = this.KeySetup(this.key, 92);
|
||||
this.algo.Initialize();
|
||||
this.algo.TransformBlock(array2, 0, array2.Length, array2, 0);
|
||||
this.algo.TransformFinalBlock(array, 0, array.Length);
|
||||
this.hash = this.algo.Hash;
|
||||
this.algo.Clear();
|
||||
Array.Clear(array2, 0, array2.Length);
|
||||
Array.Clear(array, 0, array.Length);
|
||||
return this.hash;
|
||||
}
|
||||
|
||||
// Token: 0x040001ED RID: 493
|
||||
private byte[] key;
|
||||
|
||||
// Token: 0x040001EE RID: 494
|
||||
private byte[] hash;
|
||||
|
||||
// Token: 0x040001EF RID: 495
|
||||
private HashAlgorithm algo;
|
||||
|
||||
// Token: 0x040001F0 RID: 496
|
||||
private string hashName;
|
||||
|
||||
// Token: 0x040001F1 RID: 497
|
||||
private BlockProcessor block;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Mono.Security.Cryptography
|
||||
{
|
||||
// Token: 0x020000A2 RID: 162
|
||||
internal sealed class KeyBuilder
|
||||
{
|
||||
// Token: 0x060008E7 RID: 2279 RVA: 0x00023034 File Offset: 0x00021234
|
||||
private KeyBuilder()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x170000F1 RID: 241
|
||||
// (get) Token: 0x060008E8 RID: 2280 RVA: 0x0002303C File Offset: 0x0002123C
|
||||
private static RandomNumberGenerator Rng
|
||||
{
|
||||
get
|
||||
{
|
||||
if (KeyBuilder.rng == null)
|
||||
{
|
||||
KeyBuilder.rng = RandomNumberGenerator.Create();
|
||||
}
|
||||
return KeyBuilder.rng;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060008E9 RID: 2281 RVA: 0x00023058 File Offset: 0x00021258
|
||||
public static byte[] Key(int size)
|
||||
{
|
||||
byte[] array = new byte[size];
|
||||
KeyBuilder.Rng.GetBytes(array);
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x060008EA RID: 2282 RVA: 0x00023078 File Offset: 0x00021278
|
||||
public static byte[] IV(int size)
|
||||
{
|
||||
byte[] array = new byte[size];
|
||||
KeyBuilder.Rng.GetBytes(array);
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x040001DA RID: 474
|
||||
private static RandomNumberGenerator rng;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,398 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Security;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Mono.Xml;
|
||||
|
||||
namespace Mono.Security.Cryptography
|
||||
{
|
||||
// Token: 0x020000A6 RID: 166
|
||||
internal class KeyPairPersistence
|
||||
{
|
||||
// Token: 0x06000913 RID: 2323 RVA: 0x00024114 File Offset: 0x00022314
|
||||
public KeyPairPersistence(CspParameters parameters)
|
||||
: this(parameters, null)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000914 RID: 2324 RVA: 0x00024120 File Offset: 0x00022320
|
||||
public KeyPairPersistence(CspParameters parameters, string keyPair)
|
||||
{
|
||||
if (parameters == null)
|
||||
{
|
||||
throw new ArgumentNullException("parameters");
|
||||
}
|
||||
this._params = this.Copy(parameters);
|
||||
this._keyvalue = keyPair;
|
||||
}
|
||||
|
||||
// Token: 0x170000FA RID: 250
|
||||
// (get) Token: 0x06000916 RID: 2326 RVA: 0x00024168 File Offset: 0x00022368
|
||||
public string Filename
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._filename == null)
|
||||
{
|
||||
this._filename = string.Format(CultureInfo.InvariantCulture, "[{0}][{1}][{2}].xml", new object[]
|
||||
{
|
||||
this._params.ProviderType,
|
||||
this.ContainerName,
|
||||
this._params.KeyNumber
|
||||
});
|
||||
if (this.UseMachineKeyStore)
|
||||
{
|
||||
this._filename = Path.Combine(KeyPairPersistence.MachinePath, this._filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._filename = Path.Combine(KeyPairPersistence.UserPath, this._filename);
|
||||
}
|
||||
}
|
||||
return this._filename;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000FB RID: 251
|
||||
// (get) Token: 0x06000917 RID: 2327 RVA: 0x0002420C File Offset: 0x0002240C
|
||||
// (set) Token: 0x06000918 RID: 2328 RVA: 0x00024214 File Offset: 0x00022414
|
||||
public string KeyValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._keyvalue;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this.CanChange)
|
||||
{
|
||||
this._keyvalue = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000FC RID: 252
|
||||
// (get) Token: 0x06000919 RID: 2329 RVA: 0x00024228 File Offset: 0x00022428
|
||||
public CspParameters Parameters
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Copy(this._params);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600091A RID: 2330 RVA: 0x00024238 File Offset: 0x00022438
|
||||
public bool Load()
|
||||
{
|
||||
if (Environment.SocketSecurityEnabled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool flag = File.Exists(this.Filename);
|
||||
if (flag)
|
||||
{
|
||||
using (StreamReader streamReader = File.OpenText(this.Filename))
|
||||
{
|
||||
this.FromXml(streamReader.ReadToEnd());
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x0600091B RID: 2331 RVA: 0x000242AC File Offset: 0x000224AC
|
||||
public void Save()
|
||||
{
|
||||
if (Environment.SocketSecurityEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
using (FileStream fileStream = File.Open(this.Filename, FileMode.Create))
|
||||
{
|
||||
StreamWriter streamWriter = new StreamWriter(fileStream, Encoding.UTF8);
|
||||
streamWriter.Write(this.ToXml());
|
||||
streamWriter.Close();
|
||||
}
|
||||
if (this.UseMachineKeyStore)
|
||||
{
|
||||
KeyPairPersistence.ProtectMachine(this.Filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
KeyPairPersistence.ProtectUser(this.Filename);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600091C RID: 2332 RVA: 0x00024348 File Offset: 0x00022548
|
||||
public void Remove()
|
||||
{
|
||||
if (Environment.SocketSecurityEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
File.Delete(this.Filename);
|
||||
}
|
||||
|
||||
// Token: 0x170000FD RID: 253
|
||||
// (get) Token: 0x0600091D RID: 2333 RVA: 0x00024360 File Offset: 0x00022560
|
||||
private static string UserPath
|
||||
{
|
||||
get
|
||||
{
|
||||
object obj = KeyPairPersistence.lockobj;
|
||||
lock (obj)
|
||||
{
|
||||
if (KeyPairPersistence._userPath == null || !KeyPairPersistence._userPathExists)
|
||||
{
|
||||
KeyPairPersistence._userPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), ".mono");
|
||||
KeyPairPersistence._userPath = Path.Combine(KeyPairPersistence._userPath, "keypairs");
|
||||
KeyPairPersistence._userPathExists = Directory.Exists(KeyPairPersistence._userPath);
|
||||
if (!KeyPairPersistence._userPathExists)
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(KeyPairPersistence._userPath);
|
||||
KeyPairPersistence.ProtectUser(KeyPairPersistence._userPath);
|
||||
KeyPairPersistence._userPathExists = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string text = Locale.GetText("Could not create user key store '{0}'.");
|
||||
throw new CryptographicException(string.Format(text, KeyPairPersistence._userPath), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!KeyPairPersistence.IsUserProtected(KeyPairPersistence._userPath))
|
||||
{
|
||||
string text2 = Locale.GetText("Improperly protected user's key pairs in '{0}'.");
|
||||
throw new CryptographicException(string.Format(text2, KeyPairPersistence._userPath));
|
||||
}
|
||||
return KeyPairPersistence._userPath;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000FE RID: 254
|
||||
// (get) Token: 0x0600091E RID: 2334 RVA: 0x00024484 File Offset: 0x00022684
|
||||
private static string MachinePath
|
||||
{
|
||||
get
|
||||
{
|
||||
object obj = KeyPairPersistence.lockobj;
|
||||
lock (obj)
|
||||
{
|
||||
if (KeyPairPersistence._machinePath == null || !KeyPairPersistence._machinePathExists)
|
||||
{
|
||||
KeyPairPersistence._machinePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), ".mono");
|
||||
KeyPairPersistence._machinePath = Path.Combine(KeyPairPersistence._machinePath, "keypairs");
|
||||
KeyPairPersistence._machinePathExists = Directory.Exists(KeyPairPersistence._machinePath);
|
||||
if (!KeyPairPersistence._machinePathExists)
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(KeyPairPersistence._machinePath);
|
||||
KeyPairPersistence.ProtectMachine(KeyPairPersistence._machinePath);
|
||||
KeyPairPersistence._machinePathExists = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string text = Locale.GetText("Could not create machine key store '{0}'.");
|
||||
throw new CryptographicException(string.Format(text, KeyPairPersistence._machinePath), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!KeyPairPersistence.IsMachineProtected(KeyPairPersistence._machinePath))
|
||||
{
|
||||
string text2 = Locale.GetText("Improperly protected machine's key pairs in '{0}'.");
|
||||
throw new CryptographicException(string.Format(text2, KeyPairPersistence._machinePath));
|
||||
}
|
||||
return KeyPairPersistence._machinePath;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600091F RID: 2335
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern bool _CanSecure(string root);
|
||||
|
||||
// Token: 0x06000920 RID: 2336
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern bool _ProtectUser(string path);
|
||||
|
||||
// Token: 0x06000921 RID: 2337
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern bool _ProtectMachine(string path);
|
||||
|
||||
// Token: 0x06000922 RID: 2338
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern bool _IsUserProtected(string path);
|
||||
|
||||
// Token: 0x06000923 RID: 2339
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal static extern bool _IsMachineProtected(string path);
|
||||
|
||||
// Token: 0x06000924 RID: 2340 RVA: 0x000245A8 File Offset: 0x000227A8
|
||||
private static bool CanSecure(string path)
|
||||
{
|
||||
int platform = (int)Environment.OSVersion.Platform;
|
||||
return platform == 4 || platform == 128 || platform == 6 || KeyPairPersistence._CanSecure(Path.GetPathRoot(path));
|
||||
}
|
||||
|
||||
// Token: 0x06000925 RID: 2341 RVA: 0x000245E8 File Offset: 0x000227E8
|
||||
private static bool ProtectUser(string path)
|
||||
{
|
||||
return !KeyPairPersistence.CanSecure(path) || KeyPairPersistence._ProtectUser(path);
|
||||
}
|
||||
|
||||
// Token: 0x06000926 RID: 2342 RVA: 0x00024600 File Offset: 0x00022800
|
||||
private static bool ProtectMachine(string path)
|
||||
{
|
||||
return !KeyPairPersistence.CanSecure(path) || KeyPairPersistence._ProtectMachine(path);
|
||||
}
|
||||
|
||||
// Token: 0x06000927 RID: 2343 RVA: 0x00024618 File Offset: 0x00022818
|
||||
private static bool IsUserProtected(string path)
|
||||
{
|
||||
return !KeyPairPersistence.CanSecure(path) || KeyPairPersistence._IsUserProtected(path);
|
||||
}
|
||||
|
||||
// Token: 0x06000928 RID: 2344 RVA: 0x00024630 File Offset: 0x00022830
|
||||
private static bool IsMachineProtected(string path)
|
||||
{
|
||||
return !KeyPairPersistence.CanSecure(path) || KeyPairPersistence._IsMachineProtected(path);
|
||||
}
|
||||
|
||||
// Token: 0x170000FF RID: 255
|
||||
// (get) Token: 0x06000929 RID: 2345 RVA: 0x00024648 File Offset: 0x00022848
|
||||
private bool CanChange
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._keyvalue == null;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000100 RID: 256
|
||||
// (get) Token: 0x0600092A RID: 2346 RVA: 0x00024654 File Offset: 0x00022854
|
||||
private bool UseDefaultKeyContainer
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this._params.Flags & CspProviderFlags.UseDefaultKeyContainer) == CspProviderFlags.UseDefaultKeyContainer;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000101 RID: 257
|
||||
// (get) Token: 0x0600092B RID: 2347 RVA: 0x00024668 File Offset: 0x00022868
|
||||
private bool UseMachineKeyStore
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this._params.Flags & CspProviderFlags.UseMachineKeyStore) == CspProviderFlags.UseMachineKeyStore;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000102 RID: 258
|
||||
// (get) Token: 0x0600092C RID: 2348 RVA: 0x0002467C File Offset: 0x0002287C
|
||||
private string ContainerName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._container == null)
|
||||
{
|
||||
if (this.UseDefaultKeyContainer)
|
||||
{
|
||||
this._container = "default";
|
||||
}
|
||||
else if (this._params.KeyContainerName == null || this._params.KeyContainerName.Length == 0)
|
||||
{
|
||||
this._container = Guid.NewGuid().ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(this._params.KeyContainerName);
|
||||
MD5 md = MD5.Create();
|
||||
byte[] array = md.ComputeHash(bytes);
|
||||
Guid guid = new Guid(array);
|
||||
this._container = guid.ToString();
|
||||
}
|
||||
}
|
||||
return this._container;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600092D RID: 2349 RVA: 0x0002472C File Offset: 0x0002292C
|
||||
private CspParameters Copy(CspParameters p)
|
||||
{
|
||||
return new CspParameters(p.ProviderType, p.ProviderName, p.KeyContainerName)
|
||||
{
|
||||
KeyNumber = p.KeyNumber,
|
||||
Flags = p.Flags
|
||||
};
|
||||
}
|
||||
|
||||
// Token: 0x0600092E RID: 2350 RVA: 0x0002476C File Offset: 0x0002296C
|
||||
private void FromXml(string xml)
|
||||
{
|
||||
SecurityParser securityParser = new SecurityParser();
|
||||
securityParser.LoadXml(xml);
|
||||
SecurityElement securityElement = securityParser.ToXml();
|
||||
if (securityElement.Tag == "KeyPair")
|
||||
{
|
||||
SecurityElement securityElement2 = securityElement.SearchForChildByTag("KeyValue");
|
||||
if (securityElement2.Children.Count > 0)
|
||||
{
|
||||
this._keyvalue = securityElement2.Children[0].ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600092F RID: 2351 RVA: 0x000247D8 File Offset: 0x000229D8
|
||||
private string ToXml()
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.AppendFormat("<KeyPair>{0}\t<Properties>{0}\t\t<Provider ", Environment.NewLine);
|
||||
if (this._params.ProviderName != null && this._params.ProviderName.Length != 0)
|
||||
{
|
||||
stringBuilder.AppendFormat("Name=\"{0}\" ", this._params.ProviderName);
|
||||
}
|
||||
stringBuilder.AppendFormat("Type=\"{0}\" />{1}\t\t<Container ", this._params.ProviderType, Environment.NewLine);
|
||||
stringBuilder.AppendFormat("Name=\"{0}\" />{1}\t</Properties>{1}\t<KeyValue", this.ContainerName, Environment.NewLine);
|
||||
if (this._params.KeyNumber != -1)
|
||||
{
|
||||
stringBuilder.AppendFormat(" Id=\"{0}\" ", this._params.KeyNumber);
|
||||
}
|
||||
stringBuilder.AppendFormat(">{1}\t\t{0}{1}\t</KeyValue>{1}</KeyPair>{1}", this.KeyValue, Environment.NewLine);
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
// Token: 0x040001F2 RID: 498
|
||||
private static bool _userPathExists = false;
|
||||
|
||||
// Token: 0x040001F3 RID: 499
|
||||
private static string _userPath;
|
||||
|
||||
// Token: 0x040001F4 RID: 500
|
||||
private static bool _machinePathExists = false;
|
||||
|
||||
// Token: 0x040001F5 RID: 501
|
||||
private static string _machinePath;
|
||||
|
||||
// Token: 0x040001F6 RID: 502
|
||||
private CspParameters _params;
|
||||
|
||||
// Token: 0x040001F7 RID: 503
|
||||
private string _keyvalue;
|
||||
|
||||
// Token: 0x040001F8 RID: 504
|
||||
private string _filename;
|
||||
|
||||
// Token: 0x040001F9 RID: 505
|
||||
private string _container;
|
||||
|
||||
// Token: 0x040001FA RID: 506
|
||||
private static object lockobj = new object();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Mono.Security.Cryptography
|
||||
{
|
||||
// Token: 0x020000A7 RID: 167
|
||||
internal class MACAlgorithm
|
||||
{
|
||||
// Token: 0x06000930 RID: 2352 RVA: 0x000248BC File Offset: 0x00022ABC
|
||||
public MACAlgorithm(SymmetricAlgorithm algorithm)
|
||||
{
|
||||
this.algo = algorithm;
|
||||
this.algo.Mode = CipherMode.CBC;
|
||||
this.blockSize = this.algo.BlockSize >> 3;
|
||||
this.algo.IV = new byte[this.blockSize];
|
||||
this.block = new byte[this.blockSize];
|
||||
}
|
||||
|
||||
// Token: 0x06000931 RID: 2353 RVA: 0x0002491C File Offset: 0x00022B1C
|
||||
public void Initialize(byte[] key)
|
||||
{
|
||||
this.algo.Key = key;
|
||||
if (this.enc == null)
|
||||
{
|
||||
this.enc = this.algo.CreateEncryptor();
|
||||
}
|
||||
Array.Clear(this.block, 0, this.blockSize);
|
||||
this.blockCount = 0;
|
||||
}
|
||||
|
||||
// Token: 0x06000932 RID: 2354 RVA: 0x0002496C File Offset: 0x00022B6C
|
||||
public void Core(byte[] rgb, int ib, int cb)
|
||||
{
|
||||
int num = Math.Min(this.blockSize - this.blockCount, cb);
|
||||
Array.Copy(rgb, ib, this.block, this.blockCount, num);
|
||||
this.blockCount += num;
|
||||
if (this.blockCount == this.blockSize)
|
||||
{
|
||||
this.enc.TransformBlock(this.block, 0, this.blockSize, this.block, 0);
|
||||
int num2 = (cb - num) / this.blockSize;
|
||||
for (int i = 0; i < num2; i++)
|
||||
{
|
||||
this.enc.TransformBlock(rgb, num, this.blockSize, this.block, 0);
|
||||
num += this.blockSize;
|
||||
}
|
||||
this.blockCount = cb - num;
|
||||
if (this.blockCount > 0)
|
||||
{
|
||||
Array.Copy(rgb, num, this.block, 0, this.blockCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000933 RID: 2355 RVA: 0x00024A4C File Offset: 0x00022C4C
|
||||
public byte[] Final()
|
||||
{
|
||||
byte[] array;
|
||||
if (this.blockCount > 0 || (this.algo.Padding != PaddingMode.Zeros && this.algo.Padding != PaddingMode.None))
|
||||
{
|
||||
array = this.enc.TransformFinalBlock(this.block, 0, this.blockCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
array = (byte[])this.block.Clone();
|
||||
}
|
||||
if (!this.enc.CanReuseTransform)
|
||||
{
|
||||
this.enc.Dispose();
|
||||
this.enc = null;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x040001FB RID: 507
|
||||
private SymmetricAlgorithm algo;
|
||||
|
||||
// Token: 0x040001FC RID: 508
|
||||
private ICryptoTransform enc;
|
||||
|
||||
// Token: 0x040001FD RID: 509
|
||||
private byte[] block;
|
||||
|
||||
// Token: 0x040001FE RID: 510
|
||||
private int blockSize;
|
||||
|
||||
// Token: 0x040001FF RID: 511
|
||||
private int blockCount;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,394 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Mono.Security.Cryptography
|
||||
{
|
||||
// Token: 0x020000A8 RID: 168
|
||||
internal sealed class PKCS1
|
||||
{
|
||||
// Token: 0x06000934 RID: 2356 RVA: 0x00024ADC File Offset: 0x00022CDC
|
||||
private PKCS1()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000936 RID: 2358 RVA: 0x00024B50 File Offset: 0x00022D50
|
||||
private static bool Compare(byte[] array1, byte[] array2)
|
||||
{
|
||||
bool flag = array1.Length == array2.Length;
|
||||
if (flag)
|
||||
{
|
||||
for (int i = 0; i < array1.Length; i++)
|
||||
{
|
||||
if (array1[i] != array2[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x06000937 RID: 2359 RVA: 0x00024B90 File Offset: 0x00022D90
|
||||
private static byte[] xor(byte[] array1, byte[] array2)
|
||||
{
|
||||
byte[] array3 = new byte[array1.Length];
|
||||
for (int i = 0; i < array3.Length; i++)
|
||||
{
|
||||
array3[i] = array1[i] ^ array2[i];
|
||||
}
|
||||
return array3;
|
||||
}
|
||||
|
||||
// Token: 0x06000938 RID: 2360 RVA: 0x00024BC8 File Offset: 0x00022DC8
|
||||
private static byte[] GetEmptyHash(HashAlgorithm hash)
|
||||
{
|
||||
if (hash is SHA1)
|
||||
{
|
||||
return PKCS1.emptySHA1;
|
||||
}
|
||||
if (hash is SHA256)
|
||||
{
|
||||
return PKCS1.emptySHA256;
|
||||
}
|
||||
if (hash is SHA384)
|
||||
{
|
||||
return PKCS1.emptySHA384;
|
||||
}
|
||||
if (hash is SHA512)
|
||||
{
|
||||
return PKCS1.emptySHA512;
|
||||
}
|
||||
return hash.ComputeHash(null);
|
||||
}
|
||||
|
||||
// Token: 0x06000939 RID: 2361 RVA: 0x00024C20 File Offset: 0x00022E20
|
||||
public static byte[] I2OSP(int x, int size)
|
||||
{
|
||||
byte[] bytes = BitConverterLE.GetBytes(x);
|
||||
Array.Reverse(bytes, 0, bytes.Length);
|
||||
return PKCS1.I2OSP(bytes, size);
|
||||
}
|
||||
|
||||
// Token: 0x0600093A RID: 2362 RVA: 0x00024C48 File Offset: 0x00022E48
|
||||
public static byte[] I2OSP(byte[] x, int size)
|
||||
{
|
||||
byte[] array = new byte[size];
|
||||
Buffer.BlockCopy(x, 0, array, array.Length - x.Length, x.Length);
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x0600093B RID: 2363 RVA: 0x00024C70 File Offset: 0x00022E70
|
||||
public static byte[] OS2IP(byte[] x)
|
||||
{
|
||||
int num = 0;
|
||||
while (x[num++] == 0 && num < x.Length)
|
||||
{
|
||||
}
|
||||
num--;
|
||||
if (num > 0)
|
||||
{
|
||||
byte[] array = new byte[x.Length - num];
|
||||
Buffer.BlockCopy(x, num, array, 0, array.Length);
|
||||
return array;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
// Token: 0x0600093C RID: 2364 RVA: 0x00024CC0 File Offset: 0x00022EC0
|
||||
public static byte[] RSAEP(RSA rsa, byte[] m)
|
||||
{
|
||||
return rsa.EncryptValue(m);
|
||||
}
|
||||
|
||||
// Token: 0x0600093D RID: 2365 RVA: 0x00024CCC File Offset: 0x00022ECC
|
||||
public static byte[] RSADP(RSA rsa, byte[] c)
|
||||
{
|
||||
return rsa.DecryptValue(c);
|
||||
}
|
||||
|
||||
// Token: 0x0600093E RID: 2366 RVA: 0x00024CD8 File Offset: 0x00022ED8
|
||||
public static byte[] RSASP1(RSA rsa, byte[] m)
|
||||
{
|
||||
return rsa.DecryptValue(m);
|
||||
}
|
||||
|
||||
// Token: 0x0600093F RID: 2367 RVA: 0x00024CE4 File Offset: 0x00022EE4
|
||||
public static byte[] RSAVP1(RSA rsa, byte[] s)
|
||||
{
|
||||
return rsa.EncryptValue(s);
|
||||
}
|
||||
|
||||
// Token: 0x06000940 RID: 2368 RVA: 0x00024CF0 File Offset: 0x00022EF0
|
||||
public static byte[] Encrypt_OAEP(RSA rsa, HashAlgorithm hash, RandomNumberGenerator rng, byte[] M)
|
||||
{
|
||||
int num = rsa.KeySize / 8;
|
||||
int num2 = hash.HashSize / 8;
|
||||
if (M.Length > num - 2 * num2 - 2)
|
||||
{
|
||||
throw new CryptographicException("message too long");
|
||||
}
|
||||
byte[] emptyHash = PKCS1.GetEmptyHash(hash);
|
||||
int num3 = num - M.Length - 2 * num2 - 2;
|
||||
byte[] array = new byte[emptyHash.Length + num3 + 1 + M.Length];
|
||||
Buffer.BlockCopy(emptyHash, 0, array, 0, emptyHash.Length);
|
||||
array[emptyHash.Length + num3] = 1;
|
||||
Buffer.BlockCopy(M, 0, array, array.Length - M.Length, M.Length);
|
||||
byte[] array2 = new byte[num2];
|
||||
rng.GetBytes(array2);
|
||||
byte[] array3 = PKCS1.MGF1(hash, array2, num - num2 - 1);
|
||||
byte[] array4 = PKCS1.xor(array, array3);
|
||||
byte[] array5 = PKCS1.MGF1(hash, array4, num2);
|
||||
byte[] array6 = PKCS1.xor(array2, array5);
|
||||
byte[] array7 = new byte[array6.Length + array4.Length + 1];
|
||||
Buffer.BlockCopy(array6, 0, array7, 1, array6.Length);
|
||||
Buffer.BlockCopy(array4, 0, array7, array6.Length + 1, array4.Length);
|
||||
byte[] array8 = PKCS1.OS2IP(array7);
|
||||
byte[] array9 = PKCS1.RSAEP(rsa, array8);
|
||||
return PKCS1.I2OSP(array9, num);
|
||||
}
|
||||
|
||||
// Token: 0x06000941 RID: 2369 RVA: 0x00024E08 File Offset: 0x00023008
|
||||
public static byte[] Decrypt_OAEP(RSA rsa, HashAlgorithm hash, byte[] C)
|
||||
{
|
||||
int num = rsa.KeySize / 8;
|
||||
int num2 = hash.HashSize / 8;
|
||||
if (num < 2 * num2 + 2 || C.Length != num)
|
||||
{
|
||||
throw new CryptographicException("decryption error");
|
||||
}
|
||||
byte[] array = PKCS1.OS2IP(C);
|
||||
byte[] array2 = PKCS1.RSADP(rsa, array);
|
||||
byte[] array3 = PKCS1.I2OSP(array2, num);
|
||||
byte[] array4 = new byte[num2];
|
||||
Buffer.BlockCopy(array3, 1, array4, 0, array4.Length);
|
||||
byte[] array5 = new byte[num - num2 - 1];
|
||||
Buffer.BlockCopy(array3, array3.Length - array5.Length, array5, 0, array5.Length);
|
||||
byte[] array6 = PKCS1.MGF1(hash, array5, num2);
|
||||
byte[] array7 = PKCS1.xor(array4, array6);
|
||||
byte[] array8 = PKCS1.MGF1(hash, array7, num - num2 - 1);
|
||||
byte[] array9 = PKCS1.xor(array5, array8);
|
||||
byte[] emptyHash = PKCS1.GetEmptyHash(hash);
|
||||
byte[] array10 = new byte[emptyHash.Length];
|
||||
Buffer.BlockCopy(array9, 0, array10, 0, array10.Length);
|
||||
bool flag = PKCS1.Compare(emptyHash, array10);
|
||||
int num3 = emptyHash.Length;
|
||||
while (array9[num3] == 0)
|
||||
{
|
||||
num3++;
|
||||
}
|
||||
int num4 = array9.Length - num3 - 1;
|
||||
byte[] array11 = new byte[num4];
|
||||
Buffer.BlockCopy(array9, num3 + 1, array11, 0, num4);
|
||||
if (array3[0] != 0 || !flag || array9[num3] != 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return array11;
|
||||
}
|
||||
|
||||
// Token: 0x06000942 RID: 2370 RVA: 0x00024F54 File Offset: 0x00023154
|
||||
public static byte[] Encrypt_v15(RSA rsa, RandomNumberGenerator rng, byte[] M)
|
||||
{
|
||||
int num = rsa.KeySize / 8;
|
||||
if (M.Length > num - 11)
|
||||
{
|
||||
throw new CryptographicException("message too long");
|
||||
}
|
||||
int num2 = Math.Max(8, num - M.Length - 3);
|
||||
byte[] array = new byte[num2];
|
||||
rng.GetNonZeroBytes(array);
|
||||
byte[] array2 = new byte[num];
|
||||
array2[1] = 2;
|
||||
Buffer.BlockCopy(array, 0, array2, 2, num2);
|
||||
Buffer.BlockCopy(M, 0, array2, num - M.Length, M.Length);
|
||||
byte[] array3 = PKCS1.OS2IP(array2);
|
||||
byte[] array4 = PKCS1.RSAEP(rsa, array3);
|
||||
return PKCS1.I2OSP(array4, num);
|
||||
}
|
||||
|
||||
// Token: 0x06000943 RID: 2371 RVA: 0x00024FE0 File Offset: 0x000231E0
|
||||
public static byte[] Decrypt_v15(RSA rsa, byte[] C)
|
||||
{
|
||||
int num = rsa.KeySize >> 3;
|
||||
if (num < 11 || C.Length > num)
|
||||
{
|
||||
throw new CryptographicException("decryption error");
|
||||
}
|
||||
byte[] array = PKCS1.OS2IP(C);
|
||||
byte[] array2 = PKCS1.RSADP(rsa, array);
|
||||
byte[] array3 = PKCS1.I2OSP(array2, num);
|
||||
if (array3[0] != 0 || array3[1] != 2)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
int num2 = 10;
|
||||
while (array3[num2] != 0 && num2 < array3.Length)
|
||||
{
|
||||
num2++;
|
||||
}
|
||||
if (array3[num2] != 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
num2++;
|
||||
byte[] array4 = new byte[array3.Length - num2];
|
||||
Buffer.BlockCopy(array3, num2, array4, 0, array4.Length);
|
||||
return array4;
|
||||
}
|
||||
|
||||
// Token: 0x06000944 RID: 2372 RVA: 0x00025090 File Offset: 0x00023290
|
||||
public static byte[] Sign_v15(RSA rsa, HashAlgorithm hash, byte[] hashValue)
|
||||
{
|
||||
int num = rsa.KeySize >> 3;
|
||||
byte[] array = PKCS1.Encode_v15(hash, hashValue, num);
|
||||
byte[] array2 = PKCS1.OS2IP(array);
|
||||
byte[] array3 = PKCS1.RSASP1(rsa, array2);
|
||||
return PKCS1.I2OSP(array3, num);
|
||||
}
|
||||
|
||||
// Token: 0x06000945 RID: 2373 RVA: 0x000250CC File Offset: 0x000232CC
|
||||
public static bool Verify_v15(RSA rsa, HashAlgorithm hash, byte[] hashValue, byte[] signature)
|
||||
{
|
||||
return PKCS1.Verify_v15(rsa, hash, hashValue, signature, false);
|
||||
}
|
||||
|
||||
// Token: 0x06000946 RID: 2374 RVA: 0x000250D8 File Offset: 0x000232D8
|
||||
public static bool Verify_v15(RSA rsa, HashAlgorithm hash, byte[] hashValue, byte[] signature, bool tryNonStandardEncoding)
|
||||
{
|
||||
int num = rsa.KeySize >> 3;
|
||||
byte[] array = PKCS1.OS2IP(signature);
|
||||
byte[] array2 = PKCS1.RSAVP1(rsa, array);
|
||||
byte[] array3 = PKCS1.I2OSP(array2, num);
|
||||
byte[] array4 = PKCS1.Encode_v15(hash, hashValue, num);
|
||||
bool flag = PKCS1.Compare(array4, array3);
|
||||
if (flag || !tryNonStandardEncoding)
|
||||
{
|
||||
return flag;
|
||||
}
|
||||
if (array3[0] != 0 || array3[1] != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int i;
|
||||
for (i = 2; i < array3.Length - hashValue.Length - 1; i++)
|
||||
{
|
||||
if (array3[i] != 255)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (array3[i++] != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
byte[] array5 = new byte[hashValue.Length];
|
||||
Buffer.BlockCopy(array3, i, array5, 0, array5.Length);
|
||||
return PKCS1.Compare(array5, hashValue);
|
||||
}
|
||||
|
||||
// Token: 0x06000947 RID: 2375 RVA: 0x0002519C File Offset: 0x0002339C
|
||||
public static byte[] Encode_v15(HashAlgorithm hash, byte[] hashValue, int emLength)
|
||||
{
|
||||
if (hashValue.Length != hash.HashSize >> 3)
|
||||
{
|
||||
throw new CryptographicException("bad hash length for " + hash.ToString());
|
||||
}
|
||||
string text = CryptoConfig.MapNameToOID(hash.ToString());
|
||||
byte[] array;
|
||||
if (text != null)
|
||||
{
|
||||
ASN1 asn = new ASN1(48);
|
||||
asn.Add(new ASN1(CryptoConfig.EncodeOID(text)));
|
||||
asn.Add(new ASN1(5));
|
||||
ASN1 asn2 = new ASN1(4, hashValue);
|
||||
ASN1 asn3 = new ASN1(48);
|
||||
asn3.Add(asn);
|
||||
asn3.Add(asn2);
|
||||
array = asn3.GetBytes();
|
||||
}
|
||||
else
|
||||
{
|
||||
array = hashValue;
|
||||
}
|
||||
Buffer.BlockCopy(hashValue, 0, array, array.Length - hashValue.Length, hashValue.Length);
|
||||
int num = Math.Max(8, emLength - array.Length - 3);
|
||||
byte[] array2 = new byte[num + array.Length + 3];
|
||||
array2[1] = 1;
|
||||
for (int i = 2; i < num + 2; i++)
|
||||
{
|
||||
array2[i] = byte.MaxValue;
|
||||
}
|
||||
Buffer.BlockCopy(array, 0, array2, num + 3, array.Length);
|
||||
return array2;
|
||||
}
|
||||
|
||||
// Token: 0x06000948 RID: 2376 RVA: 0x000252A8 File Offset: 0x000234A8
|
||||
public static byte[] MGF1(HashAlgorithm hash, byte[] mgfSeed, int maskLen)
|
||||
{
|
||||
if (maskLen < 0)
|
||||
{
|
||||
throw new OverflowException();
|
||||
}
|
||||
int num = mgfSeed.Length;
|
||||
int num2 = hash.HashSize >> 3;
|
||||
int num3 = maskLen / num2;
|
||||
if (maskLen % num2 != 0)
|
||||
{
|
||||
num3++;
|
||||
}
|
||||
byte[] array = new byte[num3 * num2];
|
||||
byte[] array2 = new byte[num + 4];
|
||||
int num4 = 0;
|
||||
for (int i = 0; i < num3; i++)
|
||||
{
|
||||
byte[] array3 = PKCS1.I2OSP(i, 4);
|
||||
Buffer.BlockCopy(mgfSeed, 0, array2, 0, num);
|
||||
Buffer.BlockCopy(array3, 0, array2, num, 4);
|
||||
byte[] array4 = hash.ComputeHash(array2);
|
||||
Buffer.BlockCopy(array4, 0, array, num4, num2);
|
||||
num4 += num;
|
||||
}
|
||||
byte[] array5 = new byte[maskLen];
|
||||
Buffer.BlockCopy(array, 0, array5, 0, maskLen);
|
||||
return array5;
|
||||
}
|
||||
|
||||
// Token: 0x04000200 RID: 512
|
||||
private static byte[] emptySHA1 = new byte[]
|
||||
{
|
||||
218, 57, 163, 238, 94, 107, 75, 13, 50, 85,
|
||||
191, 239, 149, 96, 24, 144, 175, 216, 7, 9
|
||||
};
|
||||
|
||||
// Token: 0x04000201 RID: 513
|
||||
private static byte[] emptySHA256 = new byte[]
|
||||
{
|
||||
227, 176, 196, 66, 152, 252, 28, 20, 154, 251,
|
||||
244, 200, 153, 111, 185, 36, 39, 174, 65, 228,
|
||||
100, 155, 147, 76, 164, 149, 153, 27, 120, 82,
|
||||
184, 85
|
||||
};
|
||||
|
||||
// Token: 0x04000202 RID: 514
|
||||
private static byte[] emptySHA384 = new byte[]
|
||||
{
|
||||
56, 176, 96, 167, 81, 172, 150, 56, 76, 217,
|
||||
50, 126, 177, 177, 227, 106, 33, 253, 183, 17,
|
||||
20, 190, 7, 67, 76, 12, 199, 191, 99, 246,
|
||||
225, 218, 39, 78, 222, 191, 231, 111, 101, 251,
|
||||
213, 26, 210, 241, 72, 152, 185, 91
|
||||
};
|
||||
|
||||
// Token: 0x04000203 RID: 515
|
||||
private static byte[] emptySHA512 = new byte[]
|
||||
{
|
||||
207, 131, 225, 53, 126, 239, 184, 189, 241, 84,
|
||||
40, 80, 214, 109, 128, 7, 214, 32, 228, 5,
|
||||
11, 87, 21, 220, 131, 244, 169, 33, 211, 108,
|
||||
233, 206, 71, 208, 209, 60, 93, 133, 242, 176,
|
||||
byte.MaxValue, 131, 24, 210, 135, 126, 236, 47, 99, 185,
|
||||
49, 189, 71, 65, 122, 129, 165, 56, 50, 122,
|
||||
249, 39, 218, 62
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,515 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Mono.Security.Cryptography
|
||||
{
|
||||
// Token: 0x020000A9 RID: 169
|
||||
internal sealed class PKCS8
|
||||
{
|
||||
// Token: 0x06000949 RID: 2377 RVA: 0x00025360 File Offset: 0x00023560
|
||||
private PKCS8()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600094A RID: 2378 RVA: 0x00025368 File Offset: 0x00023568
|
||||
public static PKCS8.KeyInfo GetType(byte[] data)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
throw new ArgumentNullException("data");
|
||||
}
|
||||
PKCS8.KeyInfo keyInfo = PKCS8.KeyInfo.Unknown;
|
||||
try
|
||||
{
|
||||
ASN1 asn = new ASN1(data);
|
||||
if (asn.Tag == 48 && asn.Count > 0)
|
||||
{
|
||||
ASN1 asn2 = asn[0];
|
||||
byte tag = asn2.Tag;
|
||||
if (tag != 2)
|
||||
{
|
||||
if (tag == 48)
|
||||
{
|
||||
keyInfo = PKCS8.KeyInfo.EncryptedPrivateKey;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
keyInfo = PKCS8.KeyInfo.PrivateKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw new CryptographicException("invalid ASN.1 data");
|
||||
}
|
||||
return keyInfo;
|
||||
}
|
||||
|
||||
// Token: 0x020000AA RID: 170
|
||||
public enum KeyInfo
|
||||
{
|
||||
// Token: 0x04000205 RID: 517
|
||||
PrivateKey,
|
||||
// Token: 0x04000206 RID: 518
|
||||
EncryptedPrivateKey,
|
||||
// Token: 0x04000207 RID: 519
|
||||
Unknown
|
||||
}
|
||||
|
||||
// Token: 0x020000AB RID: 171
|
||||
public class PrivateKeyInfo
|
||||
{
|
||||
// Token: 0x0600094B RID: 2379 RVA: 0x0002540C File Offset: 0x0002360C
|
||||
public PrivateKeyInfo()
|
||||
{
|
||||
this._version = 0;
|
||||
this._list = new ArrayList();
|
||||
}
|
||||
|
||||
// Token: 0x0600094C RID: 2380 RVA: 0x00025428 File Offset: 0x00023628
|
||||
public PrivateKeyInfo(byte[] data)
|
||||
: this()
|
||||
{
|
||||
this.Decode(data);
|
||||
}
|
||||
|
||||
// Token: 0x17000103 RID: 259
|
||||
// (get) Token: 0x0600094D RID: 2381 RVA: 0x00025438 File Offset: 0x00023638
|
||||
// (set) Token: 0x0600094E RID: 2382 RVA: 0x00025440 File Offset: 0x00023640
|
||||
public string Algorithm
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._algorithm;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._algorithm = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000104 RID: 260
|
||||
// (get) Token: 0x0600094F RID: 2383 RVA: 0x0002544C File Offset: 0x0002364C
|
||||
public ArrayList Attributes
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._list;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000105 RID: 261
|
||||
// (get) Token: 0x06000950 RID: 2384 RVA: 0x00025454 File Offset: 0x00023654
|
||||
// (set) Token: 0x06000951 RID: 2385 RVA: 0x00025474 File Offset: 0x00023674
|
||||
public byte[] PrivateKey
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._key == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (byte[])this._key.Clone();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException("PrivateKey");
|
||||
}
|
||||
this._key = (byte[])value.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000106 RID: 262
|
||||
// (get) Token: 0x06000952 RID: 2386 RVA: 0x000254A4 File Offset: 0x000236A4
|
||||
// (set) Token: 0x06000953 RID: 2387 RVA: 0x000254AC File Offset: 0x000236AC
|
||||
public int Version
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._version;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("negative version");
|
||||
}
|
||||
this._version = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000954 RID: 2388 RVA: 0x000254C8 File Offset: 0x000236C8
|
||||
private void Decode(byte[] data)
|
||||
{
|
||||
ASN1 asn = new ASN1(data);
|
||||
if (asn.Tag != 48)
|
||||
{
|
||||
throw new CryptographicException("invalid PrivateKeyInfo");
|
||||
}
|
||||
ASN1 asn2 = asn[0];
|
||||
if (asn2.Tag != 2)
|
||||
{
|
||||
throw new CryptographicException("invalid version");
|
||||
}
|
||||
this._version = (int)asn2.Value[0];
|
||||
ASN1 asn3 = asn[1];
|
||||
if (asn3.Tag != 48)
|
||||
{
|
||||
throw new CryptographicException("invalid algorithm");
|
||||
}
|
||||
ASN1 asn4 = asn3[0];
|
||||
if (asn4.Tag != 6)
|
||||
{
|
||||
throw new CryptographicException("missing algorithm OID");
|
||||
}
|
||||
this._algorithm = ASN1Convert.ToOid(asn4);
|
||||
ASN1 asn5 = asn[2];
|
||||
this._key = asn5.Value;
|
||||
if (asn.Count > 3)
|
||||
{
|
||||
ASN1 asn6 = asn[3];
|
||||
for (int i = 0; i < asn6.Count; i++)
|
||||
{
|
||||
this._list.Add(asn6[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000955 RID: 2389 RVA: 0x000255C8 File Offset: 0x000237C8
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
ASN1 asn = new ASN1(48);
|
||||
asn.Add(ASN1Convert.FromOid(this._algorithm));
|
||||
asn.Add(new ASN1(5));
|
||||
ASN1 asn2 = new ASN1(48);
|
||||
asn2.Add(new ASN1(2, new byte[] { (byte)this._version }));
|
||||
asn2.Add(asn);
|
||||
asn2.Add(new ASN1(4, this._key));
|
||||
if (this._list.Count > 0)
|
||||
{
|
||||
ASN1 asn3 = new ASN1(160);
|
||||
foreach (object obj in this._list)
|
||||
{
|
||||
ASN1 asn4 = (ASN1)obj;
|
||||
asn3.Add(asn4);
|
||||
}
|
||||
asn2.Add(asn3);
|
||||
}
|
||||
return asn2.GetBytes();
|
||||
}
|
||||
|
||||
// Token: 0x06000956 RID: 2390 RVA: 0x000256D0 File Offset: 0x000238D0
|
||||
private static byte[] RemoveLeadingZero(byte[] bigInt)
|
||||
{
|
||||
int num = 0;
|
||||
int num2 = bigInt.Length;
|
||||
if (bigInt[0] == 0)
|
||||
{
|
||||
num = 1;
|
||||
num2--;
|
||||
}
|
||||
byte[] array = new byte[num2];
|
||||
Buffer.BlockCopy(bigInt, num, array, 0, num2);
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x06000957 RID: 2391 RVA: 0x00025704 File Offset: 0x00023904
|
||||
private static byte[] Normalize(byte[] bigInt, int length)
|
||||
{
|
||||
if (bigInt.Length == length)
|
||||
{
|
||||
return bigInt;
|
||||
}
|
||||
if (bigInt.Length > length)
|
||||
{
|
||||
return PKCS8.PrivateKeyInfo.RemoveLeadingZero(bigInt);
|
||||
}
|
||||
byte[] array = new byte[length];
|
||||
Buffer.BlockCopy(bigInt, 0, array, length - bigInt.Length, bigInt.Length);
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x06000958 RID: 2392 RVA: 0x00025744 File Offset: 0x00023944
|
||||
public static RSA DecodeRSA(byte[] keypair)
|
||||
{
|
||||
ASN1 asn = new ASN1(keypair);
|
||||
if (asn.Tag != 48)
|
||||
{
|
||||
throw new CryptographicException("invalid private key format");
|
||||
}
|
||||
ASN1 asn2 = asn[0];
|
||||
if (asn2.Tag != 2)
|
||||
{
|
||||
throw new CryptographicException("missing version");
|
||||
}
|
||||
if (asn.Count < 9)
|
||||
{
|
||||
throw new CryptographicException("not enough key parameters");
|
||||
}
|
||||
RSAParameters rsaparameters = default(RSAParameters);
|
||||
rsaparameters.Modulus = PKCS8.PrivateKeyInfo.RemoveLeadingZero(asn[1].Value);
|
||||
int num = rsaparameters.Modulus.Length;
|
||||
int num2 = num >> 1;
|
||||
rsaparameters.D = PKCS8.PrivateKeyInfo.Normalize(asn[3].Value, num);
|
||||
rsaparameters.DP = PKCS8.PrivateKeyInfo.Normalize(asn[6].Value, num2);
|
||||
rsaparameters.DQ = PKCS8.PrivateKeyInfo.Normalize(asn[7].Value, num2);
|
||||
rsaparameters.Exponent = PKCS8.PrivateKeyInfo.RemoveLeadingZero(asn[2].Value);
|
||||
rsaparameters.InverseQ = PKCS8.PrivateKeyInfo.Normalize(asn[8].Value, num2);
|
||||
rsaparameters.P = PKCS8.PrivateKeyInfo.Normalize(asn[4].Value, num2);
|
||||
rsaparameters.Q = PKCS8.PrivateKeyInfo.Normalize(asn[5].Value, num2);
|
||||
RSA rsa = null;
|
||||
try
|
||||
{
|
||||
rsa = RSA.Create();
|
||||
rsa.ImportParameters(rsaparameters);
|
||||
}
|
||||
catch (CryptographicException)
|
||||
{
|
||||
rsa = new RSACryptoServiceProvider(new CspParameters
|
||||
{
|
||||
Flags = CspProviderFlags.UseMachineKeyStore
|
||||
});
|
||||
rsa.ImportParameters(rsaparameters);
|
||||
}
|
||||
return rsa;
|
||||
}
|
||||
|
||||
// Token: 0x06000959 RID: 2393 RVA: 0x000258E4 File Offset: 0x00023AE4
|
||||
public static byte[] Encode(RSA rsa)
|
||||
{
|
||||
RSAParameters rsaparameters = rsa.ExportParameters(true);
|
||||
ASN1 asn = new ASN1(48);
|
||||
asn.Add(new ASN1(2, new byte[1]));
|
||||
asn.Add(ASN1Convert.FromUnsignedBigInteger(rsaparameters.Modulus));
|
||||
asn.Add(ASN1Convert.FromUnsignedBigInteger(rsaparameters.Exponent));
|
||||
asn.Add(ASN1Convert.FromUnsignedBigInteger(rsaparameters.D));
|
||||
asn.Add(ASN1Convert.FromUnsignedBigInteger(rsaparameters.P));
|
||||
asn.Add(ASN1Convert.FromUnsignedBigInteger(rsaparameters.Q));
|
||||
asn.Add(ASN1Convert.FromUnsignedBigInteger(rsaparameters.DP));
|
||||
asn.Add(ASN1Convert.FromUnsignedBigInteger(rsaparameters.DQ));
|
||||
asn.Add(ASN1Convert.FromUnsignedBigInteger(rsaparameters.InverseQ));
|
||||
return asn.GetBytes();
|
||||
}
|
||||
|
||||
// Token: 0x0600095A RID: 2394 RVA: 0x000259B4 File Offset: 0x00023BB4
|
||||
public static DSA DecodeDSA(byte[] privateKey, DSAParameters dsaParameters)
|
||||
{
|
||||
ASN1 asn = new ASN1(privateKey);
|
||||
if (asn.Tag != 2)
|
||||
{
|
||||
throw new CryptographicException("invalid private key format");
|
||||
}
|
||||
dsaParameters.X = PKCS8.PrivateKeyInfo.Normalize(asn.Value, 20);
|
||||
DSA dsa = DSA.Create();
|
||||
dsa.ImportParameters(dsaParameters);
|
||||
return dsa;
|
||||
}
|
||||
|
||||
// Token: 0x0600095B RID: 2395 RVA: 0x00025A04 File Offset: 0x00023C04
|
||||
public static byte[] Encode(DSA dsa)
|
||||
{
|
||||
return ASN1Convert.FromUnsignedBigInteger(dsa.ExportParameters(true).X).GetBytes();
|
||||
}
|
||||
|
||||
// Token: 0x0600095C RID: 2396 RVA: 0x00025A2C File Offset: 0x00023C2C
|
||||
public static byte[] Encode(AsymmetricAlgorithm aa)
|
||||
{
|
||||
if (aa is RSA)
|
||||
{
|
||||
return PKCS8.PrivateKeyInfo.Encode((RSA)aa);
|
||||
}
|
||||
if (aa is DSA)
|
||||
{
|
||||
return PKCS8.PrivateKeyInfo.Encode((DSA)aa);
|
||||
}
|
||||
throw new CryptographicException("Unknown asymmetric algorithm {0}", aa.ToString());
|
||||
}
|
||||
|
||||
// Token: 0x04000208 RID: 520
|
||||
private int _version;
|
||||
|
||||
// Token: 0x04000209 RID: 521
|
||||
private string _algorithm;
|
||||
|
||||
// Token: 0x0400020A RID: 522
|
||||
private byte[] _key;
|
||||
|
||||
// Token: 0x0400020B RID: 523
|
||||
private ArrayList _list;
|
||||
}
|
||||
|
||||
// Token: 0x020000AC RID: 172
|
||||
public class EncryptedPrivateKeyInfo
|
||||
{
|
||||
// Token: 0x0600095D RID: 2397 RVA: 0x00025A78 File Offset: 0x00023C78
|
||||
public EncryptedPrivateKeyInfo()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600095E RID: 2398 RVA: 0x00025A80 File Offset: 0x00023C80
|
||||
public EncryptedPrivateKeyInfo(byte[] data)
|
||||
: this()
|
||||
{
|
||||
this.Decode(data);
|
||||
}
|
||||
|
||||
// Token: 0x17000107 RID: 263
|
||||
// (get) Token: 0x0600095F RID: 2399 RVA: 0x00025A90 File Offset: 0x00023C90
|
||||
// (set) Token: 0x06000960 RID: 2400 RVA: 0x00025A98 File Offset: 0x00023C98
|
||||
public string Algorithm
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._algorithm;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._algorithm = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000108 RID: 264
|
||||
// (get) Token: 0x06000961 RID: 2401 RVA: 0x00025AA4 File Offset: 0x00023CA4
|
||||
// (set) Token: 0x06000962 RID: 2402 RVA: 0x00025AC8 File Offset: 0x00023CC8
|
||||
public byte[] EncryptedData
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this._data != null) ? ((byte[])this._data.Clone()) : null;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._data = ((value != null) ? ((byte[])value.Clone()) : null);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000109 RID: 265
|
||||
// (get) Token: 0x06000963 RID: 2403 RVA: 0x00025AE8 File Offset: 0x00023CE8
|
||||
// (set) Token: 0x06000964 RID: 2404 RVA: 0x00025B30 File Offset: 0x00023D30
|
||||
public byte[] Salt
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._salt == null)
|
||||
{
|
||||
RandomNumberGenerator randomNumberGenerator = RandomNumberGenerator.Create();
|
||||
this._salt = new byte[8];
|
||||
randomNumberGenerator.GetBytes(this._salt);
|
||||
}
|
||||
return (byte[])this._salt.Clone();
|
||||
}
|
||||
set
|
||||
{
|
||||
this._salt = (byte[])value.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700010A RID: 266
|
||||
// (get) Token: 0x06000965 RID: 2405 RVA: 0x00025B44 File Offset: 0x00023D44
|
||||
// (set) Token: 0x06000966 RID: 2406 RVA: 0x00025B4C File Offset: 0x00023D4C
|
||||
public int IterationCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._iterations;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("IterationCount", "Negative");
|
||||
}
|
||||
this._iterations = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000967 RID: 2407 RVA: 0x00025B6C File Offset: 0x00023D6C
|
||||
private void Decode(byte[] data)
|
||||
{
|
||||
ASN1 asn = new ASN1(data);
|
||||
if (asn.Tag != 48)
|
||||
{
|
||||
throw new CryptographicException("invalid EncryptedPrivateKeyInfo");
|
||||
}
|
||||
ASN1 asn2 = asn[0];
|
||||
if (asn2.Tag != 48)
|
||||
{
|
||||
throw new CryptographicException("invalid encryptionAlgorithm");
|
||||
}
|
||||
ASN1 asn3 = asn2[0];
|
||||
if (asn3.Tag != 6)
|
||||
{
|
||||
throw new CryptographicException("invalid algorithm");
|
||||
}
|
||||
this._algorithm = ASN1Convert.ToOid(asn3);
|
||||
if (asn2.Count > 1)
|
||||
{
|
||||
ASN1 asn4 = asn2[1];
|
||||
if (asn4.Tag != 48)
|
||||
{
|
||||
throw new CryptographicException("invalid parameters");
|
||||
}
|
||||
ASN1 asn5 = asn4[0];
|
||||
if (asn5.Tag != 4)
|
||||
{
|
||||
throw new CryptographicException("invalid salt");
|
||||
}
|
||||
this._salt = asn5.Value;
|
||||
ASN1 asn6 = asn4[1];
|
||||
if (asn6.Tag != 2)
|
||||
{
|
||||
throw new CryptographicException("invalid iterationCount");
|
||||
}
|
||||
this._iterations = ASN1Convert.ToInt32(asn6);
|
||||
}
|
||||
ASN1 asn7 = asn[1];
|
||||
if (asn7.Tag != 4)
|
||||
{
|
||||
throw new CryptographicException("invalid EncryptedData");
|
||||
}
|
||||
this._data = asn7.Value;
|
||||
}
|
||||
|
||||
// Token: 0x06000968 RID: 2408 RVA: 0x00025C9C File Offset: 0x00023E9C
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
if (this._algorithm == null)
|
||||
{
|
||||
throw new CryptographicException("No algorithm OID specified");
|
||||
}
|
||||
ASN1 asn = new ASN1(48);
|
||||
asn.Add(ASN1Convert.FromOid(this._algorithm));
|
||||
if (this._iterations > 0 || this._salt != null)
|
||||
{
|
||||
ASN1 asn2 = new ASN1(4, this._salt);
|
||||
ASN1 asn3 = ASN1Convert.FromInt32(this._iterations);
|
||||
ASN1 asn4 = new ASN1(48);
|
||||
asn4.Add(asn2);
|
||||
asn4.Add(asn3);
|
||||
asn.Add(asn4);
|
||||
}
|
||||
ASN1 asn5 = new ASN1(4, this._data);
|
||||
ASN1 asn6 = new ASN1(48);
|
||||
asn6.Add(asn);
|
||||
asn6.Add(asn5);
|
||||
return asn6.GetBytes();
|
||||
}
|
||||
|
||||
// Token: 0x0400020C RID: 524
|
||||
private string _algorithm;
|
||||
|
||||
// Token: 0x0400020D RID: 525
|
||||
private byte[] _salt;
|
||||
|
||||
// Token: 0x0400020E RID: 526
|
||||
private int _iterations;
|
||||
|
||||
// Token: 0x0400020F RID: 527
|
||||
private byte[] _data;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,524 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Mono.Math;
|
||||
|
||||
namespace Mono.Security.Cryptography
|
||||
{
|
||||
// Token: 0x020000AD RID: 173
|
||||
internal class RSAManaged : RSA
|
||||
{
|
||||
// Token: 0x06000969 RID: 2409 RVA: 0x00025D5C File Offset: 0x00023F5C
|
||||
public RSAManaged()
|
||||
: this(1024)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600096A RID: 2410 RVA: 0x00025D6C File Offset: 0x00023F6C
|
||||
public RSAManaged(int keySize)
|
||||
{
|
||||
this.LegalKeySizesValue = new KeySizes[1];
|
||||
this.LegalKeySizesValue[0] = new KeySizes(384, 16384, 8);
|
||||
base.KeySize = keySize;
|
||||
}
|
||||
|
||||
// Token: 0x14000002 RID: 2
|
||||
// (add) Token: 0x0600096B RID: 2411 RVA: 0x00025DB4 File Offset: 0x00023FB4
|
||||
// (remove) Token: 0x0600096C RID: 2412 RVA: 0x00025DD0 File Offset: 0x00023FD0
|
||||
public event RSAManaged.KeyGeneratedEventHandler KeyGenerated;
|
||||
|
||||
// Token: 0x0600096D RID: 2413 RVA: 0x00025DEC File Offset: 0x00023FEC
|
||||
~RSAManaged()
|
||||
{
|
||||
this.Dispose(false);
|
||||
}
|
||||
|
||||
// Token: 0x0600096E RID: 2414 RVA: 0x00025E28 File Offset: 0x00024028
|
||||
private void GenerateKeyPair()
|
||||
{
|
||||
int num = this.KeySize + 1 >> 1;
|
||||
int num2 = this.KeySize - num;
|
||||
this.e = 17U;
|
||||
do
|
||||
{
|
||||
this.p = BigInteger.GeneratePseudoPrime(num);
|
||||
}
|
||||
while (this.p % 17U == 1U);
|
||||
for (;;)
|
||||
{
|
||||
do
|
||||
{
|
||||
this.q = BigInteger.GeneratePseudoPrime(num2);
|
||||
}
|
||||
while (this.q % 17U == 1U || !(this.p != this.q));
|
||||
this.n = this.p * this.q;
|
||||
if (this.n.BitCount() == this.KeySize)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (this.p < this.q)
|
||||
{
|
||||
this.p = this.q;
|
||||
}
|
||||
}
|
||||
BigInteger bigInteger = this.p - 1;
|
||||
BigInteger bigInteger2 = this.q - 1;
|
||||
BigInteger bigInteger3 = bigInteger * bigInteger2;
|
||||
this.d = this.e.ModInverse(bigInteger3);
|
||||
this.dp = this.d % bigInteger;
|
||||
this.dq = this.d % bigInteger2;
|
||||
this.qInv = this.q.ModInverse(this.p);
|
||||
this.keypairGenerated = true;
|
||||
this.isCRTpossible = true;
|
||||
if (this.KeyGenerated != null)
|
||||
{
|
||||
this.KeyGenerated(this, null);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700010B RID: 267
|
||||
// (get) Token: 0x0600096F RID: 2415 RVA: 0x00025FCC File Offset: 0x000241CC
|
||||
public override int KeySize
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.keypairGenerated)
|
||||
{
|
||||
int num = this.n.BitCount();
|
||||
if ((num & 7) != 0)
|
||||
{
|
||||
num += 8 - (num & 7);
|
||||
}
|
||||
return num;
|
||||
}
|
||||
return base.KeySize;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700010C RID: 268
|
||||
// (get) Token: 0x06000970 RID: 2416 RVA: 0x00026008 File Offset: 0x00024208
|
||||
public override string KeyExchangeAlgorithm
|
||||
{
|
||||
get
|
||||
{
|
||||
return "RSA-PKCS1-KeyEx";
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700010D RID: 269
|
||||
// (get) Token: 0x06000971 RID: 2417 RVA: 0x00026010 File Offset: 0x00024210
|
||||
public bool PublicOnly
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.keypairGenerated && (this.d == null || this.n == null);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700010E RID: 270
|
||||
// (get) Token: 0x06000972 RID: 2418 RVA: 0x0002604C File Offset: 0x0002424C
|
||||
public override string SignatureAlgorithm
|
||||
{
|
||||
get
|
||||
{
|
||||
return "http://www.w3.org/2000/09/xmldsig#rsa-sha1";
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000973 RID: 2419 RVA: 0x00026054 File Offset: 0x00024254
|
||||
public override byte[] DecryptValue(byte[] rgb)
|
||||
{
|
||||
if (this.m_disposed)
|
||||
{
|
||||
throw new ObjectDisposedException("private key");
|
||||
}
|
||||
if (!this.keypairGenerated)
|
||||
{
|
||||
this.GenerateKeyPair();
|
||||
}
|
||||
BigInteger bigInteger = new BigInteger(rgb);
|
||||
BigInteger bigInteger2 = null;
|
||||
if (this.keyBlinding)
|
||||
{
|
||||
bigInteger2 = BigInteger.GenerateRandom(this.n.BitCount());
|
||||
bigInteger = bigInteger2.ModPow(this.e, this.n) * bigInteger % this.n;
|
||||
}
|
||||
BigInteger bigInteger6;
|
||||
if (this.isCRTpossible)
|
||||
{
|
||||
BigInteger bigInteger3 = bigInteger.ModPow(this.dp, this.p);
|
||||
BigInteger bigInteger4 = bigInteger.ModPow(this.dq, this.q);
|
||||
if (bigInteger4 > bigInteger3)
|
||||
{
|
||||
BigInteger bigInteger5 = this.p - (bigInteger4 - bigInteger3) * this.qInv % this.p;
|
||||
bigInteger6 = bigInteger4 + this.q * bigInteger5;
|
||||
}
|
||||
else
|
||||
{
|
||||
BigInteger bigInteger5 = (bigInteger3 - bigInteger4) * this.qInv % this.p;
|
||||
bigInteger6 = bigInteger4 + this.q * bigInteger5;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.PublicOnly)
|
||||
{
|
||||
throw new CryptographicException(Locale.GetText("Missing private key to decrypt value."));
|
||||
}
|
||||
bigInteger6 = bigInteger.ModPow(this.d, this.n);
|
||||
}
|
||||
if (this.keyBlinding)
|
||||
{
|
||||
bigInteger6 = bigInteger6 * bigInteger2.ModInverse(this.n) % this.n;
|
||||
bigInteger2.Clear();
|
||||
}
|
||||
byte[] paddedValue = this.GetPaddedValue(bigInteger6, this.KeySize >> 3);
|
||||
bigInteger.Clear();
|
||||
bigInteger6.Clear();
|
||||
return paddedValue;
|
||||
}
|
||||
|
||||
// Token: 0x06000974 RID: 2420 RVA: 0x00026210 File Offset: 0x00024410
|
||||
public override byte[] EncryptValue(byte[] rgb)
|
||||
{
|
||||
if (this.m_disposed)
|
||||
{
|
||||
throw new ObjectDisposedException("public key");
|
||||
}
|
||||
if (!this.keypairGenerated)
|
||||
{
|
||||
this.GenerateKeyPair();
|
||||
}
|
||||
BigInteger bigInteger = new BigInteger(rgb);
|
||||
BigInteger bigInteger2 = bigInteger.ModPow(this.e, this.n);
|
||||
byte[] paddedValue = this.GetPaddedValue(bigInteger2, this.KeySize >> 3);
|
||||
bigInteger.Clear();
|
||||
bigInteger2.Clear();
|
||||
return paddedValue;
|
||||
}
|
||||
|
||||
// Token: 0x06000975 RID: 2421 RVA: 0x0002627C File Offset: 0x0002447C
|
||||
public override RSAParameters ExportParameters(bool includePrivateParameters)
|
||||
{
|
||||
if (this.m_disposed)
|
||||
{
|
||||
throw new ObjectDisposedException(Locale.GetText("Keypair was disposed"));
|
||||
}
|
||||
if (!this.keypairGenerated)
|
||||
{
|
||||
this.GenerateKeyPair();
|
||||
}
|
||||
RSAParameters rsaparameters = default(RSAParameters);
|
||||
rsaparameters.Exponent = this.e.GetBytes();
|
||||
rsaparameters.Modulus = this.n.GetBytes();
|
||||
if (includePrivateParameters)
|
||||
{
|
||||
if (this.d == null)
|
||||
{
|
||||
throw new CryptographicException("Missing private key");
|
||||
}
|
||||
rsaparameters.D = this.d.GetBytes();
|
||||
if (rsaparameters.D.Length != rsaparameters.Modulus.Length)
|
||||
{
|
||||
byte[] array = new byte[rsaparameters.Modulus.Length];
|
||||
Buffer.BlockCopy(rsaparameters.D, 0, array, array.Length - rsaparameters.D.Length, rsaparameters.D.Length);
|
||||
rsaparameters.D = array;
|
||||
}
|
||||
if (this.p != null && this.q != null && this.dp != null && this.dq != null && this.qInv != null)
|
||||
{
|
||||
int num = this.KeySize >> 4;
|
||||
rsaparameters.P = this.GetPaddedValue(this.p, num);
|
||||
rsaparameters.Q = this.GetPaddedValue(this.q, num);
|
||||
rsaparameters.DP = this.GetPaddedValue(this.dp, num);
|
||||
rsaparameters.DQ = this.GetPaddedValue(this.dq, num);
|
||||
rsaparameters.InverseQ = this.GetPaddedValue(this.qInv, num);
|
||||
}
|
||||
}
|
||||
return rsaparameters;
|
||||
}
|
||||
|
||||
// Token: 0x06000976 RID: 2422 RVA: 0x0002642C File Offset: 0x0002462C
|
||||
public override void ImportParameters(RSAParameters parameters)
|
||||
{
|
||||
if (this.m_disposed)
|
||||
{
|
||||
throw new ObjectDisposedException(Locale.GetText("Keypair was disposed"));
|
||||
}
|
||||
if (parameters.Exponent == null)
|
||||
{
|
||||
throw new CryptographicException(Locale.GetText("Missing Exponent"));
|
||||
}
|
||||
if (parameters.Modulus == null)
|
||||
{
|
||||
throw new CryptographicException(Locale.GetText("Missing Modulus"));
|
||||
}
|
||||
this.e = new BigInteger(parameters.Exponent);
|
||||
this.n = new BigInteger(parameters.Modulus);
|
||||
if (parameters.D != null)
|
||||
{
|
||||
this.d = new BigInteger(parameters.D);
|
||||
}
|
||||
if (parameters.DP != null)
|
||||
{
|
||||
this.dp = new BigInteger(parameters.DP);
|
||||
}
|
||||
if (parameters.DQ != null)
|
||||
{
|
||||
this.dq = new BigInteger(parameters.DQ);
|
||||
}
|
||||
if (parameters.InverseQ != null)
|
||||
{
|
||||
this.qInv = new BigInteger(parameters.InverseQ);
|
||||
}
|
||||
if (parameters.P != null)
|
||||
{
|
||||
this.p = new BigInteger(parameters.P);
|
||||
}
|
||||
if (parameters.Q != null)
|
||||
{
|
||||
this.q = new BigInteger(parameters.Q);
|
||||
}
|
||||
this.keypairGenerated = true;
|
||||
bool flag = this.p != null && this.q != null && this.dp != null;
|
||||
this.isCRTpossible = flag && this.dq != null && this.qInv != null;
|
||||
if (!flag)
|
||||
{
|
||||
return;
|
||||
}
|
||||
bool flag2 = this.n == this.p * this.q;
|
||||
if (flag2)
|
||||
{
|
||||
BigInteger bigInteger = this.p - 1;
|
||||
BigInteger bigInteger2 = this.q - 1;
|
||||
BigInteger bigInteger3 = bigInteger * bigInteger2;
|
||||
BigInteger bigInteger4 = this.e.ModInverse(bigInteger3);
|
||||
flag2 = this.d == bigInteger4;
|
||||
if (!flag2 && this.isCRTpossible)
|
||||
{
|
||||
flag2 = this.dp == bigInteger4 % bigInteger && this.dq == bigInteger4 % bigInteger2 && this.qInv == this.q.ModInverse(this.p);
|
||||
}
|
||||
}
|
||||
if (!flag2)
|
||||
{
|
||||
throw new CryptographicException(Locale.GetText("Private/public key mismatch"));
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000977 RID: 2423 RVA: 0x000266B4 File Offset: 0x000248B4
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (!this.m_disposed)
|
||||
{
|
||||
if (this.d != null)
|
||||
{
|
||||
this.d.Clear();
|
||||
this.d = null;
|
||||
}
|
||||
if (this.p != null)
|
||||
{
|
||||
this.p.Clear();
|
||||
this.p = null;
|
||||
}
|
||||
if (this.q != null)
|
||||
{
|
||||
this.q.Clear();
|
||||
this.q = null;
|
||||
}
|
||||
if (this.dp != null)
|
||||
{
|
||||
this.dp.Clear();
|
||||
this.dp = null;
|
||||
}
|
||||
if (this.dq != null)
|
||||
{
|
||||
this.dq.Clear();
|
||||
this.dq = null;
|
||||
}
|
||||
if (this.qInv != null)
|
||||
{
|
||||
this.qInv.Clear();
|
||||
this.qInv = null;
|
||||
}
|
||||
if (disposing)
|
||||
{
|
||||
if (this.e != null)
|
||||
{
|
||||
this.e.Clear();
|
||||
this.e = null;
|
||||
}
|
||||
if (this.n != null)
|
||||
{
|
||||
this.n.Clear();
|
||||
this.n = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.m_disposed = true;
|
||||
}
|
||||
|
||||
// Token: 0x06000978 RID: 2424 RVA: 0x000267F4 File Offset: 0x000249F4
|
||||
public override string ToXmlString(bool includePrivateParameters)
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
RSAParameters rsaparameters = this.ExportParameters(includePrivateParameters);
|
||||
try
|
||||
{
|
||||
stringBuilder.Append("<RSAKeyValue>");
|
||||
stringBuilder.Append("<Modulus>");
|
||||
stringBuilder.Append(Convert.ToBase64String(rsaparameters.Modulus));
|
||||
stringBuilder.Append("</Modulus>");
|
||||
stringBuilder.Append("<Exponent>");
|
||||
stringBuilder.Append(Convert.ToBase64String(rsaparameters.Exponent));
|
||||
stringBuilder.Append("</Exponent>");
|
||||
if (includePrivateParameters)
|
||||
{
|
||||
if (rsaparameters.P != null)
|
||||
{
|
||||
stringBuilder.Append("<P>");
|
||||
stringBuilder.Append(Convert.ToBase64String(rsaparameters.P));
|
||||
stringBuilder.Append("</P>");
|
||||
}
|
||||
if (rsaparameters.Q != null)
|
||||
{
|
||||
stringBuilder.Append("<Q>");
|
||||
stringBuilder.Append(Convert.ToBase64String(rsaparameters.Q));
|
||||
stringBuilder.Append("</Q>");
|
||||
}
|
||||
if (rsaparameters.DP != null)
|
||||
{
|
||||
stringBuilder.Append("<DP>");
|
||||
stringBuilder.Append(Convert.ToBase64String(rsaparameters.DP));
|
||||
stringBuilder.Append("</DP>");
|
||||
}
|
||||
if (rsaparameters.DQ != null)
|
||||
{
|
||||
stringBuilder.Append("<DQ>");
|
||||
stringBuilder.Append(Convert.ToBase64String(rsaparameters.DQ));
|
||||
stringBuilder.Append("</DQ>");
|
||||
}
|
||||
if (rsaparameters.InverseQ != null)
|
||||
{
|
||||
stringBuilder.Append("<InverseQ>");
|
||||
stringBuilder.Append(Convert.ToBase64String(rsaparameters.InverseQ));
|
||||
stringBuilder.Append("</InverseQ>");
|
||||
}
|
||||
stringBuilder.Append("<D>");
|
||||
stringBuilder.Append(Convert.ToBase64String(rsaparameters.D));
|
||||
stringBuilder.Append("</D>");
|
||||
}
|
||||
stringBuilder.Append("</RSAKeyValue>");
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (rsaparameters.P != null)
|
||||
{
|
||||
Array.Clear(rsaparameters.P, 0, rsaparameters.P.Length);
|
||||
}
|
||||
if (rsaparameters.Q != null)
|
||||
{
|
||||
Array.Clear(rsaparameters.Q, 0, rsaparameters.Q.Length);
|
||||
}
|
||||
if (rsaparameters.DP != null)
|
||||
{
|
||||
Array.Clear(rsaparameters.DP, 0, rsaparameters.DP.Length);
|
||||
}
|
||||
if (rsaparameters.DQ != null)
|
||||
{
|
||||
Array.Clear(rsaparameters.DQ, 0, rsaparameters.DQ.Length);
|
||||
}
|
||||
if (rsaparameters.InverseQ != null)
|
||||
{
|
||||
Array.Clear(rsaparameters.InverseQ, 0, rsaparameters.InverseQ.Length);
|
||||
}
|
||||
if (rsaparameters.D != null)
|
||||
{
|
||||
Array.Clear(rsaparameters.D, 0, rsaparameters.D.Length);
|
||||
}
|
||||
throw;
|
||||
}
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
// Token: 0x1700010F RID: 271
|
||||
// (get) Token: 0x06000979 RID: 2425 RVA: 0x00026ABC File Offset: 0x00024CBC
|
||||
// (set) Token: 0x0600097A RID: 2426 RVA: 0x00026AC4 File Offset: 0x00024CC4
|
||||
public bool UseKeyBlinding
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.keyBlinding;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.keyBlinding = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000110 RID: 272
|
||||
// (get) Token: 0x0600097B RID: 2427 RVA: 0x00026AD0 File Offset: 0x00024CD0
|
||||
public bool IsCrtPossible
|
||||
{
|
||||
get
|
||||
{
|
||||
return !this.keypairGenerated || this.isCRTpossible;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600097C RID: 2428 RVA: 0x00026AE8 File Offset: 0x00024CE8
|
||||
private byte[] GetPaddedValue(BigInteger value, int length)
|
||||
{
|
||||
byte[] bytes = value.GetBytes();
|
||||
if (bytes.Length >= length)
|
||||
{
|
||||
return bytes;
|
||||
}
|
||||
byte[] array = new byte[length];
|
||||
Buffer.BlockCopy(bytes, 0, array, length - bytes.Length, bytes.Length);
|
||||
Array.Clear(bytes, 0, bytes.Length);
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x04000210 RID: 528
|
||||
private const int defaultKeySize = 1024;
|
||||
|
||||
// Token: 0x04000211 RID: 529
|
||||
private bool isCRTpossible;
|
||||
|
||||
// Token: 0x04000212 RID: 530
|
||||
private bool keyBlinding = true;
|
||||
|
||||
// Token: 0x04000213 RID: 531
|
||||
private bool keypairGenerated;
|
||||
|
||||
// Token: 0x04000214 RID: 532
|
||||
private bool m_disposed;
|
||||
|
||||
// Token: 0x04000215 RID: 533
|
||||
private BigInteger d;
|
||||
|
||||
// Token: 0x04000216 RID: 534
|
||||
private BigInteger p;
|
||||
|
||||
// Token: 0x04000217 RID: 535
|
||||
private BigInteger q;
|
||||
|
||||
// Token: 0x04000218 RID: 536
|
||||
private BigInteger dp;
|
||||
|
||||
// Token: 0x04000219 RID: 537
|
||||
private BigInteger dq;
|
||||
|
||||
// Token: 0x0400021A RID: 538
|
||||
private BigInteger qInv;
|
||||
|
||||
// Token: 0x0400021B RID: 539
|
||||
private BigInteger n;
|
||||
|
||||
// Token: 0x0400021C RID: 540
|
||||
private BigInteger e;
|
||||
|
||||
// Token: 0x020006C5 RID: 1733
|
||||
// (Invoke) Token: 0x0600419C RID: 16796
|
||||
public delegate void KeyGeneratedEventHandler(object sender, EventArgs e);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,556 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Mono.Security.Cryptography
|
||||
{
|
||||
// Token: 0x020000AE RID: 174
|
||||
internal abstract class SymmetricTransform : IDisposable, ICryptoTransform
|
||||
{
|
||||
// Token: 0x0600097D RID: 2429 RVA: 0x00026B2C File Offset: 0x00024D2C
|
||||
public SymmetricTransform(SymmetricAlgorithm symmAlgo, bool encryption, byte[] rgbIV)
|
||||
{
|
||||
this.algo = symmAlgo;
|
||||
this.encrypt = encryption;
|
||||
this.BlockSizeByte = this.algo.BlockSize >> 3;
|
||||
if (rgbIV == null)
|
||||
{
|
||||
rgbIV = KeyBuilder.IV(this.BlockSizeByte);
|
||||
}
|
||||
else
|
||||
{
|
||||
rgbIV = (byte[])rgbIV.Clone();
|
||||
}
|
||||
if (rgbIV.Length < this.BlockSizeByte)
|
||||
{
|
||||
string text = Locale.GetText("IV is too small ({0} bytes), it should be {1} bytes long.", new object[] { rgbIV.Length, this.BlockSizeByte });
|
||||
throw new CryptographicException(text);
|
||||
}
|
||||
this.temp = new byte[this.BlockSizeByte];
|
||||
Buffer.BlockCopy(rgbIV, 0, this.temp, 0, Math.Min(this.BlockSizeByte, rgbIV.Length));
|
||||
this.temp2 = new byte[this.BlockSizeByte];
|
||||
this.FeedBackByte = this.algo.FeedbackSize >> 3;
|
||||
if (this.FeedBackByte != 0)
|
||||
{
|
||||
this.FeedBackIter = this.BlockSizeByte / this.FeedBackByte;
|
||||
}
|
||||
this.workBuff = new byte[this.BlockSizeByte];
|
||||
this.workout = new byte[this.BlockSizeByte];
|
||||
}
|
||||
|
||||
// Token: 0x0600097E RID: 2430 RVA: 0x00026C58 File Offset: 0x00024E58
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
this.Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
// Token: 0x0600097F RID: 2431 RVA: 0x00026C68 File Offset: 0x00024E68
|
||||
~SymmetricTransform()
|
||||
{
|
||||
this.Dispose(false);
|
||||
}
|
||||
|
||||
// Token: 0x06000980 RID: 2432 RVA: 0x00026CA4 File Offset: 0x00024EA4
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!this.m_disposed)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
Array.Clear(this.temp, 0, this.BlockSizeByte);
|
||||
this.temp = null;
|
||||
Array.Clear(this.temp2, 0, this.BlockSizeByte);
|
||||
this.temp2 = null;
|
||||
}
|
||||
this.m_disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000111 RID: 273
|
||||
// (get) Token: 0x06000981 RID: 2433 RVA: 0x00026CFC File Offset: 0x00024EFC
|
||||
public virtual bool CanTransformMultipleBlocks
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000112 RID: 274
|
||||
// (get) Token: 0x06000982 RID: 2434 RVA: 0x00026D00 File Offset: 0x00024F00
|
||||
public virtual bool CanReuseTransform
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000113 RID: 275
|
||||
// (get) Token: 0x06000983 RID: 2435 RVA: 0x00026D04 File Offset: 0x00024F04
|
||||
public virtual int InputBlockSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.BlockSizeByte;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000114 RID: 276
|
||||
// (get) Token: 0x06000984 RID: 2436 RVA: 0x00026D0C File Offset: 0x00024F0C
|
||||
public virtual int OutputBlockSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.BlockSizeByte;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000985 RID: 2437 RVA: 0x00026D14 File Offset: 0x00024F14
|
||||
protected virtual void Transform(byte[] input, byte[] output)
|
||||
{
|
||||
switch (this.algo.Mode)
|
||||
{
|
||||
case CipherMode.CBC:
|
||||
this.CBC(input, output);
|
||||
break;
|
||||
case CipherMode.ECB:
|
||||
this.ECB(input, output);
|
||||
break;
|
||||
case CipherMode.OFB:
|
||||
this.OFB(input, output);
|
||||
break;
|
||||
case CipherMode.CFB:
|
||||
this.CFB(input, output);
|
||||
break;
|
||||
case CipherMode.CTS:
|
||||
this.CTS(input, output);
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException("Unkown CipherMode" + this.algo.Mode.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000986 RID: 2438
|
||||
protected abstract void ECB(byte[] input, byte[] output);
|
||||
|
||||
// Token: 0x06000987 RID: 2439 RVA: 0x00026DB4 File Offset: 0x00024FB4
|
||||
protected virtual void CBC(byte[] input, byte[] output)
|
||||
{
|
||||
if (this.encrypt)
|
||||
{
|
||||
for (int i = 0; i < this.BlockSizeByte; i++)
|
||||
{
|
||||
byte[] array = this.temp;
|
||||
int num = i;
|
||||
array[num] ^= input[i];
|
||||
}
|
||||
this.ECB(this.temp, output);
|
||||
Buffer.BlockCopy(output, 0, this.temp, 0, this.BlockSizeByte);
|
||||
}
|
||||
else
|
||||
{
|
||||
Buffer.BlockCopy(input, 0, this.temp2, 0, this.BlockSizeByte);
|
||||
this.ECB(input, output);
|
||||
for (int j = 0; j < this.BlockSizeByte; j++)
|
||||
{
|
||||
int num2 = j;
|
||||
output[num2] ^= this.temp[j];
|
||||
}
|
||||
Buffer.BlockCopy(this.temp2, 0, this.temp, 0, this.BlockSizeByte);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000988 RID: 2440 RVA: 0x00026E80 File Offset: 0x00025080
|
||||
protected virtual void CFB(byte[] input, byte[] output)
|
||||
{
|
||||
if (this.encrypt)
|
||||
{
|
||||
for (int i = 0; i < this.FeedBackIter; i++)
|
||||
{
|
||||
this.ECB(this.temp, this.temp2);
|
||||
for (int j = 0; j < this.FeedBackByte; j++)
|
||||
{
|
||||
output[j + i] = this.temp2[j] ^ input[j + i];
|
||||
}
|
||||
Buffer.BlockCopy(this.temp, this.FeedBackByte, this.temp, 0, this.BlockSizeByte - this.FeedBackByte);
|
||||
Buffer.BlockCopy(output, i, this.temp, this.BlockSizeByte - this.FeedBackByte, this.FeedBackByte);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int k = 0; k < this.FeedBackIter; k++)
|
||||
{
|
||||
this.encrypt = true;
|
||||
this.ECB(this.temp, this.temp2);
|
||||
this.encrypt = false;
|
||||
Buffer.BlockCopy(this.temp, this.FeedBackByte, this.temp, 0, this.BlockSizeByte - this.FeedBackByte);
|
||||
Buffer.BlockCopy(input, k, this.temp, this.BlockSizeByte - this.FeedBackByte, this.FeedBackByte);
|
||||
for (int l = 0; l < this.FeedBackByte; l++)
|
||||
{
|
||||
output[l + k] = this.temp2[l] ^ input[l + k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000989 RID: 2441 RVA: 0x00026FE0 File Offset: 0x000251E0
|
||||
protected virtual void OFB(byte[] input, byte[] output)
|
||||
{
|
||||
throw new CryptographicException("OFB isn't supported by the framework");
|
||||
}
|
||||
|
||||
// Token: 0x0600098A RID: 2442 RVA: 0x00026FEC File Offset: 0x000251EC
|
||||
protected virtual void CTS(byte[] input, byte[] output)
|
||||
{
|
||||
throw new CryptographicException("CTS isn't supported by the framework");
|
||||
}
|
||||
|
||||
// Token: 0x0600098B RID: 2443 RVA: 0x00026FF8 File Offset: 0x000251F8
|
||||
private void CheckInput(byte[] inputBuffer, int inputOffset, int inputCount)
|
||||
{
|
||||
if (inputBuffer == null)
|
||||
{
|
||||
throw new ArgumentNullException("inputBuffer");
|
||||
}
|
||||
if (inputOffset < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("inputOffset", "< 0");
|
||||
}
|
||||
if (inputCount < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("inputCount", "< 0");
|
||||
}
|
||||
if (inputOffset > inputBuffer.Length - inputCount)
|
||||
{
|
||||
throw new ArgumentException("inputBuffer", Locale.GetText("Overflow"));
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600098C RID: 2444 RVA: 0x00027064 File Offset: 0x00025264
|
||||
public virtual int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
|
||||
{
|
||||
if (this.m_disposed)
|
||||
{
|
||||
throw new ObjectDisposedException("Object is disposed");
|
||||
}
|
||||
this.CheckInput(inputBuffer, inputOffset, inputCount);
|
||||
if (outputBuffer == null)
|
||||
{
|
||||
throw new ArgumentNullException("outputBuffer");
|
||||
}
|
||||
if (outputOffset < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("outputOffset", "< 0");
|
||||
}
|
||||
int num = outputBuffer.Length - inputCount - outputOffset;
|
||||
if (!this.encrypt && 0 > num && (this.algo.Padding == PaddingMode.None || this.algo.Padding == PaddingMode.Zeros))
|
||||
{
|
||||
throw new CryptographicException("outputBuffer", Locale.GetText("Overflow"));
|
||||
}
|
||||
if (this.KeepLastBlock)
|
||||
{
|
||||
if (0 > num + this.BlockSizeByte)
|
||||
{
|
||||
throw new CryptographicException("outputBuffer", Locale.GetText("Overflow"));
|
||||
}
|
||||
}
|
||||
else if (0 > num)
|
||||
{
|
||||
if (inputBuffer.Length - inputOffset - outputBuffer.Length != this.BlockSizeByte)
|
||||
{
|
||||
throw new CryptographicException("outputBuffer", Locale.GetText("Overflow"));
|
||||
}
|
||||
inputCount = outputBuffer.Length - outputOffset;
|
||||
}
|
||||
return this.InternalTransformBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
|
||||
}
|
||||
|
||||
// Token: 0x17000115 RID: 277
|
||||
// (get) Token: 0x0600098D RID: 2445 RVA: 0x0002718C File Offset: 0x0002538C
|
||||
private bool KeepLastBlock
|
||||
{
|
||||
get
|
||||
{
|
||||
return !this.encrypt && this.algo.Padding != PaddingMode.None && this.algo.Padding != PaddingMode.Zeros;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600098E RID: 2446 RVA: 0x000271CC File Offset: 0x000253CC
|
||||
private int InternalTransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
|
||||
{
|
||||
int num = inputOffset;
|
||||
int num2;
|
||||
if (inputCount != this.BlockSizeByte)
|
||||
{
|
||||
if (inputCount % this.BlockSizeByte != 0)
|
||||
{
|
||||
throw new CryptographicException("Invalid input block size.");
|
||||
}
|
||||
num2 = inputCount / this.BlockSizeByte;
|
||||
}
|
||||
else
|
||||
{
|
||||
num2 = 1;
|
||||
}
|
||||
if (this.KeepLastBlock)
|
||||
{
|
||||
num2--;
|
||||
}
|
||||
int num3 = 0;
|
||||
if (this.lastBlock)
|
||||
{
|
||||
this.Transform(this.workBuff, this.workout);
|
||||
Buffer.BlockCopy(this.workout, 0, outputBuffer, outputOffset, this.BlockSizeByte);
|
||||
outputOffset += this.BlockSizeByte;
|
||||
num3 += this.BlockSizeByte;
|
||||
this.lastBlock = false;
|
||||
}
|
||||
for (int i = 0; i < num2; i++)
|
||||
{
|
||||
Buffer.BlockCopy(inputBuffer, num, this.workBuff, 0, this.BlockSizeByte);
|
||||
this.Transform(this.workBuff, this.workout);
|
||||
Buffer.BlockCopy(this.workout, 0, outputBuffer, outputOffset, this.BlockSizeByte);
|
||||
num += this.BlockSizeByte;
|
||||
outputOffset += this.BlockSizeByte;
|
||||
num3 += this.BlockSizeByte;
|
||||
}
|
||||
if (this.KeepLastBlock)
|
||||
{
|
||||
Buffer.BlockCopy(inputBuffer, num, this.workBuff, 0, this.BlockSizeByte);
|
||||
this.lastBlock = true;
|
||||
}
|
||||
return num3;
|
||||
}
|
||||
|
||||
// Token: 0x0600098F RID: 2447 RVA: 0x00027300 File Offset: 0x00025500
|
||||
private void Random(byte[] buffer, int start, int length)
|
||||
{
|
||||
if (this._rng == null)
|
||||
{
|
||||
this._rng = RandomNumberGenerator.Create();
|
||||
}
|
||||
byte[] array = new byte[length];
|
||||
this._rng.GetBytes(array);
|
||||
Buffer.BlockCopy(array, 0, buffer, start, length);
|
||||
}
|
||||
|
||||
// Token: 0x06000990 RID: 2448 RVA: 0x00027340 File Offset: 0x00025540
|
||||
private void ThrowBadPaddingException(PaddingMode padding, int length, int position)
|
||||
{
|
||||
string text = string.Format(Locale.GetText("Bad {0} padding."), padding);
|
||||
if (length >= 0)
|
||||
{
|
||||
text += string.Format(Locale.GetText(" Invalid length {0}."), length);
|
||||
}
|
||||
if (position >= 0)
|
||||
{
|
||||
text += string.Format(Locale.GetText(" Error found at position {0}."), position);
|
||||
}
|
||||
throw new CryptographicException(text);
|
||||
}
|
||||
|
||||
// Token: 0x06000991 RID: 2449 RVA: 0x000273B0 File Offset: 0x000255B0
|
||||
private byte[] FinalEncrypt(byte[] inputBuffer, int inputOffset, int inputCount)
|
||||
{
|
||||
int num = inputCount / this.BlockSizeByte * this.BlockSizeByte;
|
||||
int num2 = inputCount - num;
|
||||
int i = num;
|
||||
switch (this.algo.Padding)
|
||||
{
|
||||
case PaddingMode.PKCS7:
|
||||
case PaddingMode.ANSIX923:
|
||||
case PaddingMode.ISO10126:
|
||||
i += this.BlockSizeByte;
|
||||
goto IL_A8;
|
||||
}
|
||||
if (inputCount == 0)
|
||||
{
|
||||
return new byte[0];
|
||||
}
|
||||
if (num2 != 0)
|
||||
{
|
||||
if (this.algo.Padding == PaddingMode.None)
|
||||
{
|
||||
throw new CryptographicException("invalid block length");
|
||||
}
|
||||
byte[] array = new byte[num + this.BlockSizeByte];
|
||||
Buffer.BlockCopy(inputBuffer, inputOffset, array, 0, inputCount);
|
||||
inputBuffer = array;
|
||||
inputOffset = 0;
|
||||
inputCount = array.Length;
|
||||
i = inputCount;
|
||||
}
|
||||
IL_A8:
|
||||
byte[] array2 = new byte[i];
|
||||
int num3 = 0;
|
||||
while (i > this.BlockSizeByte)
|
||||
{
|
||||
this.InternalTransformBlock(inputBuffer, inputOffset, this.BlockSizeByte, array2, num3);
|
||||
inputOffset += this.BlockSizeByte;
|
||||
num3 += this.BlockSizeByte;
|
||||
i -= this.BlockSizeByte;
|
||||
}
|
||||
byte b = (byte)(this.BlockSizeByte - num2);
|
||||
switch (this.algo.Padding)
|
||||
{
|
||||
case PaddingMode.PKCS7:
|
||||
{
|
||||
int num4 = array2.Length;
|
||||
while (--num4 >= array2.Length - (int)b)
|
||||
{
|
||||
array2[num4] = b;
|
||||
}
|
||||
Buffer.BlockCopy(inputBuffer, inputOffset, array2, num, num2);
|
||||
this.InternalTransformBlock(array2, num, this.BlockSizeByte, array2, num);
|
||||
return array2;
|
||||
}
|
||||
case PaddingMode.ANSIX923:
|
||||
array2[array2.Length - 1] = b;
|
||||
Buffer.BlockCopy(inputBuffer, inputOffset, array2, num, num2);
|
||||
this.InternalTransformBlock(array2, num, this.BlockSizeByte, array2, num);
|
||||
return array2;
|
||||
case PaddingMode.ISO10126:
|
||||
this.Random(array2, array2.Length - (int)b, (int)(b - 1));
|
||||
array2[array2.Length - 1] = b;
|
||||
Buffer.BlockCopy(inputBuffer, inputOffset, array2, num, num2);
|
||||
this.InternalTransformBlock(array2, num, this.BlockSizeByte, array2, num);
|
||||
return array2;
|
||||
}
|
||||
this.InternalTransformBlock(inputBuffer, inputOffset, this.BlockSizeByte, array2, num3);
|
||||
return array2;
|
||||
}
|
||||
|
||||
// Token: 0x06000992 RID: 2450 RVA: 0x000275BC File Offset: 0x000257BC
|
||||
private byte[] FinalDecrypt(byte[] inputBuffer, int inputOffset, int inputCount)
|
||||
{
|
||||
if (inputCount % this.BlockSizeByte > 0)
|
||||
{
|
||||
throw new CryptographicException("Invalid input block size.");
|
||||
}
|
||||
int num = inputCount;
|
||||
if (this.lastBlock)
|
||||
{
|
||||
num += this.BlockSizeByte;
|
||||
}
|
||||
byte[] array = new byte[num];
|
||||
int num2 = 0;
|
||||
while (inputCount > 0)
|
||||
{
|
||||
int num3 = this.InternalTransformBlock(inputBuffer, inputOffset, this.BlockSizeByte, array, num2);
|
||||
inputOffset += this.BlockSizeByte;
|
||||
num2 += num3;
|
||||
inputCount -= this.BlockSizeByte;
|
||||
}
|
||||
if (this.lastBlock)
|
||||
{
|
||||
this.Transform(this.workBuff, this.workout);
|
||||
Buffer.BlockCopy(this.workout, 0, array, num2, this.BlockSizeByte);
|
||||
num2 += this.BlockSizeByte;
|
||||
this.lastBlock = false;
|
||||
}
|
||||
byte b = ((num <= 0) ? 0 : array[num - 1]);
|
||||
switch (this.algo.Padding)
|
||||
{
|
||||
case PaddingMode.PKCS7:
|
||||
{
|
||||
if (b == 0 || (int)b > this.BlockSizeByte)
|
||||
{
|
||||
this.ThrowBadPaddingException(this.algo.Padding, (int)b, -1);
|
||||
}
|
||||
for (int i = (int)(b - 1); i > 0; i--)
|
||||
{
|
||||
if (array[num - 1 - i] != b)
|
||||
{
|
||||
this.ThrowBadPaddingException(this.algo.Padding, -1, i);
|
||||
}
|
||||
}
|
||||
num -= (int)b;
|
||||
break;
|
||||
}
|
||||
case PaddingMode.ANSIX923:
|
||||
{
|
||||
if (b == 0 || (int)b > this.BlockSizeByte)
|
||||
{
|
||||
this.ThrowBadPaddingException(this.algo.Padding, (int)b, -1);
|
||||
}
|
||||
for (int j = (int)(b - 1); j > 0; j--)
|
||||
{
|
||||
if (array[num - 1 - j] != 0)
|
||||
{
|
||||
this.ThrowBadPaddingException(this.algo.Padding, -1, j);
|
||||
}
|
||||
}
|
||||
num -= (int)b;
|
||||
break;
|
||||
}
|
||||
case PaddingMode.ISO10126:
|
||||
if (b == 0 || (int)b > this.BlockSizeByte)
|
||||
{
|
||||
this.ThrowBadPaddingException(this.algo.Padding, (int)b, -1);
|
||||
}
|
||||
num -= (int)b;
|
||||
break;
|
||||
}
|
||||
if (num > 0)
|
||||
{
|
||||
byte[] array2 = new byte[num];
|
||||
Buffer.BlockCopy(array, 0, array2, 0, num);
|
||||
Array.Clear(array, 0, array.Length);
|
||||
return array2;
|
||||
}
|
||||
return new byte[0];
|
||||
}
|
||||
|
||||
// Token: 0x06000993 RID: 2451 RVA: 0x000277F8 File Offset: 0x000259F8
|
||||
public virtual byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount)
|
||||
{
|
||||
if (this.m_disposed)
|
||||
{
|
||||
throw new ObjectDisposedException("Object is disposed");
|
||||
}
|
||||
this.CheckInput(inputBuffer, inputOffset, inputCount);
|
||||
if (this.encrypt)
|
||||
{
|
||||
return this.FinalEncrypt(inputBuffer, inputOffset, inputCount);
|
||||
}
|
||||
return this.FinalDecrypt(inputBuffer, inputOffset, inputCount);
|
||||
}
|
||||
|
||||
// Token: 0x0400021E RID: 542
|
||||
protected SymmetricAlgorithm algo;
|
||||
|
||||
// Token: 0x0400021F RID: 543
|
||||
protected bool encrypt;
|
||||
|
||||
// Token: 0x04000220 RID: 544
|
||||
private int BlockSizeByte;
|
||||
|
||||
// Token: 0x04000221 RID: 545
|
||||
private byte[] temp;
|
||||
|
||||
// Token: 0x04000222 RID: 546
|
||||
private byte[] temp2;
|
||||
|
||||
// Token: 0x04000223 RID: 547
|
||||
private byte[] workBuff;
|
||||
|
||||
// Token: 0x04000224 RID: 548
|
||||
private byte[] workout;
|
||||
|
||||
// Token: 0x04000225 RID: 549
|
||||
private int FeedBackByte;
|
||||
|
||||
// Token: 0x04000226 RID: 550
|
||||
private int FeedBackIter;
|
||||
|
||||
// Token: 0x04000227 RID: 551
|
||||
private bool m_disposed;
|
||||
|
||||
// Token: 0x04000228 RID: 552
|
||||
private bool lastBlock;
|
||||
|
||||
// Token: 0x04000229 RID: 553
|
||||
private RandomNumberGenerator _rng;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,1267 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Security.Cryptography;
|
||||
using Mono.Security.X509;
|
||||
|
||||
namespace Mono.Security
|
||||
{
|
||||
// Token: 0x020000DD RID: 221
|
||||
internal sealed class PKCS7
|
||||
{
|
||||
// Token: 0x06000B10 RID: 2832 RVA: 0x00030E6C File Offset: 0x0002F06C
|
||||
private PKCS7()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000B11 RID: 2833 RVA: 0x00030E74 File Offset: 0x0002F074
|
||||
public static ASN1 Attribute(string oid, ASN1 value)
|
||||
{
|
||||
ASN1 asn = new ASN1(48);
|
||||
asn.Add(ASN1Convert.FromOid(oid));
|
||||
ASN1 asn2 = asn.Add(new ASN1(49));
|
||||
asn2.Add(value);
|
||||
return asn;
|
||||
}
|
||||
|
||||
// Token: 0x06000B12 RID: 2834 RVA: 0x00030EB0 File Offset: 0x0002F0B0
|
||||
public static ASN1 AlgorithmIdentifier(string oid)
|
||||
{
|
||||
ASN1 asn = new ASN1(48);
|
||||
asn.Add(ASN1Convert.FromOid(oid));
|
||||
asn.Add(new ASN1(5));
|
||||
return asn;
|
||||
}
|
||||
|
||||
// Token: 0x06000B13 RID: 2835 RVA: 0x00030EE0 File Offset: 0x0002F0E0
|
||||
public static ASN1 AlgorithmIdentifier(string oid, ASN1 parameters)
|
||||
{
|
||||
ASN1 asn = new ASN1(48);
|
||||
asn.Add(ASN1Convert.FromOid(oid));
|
||||
asn.Add(parameters);
|
||||
return asn;
|
||||
}
|
||||
|
||||
// Token: 0x06000B14 RID: 2836 RVA: 0x00030F0C File Offset: 0x0002F10C
|
||||
public static ASN1 IssuerAndSerialNumber(X509Certificate x509)
|
||||
{
|
||||
ASN1 asn = null;
|
||||
ASN1 asn2 = null;
|
||||
ASN1 asn3 = new ASN1(x509.RawData);
|
||||
int i = 0;
|
||||
bool flag = false;
|
||||
while (i < asn3[0].Count)
|
||||
{
|
||||
ASN1 asn4 = asn3[0][i++];
|
||||
if (asn4.Tag == 2)
|
||||
{
|
||||
asn2 = asn4;
|
||||
}
|
||||
else if (asn4.Tag == 48)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
asn = asn4;
|
||||
break;
|
||||
}
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
ASN1 asn5 = new ASN1(48);
|
||||
asn5.Add(asn);
|
||||
asn5.Add(asn2);
|
||||
return asn5;
|
||||
}
|
||||
|
||||
// Token: 0x020000DE RID: 222
|
||||
public class Oid
|
||||
{
|
||||
// Token: 0x040002D7 RID: 727
|
||||
public const string rsaEncryption = "1.2.840.113549.1.1.1";
|
||||
|
||||
// Token: 0x040002D8 RID: 728
|
||||
public const string data = "1.2.840.113549.1.7.1";
|
||||
|
||||
// Token: 0x040002D9 RID: 729
|
||||
public const string signedData = "1.2.840.113549.1.7.2";
|
||||
|
||||
// Token: 0x040002DA RID: 730
|
||||
public const string envelopedData = "1.2.840.113549.1.7.3";
|
||||
|
||||
// Token: 0x040002DB RID: 731
|
||||
public const string signedAndEnvelopedData = "1.2.840.113549.1.7.4";
|
||||
|
||||
// Token: 0x040002DC RID: 732
|
||||
public const string digestedData = "1.2.840.113549.1.7.5";
|
||||
|
||||
// Token: 0x040002DD RID: 733
|
||||
public const string encryptedData = "1.2.840.113549.1.7.6";
|
||||
|
||||
// Token: 0x040002DE RID: 734
|
||||
public const string contentType = "1.2.840.113549.1.9.3";
|
||||
|
||||
// Token: 0x040002DF RID: 735
|
||||
public const string messageDigest = "1.2.840.113549.1.9.4";
|
||||
|
||||
// Token: 0x040002E0 RID: 736
|
||||
public const string signingTime = "1.2.840.113549.1.9.5";
|
||||
|
||||
// Token: 0x040002E1 RID: 737
|
||||
public const string countersignature = "1.2.840.113549.1.9.6";
|
||||
}
|
||||
|
||||
// Token: 0x020000DF RID: 223
|
||||
public class ContentInfo
|
||||
{
|
||||
// Token: 0x06000B16 RID: 2838 RVA: 0x00030FB4 File Offset: 0x0002F1B4
|
||||
public ContentInfo()
|
||||
{
|
||||
this.content = new ASN1(160);
|
||||
}
|
||||
|
||||
// Token: 0x06000B17 RID: 2839 RVA: 0x00030FCC File Offset: 0x0002F1CC
|
||||
public ContentInfo(string oid)
|
||||
: this()
|
||||
{
|
||||
this.contentType = oid;
|
||||
}
|
||||
|
||||
// Token: 0x06000B18 RID: 2840 RVA: 0x00030FDC File Offset: 0x0002F1DC
|
||||
public ContentInfo(byte[] data)
|
||||
: this(new ASN1(data))
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000B19 RID: 2841 RVA: 0x00030FEC File Offset: 0x0002F1EC
|
||||
public ContentInfo(ASN1 asn1)
|
||||
{
|
||||
if (asn1.Tag != 48 || (asn1.Count < 1 && asn1.Count > 2))
|
||||
{
|
||||
throw new ArgumentException("Invalid ASN1");
|
||||
}
|
||||
if (asn1[0].Tag != 6)
|
||||
{
|
||||
throw new ArgumentException("Invalid contentType");
|
||||
}
|
||||
this.contentType = ASN1Convert.ToOid(asn1[0]);
|
||||
if (asn1.Count > 1)
|
||||
{
|
||||
if (asn1[1].Tag != 160)
|
||||
{
|
||||
throw new ArgumentException("Invalid content");
|
||||
}
|
||||
this.content = asn1[1];
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000173 RID: 371
|
||||
// (get) Token: 0x06000B1A RID: 2842 RVA: 0x00031098 File Offset: 0x0002F298
|
||||
public ASN1 ASN1
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.GetASN1();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000174 RID: 372
|
||||
// (get) Token: 0x06000B1B RID: 2843 RVA: 0x000310A0 File Offset: 0x0002F2A0
|
||||
// (set) Token: 0x06000B1C RID: 2844 RVA: 0x000310A8 File Offset: 0x0002F2A8
|
||||
public ASN1 Content
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.content;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.content = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000175 RID: 373
|
||||
// (get) Token: 0x06000B1D RID: 2845 RVA: 0x000310B4 File Offset: 0x0002F2B4
|
||||
// (set) Token: 0x06000B1E RID: 2846 RVA: 0x000310BC File Offset: 0x0002F2BC
|
||||
public string ContentType
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.contentType;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.contentType = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000B1F RID: 2847 RVA: 0x000310C8 File Offset: 0x0002F2C8
|
||||
internal ASN1 GetASN1()
|
||||
{
|
||||
ASN1 asn = new ASN1(48);
|
||||
asn.Add(ASN1Convert.FromOid(this.contentType));
|
||||
if (this.content != null && this.content.Count > 0)
|
||||
{
|
||||
asn.Add(this.content);
|
||||
}
|
||||
return asn;
|
||||
}
|
||||
|
||||
// Token: 0x06000B20 RID: 2848 RVA: 0x0003111C File Offset: 0x0002F31C
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
return this.GetASN1().GetBytes();
|
||||
}
|
||||
|
||||
// Token: 0x040002E2 RID: 738
|
||||
private string contentType;
|
||||
|
||||
// Token: 0x040002E3 RID: 739
|
||||
private ASN1 content;
|
||||
}
|
||||
|
||||
// Token: 0x020000E0 RID: 224
|
||||
public class EncryptedData
|
||||
{
|
||||
// Token: 0x06000B21 RID: 2849 RVA: 0x0003112C File Offset: 0x0002F32C
|
||||
public EncryptedData()
|
||||
{
|
||||
this._version = 0;
|
||||
}
|
||||
|
||||
// Token: 0x06000B22 RID: 2850 RVA: 0x0003113C File Offset: 0x0002F33C
|
||||
public EncryptedData(byte[] data)
|
||||
: this(new ASN1(data))
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000B23 RID: 2851 RVA: 0x0003114C File Offset: 0x0002F34C
|
||||
public EncryptedData(ASN1 asn1)
|
||||
: this()
|
||||
{
|
||||
if (asn1.Tag != 48 || asn1.Count < 2)
|
||||
{
|
||||
throw new ArgumentException("Invalid EncryptedData");
|
||||
}
|
||||
if (asn1[0].Tag != 2)
|
||||
{
|
||||
throw new ArgumentException("Invalid version");
|
||||
}
|
||||
this._version = asn1[0].Value[0];
|
||||
ASN1 asn2 = asn1[1];
|
||||
if (asn2.Tag != 48)
|
||||
{
|
||||
throw new ArgumentException("missing EncryptedContentInfo");
|
||||
}
|
||||
ASN1 asn3 = asn2[0];
|
||||
if (asn3.Tag != 6)
|
||||
{
|
||||
throw new ArgumentException("missing EncryptedContentInfo.ContentType");
|
||||
}
|
||||
this._content = new PKCS7.ContentInfo(ASN1Convert.ToOid(asn3));
|
||||
ASN1 asn4 = asn2[1];
|
||||
if (asn4.Tag != 48)
|
||||
{
|
||||
throw new ArgumentException("missing EncryptedContentInfo.ContentEncryptionAlgorithmIdentifier");
|
||||
}
|
||||
this._encryptionAlgorithm = new PKCS7.ContentInfo(ASN1Convert.ToOid(asn4[0]));
|
||||
this._encryptionAlgorithm.Content = asn4[1];
|
||||
ASN1 asn5 = asn2[2];
|
||||
if (asn5.Tag != 128)
|
||||
{
|
||||
throw new ArgumentException("missing EncryptedContentInfo.EncryptedContent");
|
||||
}
|
||||
this._encrypted = asn5.Value;
|
||||
}
|
||||
|
||||
// Token: 0x17000176 RID: 374
|
||||
// (get) Token: 0x06000B24 RID: 2852 RVA: 0x0003127C File Offset: 0x0002F47C
|
||||
public ASN1 ASN1
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.GetASN1();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000177 RID: 375
|
||||
// (get) Token: 0x06000B25 RID: 2853 RVA: 0x00031284 File Offset: 0x0002F484
|
||||
public PKCS7.ContentInfo ContentInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._content;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000178 RID: 376
|
||||
// (get) Token: 0x06000B26 RID: 2854 RVA: 0x0003128C File Offset: 0x0002F48C
|
||||
public PKCS7.ContentInfo EncryptionAlgorithm
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._encryptionAlgorithm;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000179 RID: 377
|
||||
// (get) Token: 0x06000B27 RID: 2855 RVA: 0x00031294 File Offset: 0x0002F494
|
||||
public byte[] EncryptedContent
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._encrypted == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (byte[])this._encrypted.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700017A RID: 378
|
||||
// (get) Token: 0x06000B28 RID: 2856 RVA: 0x000312B4 File Offset: 0x0002F4B4
|
||||
// (set) Token: 0x06000B29 RID: 2857 RVA: 0x000312BC File Offset: 0x0002F4BC
|
||||
public byte Version
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._version;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._version = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000B2A RID: 2858 RVA: 0x000312C8 File Offset: 0x0002F4C8
|
||||
internal ASN1 GetASN1()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x06000B2B RID: 2859 RVA: 0x000312CC File Offset: 0x0002F4CC
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
return this.GetASN1().GetBytes();
|
||||
}
|
||||
|
||||
// Token: 0x040002E4 RID: 740
|
||||
private byte _version;
|
||||
|
||||
// Token: 0x040002E5 RID: 741
|
||||
private PKCS7.ContentInfo _content;
|
||||
|
||||
// Token: 0x040002E6 RID: 742
|
||||
private PKCS7.ContentInfo _encryptionAlgorithm;
|
||||
|
||||
// Token: 0x040002E7 RID: 743
|
||||
private byte[] _encrypted;
|
||||
}
|
||||
|
||||
// Token: 0x020000E1 RID: 225
|
||||
public class EnvelopedData
|
||||
{
|
||||
// Token: 0x06000B2C RID: 2860 RVA: 0x000312DC File Offset: 0x0002F4DC
|
||||
public EnvelopedData()
|
||||
{
|
||||
this._version = 0;
|
||||
this._content = new PKCS7.ContentInfo();
|
||||
this._encryptionAlgorithm = new PKCS7.ContentInfo();
|
||||
this._recipientInfos = new ArrayList();
|
||||
}
|
||||
|
||||
// Token: 0x06000B2D RID: 2861 RVA: 0x00031318 File Offset: 0x0002F518
|
||||
public EnvelopedData(byte[] data)
|
||||
: this(new ASN1(data))
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000B2E RID: 2862 RVA: 0x00031328 File Offset: 0x0002F528
|
||||
public EnvelopedData(ASN1 asn1)
|
||||
: this()
|
||||
{
|
||||
if (asn1[0].Tag != 48 || asn1[0].Count < 3)
|
||||
{
|
||||
throw new ArgumentException("Invalid EnvelopedData");
|
||||
}
|
||||
if (asn1[0][0].Tag != 2)
|
||||
{
|
||||
throw new ArgumentException("Invalid version");
|
||||
}
|
||||
this._version = asn1[0][0].Value[0];
|
||||
ASN1 asn2 = asn1[0][1];
|
||||
if (asn2.Tag != 49)
|
||||
{
|
||||
throw new ArgumentException("missing RecipientInfos");
|
||||
}
|
||||
for (int i = 0; i < asn2.Count; i++)
|
||||
{
|
||||
ASN1 asn3 = asn2[i];
|
||||
this._recipientInfos.Add(new PKCS7.RecipientInfo(asn3));
|
||||
}
|
||||
ASN1 asn4 = asn1[0][2];
|
||||
if (asn4.Tag != 48)
|
||||
{
|
||||
throw new ArgumentException("missing EncryptedContentInfo");
|
||||
}
|
||||
ASN1 asn5 = asn4[0];
|
||||
if (asn5.Tag != 6)
|
||||
{
|
||||
throw new ArgumentException("missing EncryptedContentInfo.ContentType");
|
||||
}
|
||||
this._content = new PKCS7.ContentInfo(ASN1Convert.ToOid(asn5));
|
||||
ASN1 asn6 = asn4[1];
|
||||
if (asn6.Tag != 48)
|
||||
{
|
||||
throw new ArgumentException("missing EncryptedContentInfo.ContentEncryptionAlgorithmIdentifier");
|
||||
}
|
||||
this._encryptionAlgorithm = new PKCS7.ContentInfo(ASN1Convert.ToOid(asn6[0]));
|
||||
this._encryptionAlgorithm.Content = asn6[1];
|
||||
ASN1 asn7 = asn4[2];
|
||||
if (asn7.Tag != 128)
|
||||
{
|
||||
throw new ArgumentException("missing EncryptedContentInfo.EncryptedContent");
|
||||
}
|
||||
this._encrypted = asn7.Value;
|
||||
}
|
||||
|
||||
// Token: 0x1700017B RID: 379
|
||||
// (get) Token: 0x06000B2F RID: 2863 RVA: 0x000314D8 File Offset: 0x0002F6D8
|
||||
public ArrayList RecipientInfos
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._recipientInfos;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700017C RID: 380
|
||||
// (get) Token: 0x06000B30 RID: 2864 RVA: 0x000314E0 File Offset: 0x0002F6E0
|
||||
public ASN1 ASN1
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.GetASN1();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700017D RID: 381
|
||||
// (get) Token: 0x06000B31 RID: 2865 RVA: 0x000314E8 File Offset: 0x0002F6E8
|
||||
public PKCS7.ContentInfo ContentInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._content;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700017E RID: 382
|
||||
// (get) Token: 0x06000B32 RID: 2866 RVA: 0x000314F0 File Offset: 0x0002F6F0
|
||||
public PKCS7.ContentInfo EncryptionAlgorithm
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._encryptionAlgorithm;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700017F RID: 383
|
||||
// (get) Token: 0x06000B33 RID: 2867 RVA: 0x000314F8 File Offset: 0x0002F6F8
|
||||
public byte[] EncryptedContent
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._encrypted == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (byte[])this._encrypted.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000180 RID: 384
|
||||
// (get) Token: 0x06000B34 RID: 2868 RVA: 0x00031518 File Offset: 0x0002F718
|
||||
// (set) Token: 0x06000B35 RID: 2869 RVA: 0x00031520 File Offset: 0x0002F720
|
||||
public byte Version
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._version;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._version = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000B36 RID: 2870 RVA: 0x0003152C File Offset: 0x0002F72C
|
||||
internal ASN1 GetASN1()
|
||||
{
|
||||
return new ASN1(48);
|
||||
}
|
||||
|
||||
// Token: 0x06000B37 RID: 2871 RVA: 0x00031544 File Offset: 0x0002F744
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
return this.GetASN1().GetBytes();
|
||||
}
|
||||
|
||||
// Token: 0x040002E8 RID: 744
|
||||
private byte _version;
|
||||
|
||||
// Token: 0x040002E9 RID: 745
|
||||
private PKCS7.ContentInfo _content;
|
||||
|
||||
// Token: 0x040002EA RID: 746
|
||||
private PKCS7.ContentInfo _encryptionAlgorithm;
|
||||
|
||||
// Token: 0x040002EB RID: 747
|
||||
private ArrayList _recipientInfos;
|
||||
|
||||
// Token: 0x040002EC RID: 748
|
||||
private byte[] _encrypted;
|
||||
}
|
||||
|
||||
// Token: 0x020000E2 RID: 226
|
||||
public class RecipientInfo
|
||||
{
|
||||
// Token: 0x06000B38 RID: 2872 RVA: 0x00031554 File Offset: 0x0002F754
|
||||
public RecipientInfo()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000B39 RID: 2873 RVA: 0x0003155C File Offset: 0x0002F75C
|
||||
public RecipientInfo(ASN1 data)
|
||||
{
|
||||
if (data.Tag != 48)
|
||||
{
|
||||
throw new ArgumentException("Invalid RecipientInfo");
|
||||
}
|
||||
ASN1 asn = data[0];
|
||||
if (asn.Tag != 2)
|
||||
{
|
||||
throw new ArgumentException("missing Version");
|
||||
}
|
||||
this._version = (int)asn.Value[0];
|
||||
ASN1 asn2 = data[1];
|
||||
if (asn2.Tag == 128 && this._version == 3)
|
||||
{
|
||||
this._ski = asn2.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._issuer = X501.ToString(asn2[0]);
|
||||
this._serial = asn2[1].Value;
|
||||
}
|
||||
ASN1 asn3 = data[2];
|
||||
this._oid = ASN1Convert.ToOid(asn3[0]);
|
||||
ASN1 asn4 = data[3];
|
||||
this._key = asn4.Value;
|
||||
}
|
||||
|
||||
// Token: 0x17000181 RID: 385
|
||||
// (get) Token: 0x06000B3A RID: 2874 RVA: 0x0003163C File Offset: 0x0002F83C
|
||||
public string Oid
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._oid;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000182 RID: 386
|
||||
// (get) Token: 0x06000B3B RID: 2875 RVA: 0x00031644 File Offset: 0x0002F844
|
||||
public byte[] Key
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._key == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (byte[])this._key.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000183 RID: 387
|
||||
// (get) Token: 0x06000B3C RID: 2876 RVA: 0x00031664 File Offset: 0x0002F864
|
||||
public byte[] SubjectKeyIdentifier
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._ski == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (byte[])this._ski.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000184 RID: 388
|
||||
// (get) Token: 0x06000B3D RID: 2877 RVA: 0x00031684 File Offset: 0x0002F884
|
||||
public string Issuer
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._issuer;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000185 RID: 389
|
||||
// (get) Token: 0x06000B3E RID: 2878 RVA: 0x0003168C File Offset: 0x0002F88C
|
||||
public byte[] Serial
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._serial == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (byte[])this._serial.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000186 RID: 390
|
||||
// (get) Token: 0x06000B3F RID: 2879 RVA: 0x000316AC File Offset: 0x0002F8AC
|
||||
public int Version
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._version;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x040002ED RID: 749
|
||||
private int _version;
|
||||
|
||||
// Token: 0x040002EE RID: 750
|
||||
private string _oid;
|
||||
|
||||
// Token: 0x040002EF RID: 751
|
||||
private byte[] _key;
|
||||
|
||||
// Token: 0x040002F0 RID: 752
|
||||
private byte[] _ski;
|
||||
|
||||
// Token: 0x040002F1 RID: 753
|
||||
private string _issuer;
|
||||
|
||||
// Token: 0x040002F2 RID: 754
|
||||
private byte[] _serial;
|
||||
}
|
||||
|
||||
// Token: 0x020000E3 RID: 227
|
||||
public class SignedData
|
||||
{
|
||||
// Token: 0x06000B40 RID: 2880 RVA: 0x000316B4 File Offset: 0x0002F8B4
|
||||
public SignedData()
|
||||
{
|
||||
this.version = 1;
|
||||
this.contentInfo = new PKCS7.ContentInfo();
|
||||
this.certs = new X509CertificateCollection();
|
||||
this.crls = new ArrayList();
|
||||
this.signerInfo = new PKCS7.SignerInfo();
|
||||
this.mda = true;
|
||||
this.signed = false;
|
||||
}
|
||||
|
||||
// Token: 0x06000B41 RID: 2881 RVA: 0x00031708 File Offset: 0x0002F908
|
||||
public SignedData(byte[] data)
|
||||
: this(new ASN1(data))
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000B42 RID: 2882 RVA: 0x00031718 File Offset: 0x0002F918
|
||||
public SignedData(ASN1 asn1)
|
||||
{
|
||||
if (asn1[0].Tag != 48 || asn1[0].Count < 4)
|
||||
{
|
||||
throw new ArgumentException("Invalid SignedData");
|
||||
}
|
||||
if (asn1[0][0].Tag != 2)
|
||||
{
|
||||
throw new ArgumentException("Invalid version");
|
||||
}
|
||||
this.version = asn1[0][0].Value[0];
|
||||
this.contentInfo = new PKCS7.ContentInfo(asn1[0][2]);
|
||||
int num = 3;
|
||||
this.certs = new X509CertificateCollection();
|
||||
if (asn1[0][num].Tag == 160)
|
||||
{
|
||||
for (int i = 0; i < asn1[0][num].Count; i++)
|
||||
{
|
||||
this.certs.Add(new X509Certificate(asn1[0][num][i].GetBytes()));
|
||||
}
|
||||
num++;
|
||||
}
|
||||
this.crls = new ArrayList();
|
||||
if (asn1[0][num].Tag == 161)
|
||||
{
|
||||
for (int j = 0; j < asn1[0][num].Count; j++)
|
||||
{
|
||||
this.crls.Add(asn1[0][num][j].GetBytes());
|
||||
}
|
||||
num++;
|
||||
}
|
||||
if (asn1[0][num].Count > 0)
|
||||
{
|
||||
this.signerInfo = new PKCS7.SignerInfo(asn1[0][num]);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.signerInfo = new PKCS7.SignerInfo();
|
||||
}
|
||||
if (this.signerInfo.HashName != null)
|
||||
{
|
||||
this.HashName = this.OidToName(this.signerInfo.HashName);
|
||||
}
|
||||
this.mda = this.signerInfo.AuthenticatedAttributes.Count > 0;
|
||||
}
|
||||
|
||||
// Token: 0x17000187 RID: 391
|
||||
// (get) Token: 0x06000B43 RID: 2883 RVA: 0x0003191C File Offset: 0x0002FB1C
|
||||
public ASN1 ASN1
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.GetASN1();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000188 RID: 392
|
||||
// (get) Token: 0x06000B44 RID: 2884 RVA: 0x00031924 File Offset: 0x0002FB24
|
||||
public X509CertificateCollection Certificates
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.certs;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000189 RID: 393
|
||||
// (get) Token: 0x06000B45 RID: 2885 RVA: 0x0003192C File Offset: 0x0002FB2C
|
||||
public PKCS7.ContentInfo ContentInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.contentInfo;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700018A RID: 394
|
||||
// (get) Token: 0x06000B46 RID: 2886 RVA: 0x00031934 File Offset: 0x0002FB34
|
||||
public ArrayList Crls
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.crls;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700018B RID: 395
|
||||
// (get) Token: 0x06000B47 RID: 2887 RVA: 0x0003193C File Offset: 0x0002FB3C
|
||||
// (set) Token: 0x06000B48 RID: 2888 RVA: 0x00031944 File Offset: 0x0002FB44
|
||||
public string HashName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.hashAlgorithm;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.hashAlgorithm = value;
|
||||
this.signerInfo.HashName = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700018C RID: 396
|
||||
// (get) Token: 0x06000B49 RID: 2889 RVA: 0x0003195C File Offset: 0x0002FB5C
|
||||
public PKCS7.SignerInfo SignerInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.signerInfo;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700018D RID: 397
|
||||
// (get) Token: 0x06000B4A RID: 2890 RVA: 0x00031964 File Offset: 0x0002FB64
|
||||
// (set) Token: 0x06000B4B RID: 2891 RVA: 0x0003196C File Offset: 0x0002FB6C
|
||||
public byte Version
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.version;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.version = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700018E RID: 398
|
||||
// (get) Token: 0x06000B4C RID: 2892 RVA: 0x00031978 File Offset: 0x0002FB78
|
||||
// (set) Token: 0x06000B4D RID: 2893 RVA: 0x00031980 File Offset: 0x0002FB80
|
||||
public bool UseAuthenticatedAttributes
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.mda;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.mda = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000B4E RID: 2894 RVA: 0x0003198C File Offset: 0x0002FB8C
|
||||
public bool VerifySignature(AsymmetricAlgorithm aa)
|
||||
{
|
||||
if (aa == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
RSAPKCS1SignatureDeformatter rsapkcs1SignatureDeformatter = new RSAPKCS1SignatureDeformatter(aa);
|
||||
rsapkcs1SignatureDeformatter.SetHashAlgorithm(this.hashAlgorithm);
|
||||
HashAlgorithm hashAlgorithm = HashAlgorithm.Create(this.hashAlgorithm);
|
||||
byte[] signature = this.signerInfo.Signature;
|
||||
byte[] array;
|
||||
if (this.mda)
|
||||
{
|
||||
ASN1 asn = new ASN1(49);
|
||||
foreach (object obj in this.signerInfo.AuthenticatedAttributes)
|
||||
{
|
||||
ASN1 asn2 = (ASN1)obj;
|
||||
asn.Add(asn2);
|
||||
}
|
||||
array = hashAlgorithm.ComputeHash(asn.GetBytes());
|
||||
}
|
||||
else
|
||||
{
|
||||
array = hashAlgorithm.ComputeHash(this.contentInfo.Content[0].Value);
|
||||
}
|
||||
return array != null && signature != null && rsapkcs1SignatureDeformatter.VerifySignature(array, signature);
|
||||
}
|
||||
|
||||
// Token: 0x06000B4F RID: 2895 RVA: 0x00031A9C File Offset: 0x0002FC9C
|
||||
internal string OidToName(string oid)
|
||||
{
|
||||
switch (oid)
|
||||
{
|
||||
case "1.3.14.3.2.26":
|
||||
return "SHA1";
|
||||
case "1.2.840.113549.2.2":
|
||||
return "MD2";
|
||||
case "1.2.840.113549.2.5":
|
||||
return "MD5";
|
||||
case "2.16.840.1.101.3.4.1":
|
||||
return "SHA256";
|
||||
case "2.16.840.1.101.3.4.2":
|
||||
return "SHA384";
|
||||
case "2.16.840.1.101.3.4.3":
|
||||
return "SHA512";
|
||||
}
|
||||
return oid;
|
||||
}
|
||||
|
||||
// Token: 0x06000B50 RID: 2896 RVA: 0x00031B70 File Offset: 0x0002FD70
|
||||
internal ASN1 GetASN1()
|
||||
{
|
||||
ASN1 asn = new ASN1(48);
|
||||
byte[] array = new byte[] { this.version };
|
||||
asn.Add(new ASN1(2, array));
|
||||
ASN1 asn2 = asn.Add(new ASN1(49));
|
||||
if (this.hashAlgorithm != null)
|
||||
{
|
||||
string text = CryptoConfig.MapNameToOID(this.hashAlgorithm);
|
||||
asn2.Add(PKCS7.AlgorithmIdentifier(text));
|
||||
}
|
||||
ASN1 asn3 = this.contentInfo.ASN1;
|
||||
asn.Add(asn3);
|
||||
if (!this.signed && this.hashAlgorithm != null)
|
||||
{
|
||||
if (this.mda)
|
||||
{
|
||||
ASN1 asn4 = PKCS7.Attribute("1.2.840.113549.1.9.3", asn3[0]);
|
||||
this.signerInfo.AuthenticatedAttributes.Add(asn4);
|
||||
HashAlgorithm hashAlgorithm = HashAlgorithm.Create(this.hashAlgorithm);
|
||||
byte[] array2 = hashAlgorithm.ComputeHash(asn3[1][0].Value);
|
||||
ASN1 asn5 = new ASN1(48);
|
||||
ASN1 asn6 = PKCS7.Attribute("1.2.840.113549.1.9.4", asn5.Add(new ASN1(4, array2)));
|
||||
this.signerInfo.AuthenticatedAttributes.Add(asn6);
|
||||
}
|
||||
else
|
||||
{
|
||||
RSAPKCS1SignatureFormatter rsapkcs1SignatureFormatter = new RSAPKCS1SignatureFormatter(this.signerInfo.Key);
|
||||
rsapkcs1SignatureFormatter.SetHashAlgorithm(this.hashAlgorithm);
|
||||
HashAlgorithm hashAlgorithm2 = HashAlgorithm.Create(this.hashAlgorithm);
|
||||
byte[] array3 = hashAlgorithm2.ComputeHash(asn3[1][0].Value);
|
||||
this.signerInfo.Signature = rsapkcs1SignatureFormatter.CreateSignature(array3);
|
||||
}
|
||||
this.signed = true;
|
||||
}
|
||||
if (this.certs.Count > 0)
|
||||
{
|
||||
ASN1 asn7 = asn.Add(new ASN1(160));
|
||||
foreach (X509Certificate x509Certificate in this.certs)
|
||||
{
|
||||
asn7.Add(new ASN1(x509Certificate.RawData));
|
||||
}
|
||||
}
|
||||
if (this.crls.Count > 0)
|
||||
{
|
||||
ASN1 asn8 = asn.Add(new ASN1(161));
|
||||
foreach (object obj in this.crls)
|
||||
{
|
||||
byte[] array4 = (byte[])obj;
|
||||
asn8.Add(new ASN1(array4));
|
||||
}
|
||||
}
|
||||
ASN1 asn9 = asn.Add(new ASN1(49));
|
||||
if (this.signerInfo.Key != null)
|
||||
{
|
||||
asn9.Add(this.signerInfo.ASN1);
|
||||
}
|
||||
return asn;
|
||||
}
|
||||
|
||||
// Token: 0x06000B51 RID: 2897 RVA: 0x00031E54 File Offset: 0x00030054
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
return this.GetASN1().GetBytes();
|
||||
}
|
||||
|
||||
// Token: 0x040002F3 RID: 755
|
||||
private byte version;
|
||||
|
||||
// Token: 0x040002F4 RID: 756
|
||||
private string hashAlgorithm;
|
||||
|
||||
// Token: 0x040002F5 RID: 757
|
||||
private PKCS7.ContentInfo contentInfo;
|
||||
|
||||
// Token: 0x040002F6 RID: 758
|
||||
private X509CertificateCollection certs;
|
||||
|
||||
// Token: 0x040002F7 RID: 759
|
||||
private ArrayList crls;
|
||||
|
||||
// Token: 0x040002F8 RID: 760
|
||||
private PKCS7.SignerInfo signerInfo;
|
||||
|
||||
// Token: 0x040002F9 RID: 761
|
||||
private bool mda;
|
||||
|
||||
// Token: 0x040002FA RID: 762
|
||||
private bool signed;
|
||||
}
|
||||
|
||||
// Token: 0x020000E4 RID: 228
|
||||
public class SignerInfo
|
||||
{
|
||||
// Token: 0x06000B52 RID: 2898 RVA: 0x00031E64 File Offset: 0x00030064
|
||||
public SignerInfo()
|
||||
{
|
||||
this.version = 1;
|
||||
this.authenticatedAttributes = new ArrayList();
|
||||
this.unauthenticatedAttributes = new ArrayList();
|
||||
}
|
||||
|
||||
// Token: 0x06000B53 RID: 2899 RVA: 0x00031E8C File Offset: 0x0003008C
|
||||
public SignerInfo(byte[] data)
|
||||
: this(new ASN1(data))
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000B54 RID: 2900 RVA: 0x00031E9C File Offset: 0x0003009C
|
||||
public SignerInfo(ASN1 asn1)
|
||||
: this()
|
||||
{
|
||||
if (asn1[0].Tag != 48 || asn1[0].Count < 5)
|
||||
{
|
||||
throw new ArgumentException("Invalid SignedData");
|
||||
}
|
||||
if (asn1[0][0].Tag != 2)
|
||||
{
|
||||
throw new ArgumentException("Invalid version");
|
||||
}
|
||||
this.version = asn1[0][0].Value[0];
|
||||
ASN1 asn2 = asn1[0][1];
|
||||
if (asn2.Tag == 128 && this.version == 3)
|
||||
{
|
||||
this.ski = asn2.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.issuer = X501.ToString(asn2[0]);
|
||||
this.serial = asn2[1].Value;
|
||||
}
|
||||
ASN1 asn3 = asn1[0][2];
|
||||
this.hashAlgorithm = ASN1Convert.ToOid(asn3[0]);
|
||||
int num = 3;
|
||||
ASN1 asn4 = asn1[0][num];
|
||||
if (asn4.Tag == 160)
|
||||
{
|
||||
num++;
|
||||
for (int i = 0; i < asn4.Count; i++)
|
||||
{
|
||||
this.authenticatedAttributes.Add(asn4[i]);
|
||||
}
|
||||
}
|
||||
num++;
|
||||
ASN1 asn5 = asn1[0][num++];
|
||||
if (asn5.Tag == 4)
|
||||
{
|
||||
this.signature = asn5.Value;
|
||||
}
|
||||
ASN1 asn6 = asn1[0][num];
|
||||
if (asn6 != null && asn6.Tag == 161)
|
||||
{
|
||||
for (int j = 0; j < asn6.Count; j++)
|
||||
{
|
||||
this.unauthenticatedAttributes.Add(asn6[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700018F RID: 399
|
||||
// (get) Token: 0x06000B55 RID: 2901 RVA: 0x00032078 File Offset: 0x00030278
|
||||
public string IssuerName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.issuer;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000190 RID: 400
|
||||
// (get) Token: 0x06000B56 RID: 2902 RVA: 0x00032080 File Offset: 0x00030280
|
||||
public byte[] SerialNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.serial == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (byte[])this.serial.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000191 RID: 401
|
||||
// (get) Token: 0x06000B57 RID: 2903 RVA: 0x000320A0 File Offset: 0x000302A0
|
||||
public byte[] SubjectKeyIdentifier
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.ski == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (byte[])this.ski.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000192 RID: 402
|
||||
// (get) Token: 0x06000B58 RID: 2904 RVA: 0x000320C0 File Offset: 0x000302C0
|
||||
public ASN1 ASN1
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.GetASN1();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000193 RID: 403
|
||||
// (get) Token: 0x06000B59 RID: 2905 RVA: 0x000320C8 File Offset: 0x000302C8
|
||||
public ArrayList AuthenticatedAttributes
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.authenticatedAttributes;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000194 RID: 404
|
||||
// (get) Token: 0x06000B5A RID: 2906 RVA: 0x000320D0 File Offset: 0x000302D0
|
||||
// (set) Token: 0x06000B5B RID: 2907 RVA: 0x000320D8 File Offset: 0x000302D8
|
||||
public X509Certificate Certificate
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.x509;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.x509 = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000195 RID: 405
|
||||
// (get) Token: 0x06000B5C RID: 2908 RVA: 0x000320E4 File Offset: 0x000302E4
|
||||
// (set) Token: 0x06000B5D RID: 2909 RVA: 0x000320EC File Offset: 0x000302EC
|
||||
public string HashName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.hashAlgorithm;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.hashAlgorithm = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000196 RID: 406
|
||||
// (get) Token: 0x06000B5E RID: 2910 RVA: 0x000320F8 File Offset: 0x000302F8
|
||||
// (set) Token: 0x06000B5F RID: 2911 RVA: 0x00032100 File Offset: 0x00030300
|
||||
public AsymmetricAlgorithm Key
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.key;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.key = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000197 RID: 407
|
||||
// (get) Token: 0x06000B60 RID: 2912 RVA: 0x0003210C File Offset: 0x0003030C
|
||||
// (set) Token: 0x06000B61 RID: 2913 RVA: 0x0003212C File Offset: 0x0003032C
|
||||
public byte[] Signature
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.signature == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (byte[])this.signature.Clone();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
this.signature = (byte[])value.Clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000198 RID: 408
|
||||
// (get) Token: 0x06000B62 RID: 2914 RVA: 0x00032148 File Offset: 0x00030348
|
||||
public ArrayList UnauthenticatedAttributes
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.unauthenticatedAttributes;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000199 RID: 409
|
||||
// (get) Token: 0x06000B63 RID: 2915 RVA: 0x00032150 File Offset: 0x00030350
|
||||
// (set) Token: 0x06000B64 RID: 2916 RVA: 0x00032158 File Offset: 0x00030358
|
||||
public byte Version
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.version;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.version = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000B65 RID: 2917 RVA: 0x00032164 File Offset: 0x00030364
|
||||
internal ASN1 GetASN1()
|
||||
{
|
||||
if (this.key == null || this.hashAlgorithm == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
byte[] array = new byte[] { this.version };
|
||||
ASN1 asn = new ASN1(48);
|
||||
asn.Add(new ASN1(2, array));
|
||||
asn.Add(PKCS7.IssuerAndSerialNumber(this.x509));
|
||||
string text = CryptoConfig.MapNameToOID(this.hashAlgorithm);
|
||||
asn.Add(PKCS7.AlgorithmIdentifier(text));
|
||||
ASN1 asn2 = null;
|
||||
if (this.authenticatedAttributes.Count > 0)
|
||||
{
|
||||
asn2 = asn.Add(new ASN1(160));
|
||||
foreach (object obj in this.authenticatedAttributes)
|
||||
{
|
||||
ASN1 asn3 = (ASN1)obj;
|
||||
asn2.Add(asn3);
|
||||
}
|
||||
}
|
||||
if (this.key is RSA)
|
||||
{
|
||||
asn.Add(PKCS7.AlgorithmIdentifier("1.2.840.113549.1.1.1"));
|
||||
if (asn2 != null)
|
||||
{
|
||||
RSAPKCS1SignatureFormatter rsapkcs1SignatureFormatter = new RSAPKCS1SignatureFormatter(this.key);
|
||||
rsapkcs1SignatureFormatter.SetHashAlgorithm(this.hashAlgorithm);
|
||||
byte[] bytes = asn2.GetBytes();
|
||||
bytes[0] = 49;
|
||||
HashAlgorithm hashAlgorithm = HashAlgorithm.Create(this.hashAlgorithm);
|
||||
byte[] array2 = hashAlgorithm.ComputeHash(bytes);
|
||||
this.signature = rsapkcs1SignatureFormatter.CreateSignature(array2);
|
||||
}
|
||||
asn.Add(new ASN1(4, this.signature));
|
||||
if (this.unauthenticatedAttributes.Count > 0)
|
||||
{
|
||||
ASN1 asn4 = asn.Add(new ASN1(161));
|
||||
foreach (object obj2 in this.unauthenticatedAttributes)
|
||||
{
|
||||
ASN1 asn5 = (ASN1)obj2;
|
||||
asn4.Add(asn5);
|
||||
}
|
||||
}
|
||||
return asn;
|
||||
}
|
||||
if (this.key is DSA)
|
||||
{
|
||||
throw new NotImplementedException("not yet");
|
||||
}
|
||||
throw new CryptographicException("Unknown assymetric algorithm");
|
||||
}
|
||||
|
||||
// Token: 0x06000B66 RID: 2918 RVA: 0x000323AC File Offset: 0x000305AC
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
return this.GetASN1().GetBytes();
|
||||
}
|
||||
|
||||
// Token: 0x040002FC RID: 764
|
||||
private byte version;
|
||||
|
||||
// Token: 0x040002FD RID: 765
|
||||
private X509Certificate x509;
|
||||
|
||||
// Token: 0x040002FE RID: 766
|
||||
private string hashAlgorithm;
|
||||
|
||||
// Token: 0x040002FF RID: 767
|
||||
private AsymmetricAlgorithm key;
|
||||
|
||||
// Token: 0x04000300 RID: 768
|
||||
private ArrayList authenticatedAttributes;
|
||||
|
||||
// Token: 0x04000301 RID: 769
|
||||
private ArrayList unauthenticatedAttributes;
|
||||
|
||||
// Token: 0x04000302 RID: 770
|
||||
private byte[] signature;
|
||||
|
||||
// Token: 0x04000303 RID: 771
|
||||
private string issuer;
|
||||
|
||||
// Token: 0x04000304 RID: 772
|
||||
private byte[] serial;
|
||||
|
||||
// Token: 0x04000305 RID: 773
|
||||
private byte[] ski;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,665 @@
|
||||
using System;
|
||||
using System.Configuration.Assemblies;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using Mono.Security.Cryptography;
|
||||
|
||||
namespace Mono.Security
|
||||
{
|
||||
// Token: 0x020000E5 RID: 229
|
||||
internal sealed class StrongName
|
||||
{
|
||||
// Token: 0x06000B67 RID: 2919 RVA: 0x000323BC File Offset: 0x000305BC
|
||||
public StrongName()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000B68 RID: 2920 RVA: 0x000323C4 File Offset: 0x000305C4
|
||||
public StrongName(int keySize)
|
||||
{
|
||||
this.rsa = new RSAManaged(keySize);
|
||||
}
|
||||
|
||||
// Token: 0x06000B69 RID: 2921 RVA: 0x000323D8 File Offset: 0x000305D8
|
||||
public StrongName(byte[] data)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
throw new ArgumentNullException("data");
|
||||
}
|
||||
if (data.Length == 16)
|
||||
{
|
||||
int i = 0;
|
||||
int num = 0;
|
||||
while (i < data.Length)
|
||||
{
|
||||
num += (int)data[i++];
|
||||
}
|
||||
if (num == 4)
|
||||
{
|
||||
this.publicKey = (byte[])data.Clone();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.RSA = CryptoConvert.FromCapiKeyBlob(data);
|
||||
if (this.rsa == null)
|
||||
{
|
||||
throw new ArgumentException("data isn't a correctly encoded RSA public key");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000B6A RID: 2922 RVA: 0x00032464 File Offset: 0x00030664
|
||||
public StrongName(RSA rsa)
|
||||
{
|
||||
if (rsa == null)
|
||||
{
|
||||
throw new ArgumentNullException("rsa");
|
||||
}
|
||||
this.RSA = rsa;
|
||||
}
|
||||
|
||||
// Token: 0x06000B6C RID: 2924 RVA: 0x00032498 File Offset: 0x00030698
|
||||
private void InvalidateCache()
|
||||
{
|
||||
this.publicKey = null;
|
||||
this.keyToken = null;
|
||||
}
|
||||
|
||||
// Token: 0x1700019A RID: 410
|
||||
// (get) Token: 0x06000B6D RID: 2925 RVA: 0x000324A8 File Offset: 0x000306A8
|
||||
public bool CanSign
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.rsa == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (this.RSA is RSACryptoServiceProvider)
|
||||
{
|
||||
return !(this.rsa as RSACryptoServiceProvider).PublicOnly;
|
||||
}
|
||||
if (this.RSA is RSAManaged)
|
||||
{
|
||||
return !(this.rsa as RSAManaged).PublicOnly;
|
||||
}
|
||||
bool flag;
|
||||
try
|
||||
{
|
||||
RSAParameters rsaparameters = this.rsa.ExportParameters(true);
|
||||
flag = rsaparameters.D != null && rsaparameters.P != null && rsaparameters.Q != null;
|
||||
}
|
||||
catch (CryptographicException)
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700019B RID: 411
|
||||
// (get) Token: 0x06000B6E RID: 2926 RVA: 0x00032574 File Offset: 0x00030774
|
||||
// (set) Token: 0x06000B6F RID: 2927 RVA: 0x00032594 File Offset: 0x00030794
|
||||
public RSA RSA
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.rsa == null)
|
||||
{
|
||||
this.rsa = RSA.Create();
|
||||
}
|
||||
return this.rsa;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.rsa = value;
|
||||
this.InvalidateCache();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700019C RID: 412
|
||||
// (get) Token: 0x06000B70 RID: 2928 RVA: 0x000325A4 File Offset: 0x000307A4
|
||||
public byte[] PublicKey
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.publicKey == null)
|
||||
{
|
||||
byte[] array = CryptoConvert.ToCapiKeyBlob(this.rsa, false);
|
||||
this.publicKey = new byte[32 + (this.rsa.KeySize >> 3)];
|
||||
this.publicKey[0] = array[4];
|
||||
this.publicKey[1] = array[5];
|
||||
this.publicKey[2] = array[6];
|
||||
this.publicKey[3] = array[7];
|
||||
this.publicKey[4] = 4;
|
||||
this.publicKey[5] = 128;
|
||||
this.publicKey[6] = 0;
|
||||
this.publicKey[7] = 0;
|
||||
byte[] bytes = BitConverterLE.GetBytes(this.publicKey.Length - 12);
|
||||
this.publicKey[8] = bytes[0];
|
||||
this.publicKey[9] = bytes[1];
|
||||
this.publicKey[10] = bytes[2];
|
||||
this.publicKey[11] = bytes[3];
|
||||
this.publicKey[12] = 6;
|
||||
Buffer.BlockCopy(array, 1, this.publicKey, 13, this.publicKey.Length - 13);
|
||||
this.publicKey[23] = 49;
|
||||
}
|
||||
return (byte[])this.publicKey.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700019D RID: 413
|
||||
// (get) Token: 0x06000B71 RID: 2929 RVA: 0x000326B8 File Offset: 0x000308B8
|
||||
public byte[] PublicKeyToken
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.keyToken == null)
|
||||
{
|
||||
byte[] array = this.PublicKey;
|
||||
if (array == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
HashAlgorithm hashAlgorithm = HashAlgorithm.Create(this.TokenAlgorithm);
|
||||
byte[] array2 = hashAlgorithm.ComputeHash(array);
|
||||
this.keyToken = new byte[8];
|
||||
Buffer.BlockCopy(array2, array2.Length - 8, this.keyToken, 0, 8);
|
||||
Array.Reverse(this.keyToken, 0, 8);
|
||||
}
|
||||
return (byte[])this.keyToken.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700019E RID: 414
|
||||
// (get) Token: 0x06000B72 RID: 2930 RVA: 0x00032730 File Offset: 0x00030930
|
||||
// (set) Token: 0x06000B73 RID: 2931 RVA: 0x00032750 File Offset: 0x00030950
|
||||
public string TokenAlgorithm
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.tokenAlgorithm == null)
|
||||
{
|
||||
this.tokenAlgorithm = "SHA1";
|
||||
}
|
||||
return this.tokenAlgorithm;
|
||||
}
|
||||
set
|
||||
{
|
||||
string text = value.ToUpper(CultureInfo.InvariantCulture);
|
||||
if (text == "SHA1" || text == "MD5")
|
||||
{
|
||||
this.tokenAlgorithm = value;
|
||||
this.InvalidateCache();
|
||||
return;
|
||||
}
|
||||
throw new ArgumentException("Unsupported hash algorithm for token");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000B74 RID: 2932 RVA: 0x000327A8 File Offset: 0x000309A8
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
return CryptoConvert.ToCapiPrivateKeyBlob(this.RSA);
|
||||
}
|
||||
|
||||
// Token: 0x06000B75 RID: 2933 RVA: 0x000327B8 File Offset: 0x000309B8
|
||||
private uint RVAtoPosition(uint r, int sections, byte[] headers)
|
||||
{
|
||||
for (int i = 0; i < sections; i++)
|
||||
{
|
||||
uint num = BitConverterLE.ToUInt32(headers, i * 40 + 20);
|
||||
uint num2 = BitConverterLE.ToUInt32(headers, i * 40 + 12);
|
||||
int num3 = (int)BitConverterLE.ToUInt32(headers, i * 40 + 8);
|
||||
if (num2 <= r && (ulong)r < (ulong)num2 + (ulong)((long)num3))
|
||||
{
|
||||
return num + r - num2;
|
||||
}
|
||||
}
|
||||
return 0U;
|
||||
}
|
||||
|
||||
// Token: 0x06000B76 RID: 2934 RVA: 0x0003281C File Offset: 0x00030A1C
|
||||
internal StrongName.StrongNameSignature StrongHash(Stream stream, StrongName.StrongNameOptions options)
|
||||
{
|
||||
StrongName.StrongNameSignature strongNameSignature = new StrongName.StrongNameSignature();
|
||||
HashAlgorithm hashAlgorithm = HashAlgorithm.Create(this.TokenAlgorithm);
|
||||
CryptoStream cryptoStream = new CryptoStream(Stream.Null, hashAlgorithm, CryptoStreamMode.Write);
|
||||
byte[] array = new byte[128];
|
||||
stream.Read(array, 0, 128);
|
||||
if (BitConverterLE.ToUInt16(array, 0) != 23117)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
uint num = BitConverterLE.ToUInt32(array, 60);
|
||||
cryptoStream.Write(array, 0, 128);
|
||||
if (num != 128U)
|
||||
{
|
||||
byte[] array2 = new byte[num - 128U];
|
||||
stream.Read(array2, 0, array2.Length);
|
||||
cryptoStream.Write(array2, 0, array2.Length);
|
||||
}
|
||||
byte[] array3 = new byte[248];
|
||||
stream.Read(array3, 0, 248);
|
||||
if (BitConverterLE.ToUInt32(array3, 0) != 17744U)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (BitConverterLE.ToUInt16(array3, 4) != 332)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
byte[] array4 = new byte[8];
|
||||
Buffer.BlockCopy(array4, 0, array3, 88, 4);
|
||||
Buffer.BlockCopy(array4, 0, array3, 152, 8);
|
||||
cryptoStream.Write(array3, 0, 248);
|
||||
ushort num2 = BitConverterLE.ToUInt16(array3, 6);
|
||||
int num3 = (int)(num2 * 40);
|
||||
byte[] array5 = new byte[num3];
|
||||
stream.Read(array5, 0, num3);
|
||||
cryptoStream.Write(array5, 0, num3);
|
||||
uint num4 = BitConverterLE.ToUInt32(array3, 232);
|
||||
uint num5 = this.RVAtoPosition(num4, (int)num2, array5);
|
||||
int num6 = (int)BitConverterLE.ToUInt32(array3, 236);
|
||||
byte[] array6 = new byte[num6];
|
||||
stream.Position = (long)((ulong)num5);
|
||||
stream.Read(array6, 0, num6);
|
||||
uint num7 = BitConverterLE.ToUInt32(array6, 32);
|
||||
strongNameSignature.SignaturePosition = this.RVAtoPosition(num7, (int)num2, array5);
|
||||
strongNameSignature.SignatureLength = BitConverterLE.ToUInt32(array6, 36);
|
||||
uint num8 = BitConverterLE.ToUInt32(array6, 8);
|
||||
strongNameSignature.MetadataPosition = this.RVAtoPosition(num8, (int)num2, array5);
|
||||
strongNameSignature.MetadataLength = BitConverterLE.ToUInt32(array6, 12);
|
||||
if (options == StrongName.StrongNameOptions.Metadata)
|
||||
{
|
||||
cryptoStream.Close();
|
||||
hashAlgorithm.Initialize();
|
||||
byte[] array7 = new byte[strongNameSignature.MetadataLength];
|
||||
stream.Position = (long)((ulong)strongNameSignature.MetadataPosition);
|
||||
stream.Read(array7, 0, array7.Length);
|
||||
strongNameSignature.Hash = hashAlgorithm.ComputeHash(array7);
|
||||
return strongNameSignature;
|
||||
}
|
||||
for (int i = 0; i < (int)num2; i++)
|
||||
{
|
||||
uint num9 = BitConverterLE.ToUInt32(array5, i * 40 + 20);
|
||||
int num10 = (int)BitConverterLE.ToUInt32(array5, i * 40 + 16);
|
||||
byte[] array8 = new byte[num10];
|
||||
stream.Position = (long)((ulong)num9);
|
||||
stream.Read(array8, 0, num10);
|
||||
if (num9 <= strongNameSignature.SignaturePosition && (ulong)strongNameSignature.SignaturePosition < (ulong)num9 + (ulong)((long)num10))
|
||||
{
|
||||
int num11 = (int)(strongNameSignature.SignaturePosition - num9);
|
||||
if (num11 > 0)
|
||||
{
|
||||
cryptoStream.Write(array8, 0, num11);
|
||||
}
|
||||
strongNameSignature.Signature = new byte[strongNameSignature.SignatureLength];
|
||||
Buffer.BlockCopy(array8, num11, strongNameSignature.Signature, 0, (int)strongNameSignature.SignatureLength);
|
||||
Array.Reverse(strongNameSignature.Signature);
|
||||
int num12 = (int)((long)num11 + (long)((ulong)strongNameSignature.SignatureLength));
|
||||
int num13 = num10 - num12;
|
||||
if (num13 > 0)
|
||||
{
|
||||
cryptoStream.Write(array8, num12, num13);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cryptoStream.Write(array8, 0, num10);
|
||||
}
|
||||
}
|
||||
cryptoStream.Close();
|
||||
strongNameSignature.Hash = hashAlgorithm.Hash;
|
||||
return strongNameSignature;
|
||||
}
|
||||
|
||||
// Token: 0x06000B77 RID: 2935 RVA: 0x00032B68 File Offset: 0x00030D68
|
||||
public byte[] Hash(string fileName)
|
||||
{
|
||||
FileStream fileStream = File.OpenRead(fileName);
|
||||
StrongName.StrongNameSignature strongNameSignature = this.StrongHash(fileStream, StrongName.StrongNameOptions.Metadata);
|
||||
fileStream.Close();
|
||||
return strongNameSignature.Hash;
|
||||
}
|
||||
|
||||
// Token: 0x06000B78 RID: 2936 RVA: 0x00032B94 File Offset: 0x00030D94
|
||||
public bool Sign(string fileName)
|
||||
{
|
||||
bool flag = false;
|
||||
StrongName.StrongNameSignature strongNameSignature;
|
||||
using (FileStream fileStream = File.OpenRead(fileName))
|
||||
{
|
||||
strongNameSignature = this.StrongHash(fileStream, StrongName.StrongNameOptions.Signature);
|
||||
fileStream.Close();
|
||||
}
|
||||
if (strongNameSignature.Hash == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
byte[] array = null;
|
||||
try
|
||||
{
|
||||
RSAPKCS1SignatureFormatter rsapkcs1SignatureFormatter = new RSAPKCS1SignatureFormatter(this.rsa);
|
||||
rsapkcs1SignatureFormatter.SetHashAlgorithm(this.TokenAlgorithm);
|
||||
array = rsapkcs1SignatureFormatter.CreateSignature(strongNameSignature.Hash);
|
||||
Array.Reverse(array);
|
||||
}
|
||||
catch (CryptographicException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
using (FileStream fileStream2 = File.OpenWrite(fileName))
|
||||
{
|
||||
fileStream2.Position = (long)((ulong)strongNameSignature.SignaturePosition);
|
||||
fileStream2.Write(array, 0, array.Length);
|
||||
fileStream2.Close();
|
||||
flag = true;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x06000B79 RID: 2937 RVA: 0x00032CAC File Offset: 0x00030EAC
|
||||
public bool Verify(string fileName)
|
||||
{
|
||||
bool flag = false;
|
||||
using (FileStream fileStream = File.OpenRead(fileName))
|
||||
{
|
||||
flag = this.Verify(fileStream);
|
||||
fileStream.Close();
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x06000B7A RID: 2938 RVA: 0x00032D00 File Offset: 0x00030F00
|
||||
public bool Verify(Stream stream)
|
||||
{
|
||||
StrongName.StrongNameSignature strongNameSignature = this.StrongHash(stream, StrongName.StrongNameOptions.Signature);
|
||||
if (strongNameSignature.Hash == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool flag;
|
||||
try
|
||||
{
|
||||
AssemblyHashAlgorithm assemblyHashAlgorithm = AssemblyHashAlgorithm.SHA1;
|
||||
if (this.tokenAlgorithm == "MD5")
|
||||
{
|
||||
assemblyHashAlgorithm = AssemblyHashAlgorithm.MD5;
|
||||
}
|
||||
flag = StrongName.Verify(this.rsa, assemblyHashAlgorithm, strongNameSignature.Hash, strongNameSignature.Signature);
|
||||
}
|
||||
catch (CryptographicException)
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x06000B7B RID: 2939 RVA: 0x00032D94 File Offset: 0x00030F94
|
||||
public static bool IsAssemblyStrongnamed(string assemblyName)
|
||||
{
|
||||
if (!StrongName.initialized)
|
||||
{
|
||||
object obj = StrongName.lockObject;
|
||||
lock (obj)
|
||||
{
|
||||
if (!StrongName.initialized)
|
||||
{
|
||||
StrongName.initialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool flag;
|
||||
try
|
||||
{
|
||||
AssemblyName assemblyName2 = AssemblyName.GetAssemblyName(assemblyName);
|
||||
if (assemblyName2 == null)
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] mappedPublicKey = StrongNameManager.GetMappedPublicKey(assemblyName2.GetPublicKeyToken());
|
||||
if (mappedPublicKey == null || mappedPublicKey.Length < 12)
|
||||
{
|
||||
mappedPublicKey = assemblyName2.GetPublicKey();
|
||||
if (mappedPublicKey == null || mappedPublicKey.Length < 12)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!StrongNameManager.MustVerify(assemblyName2))
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
RSA rsa = CryptoConvert.FromCapiPublicKeyBlob(mappedPublicKey, 12);
|
||||
StrongName strongName = new StrongName(rsa);
|
||||
bool flag2 = strongName.Verify(assemblyName);
|
||||
flag = flag2;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x06000B7C RID: 2940 RVA: 0x00032EA4 File Offset: 0x000310A4
|
||||
public static bool VerifySignature(byte[] publicKey, int algorithm, byte[] hash, byte[] signature)
|
||||
{
|
||||
bool flag;
|
||||
try
|
||||
{
|
||||
RSA rsa = CryptoConvert.FromCapiPublicKeyBlob(publicKey);
|
||||
flag = StrongName.Verify(rsa, (AssemblyHashAlgorithm)algorithm, hash, signature);
|
||||
}
|
||||
catch
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x06000B7D RID: 2941 RVA: 0x00032EF8 File Offset: 0x000310F8
|
||||
private static bool Verify(RSA rsa, AssemblyHashAlgorithm algorithm, byte[] hash, byte[] signature)
|
||||
{
|
||||
RSAPKCS1SignatureDeformatter rsapkcs1SignatureDeformatter = new RSAPKCS1SignatureDeformatter(rsa);
|
||||
if (algorithm != AssemblyHashAlgorithm.MD5)
|
||||
{
|
||||
if (algorithm != AssemblyHashAlgorithm.SHA1 && algorithm != AssemblyHashAlgorithm.None)
|
||||
{
|
||||
}
|
||||
rsapkcs1SignatureDeformatter.SetHashAlgorithm("SHA1");
|
||||
}
|
||||
else
|
||||
{
|
||||
rsapkcs1SignatureDeformatter.SetHashAlgorithm("MD5");
|
||||
}
|
||||
return rsapkcs1SignatureDeformatter.VerifySignature(hash, signature);
|
||||
}
|
||||
|
||||
// Token: 0x04000306 RID: 774
|
||||
private RSA rsa;
|
||||
|
||||
// Token: 0x04000307 RID: 775
|
||||
private byte[] publicKey;
|
||||
|
||||
// Token: 0x04000308 RID: 776
|
||||
private byte[] keyToken;
|
||||
|
||||
// Token: 0x04000309 RID: 777
|
||||
private string tokenAlgorithm;
|
||||
|
||||
// Token: 0x0400030A RID: 778
|
||||
private static object lockObject = new object();
|
||||
|
||||
// Token: 0x0400030B RID: 779
|
||||
private static bool initialized = false;
|
||||
|
||||
// Token: 0x020000E6 RID: 230
|
||||
internal class StrongNameSignature
|
||||
{
|
||||
// Token: 0x1700019F RID: 415
|
||||
// (get) Token: 0x06000B7F RID: 2943 RVA: 0x00032F60 File Offset: 0x00031160
|
||||
// (set) Token: 0x06000B80 RID: 2944 RVA: 0x00032F68 File Offset: 0x00031168
|
||||
public byte[] Hash
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.hash;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.hash = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001A0 RID: 416
|
||||
// (get) Token: 0x06000B81 RID: 2945 RVA: 0x00032F74 File Offset: 0x00031174
|
||||
// (set) Token: 0x06000B82 RID: 2946 RVA: 0x00032F7C File Offset: 0x0003117C
|
||||
public byte[] Signature
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.signature;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.signature = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001A1 RID: 417
|
||||
// (get) Token: 0x06000B83 RID: 2947 RVA: 0x00032F88 File Offset: 0x00031188
|
||||
// (set) Token: 0x06000B84 RID: 2948 RVA: 0x00032F90 File Offset: 0x00031190
|
||||
public uint MetadataPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.metadataPosition;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.metadataPosition = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001A2 RID: 418
|
||||
// (get) Token: 0x06000B85 RID: 2949 RVA: 0x00032F9C File Offset: 0x0003119C
|
||||
// (set) Token: 0x06000B86 RID: 2950 RVA: 0x00032FA4 File Offset: 0x000311A4
|
||||
public uint MetadataLength
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.metadataLength;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.metadataLength = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001A3 RID: 419
|
||||
// (get) Token: 0x06000B87 RID: 2951 RVA: 0x00032FB0 File Offset: 0x000311B0
|
||||
// (set) Token: 0x06000B88 RID: 2952 RVA: 0x00032FB8 File Offset: 0x000311B8
|
||||
public uint SignaturePosition
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.signaturePosition;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.signaturePosition = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001A4 RID: 420
|
||||
// (get) Token: 0x06000B89 RID: 2953 RVA: 0x00032FC4 File Offset: 0x000311C4
|
||||
// (set) Token: 0x06000B8A RID: 2954 RVA: 0x00032FCC File Offset: 0x000311CC
|
||||
public uint SignatureLength
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.signatureLength;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.signatureLength = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001A5 RID: 421
|
||||
// (get) Token: 0x06000B8B RID: 2955 RVA: 0x00032FD8 File Offset: 0x000311D8
|
||||
// (set) Token: 0x06000B8C RID: 2956 RVA: 0x00032FE0 File Offset: 0x000311E0
|
||||
public byte CliFlag
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.cliFlag;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.cliFlag = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001A6 RID: 422
|
||||
// (get) Token: 0x06000B8D RID: 2957 RVA: 0x00032FEC File Offset: 0x000311EC
|
||||
// (set) Token: 0x06000B8E RID: 2958 RVA: 0x00032FF4 File Offset: 0x000311F4
|
||||
public uint CliFlagPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.cliFlagPosition;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.cliFlagPosition = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0400030C RID: 780
|
||||
private byte[] hash;
|
||||
|
||||
// Token: 0x0400030D RID: 781
|
||||
private byte[] signature;
|
||||
|
||||
// Token: 0x0400030E RID: 782
|
||||
private uint signaturePosition;
|
||||
|
||||
// Token: 0x0400030F RID: 783
|
||||
private uint signatureLength;
|
||||
|
||||
// Token: 0x04000310 RID: 784
|
||||
private uint metadataPosition;
|
||||
|
||||
// Token: 0x04000311 RID: 785
|
||||
private uint metadataLength;
|
||||
|
||||
// Token: 0x04000312 RID: 786
|
||||
private byte cliFlag;
|
||||
|
||||
// Token: 0x04000313 RID: 787
|
||||
private uint cliFlagPosition;
|
||||
}
|
||||
|
||||
// Token: 0x020000E7 RID: 231
|
||||
internal enum StrongNameOptions
|
||||
{
|
||||
// Token: 0x04000315 RID: 789
|
||||
Metadata,
|
||||
// Token: 0x04000316 RID: 790
|
||||
Signature
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Security;
|
||||
using System.Text;
|
||||
using Mono.Security.Cryptography;
|
||||
using Mono.Xml;
|
||||
|
||||
namespace Mono.Security
|
||||
{
|
||||
// Token: 0x020000E8 RID: 232
|
||||
internal class StrongNameManager
|
||||
{
|
||||
// Token: 0x06000B91 RID: 2961 RVA: 0x0003300C File Offset: 0x0003120C
|
||||
public static void LoadConfig(string filename)
|
||||
{
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
SecurityParser securityParser = new SecurityParser();
|
||||
using (StreamReader streamReader = new StreamReader(filename))
|
||||
{
|
||||
string text = streamReader.ReadToEnd();
|
||||
securityParser.LoadXml(text);
|
||||
}
|
||||
SecurityElement securityElement = securityParser.ToXml();
|
||||
if (securityElement != null && securityElement.Tag == "configuration")
|
||||
{
|
||||
SecurityElement securityElement2 = securityElement.SearchForChildByTag("strongNames");
|
||||
if (securityElement2 != null && securityElement2.Children.Count > 0)
|
||||
{
|
||||
SecurityElement securityElement3 = securityElement2.SearchForChildByTag("pubTokenMapping");
|
||||
if (securityElement3 != null && securityElement3.Children.Count > 0)
|
||||
{
|
||||
StrongNameManager.LoadMapping(securityElement3);
|
||||
}
|
||||
SecurityElement securityElement4 = securityElement2.SearchForChildByTag("verificationSettings");
|
||||
if (securityElement4 != null && securityElement4.Children.Count > 0)
|
||||
{
|
||||
StrongNameManager.LoadVerificationSettings(securityElement4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000B92 RID: 2962 RVA: 0x00033114 File Offset: 0x00031314
|
||||
private static void LoadMapping(SecurityElement mapping)
|
||||
{
|
||||
if (StrongNameManager.mappings == null)
|
||||
{
|
||||
StrongNameManager.mappings = new Hashtable();
|
||||
}
|
||||
object syncRoot = StrongNameManager.mappings.SyncRoot;
|
||||
lock (syncRoot)
|
||||
{
|
||||
foreach (object obj in mapping.Children)
|
||||
{
|
||||
SecurityElement securityElement = (SecurityElement)obj;
|
||||
if (!(securityElement.Tag != "map"))
|
||||
{
|
||||
string text = securityElement.Attribute("Token");
|
||||
if (text != null && text.Length == 16)
|
||||
{
|
||||
text = text.ToUpper(CultureInfo.InvariantCulture);
|
||||
string text2 = securityElement.Attribute("PublicKey");
|
||||
if (text2 != null)
|
||||
{
|
||||
if (StrongNameManager.mappings[text] == null)
|
||||
{
|
||||
StrongNameManager.mappings.Add(text, text2);
|
||||
}
|
||||
else
|
||||
{
|
||||
StrongNameManager.mappings[text] = text2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000B93 RID: 2963 RVA: 0x0003325C File Offset: 0x0003145C
|
||||
private static void LoadVerificationSettings(SecurityElement settings)
|
||||
{
|
||||
if (StrongNameManager.tokens == null)
|
||||
{
|
||||
StrongNameManager.tokens = new Hashtable();
|
||||
}
|
||||
object syncRoot = StrongNameManager.tokens.SyncRoot;
|
||||
lock (syncRoot)
|
||||
{
|
||||
foreach (object obj in settings.Children)
|
||||
{
|
||||
SecurityElement securityElement = (SecurityElement)obj;
|
||||
if (!(securityElement.Tag != "skip"))
|
||||
{
|
||||
string text = securityElement.Attribute("Token");
|
||||
if (text != null)
|
||||
{
|
||||
text = text.ToUpper(CultureInfo.InvariantCulture);
|
||||
string text2 = securityElement.Attribute("Assembly");
|
||||
if (text2 == null)
|
||||
{
|
||||
text2 = "*";
|
||||
}
|
||||
string text3 = securityElement.Attribute("Users");
|
||||
if (text3 == null)
|
||||
{
|
||||
text3 = "*";
|
||||
}
|
||||
StrongNameManager.Element element = (StrongNameManager.Element)StrongNameManager.tokens[text];
|
||||
if (element == null)
|
||||
{
|
||||
element = new StrongNameManager.Element(text2, text3);
|
||||
StrongNameManager.tokens.Add(text, element);
|
||||
}
|
||||
else if ((string)element.assemblies[text2] == null)
|
||||
{
|
||||
element.assemblies.Add(text2, text3);
|
||||
}
|
||||
else if (text3 == "*")
|
||||
{
|
||||
element.assemblies[text2] = "*";
|
||||
}
|
||||
else
|
||||
{
|
||||
string text4 = (string)element.assemblies[text2];
|
||||
string text5 = text4 + "," + text3;
|
||||
element.assemblies[text2] = text5;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000B94 RID: 2964 RVA: 0x00033448 File Offset: 0x00031648
|
||||
public static byte[] GetMappedPublicKey(byte[] token)
|
||||
{
|
||||
if (StrongNameManager.mappings == null || token == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
string text = CryptoConvert.ToHex(token);
|
||||
string text2 = (string)StrongNameManager.mappings[text];
|
||||
if (text2 == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return CryptoConvert.FromHex(text2);
|
||||
}
|
||||
|
||||
// Token: 0x06000B95 RID: 2965 RVA: 0x00033490 File Offset: 0x00031690
|
||||
public static bool MustVerify(AssemblyName an)
|
||||
{
|
||||
if (an == null || StrongNameManager.tokens == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
string text = CryptoConvert.ToHex(an.GetPublicKeyToken());
|
||||
StrongNameManager.Element element = (StrongNameManager.Element)StrongNameManager.tokens[text];
|
||||
if (element != null)
|
||||
{
|
||||
string text2 = element.GetUsers(an.Name);
|
||||
if (text2 == null)
|
||||
{
|
||||
text2 = element.GetUsers("*");
|
||||
}
|
||||
if (text2 != null)
|
||||
{
|
||||
return !(text2 == "*") && text2.IndexOf(Environment.UserName) < 0;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x06000B96 RID: 2966 RVA: 0x0003351C File Offset: 0x0003171C
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.Append("Public Key Token\tAssemblies\t\tUsers");
|
||||
stringBuilder.Append(Environment.NewLine);
|
||||
foreach (object obj in StrongNameManager.tokens)
|
||||
{
|
||||
DictionaryEntry dictionaryEntry = (DictionaryEntry)obj;
|
||||
stringBuilder.Append((string)dictionaryEntry.Key);
|
||||
StrongNameManager.Element element = (StrongNameManager.Element)dictionaryEntry.Value;
|
||||
bool flag = true;
|
||||
foreach (object obj2 in element.assemblies)
|
||||
{
|
||||
DictionaryEntry dictionaryEntry2 = (DictionaryEntry)obj2;
|
||||
if (flag)
|
||||
{
|
||||
stringBuilder.Append("\t");
|
||||
flag = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
stringBuilder.Append("\t\t\t");
|
||||
}
|
||||
stringBuilder.Append((string)dictionaryEntry2.Key);
|
||||
stringBuilder.Append("\t");
|
||||
string text = (string)dictionaryEntry2.Value;
|
||||
if (text == "*")
|
||||
{
|
||||
text = "All users";
|
||||
}
|
||||
stringBuilder.Append(text);
|
||||
stringBuilder.Append(Environment.NewLine);
|
||||
}
|
||||
}
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
// Token: 0x04000317 RID: 791
|
||||
private static Hashtable mappings;
|
||||
|
||||
// Token: 0x04000318 RID: 792
|
||||
private static Hashtable tokens;
|
||||
|
||||
// Token: 0x020000E9 RID: 233
|
||||
private class Element
|
||||
{
|
||||
// Token: 0x06000B97 RID: 2967 RVA: 0x000336B0 File Offset: 0x000318B0
|
||||
public Element()
|
||||
{
|
||||
this.assemblies = new Hashtable();
|
||||
}
|
||||
|
||||
// Token: 0x06000B98 RID: 2968 RVA: 0x000336C4 File Offset: 0x000318C4
|
||||
public Element(string assembly, string users)
|
||||
: this()
|
||||
{
|
||||
this.assemblies.Add(assembly, users);
|
||||
}
|
||||
|
||||
// Token: 0x06000B99 RID: 2969 RVA: 0x000336DC File Offset: 0x000318DC
|
||||
public string GetUsers(string assembly)
|
||||
{
|
||||
return (string)this.assemblies[assembly];
|
||||
}
|
||||
|
||||
// Token: 0x04000319 RID: 793
|
||||
internal Hashtable assemblies;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,1423 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Mono.Security
|
||||
{
|
||||
// Token: 0x020000EB RID: 235
|
||||
internal class Uri
|
||||
{
|
||||
// Token: 0x06000B9A RID: 2970 RVA: 0x000336F0 File Offset: 0x000318F0
|
||||
public Uri(string uriString)
|
||||
: this(uriString, false)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000B9B RID: 2971 RVA: 0x000336FC File Offset: 0x000318FC
|
||||
public Uri(string uriString, bool dontEscape)
|
||||
{
|
||||
this.scheme = string.Empty;
|
||||
this.host = string.Empty;
|
||||
this.port = -1;
|
||||
this.path = string.Empty;
|
||||
this.query = string.Empty;
|
||||
this.fragment = string.Empty;
|
||||
this.userinfo = string.Empty;
|
||||
this.reduce = true;
|
||||
base..ctor();
|
||||
this.userEscaped = dontEscape;
|
||||
this.source = uriString;
|
||||
this.Parse();
|
||||
}
|
||||
|
||||
// Token: 0x06000B9C RID: 2972 RVA: 0x00033774 File Offset: 0x00031974
|
||||
public Uri(string uriString, bool dontEscape, bool reduce)
|
||||
{
|
||||
this.scheme = string.Empty;
|
||||
this.host = string.Empty;
|
||||
this.port = -1;
|
||||
this.path = string.Empty;
|
||||
this.query = string.Empty;
|
||||
this.fragment = string.Empty;
|
||||
this.userinfo = string.Empty;
|
||||
this.reduce = true;
|
||||
base..ctor();
|
||||
this.userEscaped = dontEscape;
|
||||
this.source = uriString;
|
||||
this.reduce = reduce;
|
||||
this.Parse();
|
||||
}
|
||||
|
||||
// Token: 0x06000B9D RID: 2973 RVA: 0x000337F4 File Offset: 0x000319F4
|
||||
public Uri(Uri baseUri, string relativeUri)
|
||||
: this(baseUri, relativeUri, false)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000B9E RID: 2974 RVA: 0x00033800 File Offset: 0x00031A00
|
||||
public Uri(Uri baseUri, string relativeUri, bool dontEscape)
|
||||
{
|
||||
this.scheme = string.Empty;
|
||||
this.host = string.Empty;
|
||||
this.port = -1;
|
||||
this.path = string.Empty;
|
||||
this.query = string.Empty;
|
||||
this.fragment = string.Empty;
|
||||
this.userinfo = string.Empty;
|
||||
this.reduce = true;
|
||||
base..ctor();
|
||||
if (baseUri == null)
|
||||
{
|
||||
throw new NullReferenceException("baseUri");
|
||||
}
|
||||
this.userEscaped = dontEscape;
|
||||
if (relativeUri == null)
|
||||
{
|
||||
throw new NullReferenceException("relativeUri");
|
||||
}
|
||||
if (relativeUri.StartsWith("\\\\"))
|
||||
{
|
||||
this.source = relativeUri;
|
||||
this.Parse();
|
||||
return;
|
||||
}
|
||||
int num = relativeUri.IndexOf(':');
|
||||
if (num != -1)
|
||||
{
|
||||
int num2 = relativeUri.IndexOfAny(new char[] { '/', '\\', '?' });
|
||||
if (num2 > num || num2 < 0)
|
||||
{
|
||||
this.source = relativeUri;
|
||||
this.Parse();
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.scheme = baseUri.scheme;
|
||||
this.host = baseUri.host;
|
||||
this.port = baseUri.port;
|
||||
this.userinfo = baseUri.userinfo;
|
||||
this.isUnc = baseUri.isUnc;
|
||||
this.isUnixFilePath = baseUri.isUnixFilePath;
|
||||
this.isOpaquePart = baseUri.isOpaquePart;
|
||||
if (relativeUri == string.Empty)
|
||||
{
|
||||
this.path = baseUri.path;
|
||||
this.query = baseUri.query;
|
||||
this.fragment = baseUri.fragment;
|
||||
return;
|
||||
}
|
||||
num = relativeUri.IndexOf('#');
|
||||
if (num != -1)
|
||||
{
|
||||
this.fragment = relativeUri.Substring(num);
|
||||
relativeUri = relativeUri.Substring(0, num);
|
||||
}
|
||||
num = relativeUri.IndexOf('?');
|
||||
if (num != -1)
|
||||
{
|
||||
this.query = relativeUri.Substring(num);
|
||||
if (!this.userEscaped)
|
||||
{
|
||||
this.query = Uri.EscapeString(this.query);
|
||||
}
|
||||
relativeUri = relativeUri.Substring(0, num);
|
||||
}
|
||||
if (relativeUri.Length > 0 && relativeUri[0] == '/')
|
||||
{
|
||||
if (relativeUri.Length > 1 && relativeUri[1] == '/')
|
||||
{
|
||||
this.source = this.scheme + ':' + relativeUri;
|
||||
this.Parse();
|
||||
return;
|
||||
}
|
||||
this.path = relativeUri;
|
||||
if (!this.userEscaped)
|
||||
{
|
||||
this.path = Uri.EscapeString(this.path);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.path = baseUri.path;
|
||||
if (relativeUri.Length > 0 || this.query.Length > 0)
|
||||
{
|
||||
num = this.path.LastIndexOf('/');
|
||||
if (num >= 0)
|
||||
{
|
||||
this.path = this.path.Substring(0, num + 1);
|
||||
}
|
||||
}
|
||||
if (relativeUri.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.path += relativeUri;
|
||||
int num3 = 0;
|
||||
for (;;)
|
||||
{
|
||||
num = this.path.IndexOf("./", num3);
|
||||
if (num == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (num == 0)
|
||||
{
|
||||
this.path = this.path.Remove(0, 2);
|
||||
}
|
||||
else if (this.path[num - 1] != '.')
|
||||
{
|
||||
this.path = this.path.Remove(num, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
num3 = num + 1;
|
||||
}
|
||||
}
|
||||
if (this.path.Length > 1 && this.path[this.path.Length - 1] == '.' && this.path[this.path.Length - 2] == '/')
|
||||
{
|
||||
this.path = this.path.Remove(this.path.Length - 1, 1);
|
||||
}
|
||||
num3 = 0;
|
||||
for (;;)
|
||||
{
|
||||
num = this.path.IndexOf("/../", num3);
|
||||
if (num == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (num == 0)
|
||||
{
|
||||
num3 = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
int num4 = this.path.LastIndexOf('/', num - 1);
|
||||
if (num4 == -1)
|
||||
{
|
||||
num3 = num + 1;
|
||||
}
|
||||
else if (this.path.Substring(num4 + 1, num - num4 - 1) != "..")
|
||||
{
|
||||
this.path = this.path.Remove(num4 + 1, num - num4 + 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
num3 = num + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.path.Length > 3 && this.path.EndsWith("/.."))
|
||||
{
|
||||
num = this.path.LastIndexOf('/', this.path.Length - 4);
|
||||
if (num != -1 && this.path.Substring(num + 1, this.path.Length - num - 4) != "..")
|
||||
{
|
||||
this.path = this.path.Remove(num + 1, this.path.Length - num - 1);
|
||||
}
|
||||
}
|
||||
if (!this.userEscaped)
|
||||
{
|
||||
this.path = Uri.EscapeString(this.path);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001A7 RID: 423
|
||||
// (get) Token: 0x06000BA0 RID: 2976 RVA: 0x00033E64 File Offset: 0x00032064
|
||||
public string AbsolutePath
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.path;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001A8 RID: 424
|
||||
// (get) Token: 0x06000BA1 RID: 2977 RVA: 0x00033E6C File Offset: 0x0003206C
|
||||
public string AbsoluteUri
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.cachedAbsoluteUri == null)
|
||||
{
|
||||
this.cachedAbsoluteUri = this.GetLeftPart(UriPartial.Path) + this.query + this.fragment;
|
||||
}
|
||||
return this.cachedAbsoluteUri;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001A9 RID: 425
|
||||
// (get) Token: 0x06000BA2 RID: 2978 RVA: 0x00033EA0 File Offset: 0x000320A0
|
||||
public string Authority
|
||||
{
|
||||
get
|
||||
{
|
||||
return (Uri.GetDefaultPort(this.scheme) != this.port) ? (this.host + ":" + this.port) : this.host;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001AA RID: 426
|
||||
// (get) Token: 0x06000BA3 RID: 2979 RVA: 0x00033EEC File Offset: 0x000320EC
|
||||
public string Fragment
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.fragment;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001AB RID: 427
|
||||
// (get) Token: 0x06000BA4 RID: 2980 RVA: 0x00033EF4 File Offset: 0x000320F4
|
||||
public string Host
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.host;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001AC RID: 428
|
||||
// (get) Token: 0x06000BA5 RID: 2981 RVA: 0x00033EFC File Offset: 0x000320FC
|
||||
public bool IsDefaultPort
|
||||
{
|
||||
get
|
||||
{
|
||||
return Uri.GetDefaultPort(this.scheme) == this.port;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001AD RID: 429
|
||||
// (get) Token: 0x06000BA6 RID: 2982 RVA: 0x00033F14 File Offset: 0x00032114
|
||||
public bool IsFile
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.scheme == Uri.UriSchemeFile;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001AE RID: 430
|
||||
// (get) Token: 0x06000BA7 RID: 2983 RVA: 0x00033F28 File Offset: 0x00032128
|
||||
public bool IsLoopback
|
||||
{
|
||||
get
|
||||
{
|
||||
return !(this.host == string.Empty) && (this.host == "loopback" || this.host == "localhost");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001AF RID: 431
|
||||
// (get) Token: 0x06000BA8 RID: 2984 RVA: 0x00033F7C File Offset: 0x0003217C
|
||||
public bool IsUnc
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.isUnc;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001B0 RID: 432
|
||||
// (get) Token: 0x06000BA9 RID: 2985 RVA: 0x00033F84 File Offset: 0x00032184
|
||||
public string LocalPath
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.cachedLocalPath != null)
|
||||
{
|
||||
return this.cachedLocalPath;
|
||||
}
|
||||
if (!this.IsFile)
|
||||
{
|
||||
return this.AbsolutePath;
|
||||
}
|
||||
bool flag = this.path.Length > 3 && this.path[1] == ':' && (this.path[2] == '\\' || this.path[2] == '/');
|
||||
if (!this.IsUnc)
|
||||
{
|
||||
string text = this.Unescape(this.path);
|
||||
if (Path.DirectorySeparatorChar == '\\' || flag)
|
||||
{
|
||||
this.cachedLocalPath = text.Replace('/', '\\');
|
||||
}
|
||||
else
|
||||
{
|
||||
this.cachedLocalPath = text;
|
||||
}
|
||||
}
|
||||
else if (this.path.Length > 1 && this.path[1] == ':')
|
||||
{
|
||||
this.cachedLocalPath = this.Unescape(this.path.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar));
|
||||
}
|
||||
else if (Path.DirectorySeparatorChar == '\\')
|
||||
{
|
||||
this.cachedLocalPath = "\\\\" + this.Unescape(this.host + this.path.Replace('/', '\\'));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.cachedLocalPath = this.Unescape(this.path);
|
||||
}
|
||||
if (this.cachedLocalPath == string.Empty)
|
||||
{
|
||||
this.cachedLocalPath = Path.DirectorySeparatorChar.ToString();
|
||||
}
|
||||
return this.cachedLocalPath;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001B1 RID: 433
|
||||
// (get) Token: 0x06000BAA RID: 2986 RVA: 0x0003411C File Offset: 0x0003231C
|
||||
public string PathAndQuery
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.path + this.query;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001B2 RID: 434
|
||||
// (get) Token: 0x06000BAB RID: 2987 RVA: 0x00034130 File Offset: 0x00032330
|
||||
public int Port
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.port;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001B3 RID: 435
|
||||
// (get) Token: 0x06000BAC RID: 2988 RVA: 0x00034138 File Offset: 0x00032338
|
||||
public string Query
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.query;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001B4 RID: 436
|
||||
// (get) Token: 0x06000BAD RID: 2989 RVA: 0x00034140 File Offset: 0x00032340
|
||||
public string Scheme
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.scheme;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001B5 RID: 437
|
||||
// (get) Token: 0x06000BAE RID: 2990 RVA: 0x00034148 File Offset: 0x00032348
|
||||
public string[] Segments
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.segments != null)
|
||||
{
|
||||
return this.segments;
|
||||
}
|
||||
if (this.path.Length == 0)
|
||||
{
|
||||
this.segments = new string[0];
|
||||
return this.segments;
|
||||
}
|
||||
string[] array = this.path.Split(new char[] { '/' });
|
||||
this.segments = array;
|
||||
bool flag = this.path.EndsWith("/");
|
||||
if (array.Length > 0 && flag)
|
||||
{
|
||||
string[] array2 = new string[array.Length - 1];
|
||||
Array.Copy(array, 0, array2, 0, array.Length - 1);
|
||||
array = array2;
|
||||
}
|
||||
int i = 0;
|
||||
if (this.IsFile && this.path.Length > 1 && this.path[1] == ':')
|
||||
{
|
||||
string[] array3 = new string[array.Length + 1];
|
||||
Array.Copy(array, 1, array3, 2, array.Length - 1);
|
||||
array = array3;
|
||||
array[0] = this.path.Substring(0, 2);
|
||||
array[1] = string.Empty;
|
||||
i++;
|
||||
}
|
||||
int num = array.Length;
|
||||
while (i < num)
|
||||
{
|
||||
if (i != num - 1 || flag)
|
||||
{
|
||||
string[] array4 = array;
|
||||
int num2 = i;
|
||||
array4[num2] += '/';
|
||||
}
|
||||
i++;
|
||||
}
|
||||
this.segments = array;
|
||||
return this.segments;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001B6 RID: 438
|
||||
// (get) Token: 0x06000BAF RID: 2991 RVA: 0x00034298 File Offset: 0x00032498
|
||||
public bool UserEscaped
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.userEscaped;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001B7 RID: 439
|
||||
// (get) Token: 0x06000BB0 RID: 2992 RVA: 0x000342A0 File Offset: 0x000324A0
|
||||
public string UserInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.userinfo;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000BB1 RID: 2993 RVA: 0x000342A8 File Offset: 0x000324A8
|
||||
internal static bool IsIPv4Address(string name)
|
||||
{
|
||||
string[] array = name.Split(new char[] { '.' });
|
||||
if (array.Length != 4)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
int num = int.Parse(array[i], CultureInfo.InvariantCulture);
|
||||
if (num < 0 || num > 255)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x06000BB2 RID: 2994 RVA: 0x0003433C File Offset: 0x0003253C
|
||||
internal static bool IsDomainAddress(string name)
|
||||
{
|
||||
int length = name.Length;
|
||||
if (name[length - 1] == '.')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int num = 0;
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
char c = name[i];
|
||||
if (num == 0)
|
||||
{
|
||||
if (!char.IsLetterOrDigit(c))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (c == '.')
|
||||
{
|
||||
num = 0;
|
||||
}
|
||||
else if (!char.IsLetterOrDigit(c) && c != '-' && c != '_')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (++num == 64)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x06000BB3 RID: 2995 RVA: 0x000343D4 File Offset: 0x000325D4
|
||||
public static bool CheckSchemeName(string schemeName)
|
||||
{
|
||||
if (schemeName == null || schemeName.Length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!char.IsLetter(schemeName[0]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int length = schemeName.Length;
|
||||
for (int i = 1; i < length; i++)
|
||||
{
|
||||
char c = schemeName[i];
|
||||
if (!char.IsLetterOrDigit(c) && c != '.' && c != '+' && c != '-')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x06000BB4 RID: 2996 RVA: 0x00034450 File Offset: 0x00032650
|
||||
public override bool Equals(object comparant)
|
||||
{
|
||||
if (comparant == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Uri uri = comparant as Uri;
|
||||
if (uri == null)
|
||||
{
|
||||
string text = comparant as string;
|
||||
if (text == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
uri = new Uri(text);
|
||||
}
|
||||
CultureInfo invariantCulture = CultureInfo.InvariantCulture;
|
||||
return this.scheme.ToLower(invariantCulture) == uri.scheme.ToLower(invariantCulture) && this.userinfo.ToLower(invariantCulture) == uri.userinfo.ToLower(invariantCulture) && this.host.ToLower(invariantCulture) == uri.host.ToLower(invariantCulture) && this.port == uri.port && this.path == uri.path && this.query.ToLower(invariantCulture) == uri.query.ToLower(invariantCulture);
|
||||
}
|
||||
|
||||
// Token: 0x06000BB5 RID: 2997 RVA: 0x0003453C File Offset: 0x0003273C
|
||||
public override int GetHashCode()
|
||||
{
|
||||
if (this.cachedHashCode == 0)
|
||||
{
|
||||
this.cachedHashCode = this.scheme.GetHashCode() + this.userinfo.GetHashCode() + this.host.GetHashCode() + this.port + this.path.GetHashCode() + this.query.GetHashCode();
|
||||
}
|
||||
return this.cachedHashCode;
|
||||
}
|
||||
|
||||
// Token: 0x06000BB6 RID: 2998 RVA: 0x000345A4 File Offset: 0x000327A4
|
||||
public string GetLeftPart(UriPartial part)
|
||||
{
|
||||
switch (part)
|
||||
{
|
||||
case UriPartial.Scheme:
|
||||
return this.scheme + this.GetOpaqueWiseSchemeDelimiter();
|
||||
case UriPartial.Authority:
|
||||
{
|
||||
if (this.host == string.Empty || this.scheme == Uri.UriSchemeMailto || this.scheme == Uri.UriSchemeNews)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.Append(this.scheme);
|
||||
stringBuilder.Append(this.GetOpaqueWiseSchemeDelimiter());
|
||||
if (this.path.Length > 1 && this.path[1] == ':' && Uri.UriSchemeFile == this.scheme)
|
||||
{
|
||||
stringBuilder.Append('/');
|
||||
}
|
||||
if (this.userinfo.Length > 0)
|
||||
{
|
||||
stringBuilder.Append(this.userinfo).Append('@');
|
||||
}
|
||||
stringBuilder.Append(this.host);
|
||||
int num = Uri.GetDefaultPort(this.scheme);
|
||||
if (this.port != -1 && this.port != num)
|
||||
{
|
||||
stringBuilder.Append(':').Append(this.port);
|
||||
}
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
case UriPartial.Path:
|
||||
{
|
||||
StringBuilder stringBuilder2 = new StringBuilder();
|
||||
stringBuilder2.Append(this.scheme);
|
||||
stringBuilder2.Append(this.GetOpaqueWiseSchemeDelimiter());
|
||||
if (this.path.Length > 1 && this.path[1] == ':' && Uri.UriSchemeFile == this.scheme)
|
||||
{
|
||||
stringBuilder2.Append('/');
|
||||
}
|
||||
if (this.userinfo.Length > 0)
|
||||
{
|
||||
stringBuilder2.Append(this.userinfo).Append('@');
|
||||
}
|
||||
stringBuilder2.Append(this.host);
|
||||
int num = Uri.GetDefaultPort(this.scheme);
|
||||
if (this.port != -1 && this.port != num)
|
||||
{
|
||||
stringBuilder2.Append(':').Append(this.port);
|
||||
}
|
||||
stringBuilder2.Append(this.path);
|
||||
return stringBuilder2.ToString();
|
||||
}
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000BB7 RID: 2999 RVA: 0x000347D8 File Offset: 0x000329D8
|
||||
public static int FromHex(char digit)
|
||||
{
|
||||
if ('0' <= digit && digit <= '9')
|
||||
{
|
||||
return (int)(digit - '0');
|
||||
}
|
||||
if ('a' <= digit && digit <= 'f')
|
||||
{
|
||||
return (int)(digit - 'a' + '\n');
|
||||
}
|
||||
if ('A' <= digit && digit <= 'F')
|
||||
{
|
||||
return (int)(digit - 'A' + '\n');
|
||||
}
|
||||
throw new ArgumentException("digit");
|
||||
}
|
||||
|
||||
// Token: 0x06000BB8 RID: 3000 RVA: 0x00034834 File Offset: 0x00032A34
|
||||
public static string HexEscape(char character)
|
||||
{
|
||||
if (character > 'ÿ')
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("character");
|
||||
}
|
||||
return "%" + Uri.hexUpperChars[(int)((character & 'ð') >> 4)] + Uri.hexUpperChars[(int)(character & '\u000f')];
|
||||
}
|
||||
|
||||
// Token: 0x06000BB9 RID: 3001 RVA: 0x0003488C File Offset: 0x00032A8C
|
||||
public static char HexUnescape(string pattern, ref int index)
|
||||
{
|
||||
if (pattern == null)
|
||||
{
|
||||
throw new ArgumentException("pattern");
|
||||
}
|
||||
if (index < 0 || index >= pattern.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("index");
|
||||
}
|
||||
int num = 0;
|
||||
int num2 = 0;
|
||||
while (index + 3 <= pattern.Length && pattern[index] == '%' && Uri.IsHexDigit(pattern[index + 1]) && Uri.IsHexDigit(pattern[index + 2]))
|
||||
{
|
||||
index++;
|
||||
int num3 = Uri.FromHex(pattern[index++]);
|
||||
int num4 = Uri.FromHex(pattern[index++]);
|
||||
int num5 = (num3 << 4) + num4;
|
||||
if (num == 0)
|
||||
{
|
||||
if (num5 < 192)
|
||||
{
|
||||
return (char)num5;
|
||||
}
|
||||
if (num5 < 224)
|
||||
{
|
||||
num2 = num5 - 192;
|
||||
num = 2;
|
||||
}
|
||||
else if (num5 < 240)
|
||||
{
|
||||
num2 = num5 - 224;
|
||||
num = 3;
|
||||
}
|
||||
else if (num5 < 248)
|
||||
{
|
||||
num2 = num5 - 240;
|
||||
num = 4;
|
||||
}
|
||||
else if (num5 < 251)
|
||||
{
|
||||
num2 = num5 - 248;
|
||||
num = 5;
|
||||
}
|
||||
else if (num5 < 254)
|
||||
{
|
||||
num2 = num5 - 252;
|
||||
num = 6;
|
||||
}
|
||||
num2 <<= (num - 1) * 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
num2 += num5 - 128 << (num - 1) * 6;
|
||||
}
|
||||
num--;
|
||||
if (num <= 0)
|
||||
{
|
||||
IL_1A2:
|
||||
return (char)num2;
|
||||
}
|
||||
}
|
||||
if (num == 0)
|
||||
{
|
||||
return pattern[index++];
|
||||
}
|
||||
goto IL_1A2;
|
||||
}
|
||||
|
||||
// Token: 0x06000BBA RID: 3002 RVA: 0x00034A40 File Offset: 0x00032C40
|
||||
public static bool IsHexDigit(char digit)
|
||||
{
|
||||
return ('0' <= digit && digit <= '9') || ('a' <= digit && digit <= 'f') || ('A' <= digit && digit <= 'F');
|
||||
}
|
||||
|
||||
// Token: 0x06000BBB RID: 3003 RVA: 0x00034A84 File Offset: 0x00032C84
|
||||
public static bool IsHexEncoding(string pattern, int index)
|
||||
{
|
||||
return index + 3 <= pattern.Length && (pattern[index++] == '%' && Uri.IsHexDigit(pattern[index++])) && Uri.IsHexDigit(pattern[index]);
|
||||
}
|
||||
|
||||
// Token: 0x06000BBC RID: 3004 RVA: 0x00034ADC File Offset: 0x00032CDC
|
||||
public string MakeRelative(Uri toUri)
|
||||
{
|
||||
if (this.Scheme != toUri.Scheme || this.Authority != toUri.Authority)
|
||||
{
|
||||
return toUri.ToString();
|
||||
}
|
||||
if (this.path == toUri.path)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
string[] array = this.Segments;
|
||||
string[] array2 = toUri.Segments;
|
||||
int i = 0;
|
||||
int num = Math.Min(array.Length, array2.Length);
|
||||
while (i < num)
|
||||
{
|
||||
if (array[i] != array2[i])
|
||||
{
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
string text = string.Empty;
|
||||
for (int j = i + 1; j < array.Length; j++)
|
||||
{
|
||||
text += "../";
|
||||
}
|
||||
for (int k = i; k < array2.Length; k++)
|
||||
{
|
||||
text += array2[k];
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
// Token: 0x06000BBD RID: 3005 RVA: 0x00034BD0 File Offset: 0x00032DD0
|
||||
public override string ToString()
|
||||
{
|
||||
if (this.cachedToString != null)
|
||||
{
|
||||
return this.cachedToString;
|
||||
}
|
||||
string text = ((!this.query.StartsWith("?")) ? this.Unescape(this.query) : ('?' + this.Unescape(this.query.Substring(1))));
|
||||
this.cachedToString = this.Unescape(this.GetLeftPart(UriPartial.Path), true) + text + this.fragment;
|
||||
return this.cachedToString;
|
||||
}
|
||||
|
||||
// Token: 0x06000BBE RID: 3006 RVA: 0x00034C5C File Offset: 0x00032E5C
|
||||
protected void Escape()
|
||||
{
|
||||
this.path = Uri.EscapeString(this.path);
|
||||
}
|
||||
|
||||
// Token: 0x06000BBF RID: 3007 RVA: 0x00034C70 File Offset: 0x00032E70
|
||||
protected static string EscapeString(string str)
|
||||
{
|
||||
return Uri.EscapeString(str, false, true, true);
|
||||
}
|
||||
|
||||
// Token: 0x06000BC0 RID: 3008 RVA: 0x00034C7C File Offset: 0x00032E7C
|
||||
internal static string EscapeString(string str, bool escapeReserved, bool escapeHex, bool escapeBrackets)
|
||||
{
|
||||
if (str == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
int length = str.Length;
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
if (Uri.IsHexEncoding(str, i))
|
||||
{
|
||||
stringBuilder.Append(str.Substring(i, 3));
|
||||
i += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(new char[] { str[i] });
|
||||
int num = bytes.Length;
|
||||
for (int j = 0; j < num; j++)
|
||||
{
|
||||
char c = (char)bytes[j];
|
||||
if (c <= ' ' || c >= '\u007f' || "<>%\"{}|\\^`".IndexOf(c) != -1 || (escapeHex && c == '#') || (escapeBrackets && (c == '[' || c == ']')) || (escapeReserved && ";/?:@&=+$,".IndexOf(c) != -1))
|
||||
{
|
||||
stringBuilder.Append(Uri.HexEscape(c));
|
||||
}
|
||||
else
|
||||
{
|
||||
stringBuilder.Append(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
// Token: 0x06000BC1 RID: 3009 RVA: 0x00034D9C File Offset: 0x00032F9C
|
||||
protected void Parse()
|
||||
{
|
||||
this.Parse(this.source);
|
||||
if (this.userEscaped)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.host = Uri.EscapeString(this.host, false, true, false);
|
||||
this.path = Uri.EscapeString(this.path);
|
||||
}
|
||||
|
||||
// Token: 0x06000BC2 RID: 3010 RVA: 0x00034DE8 File Offset: 0x00032FE8
|
||||
protected string Unescape(string str)
|
||||
{
|
||||
return this.Unescape(str, false);
|
||||
}
|
||||
|
||||
// Token: 0x06000BC3 RID: 3011 RVA: 0x00034DF4 File Offset: 0x00032FF4
|
||||
internal string Unescape(string str, bool excludeSharp)
|
||||
{
|
||||
if (str == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
int length = str.Length;
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
char c = str[i];
|
||||
if (c == '%')
|
||||
{
|
||||
char c2 = Uri.HexUnescape(str, ref i);
|
||||
if (excludeSharp && c2 == '#')
|
||||
{
|
||||
stringBuilder.Append("%23");
|
||||
}
|
||||
else
|
||||
{
|
||||
stringBuilder.Append(c2);
|
||||
}
|
||||
i--;
|
||||
}
|
||||
else
|
||||
{
|
||||
stringBuilder.Append(c);
|
||||
}
|
||||
}
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
// Token: 0x06000BC4 RID: 3012 RVA: 0x00034E88 File Offset: 0x00033088
|
||||
private void ParseAsWindowsUNC(string uriString)
|
||||
{
|
||||
this.scheme = Uri.UriSchemeFile;
|
||||
this.port = -1;
|
||||
this.fragment = string.Empty;
|
||||
this.query = string.Empty;
|
||||
this.isUnc = true;
|
||||
uriString = uriString.TrimStart(new char[] { '\\' });
|
||||
int num = uriString.IndexOf('\\');
|
||||
if (num > 0)
|
||||
{
|
||||
this.path = uriString.Substring(num);
|
||||
this.host = uriString.Substring(0, num);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.host = uriString;
|
||||
this.path = string.Empty;
|
||||
}
|
||||
this.path = this.path.Replace("\\", "/");
|
||||
}
|
||||
|
||||
// Token: 0x06000BC5 RID: 3013 RVA: 0x00034F34 File Offset: 0x00033134
|
||||
private void ParseAsWindowsAbsoluteFilePath(string uriString)
|
||||
{
|
||||
if (uriString.Length > 2 && uriString[2] != '\\' && uriString[2] != '/')
|
||||
{
|
||||
throw new FormatException("Relative file path is not allowed.");
|
||||
}
|
||||
this.scheme = Uri.UriSchemeFile;
|
||||
this.host = string.Empty;
|
||||
this.port = -1;
|
||||
this.path = uriString.Replace("\\", "/");
|
||||
this.fragment = string.Empty;
|
||||
this.query = string.Empty;
|
||||
}
|
||||
|
||||
// Token: 0x06000BC6 RID: 3014 RVA: 0x00034FC0 File Offset: 0x000331C0
|
||||
private void ParseAsUnixAbsoluteFilePath(string uriString)
|
||||
{
|
||||
this.isUnixFilePath = true;
|
||||
this.scheme = Uri.UriSchemeFile;
|
||||
this.port = -1;
|
||||
this.fragment = string.Empty;
|
||||
this.query = string.Empty;
|
||||
this.host = string.Empty;
|
||||
this.path = null;
|
||||
if (uriString.StartsWith("//"))
|
||||
{
|
||||
uriString = uriString.TrimStart(new char[] { '/' });
|
||||
this.path = '/' + uriString;
|
||||
}
|
||||
if (this.path == null)
|
||||
{
|
||||
this.path = uriString;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000BC7 RID: 3015 RVA: 0x00035058 File Offset: 0x00033258
|
||||
private void Parse(string uriString)
|
||||
{
|
||||
if (uriString == null)
|
||||
{
|
||||
throw new ArgumentNullException("uriString");
|
||||
}
|
||||
int length = uriString.Length;
|
||||
if (length <= 1)
|
||||
{
|
||||
throw new FormatException();
|
||||
}
|
||||
int num = uriString.IndexOf(':');
|
||||
if (num < 0)
|
||||
{
|
||||
if (uriString[0] == '/')
|
||||
{
|
||||
this.ParseAsUnixAbsoluteFilePath(uriString);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!uriString.StartsWith("\\\\"))
|
||||
{
|
||||
throw new FormatException("URI scheme was not recognized, nor input string is not recognized as an absolute file path.");
|
||||
}
|
||||
this.ParseAsWindowsUNC(uriString);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (num == 1)
|
||||
{
|
||||
if (!char.IsLetter(uriString[0]))
|
||||
{
|
||||
throw new FormatException("URI scheme must start with alphabet character.");
|
||||
}
|
||||
this.ParseAsWindowsAbsoluteFilePath(uriString);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.scheme = uriString.Substring(0, num).ToLower(CultureInfo.InvariantCulture);
|
||||
if (!char.IsLetter(this.scheme[0]))
|
||||
{
|
||||
throw new FormatException("URI scheme must start with alphabet character.");
|
||||
}
|
||||
for (int i = 1; i < this.scheme.Length; i++)
|
||||
{
|
||||
if (!char.IsLetterOrDigit(this.scheme, i))
|
||||
{
|
||||
switch (this.scheme[i])
|
||||
{
|
||||
case '+':
|
||||
case '-':
|
||||
case '.':
|
||||
goto IL_132;
|
||||
}
|
||||
throw new FormatException("URI scheme must consist of one of alphabet, digits, '+', '-' or '.' character.");
|
||||
}
|
||||
IL_132:;
|
||||
}
|
||||
uriString = uriString.Substring(num + 1);
|
||||
num = uriString.IndexOf('#');
|
||||
if (!this.IsUnc && num != -1)
|
||||
{
|
||||
this.fragment = uriString.Substring(num);
|
||||
uriString = uriString.Substring(0, num);
|
||||
}
|
||||
num = uriString.IndexOf('?');
|
||||
if (num != -1)
|
||||
{
|
||||
this.query = uriString.Substring(num);
|
||||
uriString = uriString.Substring(0, num);
|
||||
if (!this.userEscaped)
|
||||
{
|
||||
this.query = Uri.EscapeString(this.query);
|
||||
}
|
||||
}
|
||||
bool flag = this.scheme == Uri.UriSchemeFile && uriString.StartsWith("///");
|
||||
if (uriString.StartsWith("//"))
|
||||
{
|
||||
if (uriString.StartsWith("////"))
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
uriString = uriString.TrimStart(new char[] { '/' });
|
||||
if (uriString.Length > 1 && uriString[1] == ':')
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
else if (!Uri.IsPredefinedScheme(this.scheme))
|
||||
{
|
||||
this.path = uriString;
|
||||
this.isOpaquePart = true;
|
||||
return;
|
||||
}
|
||||
num = uriString.IndexOfAny(new char[] { '/' });
|
||||
if (flag)
|
||||
{
|
||||
num = -1;
|
||||
}
|
||||
if (num == -1)
|
||||
{
|
||||
if (this.scheme != Uri.UriSchemeMailto && this.scheme != Uri.UriSchemeNews && this.scheme != Uri.UriSchemeFile)
|
||||
{
|
||||
this.path = "/";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.path = uriString.Substring(num);
|
||||
uriString = uriString.Substring(0, num);
|
||||
}
|
||||
num = uriString.IndexOf("@");
|
||||
if (num != -1)
|
||||
{
|
||||
this.userinfo = uriString.Substring(0, num);
|
||||
uriString = uriString.Remove(0, num + 1);
|
||||
}
|
||||
this.port = -1;
|
||||
num = uriString.LastIndexOf(":");
|
||||
if (flag)
|
||||
{
|
||||
num = -1;
|
||||
}
|
||||
if (num != -1 && num != uriString.Length - 1)
|
||||
{
|
||||
string text = uriString.Remove(0, num + 1);
|
||||
if (text.Length > 1 && text[text.Length - 1] != ']')
|
||||
{
|
||||
try
|
||||
{
|
||||
this.port = (int)uint.Parse(text, CultureInfo.InvariantCulture);
|
||||
uriString = uriString.Substring(0, num);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new FormatException("Invalid URI: invalid port number");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.port == -1)
|
||||
{
|
||||
this.port = Uri.GetDefaultPort(this.scheme);
|
||||
}
|
||||
this.host = uriString;
|
||||
if (flag)
|
||||
{
|
||||
this.path = '/' + uriString;
|
||||
this.host = string.Empty;
|
||||
}
|
||||
else if (this.host.Length == 2 && this.host[1] == ':')
|
||||
{
|
||||
this.path = this.host + this.path;
|
||||
this.host = string.Empty;
|
||||
}
|
||||
else if (this.isUnixFilePath)
|
||||
{
|
||||
uriString = "//" + uriString;
|
||||
this.host = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.host.Length == 0)
|
||||
{
|
||||
throw new FormatException("Invalid URI: The hostname could not be parsed");
|
||||
}
|
||||
if (this.scheme == Uri.UriSchemeFile)
|
||||
{
|
||||
this.isUnc = true;
|
||||
}
|
||||
}
|
||||
if (this.scheme != Uri.UriSchemeMailto && this.scheme != Uri.UriSchemeNews && this.scheme != Uri.UriSchemeFile && this.reduce)
|
||||
{
|
||||
this.path = Uri.Reduce(this.path);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000BC8 RID: 3016 RVA: 0x0003557C File Offset: 0x0003377C
|
||||
private static string Reduce(string path)
|
||||
{
|
||||
path = path.Replace('\\', '/');
|
||||
string[] array = path.Split(new char[] { '/' });
|
||||
ArrayList arrayList = new ArrayList();
|
||||
int num = array.Length;
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
string text = array[i];
|
||||
if (text.Length != 0 && !(text == "."))
|
||||
{
|
||||
if (text == "..")
|
||||
{
|
||||
if (arrayList.Count == 0)
|
||||
{
|
||||
if (i != 1)
|
||||
{
|
||||
throw new Exception("Invalid path.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
arrayList.RemoveAt(arrayList.Count - 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
arrayList.Add(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (arrayList.Count == 0)
|
||||
{
|
||||
return "/";
|
||||
}
|
||||
arrayList.Insert(0, string.Empty);
|
||||
string text2 = string.Join("/", (string[])arrayList.ToArray(typeof(string)));
|
||||
if (path.EndsWith("/"))
|
||||
{
|
||||
text2 += '/';
|
||||
}
|
||||
return text2;
|
||||
}
|
||||
|
||||
// Token: 0x06000BC9 RID: 3017 RVA: 0x0003569C File Offset: 0x0003389C
|
||||
internal static string GetSchemeDelimiter(string scheme)
|
||||
{
|
||||
for (int i = 0; i < Uri.schemes.Length; i++)
|
||||
{
|
||||
if (Uri.schemes[i].scheme == scheme)
|
||||
{
|
||||
return Uri.schemes[i].delimiter;
|
||||
}
|
||||
}
|
||||
return Uri.SchemeDelimiter;
|
||||
}
|
||||
|
||||
// Token: 0x06000BCA RID: 3018 RVA: 0x000356F4 File Offset: 0x000338F4
|
||||
internal static int GetDefaultPort(string scheme)
|
||||
{
|
||||
for (int i = 0; i < Uri.schemes.Length; i++)
|
||||
{
|
||||
if (Uri.schemes[i].scheme == scheme)
|
||||
{
|
||||
return Uri.schemes[i].defaultPort;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Token: 0x06000BCB RID: 3019 RVA: 0x00035748 File Offset: 0x00033948
|
||||
private string GetOpaqueWiseSchemeDelimiter()
|
||||
{
|
||||
if (this.isOpaquePart)
|
||||
{
|
||||
return ":";
|
||||
}
|
||||
return Uri.GetSchemeDelimiter(this.scheme);
|
||||
}
|
||||
|
||||
// Token: 0x06000BCC RID: 3020 RVA: 0x00035768 File Offset: 0x00033968
|
||||
protected bool IsBadFileSystemCharacter(char ch)
|
||||
{
|
||||
if (ch < ' ' || (ch < '@' && ch > '9'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
switch (ch)
|
||||
{
|
||||
case '*':
|
||||
case ',':
|
||||
case '/':
|
||||
break;
|
||||
default:
|
||||
switch (ch)
|
||||
{
|
||||
case '\\':
|
||||
case '^':
|
||||
break;
|
||||
default:
|
||||
if (ch != '\0' && ch != '"' && ch != '&' && ch != '|')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x06000BCD RID: 3021 RVA: 0x000357F0 File Offset: 0x000339F0
|
||||
protected static bool IsExcludedCharacter(char ch)
|
||||
{
|
||||
return ch <= ' ' || ch >= '\u007f' || (ch == '"' || ch == '#' || ch == '%' || ch == '<' || ch == '>' || ch == '[' || ch == '\\' || ch == ']' || ch == '^' || ch == '`' || ch == '{' || ch == '|' || ch == '}');
|
||||
}
|
||||
|
||||
// Token: 0x06000BCE RID: 3022 RVA: 0x0003587C File Offset: 0x00033A7C
|
||||
private static bool IsPredefinedScheme(string scheme)
|
||||
{
|
||||
if (scheme != null)
|
||||
{
|
||||
if (Uri.<>f__switch$map17 == null)
|
||||
{
|
||||
Uri.<>f__switch$map17 = new Dictionary<string, int>(8)
|
||||
{
|
||||
{ "http", 0 },
|
||||
{ "https", 0 },
|
||||
{ "file", 0 },
|
||||
{ "ftp", 0 },
|
||||
{ "nntp", 0 },
|
||||
{ "gopher", 0 },
|
||||
{ "mailto", 0 },
|
||||
{ "news", 0 }
|
||||
};
|
||||
}
|
||||
int num;
|
||||
if (Uri.<>f__switch$map17.TryGetValue(scheme, out num))
|
||||
{
|
||||
if (num == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Token: 0x06000BCF RID: 3023 RVA: 0x00035928 File Offset: 0x00033B28
|
||||
protected bool IsReservedCharacter(char ch)
|
||||
{
|
||||
return ch == '$' || ch == '&' || ch == '+' || ch == ',' || ch == '/' || ch == ':' || ch == ';' || ch == '=' || ch == '@';
|
||||
}
|
||||
|
||||
// Token: 0x0400031E RID: 798
|
||||
private bool isUnixFilePath;
|
||||
|
||||
// Token: 0x0400031F RID: 799
|
||||
private string source;
|
||||
|
||||
// Token: 0x04000320 RID: 800
|
||||
private string scheme;
|
||||
|
||||
// Token: 0x04000321 RID: 801
|
||||
private string host;
|
||||
|
||||
// Token: 0x04000322 RID: 802
|
||||
private int port;
|
||||
|
||||
// Token: 0x04000323 RID: 803
|
||||
private string path;
|
||||
|
||||
// Token: 0x04000324 RID: 804
|
||||
private string query;
|
||||
|
||||
// Token: 0x04000325 RID: 805
|
||||
private string fragment;
|
||||
|
||||
// Token: 0x04000326 RID: 806
|
||||
private string userinfo;
|
||||
|
||||
// Token: 0x04000327 RID: 807
|
||||
private bool isUnc;
|
||||
|
||||
// Token: 0x04000328 RID: 808
|
||||
private bool isOpaquePart;
|
||||
|
||||
// Token: 0x04000329 RID: 809
|
||||
private string[] segments;
|
||||
|
||||
// Token: 0x0400032A RID: 810
|
||||
private bool userEscaped;
|
||||
|
||||
// Token: 0x0400032B RID: 811
|
||||
private string cachedAbsoluteUri;
|
||||
|
||||
// Token: 0x0400032C RID: 812
|
||||
private string cachedToString;
|
||||
|
||||
// Token: 0x0400032D RID: 813
|
||||
private string cachedLocalPath;
|
||||
|
||||
// Token: 0x0400032E RID: 814
|
||||
private int cachedHashCode;
|
||||
|
||||
// Token: 0x0400032F RID: 815
|
||||
private bool reduce;
|
||||
|
||||
// Token: 0x04000330 RID: 816
|
||||
private static readonly string hexUpperChars = "0123456789ABCDEF";
|
||||
|
||||
// Token: 0x04000331 RID: 817
|
||||
public static readonly string SchemeDelimiter = "://";
|
||||
|
||||
// Token: 0x04000332 RID: 818
|
||||
public static readonly string UriSchemeFile = "file";
|
||||
|
||||
// Token: 0x04000333 RID: 819
|
||||
public static readonly string UriSchemeFtp = "ftp";
|
||||
|
||||
// Token: 0x04000334 RID: 820
|
||||
public static readonly string UriSchemeGopher = "gopher";
|
||||
|
||||
// Token: 0x04000335 RID: 821
|
||||
public static readonly string UriSchemeHttp = "http";
|
||||
|
||||
// Token: 0x04000336 RID: 822
|
||||
public static readonly string UriSchemeHttps = "https";
|
||||
|
||||
// Token: 0x04000337 RID: 823
|
||||
public static readonly string UriSchemeMailto = "mailto";
|
||||
|
||||
// Token: 0x04000338 RID: 824
|
||||
public static readonly string UriSchemeNews = "news";
|
||||
|
||||
// Token: 0x04000339 RID: 825
|
||||
public static readonly string UriSchemeNntp = "nntp";
|
||||
|
||||
// Token: 0x0400033A RID: 826
|
||||
private static Uri.UriScheme[] schemes = new Uri.UriScheme[]
|
||||
{
|
||||
new Uri.UriScheme(Uri.UriSchemeHttp, Uri.SchemeDelimiter, 80),
|
||||
new Uri.UriScheme(Uri.UriSchemeHttps, Uri.SchemeDelimiter, 443),
|
||||
new Uri.UriScheme(Uri.UriSchemeFtp, Uri.SchemeDelimiter, 21),
|
||||
new Uri.UriScheme(Uri.UriSchemeFile, Uri.SchemeDelimiter, -1),
|
||||
new Uri.UriScheme(Uri.UriSchemeMailto, ":", 25),
|
||||
new Uri.UriScheme(Uri.UriSchemeNews, ":", -1),
|
||||
new Uri.UriScheme(Uri.UriSchemeNntp, Uri.SchemeDelimiter, 119),
|
||||
new Uri.UriScheme(Uri.UriSchemeGopher, Uri.SchemeDelimiter, 70)
|
||||
};
|
||||
|
||||
// Token: 0x020000EC RID: 236
|
||||
private struct UriScheme
|
||||
{
|
||||
// Token: 0x06000BD0 RID: 3024 RVA: 0x00035980 File Offset: 0x00033B80
|
||||
public UriScheme(string s, string d, int p)
|
||||
{
|
||||
this.scheme = s;
|
||||
this.delimiter = d;
|
||||
this.defaultPort = p;
|
||||
}
|
||||
|
||||
// Token: 0x0400033C RID: 828
|
||||
public string scheme;
|
||||
|
||||
// Token: 0x0400033D RID: 829
|
||||
public string delimiter;
|
||||
|
||||
// Token: 0x0400033E RID: 830
|
||||
public int defaultPort;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security
|
||||
{
|
||||
// Token: 0x020000EA RID: 234
|
||||
internal enum UriPartial
|
||||
{
|
||||
// Token: 0x0400031B RID: 795
|
||||
Scheme,
|
||||
// Token: 0x0400031C RID: 796
|
||||
Authority,
|
||||
// Token: 0x0400031D RID: 797
|
||||
Path
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace Mono.Security.X509.Extensions
|
||||
{
|
||||
// Token: 0x020000AF RID: 175
|
||||
internal class BasicConstraintsExtension : X509Extension
|
||||
{
|
||||
// Token: 0x06000994 RID: 2452 RVA: 0x00027844 File Offset: 0x00025A44
|
||||
public BasicConstraintsExtension()
|
||||
{
|
||||
this.extnOid = "2.5.29.19";
|
||||
this.pathLenConstraint = -1;
|
||||
}
|
||||
|
||||
// Token: 0x06000995 RID: 2453 RVA: 0x00027860 File Offset: 0x00025A60
|
||||
public BasicConstraintsExtension(ASN1 asn1)
|
||||
: base(asn1)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000996 RID: 2454 RVA: 0x0002786C File Offset: 0x00025A6C
|
||||
public BasicConstraintsExtension(X509Extension extension)
|
||||
: base(extension)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000997 RID: 2455 RVA: 0x00027878 File Offset: 0x00025A78
|
||||
protected override void Decode()
|
||||
{
|
||||
this.cA = false;
|
||||
this.pathLenConstraint = -1;
|
||||
ASN1 asn = new ASN1(this.extnValue.Value);
|
||||
if (asn.Tag != 48)
|
||||
{
|
||||
throw new ArgumentException("Invalid BasicConstraints extension");
|
||||
}
|
||||
int num = 0;
|
||||
ASN1 asn2 = asn[num++];
|
||||
if (asn2 != null && asn2.Tag == 1)
|
||||
{
|
||||
this.cA = asn2.Value[0] == byte.MaxValue;
|
||||
asn2 = asn[num++];
|
||||
}
|
||||
if (asn2 != null && asn2.Tag == 2)
|
||||
{
|
||||
this.pathLenConstraint = ASN1Convert.ToInt32(asn2);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000998 RID: 2456 RVA: 0x0002791C File Offset: 0x00025B1C
|
||||
protected override void Encode()
|
||||
{
|
||||
ASN1 asn = new ASN1(48);
|
||||
if (this.cA)
|
||||
{
|
||||
asn.Add(new ASN1(1, new byte[] { byte.MaxValue }));
|
||||
}
|
||||
if (this.cA && this.pathLenConstraint >= 0)
|
||||
{
|
||||
asn.Add(ASN1Convert.FromInt32(this.pathLenConstraint));
|
||||
}
|
||||
this.extnValue = new ASN1(4);
|
||||
this.extnValue.Add(asn);
|
||||
}
|
||||
|
||||
// Token: 0x17000116 RID: 278
|
||||
// (get) Token: 0x06000999 RID: 2457 RVA: 0x0002799C File Offset: 0x00025B9C
|
||||
// (set) Token: 0x0600099A RID: 2458 RVA: 0x000279A4 File Offset: 0x00025BA4
|
||||
public bool CertificateAuthority
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.cA;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.cA = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000117 RID: 279
|
||||
// (get) Token: 0x0600099B RID: 2459 RVA: 0x000279B0 File Offset: 0x00025BB0
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Basic Constraints";
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000118 RID: 280
|
||||
// (get) Token: 0x0600099C RID: 2460 RVA: 0x000279B8 File Offset: 0x00025BB8
|
||||
// (set) Token: 0x0600099D RID: 2461 RVA: 0x000279C0 File Offset: 0x00025BC0
|
||||
public int PathLenConstraint
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.pathLenConstraint;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value < -1)
|
||||
{
|
||||
string text = Locale.GetText("PathLenConstraint must be positive or -1 for none ({0}).", new object[] { value });
|
||||
throw new ArgumentOutOfRangeException(text);
|
||||
}
|
||||
this.pathLenConstraint = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600099E RID: 2462 RVA: 0x000279FC File Offset: 0x00025BFC
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.Append("Subject Type=");
|
||||
stringBuilder.Append((!this.cA) ? "End Entity" : "CA");
|
||||
stringBuilder.Append(Environment.NewLine);
|
||||
stringBuilder.Append("Path Length Constraint=");
|
||||
if (this.pathLenConstraint == -1)
|
||||
{
|
||||
stringBuilder.Append("None");
|
||||
}
|
||||
else
|
||||
{
|
||||
stringBuilder.Append(this.pathLenConstraint.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
stringBuilder.Append(Environment.NewLine);
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
// Token: 0x0400022A RID: 554
|
||||
public const int NoPathLengthConstraint = -1;
|
||||
|
||||
// Token: 0x0400022B RID: 555
|
||||
private bool cA;
|
||||
|
||||
// Token: 0x0400022C RID: 556
|
||||
private int pathLenConstraint;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace Mono.Security.X509.Extensions
|
||||
{
|
||||
// Token: 0x020000B1 RID: 177
|
||||
internal class KeyUsageExtension : X509Extension
|
||||
{
|
||||
// Token: 0x0600099F RID: 2463 RVA: 0x00027A9C File Offset: 0x00025C9C
|
||||
public KeyUsageExtension(ASN1 asn1)
|
||||
: base(asn1)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060009A0 RID: 2464 RVA: 0x00027AA8 File Offset: 0x00025CA8
|
||||
public KeyUsageExtension(X509Extension extension)
|
||||
: base(extension)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060009A1 RID: 2465 RVA: 0x00027AB4 File Offset: 0x00025CB4
|
||||
public KeyUsageExtension()
|
||||
{
|
||||
this.extnOid = "2.5.29.15";
|
||||
}
|
||||
|
||||
// Token: 0x060009A2 RID: 2466 RVA: 0x00027AC8 File Offset: 0x00025CC8
|
||||
protected override void Decode()
|
||||
{
|
||||
ASN1 asn = new ASN1(this.extnValue.Value);
|
||||
if (asn.Tag != 3)
|
||||
{
|
||||
throw new ArgumentException("Invalid KeyUsage extension");
|
||||
}
|
||||
int i = 1;
|
||||
while (i < asn.Value.Length)
|
||||
{
|
||||
this.kubits = (this.kubits << 8) + (int)asn.Value[i++];
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060009A3 RID: 2467 RVA: 0x00027B30 File Offset: 0x00025D30
|
||||
protected override void Encode()
|
||||
{
|
||||
this.extnValue = new ASN1(4);
|
||||
ushort num = (ushort)this.kubits;
|
||||
if (num > 0)
|
||||
{
|
||||
byte b;
|
||||
for (b = 15; b > 0; b -= 1)
|
||||
{
|
||||
if ((num & 32768) == 32768)
|
||||
{
|
||||
break;
|
||||
}
|
||||
num = (ushort)(num << 1);
|
||||
}
|
||||
if (this.kubits > 255)
|
||||
{
|
||||
b -= 8;
|
||||
this.extnValue.Add(new ASN1(3, new byte[]
|
||||
{
|
||||
b,
|
||||
(byte)this.kubits,
|
||||
(byte)(this.kubits >> 8)
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.extnValue.Add(new ASN1(3, new byte[]
|
||||
{
|
||||
b,
|
||||
(byte)this.kubits
|
||||
}));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ASN1 extnValue = this.extnValue;
|
||||
byte b2 = 3;
|
||||
byte[] array = new byte[2];
|
||||
array[0] = 7;
|
||||
extnValue.Add(new ASN1(b2, array));
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000119 RID: 281
|
||||
// (get) Token: 0x060009A4 RID: 2468 RVA: 0x00027C20 File Offset: 0x00025E20
|
||||
// (set) Token: 0x060009A5 RID: 2469 RVA: 0x00027C28 File Offset: 0x00025E28
|
||||
public KeyUsages KeyUsage
|
||||
{
|
||||
get
|
||||
{
|
||||
return (KeyUsages)this.kubits;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.kubits = Convert.ToInt32(value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700011A RID: 282
|
||||
// (get) Token: 0x060009A6 RID: 2470 RVA: 0x00027C40 File Offset: 0x00025E40
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Key Usage";
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060009A7 RID: 2471 RVA: 0x00027C48 File Offset: 0x00025E48
|
||||
public bool Support(KeyUsages usage)
|
||||
{
|
||||
int num = Convert.ToInt32(usage, CultureInfo.InvariantCulture);
|
||||
return (num & this.kubits) == num;
|
||||
}
|
||||
|
||||
// Token: 0x060009A8 RID: 2472 RVA: 0x00027C74 File Offset: 0x00025E74
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
if (this.Support(KeyUsages.digitalSignature))
|
||||
{
|
||||
stringBuilder.Append("Digital Signature");
|
||||
}
|
||||
if (this.Support(KeyUsages.nonRepudiation))
|
||||
{
|
||||
if (stringBuilder.Length > 0)
|
||||
{
|
||||
stringBuilder.Append(" , ");
|
||||
}
|
||||
stringBuilder.Append("Non-Repudiation");
|
||||
}
|
||||
if (this.Support(KeyUsages.keyEncipherment))
|
||||
{
|
||||
if (stringBuilder.Length > 0)
|
||||
{
|
||||
stringBuilder.Append(" , ");
|
||||
}
|
||||
stringBuilder.Append("Key Encipherment");
|
||||
}
|
||||
if (this.Support(KeyUsages.dataEncipherment))
|
||||
{
|
||||
if (stringBuilder.Length > 0)
|
||||
{
|
||||
stringBuilder.Append(" , ");
|
||||
}
|
||||
stringBuilder.Append("Data Encipherment");
|
||||
}
|
||||
if (this.Support(KeyUsages.keyAgreement))
|
||||
{
|
||||
if (stringBuilder.Length > 0)
|
||||
{
|
||||
stringBuilder.Append(" , ");
|
||||
}
|
||||
stringBuilder.Append("Key Agreement");
|
||||
}
|
||||
if (this.Support(KeyUsages.keyCertSign))
|
||||
{
|
||||
if (stringBuilder.Length > 0)
|
||||
{
|
||||
stringBuilder.Append(" , ");
|
||||
}
|
||||
stringBuilder.Append("Certificate Signing");
|
||||
}
|
||||
if (this.Support(KeyUsages.cRLSign))
|
||||
{
|
||||
if (stringBuilder.Length > 0)
|
||||
{
|
||||
stringBuilder.Append(" , ");
|
||||
}
|
||||
stringBuilder.Append("CRL Signing");
|
||||
}
|
||||
if (this.Support(KeyUsages.encipherOnly))
|
||||
{
|
||||
if (stringBuilder.Length > 0)
|
||||
{
|
||||
stringBuilder.Append(" , ");
|
||||
}
|
||||
stringBuilder.Append("Encipher Only ");
|
||||
}
|
||||
if (this.Support(KeyUsages.decipherOnly))
|
||||
{
|
||||
if (stringBuilder.Length > 0)
|
||||
{
|
||||
stringBuilder.Append(" , ");
|
||||
}
|
||||
stringBuilder.Append("Decipher Only");
|
||||
}
|
||||
stringBuilder.Append("(");
|
||||
stringBuilder.Append(this.kubits.ToString("X2", CultureInfo.InvariantCulture));
|
||||
stringBuilder.Append(")");
|
||||
stringBuilder.Append(Environment.NewLine);
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
// Token: 0x04000238 RID: 568
|
||||
private int kubits;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.X509.Extensions
|
||||
{
|
||||
// Token: 0x020000B0 RID: 176
|
||||
[Flags]
|
||||
internal enum KeyUsages
|
||||
{
|
||||
// Token: 0x0400022E RID: 558
|
||||
digitalSignature = 128,
|
||||
// Token: 0x0400022F RID: 559
|
||||
nonRepudiation = 64,
|
||||
// Token: 0x04000230 RID: 560
|
||||
keyEncipherment = 32,
|
||||
// Token: 0x04000231 RID: 561
|
||||
dataEncipherment = 16,
|
||||
// Token: 0x04000232 RID: 562
|
||||
keyAgreement = 8,
|
||||
// Token: 0x04000233 RID: 563
|
||||
keyCertSign = 4,
|
||||
// Token: 0x04000234 RID: 564
|
||||
cRLSign = 2,
|
||||
// Token: 0x04000235 RID: 565
|
||||
encipherOnly = 1,
|
||||
// Token: 0x04000236 RID: 566
|
||||
decipherOnly = 2048,
|
||||
// Token: 0x04000237 RID: 567
|
||||
none = 0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace Mono.Security.X509.Extensions
|
||||
{
|
||||
// Token: 0x020000B2 RID: 178
|
||||
internal class SubjectKeyIdentifierExtension : X509Extension
|
||||
{
|
||||
// Token: 0x060009A9 RID: 2473 RVA: 0x00027E70 File Offset: 0x00026070
|
||||
public SubjectKeyIdentifierExtension()
|
||||
{
|
||||
this.extnOid = "2.5.29.14";
|
||||
}
|
||||
|
||||
// Token: 0x060009AA RID: 2474 RVA: 0x00027E84 File Offset: 0x00026084
|
||||
public SubjectKeyIdentifierExtension(ASN1 asn1)
|
||||
: base(asn1)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060009AB RID: 2475 RVA: 0x00027E90 File Offset: 0x00026090
|
||||
public SubjectKeyIdentifierExtension(X509Extension extension)
|
||||
: base(extension)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060009AC RID: 2476 RVA: 0x00027E9C File Offset: 0x0002609C
|
||||
protected override void Decode()
|
||||
{
|
||||
ASN1 asn = new ASN1(this.extnValue.Value);
|
||||
if (asn.Tag != 4)
|
||||
{
|
||||
throw new ArgumentException("Invalid SubjectKeyIdentifier extension");
|
||||
}
|
||||
this.ski = asn.Value;
|
||||
}
|
||||
|
||||
// Token: 0x1700011B RID: 283
|
||||
// (get) Token: 0x060009AD RID: 2477 RVA: 0x00027EE0 File Offset: 0x000260E0
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Subject Key Identifier";
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700011C RID: 284
|
||||
// (get) Token: 0x060009AE RID: 2478 RVA: 0x00027EE8 File Offset: 0x000260E8
|
||||
public byte[] Identifier
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.ski == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (byte[])this.ski.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060009AF RID: 2479 RVA: 0x00027F08 File Offset: 0x00026108
|
||||
public override string ToString()
|
||||
{
|
||||
if (this.ski == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (int i = 0; i < this.ski.Length; i++)
|
||||
{
|
||||
stringBuilder.Append(this.ski[i].ToString("X2", CultureInfo.InvariantCulture));
|
||||
if (i % 2 == 1)
|
||||
{
|
||||
stringBuilder.Append(" ");
|
||||
}
|
||||
}
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
// Token: 0x04000239 RID: 569
|
||||
private byte[] ski;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2347 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Mono.Security.Cryptography;
|
||||
|
||||
namespace Mono.Security.X509
|
||||
{
|
||||
// Token: 0x020000B6 RID: 182
|
||||
internal class PKCS12 : ICloneable
|
||||
{
|
||||
// Token: 0x060009B5 RID: 2485 RVA: 0x00027FB8 File Offset: 0x000261B8
|
||||
public PKCS12()
|
||||
{
|
||||
this._iterations = PKCS12.recommendedIterationCount;
|
||||
this._keyBags = new ArrayList();
|
||||
this._secretBags = new ArrayList();
|
||||
this._certs = new X509CertificateCollection();
|
||||
this._keyBagsChanged = false;
|
||||
this._secretBagsChanged = false;
|
||||
this._certsChanged = false;
|
||||
this._safeBags = new ArrayList();
|
||||
}
|
||||
|
||||
// Token: 0x060009B6 RID: 2486 RVA: 0x00028018 File Offset: 0x00026218
|
||||
public PKCS12(byte[] data)
|
||||
: this()
|
||||
{
|
||||
this.Password = null;
|
||||
this.Decode(data);
|
||||
}
|
||||
|
||||
// Token: 0x060009B7 RID: 2487 RVA: 0x00028030 File Offset: 0x00026230
|
||||
public PKCS12(byte[] data, string password)
|
||||
: this()
|
||||
{
|
||||
this.Password = password;
|
||||
this.Decode(data);
|
||||
}
|
||||
|
||||
// Token: 0x060009B8 RID: 2488 RVA: 0x00028048 File Offset: 0x00026248
|
||||
public PKCS12(byte[] data, byte[] password)
|
||||
: this()
|
||||
{
|
||||
this._password = password;
|
||||
this.Decode(data);
|
||||
}
|
||||
|
||||
// Token: 0x060009BA RID: 2490 RVA: 0x00028078 File Offset: 0x00026278
|
||||
private void Decode(byte[] data)
|
||||
{
|
||||
ASN1 asn = new ASN1(data);
|
||||
if (asn.Tag != 48)
|
||||
{
|
||||
throw new ArgumentException("invalid data");
|
||||
}
|
||||
ASN1 asn2 = asn[0];
|
||||
if (asn2.Tag != 2)
|
||||
{
|
||||
throw new ArgumentException("invalid PFX version");
|
||||
}
|
||||
PKCS7.ContentInfo contentInfo = new PKCS7.ContentInfo(asn[1]);
|
||||
if (contentInfo.ContentType != "1.2.840.113549.1.7.1")
|
||||
{
|
||||
throw new ArgumentException("invalid authenticated safe");
|
||||
}
|
||||
if (asn.Count > 2)
|
||||
{
|
||||
ASN1 asn3 = asn[2];
|
||||
if (asn3.Tag != 48)
|
||||
{
|
||||
throw new ArgumentException("invalid MAC");
|
||||
}
|
||||
ASN1 asn4 = asn3[0];
|
||||
if (asn4.Tag != 48)
|
||||
{
|
||||
throw new ArgumentException("invalid MAC");
|
||||
}
|
||||
ASN1 asn5 = asn4[0];
|
||||
string text = ASN1Convert.ToOid(asn5[0]);
|
||||
if (text != "1.3.14.3.2.26")
|
||||
{
|
||||
throw new ArgumentException("unsupported HMAC");
|
||||
}
|
||||
byte[] value = asn4[1].Value;
|
||||
ASN1 asn6 = asn3[1];
|
||||
if (asn6.Tag != 4)
|
||||
{
|
||||
throw new ArgumentException("missing MAC salt");
|
||||
}
|
||||
this._iterations = 1;
|
||||
if (asn3.Count > 2)
|
||||
{
|
||||
ASN1 asn7 = asn3[2];
|
||||
if (asn7.Tag != 2)
|
||||
{
|
||||
throw new ArgumentException("invalid MAC iteration");
|
||||
}
|
||||
this._iterations = ASN1Convert.ToInt32(asn7);
|
||||
}
|
||||
byte[] value2 = contentInfo.Content[0].Value;
|
||||
byte[] array = this.MAC(this._password, asn6.Value, this._iterations, value2);
|
||||
if (!this.Compare(value, array))
|
||||
{
|
||||
throw new CryptographicException("Invalid MAC - file may have been tampered!");
|
||||
}
|
||||
}
|
||||
ASN1 asn8 = new ASN1(contentInfo.Content[0].Value);
|
||||
int i = 0;
|
||||
while (i < asn8.Count)
|
||||
{
|
||||
PKCS7.ContentInfo contentInfo2 = new PKCS7.ContentInfo(asn8[i]);
|
||||
string contentType = contentInfo2.ContentType;
|
||||
if (contentType != null)
|
||||
{
|
||||
if (PKCS12.<>f__switch$map8 == null)
|
||||
{
|
||||
PKCS12.<>f__switch$map8 = new Dictionary<string, int>(3)
|
||||
{
|
||||
{ "1.2.840.113549.1.7.1", 0 },
|
||||
{ "1.2.840.113549.1.7.6", 1 },
|
||||
{ "1.2.840.113549.1.7.3", 2 }
|
||||
};
|
||||
}
|
||||
int num;
|
||||
if (PKCS12.<>f__switch$map8.TryGetValue(contentType, out num))
|
||||
{
|
||||
switch (num)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
ASN1 asn9 = new ASN1(contentInfo2.Content[0].Value);
|
||||
for (int j = 0; j < asn9.Count; j++)
|
||||
{
|
||||
ASN1 asn10 = asn9[j];
|
||||
this.ReadSafeBag(asn10);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
PKCS7.EncryptedData encryptedData = new PKCS7.EncryptedData(contentInfo2.Content[0]);
|
||||
ASN1 asn11 = new ASN1(this.Decrypt(encryptedData));
|
||||
for (int k = 0; k < asn11.Count; k++)
|
||||
{
|
||||
ASN1 asn12 = asn11[k];
|
||||
this.ReadSafeBag(asn12);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
throw new NotImplementedException("public key encrypted");
|
||||
default:
|
||||
goto IL_303;
|
||||
}
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
IL_303:
|
||||
throw new ArgumentException("unknown authenticatedSafe");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060009BB RID: 2491 RVA: 0x000283A8 File Offset: 0x000265A8
|
||||
~PKCS12()
|
||||
{
|
||||
if (this._password != null)
|
||||
{
|
||||
Array.Clear(this._password, 0, this._password.Length);
|
||||
}
|
||||
this._password = null;
|
||||
}
|
||||
|
||||
// Token: 0x1700011F RID: 287
|
||||
// (set) Token: 0x060009BC RID: 2492 RVA: 0x00028404 File Offset: 0x00026604
|
||||
public string Password
|
||||
{
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
if (value.Length > 0)
|
||||
{
|
||||
int num = value.Length;
|
||||
int num2 = 0;
|
||||
if (num < PKCS12.MaximumPasswordLength)
|
||||
{
|
||||
if (value[num - 1] != '\0')
|
||||
{
|
||||
num2 = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
num = PKCS12.MaximumPasswordLength;
|
||||
}
|
||||
this._password = new byte[num + num2 << 1];
|
||||
Encoding.BigEndianUnicode.GetBytes(value, 0, num, this._password, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._password = new byte[2];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this._password = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000120 RID: 288
|
||||
// (get) Token: 0x060009BD RID: 2493 RVA: 0x00028494 File Offset: 0x00026694
|
||||
// (set) Token: 0x060009BE RID: 2494 RVA: 0x0002849C File Offset: 0x0002669C
|
||||
public int IterationCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._iterations;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._iterations = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000121 RID: 289
|
||||
// (get) Token: 0x060009BF RID: 2495 RVA: 0x000284A8 File Offset: 0x000266A8
|
||||
public ArrayList Keys
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._keyBagsChanged)
|
||||
{
|
||||
this._keyBags.Clear();
|
||||
foreach (object obj in this._safeBags)
|
||||
{
|
||||
SafeBag safeBag = (SafeBag)obj;
|
||||
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.1"))
|
||||
{
|
||||
ASN1 asn = safeBag.ASN1;
|
||||
ASN1 asn2 = asn[1];
|
||||
PKCS8.PrivateKeyInfo privateKeyInfo = new PKCS8.PrivateKeyInfo(asn2.Value);
|
||||
byte[] privateKey = privateKeyInfo.PrivateKey;
|
||||
byte b = privateKey[0];
|
||||
if (b != 2)
|
||||
{
|
||||
if (b == 48)
|
||||
{
|
||||
this._keyBags.Add(PKCS8.PrivateKeyInfo.DecodeRSA(privateKey));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DSAParameters dsaparameters = default(DSAParameters);
|
||||
this._keyBags.Add(PKCS8.PrivateKeyInfo.DecodeDSA(privateKey, dsaparameters));
|
||||
}
|
||||
Array.Clear(privateKey, 0, privateKey.Length);
|
||||
}
|
||||
else if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.2"))
|
||||
{
|
||||
ASN1 asn3 = safeBag.ASN1;
|
||||
ASN1 asn4 = asn3[1];
|
||||
PKCS8.EncryptedPrivateKeyInfo encryptedPrivateKeyInfo = new PKCS8.EncryptedPrivateKeyInfo(asn4.Value);
|
||||
byte[] array = this.Decrypt(encryptedPrivateKeyInfo.Algorithm, encryptedPrivateKeyInfo.Salt, encryptedPrivateKeyInfo.IterationCount, encryptedPrivateKeyInfo.EncryptedData);
|
||||
PKCS8.PrivateKeyInfo privateKeyInfo2 = new PKCS8.PrivateKeyInfo(array);
|
||||
byte[] privateKey2 = privateKeyInfo2.PrivateKey;
|
||||
byte b = privateKey2[0];
|
||||
if (b != 2)
|
||||
{
|
||||
if (b == 48)
|
||||
{
|
||||
this._keyBags.Add(PKCS8.PrivateKeyInfo.DecodeRSA(privateKey2));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DSAParameters dsaparameters2 = default(DSAParameters);
|
||||
this._keyBags.Add(PKCS8.PrivateKeyInfo.DecodeDSA(privateKey2, dsaparameters2));
|
||||
}
|
||||
Array.Clear(privateKey2, 0, privateKey2.Length);
|
||||
Array.Clear(array, 0, array.Length);
|
||||
}
|
||||
}
|
||||
this._keyBagsChanged = false;
|
||||
}
|
||||
return ArrayList.ReadOnly(this._keyBags);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000122 RID: 290
|
||||
// (get) Token: 0x060009C0 RID: 2496 RVA: 0x000286C0 File Offset: 0x000268C0
|
||||
public ArrayList Secrets
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._secretBagsChanged)
|
||||
{
|
||||
this._secretBags.Clear();
|
||||
foreach (object obj in this._safeBags)
|
||||
{
|
||||
SafeBag safeBag = (SafeBag)obj;
|
||||
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.5"))
|
||||
{
|
||||
ASN1 asn = safeBag.ASN1;
|
||||
ASN1 asn2 = asn[1];
|
||||
byte[] value = asn2.Value;
|
||||
this._secretBags.Add(value);
|
||||
}
|
||||
}
|
||||
this._secretBagsChanged = false;
|
||||
}
|
||||
return ArrayList.ReadOnly(this._secretBags);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000123 RID: 291
|
||||
// (get) Token: 0x060009C1 RID: 2497 RVA: 0x00028790 File Offset: 0x00026990
|
||||
public X509CertificateCollection Certificates
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._certsChanged)
|
||||
{
|
||||
this._certs.Clear();
|
||||
foreach (object obj in this._safeBags)
|
||||
{
|
||||
SafeBag safeBag = (SafeBag)obj;
|
||||
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.3"))
|
||||
{
|
||||
ASN1 asn = safeBag.ASN1;
|
||||
ASN1 asn2 = asn[1];
|
||||
PKCS7.ContentInfo contentInfo = new PKCS7.ContentInfo(asn2.Value);
|
||||
this._certs.Add(new X509Certificate(contentInfo.Content[0].Value));
|
||||
}
|
||||
}
|
||||
this._certsChanged = false;
|
||||
}
|
||||
return this._certs;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000124 RID: 292
|
||||
// (get) Token: 0x060009C2 RID: 2498 RVA: 0x00028874 File Offset: 0x00026A74
|
||||
internal RandomNumberGenerator RNG
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._rng == null)
|
||||
{
|
||||
this._rng = RandomNumberGenerator.Create();
|
||||
}
|
||||
return this._rng;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060009C3 RID: 2499 RVA: 0x00028894 File Offset: 0x00026A94
|
||||
private bool Compare(byte[] expected, byte[] actual)
|
||||
{
|
||||
bool flag = false;
|
||||
if (expected.Length == actual.Length)
|
||||
{
|
||||
for (int i = 0; i < expected.Length; i++)
|
||||
{
|
||||
if (expected[i] != actual[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
flag = true;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x060009C4 RID: 2500 RVA: 0x000288D4 File Offset: 0x00026AD4
|
||||
private SymmetricAlgorithm GetSymmetricAlgorithm(string algorithmOid, byte[] salt, int iterationCount)
|
||||
{
|
||||
string text = null;
|
||||
int num = 8;
|
||||
int num2 = 8;
|
||||
PKCS12.DeriveBytes deriveBytes = new PKCS12.DeriveBytes();
|
||||
deriveBytes.Password = this._password;
|
||||
deriveBytes.Salt = salt;
|
||||
deriveBytes.IterationCount = iterationCount;
|
||||
if (algorithmOid != null)
|
||||
{
|
||||
if (PKCS12.<>f__switch$map9 == null)
|
||||
{
|
||||
PKCS12.<>f__switch$map9 = new Dictionary<string, int>(12)
|
||||
{
|
||||
{ "1.2.840.113549.1.5.1", 0 },
|
||||
{ "1.2.840.113549.1.5.3", 1 },
|
||||
{ "1.2.840.113549.1.5.4", 2 },
|
||||
{ "1.2.840.113549.1.5.6", 3 },
|
||||
{ "1.2.840.113549.1.5.10", 4 },
|
||||
{ "1.2.840.113549.1.5.11", 5 },
|
||||
{ "1.2.840.113549.1.12.1.1", 6 },
|
||||
{ "1.2.840.113549.1.12.1.2", 7 },
|
||||
{ "1.2.840.113549.1.12.1.3", 8 },
|
||||
{ "1.2.840.113549.1.12.1.4", 9 },
|
||||
{ "1.2.840.113549.1.12.1.5", 10 },
|
||||
{ "1.2.840.113549.1.12.1.6", 11 }
|
||||
};
|
||||
}
|
||||
int num3;
|
||||
if (PKCS12.<>f__switch$map9.TryGetValue(algorithmOid, out num3))
|
||||
{
|
||||
switch (num3)
|
||||
{
|
||||
case 0:
|
||||
deriveBytes.HashName = "MD2";
|
||||
text = "DES";
|
||||
break;
|
||||
case 1:
|
||||
deriveBytes.HashName = "MD5";
|
||||
text = "DES";
|
||||
break;
|
||||
case 2:
|
||||
deriveBytes.HashName = "MD2";
|
||||
text = "RC2";
|
||||
num = 4;
|
||||
break;
|
||||
case 3:
|
||||
deriveBytes.HashName = "MD5";
|
||||
text = "RC2";
|
||||
num = 4;
|
||||
break;
|
||||
case 4:
|
||||
deriveBytes.HashName = "SHA1";
|
||||
text = "DES";
|
||||
break;
|
||||
case 5:
|
||||
deriveBytes.HashName = "SHA1";
|
||||
text = "RC2";
|
||||
num = 4;
|
||||
break;
|
||||
case 6:
|
||||
deriveBytes.HashName = "SHA1";
|
||||
text = "RC4";
|
||||
num = 16;
|
||||
num2 = 0;
|
||||
break;
|
||||
case 7:
|
||||
deriveBytes.HashName = "SHA1";
|
||||
text = "RC4";
|
||||
num = 5;
|
||||
num2 = 0;
|
||||
break;
|
||||
case 8:
|
||||
deriveBytes.HashName = "SHA1";
|
||||
text = "TripleDES";
|
||||
num = 24;
|
||||
break;
|
||||
case 9:
|
||||
deriveBytes.HashName = "SHA1";
|
||||
text = "TripleDES";
|
||||
num = 16;
|
||||
break;
|
||||
case 10:
|
||||
deriveBytes.HashName = "SHA1";
|
||||
text = "RC2";
|
||||
num = 16;
|
||||
break;
|
||||
case 11:
|
||||
deriveBytes.HashName = "SHA1";
|
||||
text = "RC2";
|
||||
num = 5;
|
||||
break;
|
||||
default:
|
||||
goto IL_25A;
|
||||
}
|
||||
SymmetricAlgorithm symmetricAlgorithm = SymmetricAlgorithm.Create(text);
|
||||
symmetricAlgorithm.Key = deriveBytes.DeriveKey(num);
|
||||
if (num2 > 0)
|
||||
{
|
||||
symmetricAlgorithm.IV = deriveBytes.DeriveIV(num2);
|
||||
symmetricAlgorithm.Mode = CipherMode.CBC;
|
||||
}
|
||||
return symmetricAlgorithm;
|
||||
}
|
||||
}
|
||||
IL_25A:
|
||||
throw new NotSupportedException("unknown oid " + text);
|
||||
}
|
||||
|
||||
// Token: 0x060009C5 RID: 2501 RVA: 0x00028B84 File Offset: 0x00026D84
|
||||
public byte[] Decrypt(string algorithmOid, byte[] salt, int iterationCount, byte[] encryptedData)
|
||||
{
|
||||
SymmetricAlgorithm symmetricAlgorithm = null;
|
||||
byte[] array = null;
|
||||
try
|
||||
{
|
||||
symmetricAlgorithm = this.GetSymmetricAlgorithm(algorithmOid, salt, iterationCount);
|
||||
ICryptoTransform cryptoTransform = symmetricAlgorithm.CreateDecryptor();
|
||||
array = cryptoTransform.TransformFinalBlock(encryptedData, 0, encryptedData.Length);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (symmetricAlgorithm != null)
|
||||
{
|
||||
symmetricAlgorithm.Clear();
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x060009C6 RID: 2502 RVA: 0x00028BE4 File Offset: 0x00026DE4
|
||||
public byte[] Decrypt(PKCS7.EncryptedData ed)
|
||||
{
|
||||
return this.Decrypt(ed.EncryptionAlgorithm.ContentType, ed.EncryptionAlgorithm.Content[0].Value, ASN1Convert.ToInt32(ed.EncryptionAlgorithm.Content[1]), ed.EncryptedContent);
|
||||
}
|
||||
|
||||
// Token: 0x060009C7 RID: 2503 RVA: 0x00028C34 File Offset: 0x00026E34
|
||||
public byte[] Encrypt(string algorithmOid, byte[] salt, int iterationCount, byte[] data)
|
||||
{
|
||||
byte[] array = null;
|
||||
using (SymmetricAlgorithm symmetricAlgorithm = this.GetSymmetricAlgorithm(algorithmOid, salt, iterationCount))
|
||||
{
|
||||
ICryptoTransform cryptoTransform = symmetricAlgorithm.CreateEncryptor();
|
||||
array = cryptoTransform.TransformFinalBlock(data, 0, data.Length);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x060009C8 RID: 2504 RVA: 0x00028C94 File Offset: 0x00026E94
|
||||
private DSAParameters GetExistingParameters(out bool found)
|
||||
{
|
||||
foreach (X509Certificate x509Certificate in this.Certificates)
|
||||
{
|
||||
if (x509Certificate.KeyAlgorithmParameters != null)
|
||||
{
|
||||
DSA dsa = x509Certificate.DSA;
|
||||
if (dsa != null)
|
||||
{
|
||||
found = true;
|
||||
return dsa.ExportParameters(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
found = false;
|
||||
return default(DSAParameters);
|
||||
}
|
||||
|
||||
// Token: 0x060009C9 RID: 2505 RVA: 0x00028D34 File Offset: 0x00026F34
|
||||
private void AddPrivateKey(PKCS8.PrivateKeyInfo pki)
|
||||
{
|
||||
byte[] privateKey = pki.PrivateKey;
|
||||
byte b = privateKey[0];
|
||||
if (b != 2)
|
||||
{
|
||||
if (b != 48)
|
||||
{
|
||||
Array.Clear(privateKey, 0, privateKey.Length);
|
||||
throw new CryptographicException("Unknown private key format");
|
||||
}
|
||||
this._keyBags.Add(PKCS8.PrivateKeyInfo.DecodeRSA(privateKey));
|
||||
}
|
||||
else
|
||||
{
|
||||
bool flag;
|
||||
DSAParameters existingParameters = this.GetExistingParameters(out flag);
|
||||
if (flag)
|
||||
{
|
||||
this._keyBags.Add(PKCS8.PrivateKeyInfo.DecodeDSA(privateKey, existingParameters));
|
||||
}
|
||||
}
|
||||
Array.Clear(privateKey, 0, privateKey.Length);
|
||||
}
|
||||
|
||||
// Token: 0x060009CA RID: 2506 RVA: 0x00028DC0 File Offset: 0x00026FC0
|
||||
private void ReadSafeBag(ASN1 safeBag)
|
||||
{
|
||||
if (safeBag.Tag != 48)
|
||||
{
|
||||
throw new ArgumentException("invalid safeBag");
|
||||
}
|
||||
ASN1 asn = safeBag[0];
|
||||
if (asn.Tag != 6)
|
||||
{
|
||||
throw new ArgumentException("invalid safeBag id");
|
||||
}
|
||||
ASN1 asn2 = safeBag[1];
|
||||
string text = ASN1Convert.ToOid(asn);
|
||||
string text2 = text;
|
||||
if (text2 != null)
|
||||
{
|
||||
if (PKCS12.<>f__switch$mapA == null)
|
||||
{
|
||||
PKCS12.<>f__switch$mapA = new Dictionary<string, int>(6)
|
||||
{
|
||||
{ "1.2.840.113549.1.12.10.1.1", 0 },
|
||||
{ "1.2.840.113549.1.12.10.1.2", 1 },
|
||||
{ "1.2.840.113549.1.12.10.1.3", 2 },
|
||||
{ "1.2.840.113549.1.12.10.1.4", 3 },
|
||||
{ "1.2.840.113549.1.12.10.1.5", 4 },
|
||||
{ "1.2.840.113549.1.12.10.1.6", 5 }
|
||||
};
|
||||
}
|
||||
int num;
|
||||
if (PKCS12.<>f__switch$mapA.TryGetValue(text2, out num))
|
||||
{
|
||||
switch (num)
|
||||
{
|
||||
case 0:
|
||||
this.AddPrivateKey(new PKCS8.PrivateKeyInfo(asn2.Value));
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
PKCS8.EncryptedPrivateKeyInfo encryptedPrivateKeyInfo = new PKCS8.EncryptedPrivateKeyInfo(asn2.Value);
|
||||
byte[] array = this.Decrypt(encryptedPrivateKeyInfo.Algorithm, encryptedPrivateKeyInfo.Salt, encryptedPrivateKeyInfo.IterationCount, encryptedPrivateKeyInfo.EncryptedData);
|
||||
this.AddPrivateKey(new PKCS8.PrivateKeyInfo(array));
|
||||
Array.Clear(array, 0, array.Length);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
PKCS7.ContentInfo contentInfo = new PKCS7.ContentInfo(asn2.Value);
|
||||
if (contentInfo.ContentType != "1.2.840.113549.1.9.22.1")
|
||||
{
|
||||
throw new NotSupportedException("unsupport certificate type");
|
||||
}
|
||||
X509Certificate x509Certificate = new X509Certificate(contentInfo.Content[0].Value);
|
||||
this._certs.Add(x509Certificate);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
byte[] value = asn2.Value;
|
||||
this._secretBags.Add(value);
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
break;
|
||||
default:
|
||||
goto IL_1CD;
|
||||
}
|
||||
if (safeBag.Count > 2)
|
||||
{
|
||||
ASN1 asn3 = safeBag[2];
|
||||
if (asn3.Tag != 49)
|
||||
{
|
||||
throw new ArgumentException("invalid safeBag attributes id");
|
||||
}
|
||||
for (int i = 0; i < asn3.Count; i++)
|
||||
{
|
||||
ASN1 asn4 = asn3[i];
|
||||
if (asn4.Tag != 48)
|
||||
{
|
||||
throw new ArgumentException("invalid PKCS12 attributes id");
|
||||
}
|
||||
ASN1 asn5 = asn4[0];
|
||||
if (asn5.Tag != 6)
|
||||
{
|
||||
throw new ArgumentException("invalid attribute id");
|
||||
}
|
||||
string text3 = ASN1Convert.ToOid(asn5);
|
||||
ASN1 asn6 = asn4[1];
|
||||
int j = 0;
|
||||
while (j < asn6.Count)
|
||||
{
|
||||
ASN1 asn7 = asn6[j];
|
||||
text2 = text3;
|
||||
if (text2 != null)
|
||||
{
|
||||
if (PKCS12.<>f__switch$mapB == null)
|
||||
{
|
||||
PKCS12.<>f__switch$mapB = new Dictionary<string, int>(2)
|
||||
{
|
||||
{ "1.2.840.113549.1.9.20", 0 },
|
||||
{ "1.2.840.113549.1.9.21", 1 }
|
||||
};
|
||||
}
|
||||
if (PKCS12.<>f__switch$mapB.TryGetValue(text2, out num))
|
||||
{
|
||||
if (num != 0)
|
||||
{
|
||||
if (num == 1)
|
||||
{
|
||||
if (asn7.Tag != 4)
|
||||
{
|
||||
throw new ArgumentException("invalid attribute value id");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (asn7.Tag != 30)
|
||||
{
|
||||
throw new ArgumentException("invalid attribute value id");
|
||||
}
|
||||
}
|
||||
}
|
||||
IL_31F:
|
||||
j++;
|
||||
continue;
|
||||
goto IL_31F;
|
||||
}
|
||||
}
|
||||
}
|
||||
this._safeBags.Add(new SafeBag(text, safeBag));
|
||||
return;
|
||||
}
|
||||
}
|
||||
IL_1CD:
|
||||
throw new ArgumentException("unknown safeBag oid");
|
||||
}
|
||||
|
||||
// Token: 0x060009CB RID: 2507 RVA: 0x00029128 File Offset: 0x00027328
|
||||
private ASN1 Pkcs8ShroudedKeyBagSafeBag(AsymmetricAlgorithm aa, IDictionary attributes)
|
||||
{
|
||||
PKCS8.PrivateKeyInfo privateKeyInfo = new PKCS8.PrivateKeyInfo();
|
||||
if (aa is RSA)
|
||||
{
|
||||
privateKeyInfo.Algorithm = "1.2.840.113549.1.1.1";
|
||||
privateKeyInfo.PrivateKey = PKCS8.PrivateKeyInfo.Encode((RSA)aa);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(aa is DSA))
|
||||
{
|
||||
throw new CryptographicException("Unknown asymmetric algorithm {0}", aa.ToString());
|
||||
}
|
||||
privateKeyInfo.Algorithm = null;
|
||||
privateKeyInfo.PrivateKey = PKCS8.PrivateKeyInfo.Encode((DSA)aa);
|
||||
}
|
||||
PKCS8.EncryptedPrivateKeyInfo encryptedPrivateKeyInfo = new PKCS8.EncryptedPrivateKeyInfo();
|
||||
encryptedPrivateKeyInfo.Algorithm = "1.2.840.113549.1.12.1.3";
|
||||
encryptedPrivateKeyInfo.IterationCount = this._iterations;
|
||||
encryptedPrivateKeyInfo.EncryptedData = this.Encrypt("1.2.840.113549.1.12.1.3", encryptedPrivateKeyInfo.Salt, this._iterations, privateKeyInfo.GetBytes());
|
||||
ASN1 asn = new ASN1(48);
|
||||
asn.Add(ASN1Convert.FromOid("1.2.840.113549.1.12.10.1.2"));
|
||||
ASN1 asn2 = new ASN1(160);
|
||||
asn2.Add(new ASN1(encryptedPrivateKeyInfo.GetBytes()));
|
||||
asn.Add(asn2);
|
||||
if (attributes != null)
|
||||
{
|
||||
ASN1 asn3 = new ASN1(49);
|
||||
IDictionaryEnumerator enumerator = attributes.GetEnumerator();
|
||||
while (enumerator.MoveNext())
|
||||
{
|
||||
string text = (string)enumerator.Key;
|
||||
string text2 = text;
|
||||
if (text2 != null)
|
||||
{
|
||||
if (PKCS12.<>f__switch$mapC == null)
|
||||
{
|
||||
PKCS12.<>f__switch$mapC = new Dictionary<string, int>(2)
|
||||
{
|
||||
{ "1.2.840.113549.1.9.20", 0 },
|
||||
{ "1.2.840.113549.1.9.21", 1 }
|
||||
};
|
||||
}
|
||||
int num;
|
||||
if (PKCS12.<>f__switch$mapC.TryGetValue(text2, out num))
|
||||
{
|
||||
if (num != 0)
|
||||
{
|
||||
if (num == 1)
|
||||
{
|
||||
ArrayList arrayList = (ArrayList)enumerator.Value;
|
||||
if (arrayList.Count > 0)
|
||||
{
|
||||
ASN1 asn4 = new ASN1(48);
|
||||
asn4.Add(ASN1Convert.FromOid("1.2.840.113549.1.9.21"));
|
||||
ASN1 asn5 = new ASN1(49);
|
||||
foreach (object obj in arrayList)
|
||||
{
|
||||
byte[] array = (byte[])obj;
|
||||
asn5.Add(new ASN1(4)
|
||||
{
|
||||
Value = array
|
||||
});
|
||||
}
|
||||
asn4.Add(asn5);
|
||||
asn3.Add(asn4);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ArrayList arrayList2 = (ArrayList)enumerator.Value;
|
||||
if (arrayList2.Count > 0)
|
||||
{
|
||||
ASN1 asn6 = new ASN1(48);
|
||||
asn6.Add(ASN1Convert.FromOid("1.2.840.113549.1.9.20"));
|
||||
ASN1 asn7 = new ASN1(49);
|
||||
foreach (object obj2 in arrayList2)
|
||||
{
|
||||
byte[] array2 = (byte[])obj2;
|
||||
asn7.Add(new ASN1(30)
|
||||
{
|
||||
Value = array2
|
||||
});
|
||||
}
|
||||
asn6.Add(asn7);
|
||||
asn3.Add(asn6);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (asn3.Count > 0)
|
||||
{
|
||||
asn.Add(asn3);
|
||||
}
|
||||
}
|
||||
return asn;
|
||||
}
|
||||
|
||||
// Token: 0x060009CC RID: 2508 RVA: 0x00029478 File Offset: 0x00027678
|
||||
private ASN1 KeyBagSafeBag(AsymmetricAlgorithm aa, IDictionary attributes)
|
||||
{
|
||||
PKCS8.PrivateKeyInfo privateKeyInfo = new PKCS8.PrivateKeyInfo();
|
||||
if (aa is RSA)
|
||||
{
|
||||
privateKeyInfo.Algorithm = "1.2.840.113549.1.1.1";
|
||||
privateKeyInfo.PrivateKey = PKCS8.PrivateKeyInfo.Encode((RSA)aa);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(aa is DSA))
|
||||
{
|
||||
throw new CryptographicException("Unknown asymmetric algorithm {0}", aa.ToString());
|
||||
}
|
||||
privateKeyInfo.Algorithm = null;
|
||||
privateKeyInfo.PrivateKey = PKCS8.PrivateKeyInfo.Encode((DSA)aa);
|
||||
}
|
||||
ASN1 asn = new ASN1(48);
|
||||
asn.Add(ASN1Convert.FromOid("1.2.840.113549.1.12.10.1.1"));
|
||||
ASN1 asn2 = new ASN1(160);
|
||||
asn2.Add(new ASN1(privateKeyInfo.GetBytes()));
|
||||
asn.Add(asn2);
|
||||
if (attributes != null)
|
||||
{
|
||||
ASN1 asn3 = new ASN1(49);
|
||||
IDictionaryEnumerator enumerator = attributes.GetEnumerator();
|
||||
while (enumerator.MoveNext())
|
||||
{
|
||||
string text = (string)enumerator.Key;
|
||||
string text2 = text;
|
||||
if (text2 != null)
|
||||
{
|
||||
if (PKCS12.<>f__switch$mapD == null)
|
||||
{
|
||||
PKCS12.<>f__switch$mapD = new Dictionary<string, int>(2)
|
||||
{
|
||||
{ "1.2.840.113549.1.9.20", 0 },
|
||||
{ "1.2.840.113549.1.9.21", 1 }
|
||||
};
|
||||
}
|
||||
int num;
|
||||
if (PKCS12.<>f__switch$mapD.TryGetValue(text2, out num))
|
||||
{
|
||||
if (num != 0)
|
||||
{
|
||||
if (num == 1)
|
||||
{
|
||||
ArrayList arrayList = (ArrayList)enumerator.Value;
|
||||
if (arrayList.Count > 0)
|
||||
{
|
||||
ASN1 asn4 = new ASN1(48);
|
||||
asn4.Add(ASN1Convert.FromOid("1.2.840.113549.1.9.21"));
|
||||
ASN1 asn5 = new ASN1(49);
|
||||
foreach (object obj in arrayList)
|
||||
{
|
||||
byte[] array = (byte[])obj;
|
||||
asn5.Add(new ASN1(4)
|
||||
{
|
||||
Value = array
|
||||
});
|
||||
}
|
||||
asn4.Add(asn5);
|
||||
asn3.Add(asn4);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ArrayList arrayList2 = (ArrayList)enumerator.Value;
|
||||
if (arrayList2.Count > 0)
|
||||
{
|
||||
ASN1 asn6 = new ASN1(48);
|
||||
asn6.Add(ASN1Convert.FromOid("1.2.840.113549.1.9.20"));
|
||||
ASN1 asn7 = new ASN1(49);
|
||||
foreach (object obj2 in arrayList2)
|
||||
{
|
||||
byte[] array2 = (byte[])obj2;
|
||||
asn7.Add(new ASN1(30)
|
||||
{
|
||||
Value = array2
|
||||
});
|
||||
}
|
||||
asn6.Add(asn7);
|
||||
asn3.Add(asn6);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (asn3.Count > 0)
|
||||
{
|
||||
asn.Add(asn3);
|
||||
}
|
||||
}
|
||||
return asn;
|
||||
}
|
||||
|
||||
// Token: 0x060009CD RID: 2509 RVA: 0x00029784 File Offset: 0x00027984
|
||||
private ASN1 SecretBagSafeBag(byte[] secret, IDictionary attributes)
|
||||
{
|
||||
ASN1 asn = new ASN1(48);
|
||||
asn.Add(ASN1Convert.FromOid("1.2.840.113549.1.12.10.1.5"));
|
||||
ASN1 asn2 = new ASN1(128, secret);
|
||||
asn.Add(asn2);
|
||||
if (attributes != null)
|
||||
{
|
||||
ASN1 asn3 = new ASN1(49);
|
||||
IDictionaryEnumerator enumerator = attributes.GetEnumerator();
|
||||
while (enumerator.MoveNext())
|
||||
{
|
||||
string text = (string)enumerator.Key;
|
||||
string text2 = text;
|
||||
if (text2 != null)
|
||||
{
|
||||
if (PKCS12.<>f__switch$mapE == null)
|
||||
{
|
||||
PKCS12.<>f__switch$mapE = new Dictionary<string, int>(2)
|
||||
{
|
||||
{ "1.2.840.113549.1.9.20", 0 },
|
||||
{ "1.2.840.113549.1.9.21", 1 }
|
||||
};
|
||||
}
|
||||
int num;
|
||||
if (PKCS12.<>f__switch$mapE.TryGetValue(text2, out num))
|
||||
{
|
||||
if (num != 0)
|
||||
{
|
||||
if (num == 1)
|
||||
{
|
||||
ArrayList arrayList = (ArrayList)enumerator.Value;
|
||||
if (arrayList.Count > 0)
|
||||
{
|
||||
ASN1 asn4 = new ASN1(48);
|
||||
asn4.Add(ASN1Convert.FromOid("1.2.840.113549.1.9.21"));
|
||||
ASN1 asn5 = new ASN1(49);
|
||||
foreach (object obj in arrayList)
|
||||
{
|
||||
byte[] array = (byte[])obj;
|
||||
asn5.Add(new ASN1(4)
|
||||
{
|
||||
Value = array
|
||||
});
|
||||
}
|
||||
asn4.Add(asn5);
|
||||
asn3.Add(asn4);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ArrayList arrayList2 = (ArrayList)enumerator.Value;
|
||||
if (arrayList2.Count > 0)
|
||||
{
|
||||
ASN1 asn6 = new ASN1(48);
|
||||
asn6.Add(ASN1Convert.FromOid("1.2.840.113549.1.9.20"));
|
||||
ASN1 asn7 = new ASN1(49);
|
||||
foreach (object obj2 in arrayList2)
|
||||
{
|
||||
byte[] array2 = (byte[])obj2;
|
||||
asn7.Add(new ASN1(30)
|
||||
{
|
||||
Value = array2
|
||||
});
|
||||
}
|
||||
asn6.Add(asn7);
|
||||
asn3.Add(asn6);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (asn3.Count > 0)
|
||||
{
|
||||
asn.Add(asn3);
|
||||
}
|
||||
}
|
||||
return asn;
|
||||
}
|
||||
|
||||
// Token: 0x060009CE RID: 2510 RVA: 0x00029A0C File Offset: 0x00027C0C
|
||||
private ASN1 CertificateSafeBag(X509Certificate x509, IDictionary attributes)
|
||||
{
|
||||
ASN1 asn = new ASN1(4, x509.RawData);
|
||||
PKCS7.ContentInfo contentInfo = new PKCS7.ContentInfo();
|
||||
contentInfo.ContentType = "1.2.840.113549.1.9.22.1";
|
||||
contentInfo.Content.Add(asn);
|
||||
ASN1 asn2 = new ASN1(160);
|
||||
asn2.Add(contentInfo.ASN1);
|
||||
ASN1 asn3 = new ASN1(48);
|
||||
asn3.Add(ASN1Convert.FromOid("1.2.840.113549.1.12.10.1.3"));
|
||||
asn3.Add(asn2);
|
||||
if (attributes != null)
|
||||
{
|
||||
ASN1 asn4 = new ASN1(49);
|
||||
IDictionaryEnumerator enumerator = attributes.GetEnumerator();
|
||||
while (enumerator.MoveNext())
|
||||
{
|
||||
string text = (string)enumerator.Key;
|
||||
string text2 = text;
|
||||
if (text2 != null)
|
||||
{
|
||||
if (PKCS12.<>f__switch$mapF == null)
|
||||
{
|
||||
PKCS12.<>f__switch$mapF = new Dictionary<string, int>(2)
|
||||
{
|
||||
{ "1.2.840.113549.1.9.20", 0 },
|
||||
{ "1.2.840.113549.1.9.21", 1 }
|
||||
};
|
||||
}
|
||||
int num;
|
||||
if (PKCS12.<>f__switch$mapF.TryGetValue(text2, out num))
|
||||
{
|
||||
if (num != 0)
|
||||
{
|
||||
if (num == 1)
|
||||
{
|
||||
ArrayList arrayList = (ArrayList)enumerator.Value;
|
||||
if (arrayList.Count > 0)
|
||||
{
|
||||
ASN1 asn5 = new ASN1(48);
|
||||
asn5.Add(ASN1Convert.FromOid("1.2.840.113549.1.9.21"));
|
||||
ASN1 asn6 = new ASN1(49);
|
||||
foreach (object obj in arrayList)
|
||||
{
|
||||
byte[] array = (byte[])obj;
|
||||
asn6.Add(new ASN1(4)
|
||||
{
|
||||
Value = array
|
||||
});
|
||||
}
|
||||
asn5.Add(asn6);
|
||||
asn4.Add(asn5);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ArrayList arrayList2 = (ArrayList)enumerator.Value;
|
||||
if (arrayList2.Count > 0)
|
||||
{
|
||||
ASN1 asn7 = new ASN1(48);
|
||||
asn7.Add(ASN1Convert.FromOid("1.2.840.113549.1.9.20"));
|
||||
ASN1 asn8 = new ASN1(49);
|
||||
foreach (object obj2 in arrayList2)
|
||||
{
|
||||
byte[] array2 = (byte[])obj2;
|
||||
asn8.Add(new ASN1(30)
|
||||
{
|
||||
Value = array2
|
||||
});
|
||||
}
|
||||
asn7.Add(asn8);
|
||||
asn4.Add(asn7);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (asn4.Count > 0)
|
||||
{
|
||||
asn3.Add(asn4);
|
||||
}
|
||||
}
|
||||
return asn3;
|
||||
}
|
||||
|
||||
// Token: 0x060009CF RID: 2511 RVA: 0x00029CD8 File Offset: 0x00027ED8
|
||||
private byte[] MAC(byte[] password, byte[] salt, int iterations, byte[] data)
|
||||
{
|
||||
PKCS12.DeriveBytes deriveBytes = new PKCS12.DeriveBytes();
|
||||
deriveBytes.HashName = "SHA1";
|
||||
deriveBytes.Password = password;
|
||||
deriveBytes.Salt = salt;
|
||||
deriveBytes.IterationCount = iterations;
|
||||
HMACSHA1 hmacsha = (HMACSHA1)HMAC.Create();
|
||||
hmacsha.Key = deriveBytes.DeriveMAC(20);
|
||||
return hmacsha.ComputeHash(data, 0, data.Length);
|
||||
}
|
||||
|
||||
// Token: 0x060009D0 RID: 2512 RVA: 0x00029D34 File Offset: 0x00027F34
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
ASN1 asn = new ASN1(48);
|
||||
ArrayList arrayList = new ArrayList();
|
||||
foreach (object obj in this._safeBags)
|
||||
{
|
||||
SafeBag safeBag = (SafeBag)obj;
|
||||
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.3"))
|
||||
{
|
||||
ASN1 asn2 = safeBag.ASN1;
|
||||
ASN1 asn3 = asn2[1];
|
||||
PKCS7.ContentInfo contentInfo = new PKCS7.ContentInfo(asn3.Value);
|
||||
arrayList.Add(new X509Certificate(contentInfo.Content[0].Value));
|
||||
}
|
||||
}
|
||||
ArrayList arrayList2 = new ArrayList();
|
||||
ArrayList arrayList3 = new ArrayList();
|
||||
foreach (X509Certificate x509Certificate in this.Certificates)
|
||||
{
|
||||
bool flag = false;
|
||||
foreach (object obj2 in arrayList)
|
||||
{
|
||||
X509Certificate x509Certificate2 = (X509Certificate)obj2;
|
||||
if (this.Compare(x509Certificate.RawData, x509Certificate2.RawData))
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
arrayList2.Add(x509Certificate);
|
||||
}
|
||||
}
|
||||
foreach (object obj3 in arrayList)
|
||||
{
|
||||
X509Certificate x509Certificate3 = (X509Certificate)obj3;
|
||||
bool flag2 = false;
|
||||
foreach (X509Certificate x509Certificate4 in this.Certificates)
|
||||
{
|
||||
if (this.Compare(x509Certificate3.RawData, x509Certificate4.RawData))
|
||||
{
|
||||
flag2 = true;
|
||||
}
|
||||
}
|
||||
if (!flag2)
|
||||
{
|
||||
arrayList3.Add(x509Certificate3);
|
||||
}
|
||||
}
|
||||
foreach (object obj4 in arrayList3)
|
||||
{
|
||||
X509Certificate x509Certificate5 = (X509Certificate)obj4;
|
||||
this.RemoveCertificate(x509Certificate5);
|
||||
}
|
||||
foreach (object obj5 in arrayList2)
|
||||
{
|
||||
X509Certificate x509Certificate6 = (X509Certificate)obj5;
|
||||
this.AddCertificate(x509Certificate6);
|
||||
}
|
||||
if (this._safeBags.Count > 0)
|
||||
{
|
||||
ASN1 asn4 = new ASN1(48);
|
||||
foreach (object obj6 in this._safeBags)
|
||||
{
|
||||
SafeBag safeBag2 = (SafeBag)obj6;
|
||||
if (safeBag2.BagOID.Equals("1.2.840.113549.1.12.10.1.3"))
|
||||
{
|
||||
asn4.Add(safeBag2.ASN1);
|
||||
}
|
||||
}
|
||||
if (asn4.Count > 0)
|
||||
{
|
||||
PKCS7.ContentInfo contentInfo2 = this.EncryptedContentInfo(asn4, "1.2.840.113549.1.12.1.3");
|
||||
asn.Add(contentInfo2.ASN1);
|
||||
}
|
||||
}
|
||||
if (this._safeBags.Count > 0)
|
||||
{
|
||||
ASN1 asn5 = new ASN1(48);
|
||||
foreach (object obj7 in this._safeBags)
|
||||
{
|
||||
SafeBag safeBag3 = (SafeBag)obj7;
|
||||
if (safeBag3.BagOID.Equals("1.2.840.113549.1.12.10.1.1") || safeBag3.BagOID.Equals("1.2.840.113549.1.12.10.1.2"))
|
||||
{
|
||||
asn5.Add(safeBag3.ASN1);
|
||||
}
|
||||
}
|
||||
if (asn5.Count > 0)
|
||||
{
|
||||
ASN1 asn6 = new ASN1(160);
|
||||
asn6.Add(new ASN1(4, asn5.GetBytes()));
|
||||
asn.Add(new PKCS7.ContentInfo("1.2.840.113549.1.7.1")
|
||||
{
|
||||
Content = asn6
|
||||
}.ASN1);
|
||||
}
|
||||
}
|
||||
if (this._safeBags.Count > 0)
|
||||
{
|
||||
ASN1 asn7 = new ASN1(48);
|
||||
foreach (object obj8 in this._safeBags)
|
||||
{
|
||||
SafeBag safeBag4 = (SafeBag)obj8;
|
||||
if (safeBag4.BagOID.Equals("1.2.840.113549.1.12.10.1.5"))
|
||||
{
|
||||
asn7.Add(safeBag4.ASN1);
|
||||
}
|
||||
}
|
||||
if (asn7.Count > 0)
|
||||
{
|
||||
PKCS7.ContentInfo contentInfo3 = this.EncryptedContentInfo(asn7, "1.2.840.113549.1.12.1.3");
|
||||
asn.Add(contentInfo3.ASN1);
|
||||
}
|
||||
}
|
||||
ASN1 asn8 = new ASN1(4, asn.GetBytes());
|
||||
ASN1 asn9 = new ASN1(160);
|
||||
asn9.Add(asn8);
|
||||
PKCS7.ContentInfo contentInfo4 = new PKCS7.ContentInfo("1.2.840.113549.1.7.1");
|
||||
contentInfo4.Content = asn9;
|
||||
ASN1 asn10 = new ASN1(48);
|
||||
if (this._password != null)
|
||||
{
|
||||
byte[] array = new byte[20];
|
||||
this.RNG.GetBytes(array);
|
||||
byte[] array2 = this.MAC(this._password, array, this._iterations, contentInfo4.Content[0].Value);
|
||||
ASN1 asn11 = new ASN1(48);
|
||||
asn11.Add(ASN1Convert.FromOid("1.3.14.3.2.26"));
|
||||
asn11.Add(new ASN1(5));
|
||||
ASN1 asn12 = new ASN1(48);
|
||||
asn12.Add(asn11);
|
||||
asn12.Add(new ASN1(4, array2));
|
||||
asn10.Add(asn12);
|
||||
asn10.Add(new ASN1(4, array));
|
||||
asn10.Add(ASN1Convert.FromInt32(this._iterations));
|
||||
}
|
||||
ASN1 asn13 = new ASN1(2, new byte[] { 3 });
|
||||
ASN1 asn14 = new ASN1(48);
|
||||
asn14.Add(asn13);
|
||||
asn14.Add(contentInfo4.ASN1);
|
||||
if (asn10.Count > 0)
|
||||
{
|
||||
asn14.Add(asn10);
|
||||
}
|
||||
return asn14.GetBytes();
|
||||
}
|
||||
|
||||
// Token: 0x060009D1 RID: 2513 RVA: 0x0002A488 File Offset: 0x00028688
|
||||
private PKCS7.ContentInfo EncryptedContentInfo(ASN1 safeBags, string algorithmOid)
|
||||
{
|
||||
byte[] array = new byte[8];
|
||||
this.RNG.GetBytes(array);
|
||||
ASN1 asn = new ASN1(48);
|
||||
asn.Add(new ASN1(4, array));
|
||||
asn.Add(ASN1Convert.FromInt32(this._iterations));
|
||||
ASN1 asn2 = new ASN1(48);
|
||||
asn2.Add(ASN1Convert.FromOid(algorithmOid));
|
||||
asn2.Add(asn);
|
||||
byte[] array2 = this.Encrypt(algorithmOid, array, this._iterations, safeBags.GetBytes());
|
||||
ASN1 asn3 = new ASN1(128, array2);
|
||||
ASN1 asn4 = new ASN1(48);
|
||||
asn4.Add(ASN1Convert.FromOid("1.2.840.113549.1.7.1"));
|
||||
asn4.Add(asn2);
|
||||
asn4.Add(asn3);
|
||||
ASN1 asn5 = new ASN1(2, new byte[1]);
|
||||
ASN1 asn6 = new ASN1(48);
|
||||
asn6.Add(asn5);
|
||||
asn6.Add(asn4);
|
||||
ASN1 asn7 = new ASN1(160);
|
||||
asn7.Add(asn6);
|
||||
return new PKCS7.ContentInfo("1.2.840.113549.1.7.6")
|
||||
{
|
||||
Content = asn7
|
||||
};
|
||||
}
|
||||
|
||||
// Token: 0x060009D2 RID: 2514 RVA: 0x0002A598 File Offset: 0x00028798
|
||||
public void AddCertificate(X509Certificate cert)
|
||||
{
|
||||
this.AddCertificate(cert, null);
|
||||
}
|
||||
|
||||
// Token: 0x060009D3 RID: 2515 RVA: 0x0002A5A4 File Offset: 0x000287A4
|
||||
public void AddCertificate(X509Certificate cert, IDictionary attributes)
|
||||
{
|
||||
bool flag = false;
|
||||
int num = 0;
|
||||
while (!flag && num < this._safeBags.Count)
|
||||
{
|
||||
SafeBag safeBag = (SafeBag)this._safeBags[num];
|
||||
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.3"))
|
||||
{
|
||||
ASN1 asn = safeBag.ASN1;
|
||||
ASN1 asn2 = asn[1];
|
||||
PKCS7.ContentInfo contentInfo = new PKCS7.ContentInfo(asn2.Value);
|
||||
X509Certificate x509Certificate = new X509Certificate(contentInfo.Content[0].Value);
|
||||
if (this.Compare(cert.RawData, x509Certificate.RawData))
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
num++;
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
this._safeBags.Add(new SafeBag("1.2.840.113549.1.12.10.1.3", this.CertificateSafeBag(cert, attributes)));
|
||||
this._certsChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060009D4 RID: 2516 RVA: 0x0002A678 File Offset: 0x00028878
|
||||
public void RemoveCertificate(X509Certificate cert)
|
||||
{
|
||||
this.RemoveCertificate(cert, null);
|
||||
}
|
||||
|
||||
// Token: 0x060009D5 RID: 2517 RVA: 0x0002A684 File Offset: 0x00028884
|
||||
public void RemoveCertificate(X509Certificate cert, IDictionary attrs)
|
||||
{
|
||||
int num = -1;
|
||||
int num2 = 0;
|
||||
while (num == -1 && num2 < this._safeBags.Count)
|
||||
{
|
||||
SafeBag safeBag = (SafeBag)this._safeBags[num2];
|
||||
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.3"))
|
||||
{
|
||||
ASN1 asn = safeBag.ASN1;
|
||||
ASN1 asn2 = asn[1];
|
||||
PKCS7.ContentInfo contentInfo = new PKCS7.ContentInfo(asn2.Value);
|
||||
X509Certificate x509Certificate = new X509Certificate(contentInfo.Content[0].Value);
|
||||
if (this.Compare(cert.RawData, x509Certificate.RawData))
|
||||
{
|
||||
if (attrs != null)
|
||||
{
|
||||
if (asn.Count == 3)
|
||||
{
|
||||
ASN1 asn3 = asn[2];
|
||||
int num3 = 0;
|
||||
for (int i = 0; i < asn3.Count; i++)
|
||||
{
|
||||
ASN1 asn4 = asn3[i];
|
||||
ASN1 asn5 = asn4[0];
|
||||
string text = ASN1Convert.ToOid(asn5);
|
||||
ArrayList arrayList = (ArrayList)attrs[text];
|
||||
if (arrayList != null)
|
||||
{
|
||||
ASN1 asn6 = asn4[1];
|
||||
if (arrayList.Count == asn6.Count)
|
||||
{
|
||||
int num4 = 0;
|
||||
for (int j = 0; j < asn6.Count; j++)
|
||||
{
|
||||
ASN1 asn7 = asn6[j];
|
||||
byte[] array = (byte[])arrayList[j];
|
||||
if (this.Compare(array, asn7.Value))
|
||||
{
|
||||
num4++;
|
||||
}
|
||||
}
|
||||
if (num4 == asn6.Count)
|
||||
{
|
||||
num3++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (num3 == asn3.Count)
|
||||
{
|
||||
num = num2;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
num = num2;
|
||||
}
|
||||
}
|
||||
}
|
||||
num2++;
|
||||
}
|
||||
if (num != -1)
|
||||
{
|
||||
this._safeBags.RemoveAt(num);
|
||||
this._certsChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060009D6 RID: 2518 RVA: 0x0002A850 File Offset: 0x00028A50
|
||||
private bool CompareAsymmetricAlgorithm(AsymmetricAlgorithm a1, AsymmetricAlgorithm a2)
|
||||
{
|
||||
return a1.KeySize == a2.KeySize && a1.ToXmlString(false) == a2.ToXmlString(false);
|
||||
}
|
||||
|
||||
// Token: 0x060009D7 RID: 2519 RVA: 0x0002A884 File Offset: 0x00028A84
|
||||
public void AddPkcs8ShroudedKeyBag(AsymmetricAlgorithm aa)
|
||||
{
|
||||
this.AddPkcs8ShroudedKeyBag(aa, null);
|
||||
}
|
||||
|
||||
// Token: 0x060009D8 RID: 2520 RVA: 0x0002A890 File Offset: 0x00028A90
|
||||
public void AddPkcs8ShroudedKeyBag(AsymmetricAlgorithm aa, IDictionary attributes)
|
||||
{
|
||||
bool flag = false;
|
||||
int num = 0;
|
||||
while (!flag && num < this._safeBags.Count)
|
||||
{
|
||||
SafeBag safeBag = (SafeBag)this._safeBags[num];
|
||||
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.2"))
|
||||
{
|
||||
ASN1 asn = safeBag.ASN1[1];
|
||||
PKCS8.EncryptedPrivateKeyInfo encryptedPrivateKeyInfo = new PKCS8.EncryptedPrivateKeyInfo(asn.Value);
|
||||
byte[] array = this.Decrypt(encryptedPrivateKeyInfo.Algorithm, encryptedPrivateKeyInfo.Salt, encryptedPrivateKeyInfo.IterationCount, encryptedPrivateKeyInfo.EncryptedData);
|
||||
PKCS8.PrivateKeyInfo privateKeyInfo = new PKCS8.PrivateKeyInfo(array);
|
||||
byte[] privateKey = privateKeyInfo.PrivateKey;
|
||||
byte b = privateKey[0];
|
||||
AsymmetricAlgorithm asymmetricAlgorithm;
|
||||
if (b != 2)
|
||||
{
|
||||
if (b != 48)
|
||||
{
|
||||
Array.Clear(array, 0, array.Length);
|
||||
Array.Clear(privateKey, 0, privateKey.Length);
|
||||
throw new CryptographicException("Unknown private key format");
|
||||
}
|
||||
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeRSA(privateKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeDSA(privateKey, default(DSAParameters));
|
||||
}
|
||||
Array.Clear(array, 0, array.Length);
|
||||
Array.Clear(privateKey, 0, privateKey.Length);
|
||||
if (this.CompareAsymmetricAlgorithm(aa, asymmetricAlgorithm))
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
num++;
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
this._safeBags.Add(new SafeBag("1.2.840.113549.1.12.10.1.2", this.Pkcs8ShroudedKeyBagSafeBag(aa, attributes)));
|
||||
this._keyBagsChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060009D9 RID: 2521 RVA: 0x0002A9F4 File Offset: 0x00028BF4
|
||||
public void RemovePkcs8ShroudedKeyBag(AsymmetricAlgorithm aa)
|
||||
{
|
||||
int num = -1;
|
||||
int num2 = 0;
|
||||
while (num == -1 && num2 < this._safeBags.Count)
|
||||
{
|
||||
SafeBag safeBag = (SafeBag)this._safeBags[num2];
|
||||
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.2"))
|
||||
{
|
||||
ASN1 asn = safeBag.ASN1[1];
|
||||
PKCS8.EncryptedPrivateKeyInfo encryptedPrivateKeyInfo = new PKCS8.EncryptedPrivateKeyInfo(asn.Value);
|
||||
byte[] array = this.Decrypt(encryptedPrivateKeyInfo.Algorithm, encryptedPrivateKeyInfo.Salt, encryptedPrivateKeyInfo.IterationCount, encryptedPrivateKeyInfo.EncryptedData);
|
||||
PKCS8.PrivateKeyInfo privateKeyInfo = new PKCS8.PrivateKeyInfo(array);
|
||||
byte[] privateKey = privateKeyInfo.PrivateKey;
|
||||
byte b = privateKey[0];
|
||||
AsymmetricAlgorithm asymmetricAlgorithm;
|
||||
if (b != 2)
|
||||
{
|
||||
if (b != 48)
|
||||
{
|
||||
Array.Clear(array, 0, array.Length);
|
||||
Array.Clear(privateKey, 0, privateKey.Length);
|
||||
throw new CryptographicException("Unknown private key format");
|
||||
}
|
||||
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeRSA(privateKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeDSA(privateKey, default(DSAParameters));
|
||||
}
|
||||
Array.Clear(array, 0, array.Length);
|
||||
Array.Clear(privateKey, 0, privateKey.Length);
|
||||
if (this.CompareAsymmetricAlgorithm(aa, asymmetricAlgorithm))
|
||||
{
|
||||
num = num2;
|
||||
}
|
||||
}
|
||||
num2++;
|
||||
}
|
||||
if (num != -1)
|
||||
{
|
||||
this._safeBags.RemoveAt(num);
|
||||
this._keyBagsChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060009DA RID: 2522 RVA: 0x0002AB48 File Offset: 0x00028D48
|
||||
public void AddKeyBag(AsymmetricAlgorithm aa)
|
||||
{
|
||||
this.AddKeyBag(aa, null);
|
||||
}
|
||||
|
||||
// Token: 0x060009DB RID: 2523 RVA: 0x0002AB54 File Offset: 0x00028D54
|
||||
public void AddKeyBag(AsymmetricAlgorithm aa, IDictionary attributes)
|
||||
{
|
||||
bool flag = false;
|
||||
int num = 0;
|
||||
while (!flag && num < this._safeBags.Count)
|
||||
{
|
||||
SafeBag safeBag = (SafeBag)this._safeBags[num];
|
||||
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.1"))
|
||||
{
|
||||
ASN1 asn = safeBag.ASN1[1];
|
||||
PKCS8.PrivateKeyInfo privateKeyInfo = new PKCS8.PrivateKeyInfo(asn.Value);
|
||||
byte[] privateKey = privateKeyInfo.PrivateKey;
|
||||
byte b = privateKey[0];
|
||||
AsymmetricAlgorithm asymmetricAlgorithm;
|
||||
if (b != 2)
|
||||
{
|
||||
if (b != 48)
|
||||
{
|
||||
Array.Clear(privateKey, 0, privateKey.Length);
|
||||
throw new CryptographicException("Unknown private key format");
|
||||
}
|
||||
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeRSA(privateKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeDSA(privateKey, default(DSAParameters));
|
||||
}
|
||||
Array.Clear(privateKey, 0, privateKey.Length);
|
||||
if (this.CompareAsymmetricAlgorithm(aa, asymmetricAlgorithm))
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
num++;
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
this._safeBags.Add(new SafeBag("1.2.840.113549.1.12.10.1.1", this.KeyBagSafeBag(aa, attributes)));
|
||||
this._keyBagsChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060009DC RID: 2524 RVA: 0x0002AC74 File Offset: 0x00028E74
|
||||
public void RemoveKeyBag(AsymmetricAlgorithm aa)
|
||||
{
|
||||
int num = -1;
|
||||
int num2 = 0;
|
||||
while (num == -1 && num2 < this._safeBags.Count)
|
||||
{
|
||||
SafeBag safeBag = (SafeBag)this._safeBags[num2];
|
||||
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.1"))
|
||||
{
|
||||
ASN1 asn = safeBag.ASN1[1];
|
||||
PKCS8.PrivateKeyInfo privateKeyInfo = new PKCS8.PrivateKeyInfo(asn.Value);
|
||||
byte[] privateKey = privateKeyInfo.PrivateKey;
|
||||
byte b = privateKey[0];
|
||||
AsymmetricAlgorithm asymmetricAlgorithm;
|
||||
if (b != 2)
|
||||
{
|
||||
if (b != 48)
|
||||
{
|
||||
Array.Clear(privateKey, 0, privateKey.Length);
|
||||
throw new CryptographicException("Unknown private key format");
|
||||
}
|
||||
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeRSA(privateKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeDSA(privateKey, default(DSAParameters));
|
||||
}
|
||||
Array.Clear(privateKey, 0, privateKey.Length);
|
||||
if (this.CompareAsymmetricAlgorithm(aa, asymmetricAlgorithm))
|
||||
{
|
||||
num = num2;
|
||||
}
|
||||
}
|
||||
num2++;
|
||||
}
|
||||
if (num != -1)
|
||||
{
|
||||
this._safeBags.RemoveAt(num);
|
||||
this._keyBagsChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060009DD RID: 2525 RVA: 0x0002AD84 File Offset: 0x00028F84
|
||||
public void AddSecretBag(byte[] secret)
|
||||
{
|
||||
this.AddSecretBag(secret, null);
|
||||
}
|
||||
|
||||
// Token: 0x060009DE RID: 2526 RVA: 0x0002AD90 File Offset: 0x00028F90
|
||||
public void AddSecretBag(byte[] secret, IDictionary attributes)
|
||||
{
|
||||
bool flag = false;
|
||||
int num = 0;
|
||||
while (!flag && num < this._safeBags.Count)
|
||||
{
|
||||
SafeBag safeBag = (SafeBag)this._safeBags[num];
|
||||
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.5"))
|
||||
{
|
||||
ASN1 asn = safeBag.ASN1[1];
|
||||
byte[] value = asn.Value;
|
||||
if (this.Compare(secret, value))
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
num++;
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
this._safeBags.Add(new SafeBag("1.2.840.113549.1.12.10.1.5", this.SecretBagSafeBag(secret, attributes)));
|
||||
this._secretBagsChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060009DF RID: 2527 RVA: 0x0002AE38 File Offset: 0x00029038
|
||||
public void RemoveSecretBag(byte[] secret)
|
||||
{
|
||||
int num = -1;
|
||||
int num2 = 0;
|
||||
while (num == -1 && num2 < this._safeBags.Count)
|
||||
{
|
||||
SafeBag safeBag = (SafeBag)this._safeBags[num2];
|
||||
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.5"))
|
||||
{
|
||||
ASN1 asn = safeBag.ASN1[1];
|
||||
byte[] value = asn.Value;
|
||||
if (this.Compare(secret, value))
|
||||
{
|
||||
num = num2;
|
||||
}
|
||||
}
|
||||
num2++;
|
||||
}
|
||||
if (num != -1)
|
||||
{
|
||||
this._safeBags.RemoveAt(num);
|
||||
this._secretBagsChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060009E0 RID: 2528 RVA: 0x0002AED0 File Offset: 0x000290D0
|
||||
public AsymmetricAlgorithm GetAsymmetricAlgorithm(IDictionary attrs)
|
||||
{
|
||||
foreach (object obj in this._safeBags)
|
||||
{
|
||||
SafeBag safeBag = (SafeBag)obj;
|
||||
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.1") || safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.2"))
|
||||
{
|
||||
ASN1 asn = safeBag.ASN1;
|
||||
if (asn.Count == 3)
|
||||
{
|
||||
ASN1 asn2 = asn[2];
|
||||
int num = 0;
|
||||
for (int i = 0; i < asn2.Count; i++)
|
||||
{
|
||||
ASN1 asn3 = asn2[i];
|
||||
ASN1 asn4 = asn3[0];
|
||||
string text = ASN1Convert.ToOid(asn4);
|
||||
ArrayList arrayList = (ArrayList)attrs[text];
|
||||
if (arrayList != null)
|
||||
{
|
||||
ASN1 asn5 = asn3[1];
|
||||
if (arrayList.Count == asn5.Count)
|
||||
{
|
||||
int num2 = 0;
|
||||
for (int j = 0; j < asn5.Count; j++)
|
||||
{
|
||||
ASN1 asn6 = asn5[j];
|
||||
byte[] array = (byte[])arrayList[j];
|
||||
if (this.Compare(array, asn6.Value))
|
||||
{
|
||||
num2++;
|
||||
}
|
||||
}
|
||||
if (num2 == asn5.Count)
|
||||
{
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (num == asn2.Count)
|
||||
{
|
||||
ASN1 asn7 = asn[1];
|
||||
AsymmetricAlgorithm asymmetricAlgorithm = null;
|
||||
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.1"))
|
||||
{
|
||||
PKCS8.PrivateKeyInfo privateKeyInfo = new PKCS8.PrivateKeyInfo(asn7.Value);
|
||||
byte[] privateKey = privateKeyInfo.PrivateKey;
|
||||
byte b = privateKey[0];
|
||||
if (b != 2)
|
||||
{
|
||||
if (b == 48)
|
||||
{
|
||||
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeRSA(privateKey);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeDSA(privateKey, default(DSAParameters));
|
||||
}
|
||||
Array.Clear(privateKey, 0, privateKey.Length);
|
||||
}
|
||||
else if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.2"))
|
||||
{
|
||||
PKCS8.EncryptedPrivateKeyInfo encryptedPrivateKeyInfo = new PKCS8.EncryptedPrivateKeyInfo(asn7.Value);
|
||||
byte[] array2 = this.Decrypt(encryptedPrivateKeyInfo.Algorithm, encryptedPrivateKeyInfo.Salt, encryptedPrivateKeyInfo.IterationCount, encryptedPrivateKeyInfo.EncryptedData);
|
||||
PKCS8.PrivateKeyInfo privateKeyInfo2 = new PKCS8.PrivateKeyInfo(array2);
|
||||
byte[] privateKey2 = privateKeyInfo2.PrivateKey;
|
||||
byte b = privateKey2[0];
|
||||
if (b != 2)
|
||||
{
|
||||
if (b == 48)
|
||||
{
|
||||
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeRSA(privateKey2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeDSA(privateKey2, default(DSAParameters));
|
||||
}
|
||||
Array.Clear(privateKey2, 0, privateKey2.Length);
|
||||
Array.Clear(array2, 0, array2.Length);
|
||||
}
|
||||
return asymmetricAlgorithm;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x060009E1 RID: 2529 RVA: 0x0002B1B8 File Offset: 0x000293B8
|
||||
public byte[] GetSecret(IDictionary attrs)
|
||||
{
|
||||
foreach (object obj in this._safeBags)
|
||||
{
|
||||
SafeBag safeBag = (SafeBag)obj;
|
||||
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.5"))
|
||||
{
|
||||
ASN1 asn = safeBag.ASN1;
|
||||
if (asn.Count == 3)
|
||||
{
|
||||
ASN1 asn2 = asn[2];
|
||||
int num = 0;
|
||||
for (int i = 0; i < asn2.Count; i++)
|
||||
{
|
||||
ASN1 asn3 = asn2[i];
|
||||
ASN1 asn4 = asn3[0];
|
||||
string text = ASN1Convert.ToOid(asn4);
|
||||
ArrayList arrayList = (ArrayList)attrs[text];
|
||||
if (arrayList != null)
|
||||
{
|
||||
ASN1 asn5 = asn3[1];
|
||||
if (arrayList.Count == asn5.Count)
|
||||
{
|
||||
int num2 = 0;
|
||||
for (int j = 0; j < asn5.Count; j++)
|
||||
{
|
||||
ASN1 asn6 = asn5[j];
|
||||
byte[] array = (byte[])arrayList[j];
|
||||
if (this.Compare(array, asn6.Value))
|
||||
{
|
||||
num2++;
|
||||
}
|
||||
}
|
||||
if (num2 == asn5.Count)
|
||||
{
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (num == asn2.Count)
|
||||
{
|
||||
ASN1 asn7 = asn[1];
|
||||
return asn7.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x060009E2 RID: 2530 RVA: 0x0002B354 File Offset: 0x00029554
|
||||
public X509Certificate GetCertificate(IDictionary attrs)
|
||||
{
|
||||
foreach (object obj in this._safeBags)
|
||||
{
|
||||
SafeBag safeBag = (SafeBag)obj;
|
||||
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.3"))
|
||||
{
|
||||
ASN1 asn = safeBag.ASN1;
|
||||
if (asn.Count == 3)
|
||||
{
|
||||
ASN1 asn2 = asn[2];
|
||||
int num = 0;
|
||||
for (int i = 0; i < asn2.Count; i++)
|
||||
{
|
||||
ASN1 asn3 = asn2[i];
|
||||
ASN1 asn4 = asn3[0];
|
||||
string text = ASN1Convert.ToOid(asn4);
|
||||
ArrayList arrayList = (ArrayList)attrs[text];
|
||||
if (arrayList != null)
|
||||
{
|
||||
ASN1 asn5 = asn3[1];
|
||||
if (arrayList.Count == asn5.Count)
|
||||
{
|
||||
int num2 = 0;
|
||||
for (int j = 0; j < asn5.Count; j++)
|
||||
{
|
||||
ASN1 asn6 = asn5[j];
|
||||
byte[] array = (byte[])arrayList[j];
|
||||
if (this.Compare(array, asn6.Value))
|
||||
{
|
||||
num2++;
|
||||
}
|
||||
}
|
||||
if (num2 == asn5.Count)
|
||||
{
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (num == asn2.Count)
|
||||
{
|
||||
ASN1 asn7 = asn[1];
|
||||
PKCS7.ContentInfo contentInfo = new PKCS7.ContentInfo(asn7.Value);
|
||||
return new X509Certificate(contentInfo.Content[0].Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x060009E3 RID: 2531 RVA: 0x0002B50C File Offset: 0x0002970C
|
||||
public IDictionary GetAttributes(AsymmetricAlgorithm aa)
|
||||
{
|
||||
IDictionary dictionary = new Hashtable();
|
||||
foreach (object obj in this._safeBags)
|
||||
{
|
||||
SafeBag safeBag = (SafeBag)obj;
|
||||
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.1") || safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.2"))
|
||||
{
|
||||
ASN1 asn = safeBag.ASN1;
|
||||
ASN1 asn2 = asn[1];
|
||||
AsymmetricAlgorithm asymmetricAlgorithm = null;
|
||||
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.1"))
|
||||
{
|
||||
PKCS8.PrivateKeyInfo privateKeyInfo = new PKCS8.PrivateKeyInfo(asn2.Value);
|
||||
byte[] privateKey = privateKeyInfo.PrivateKey;
|
||||
byte b = privateKey[0];
|
||||
if (b != 2)
|
||||
{
|
||||
if (b == 48)
|
||||
{
|
||||
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeRSA(privateKey);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeDSA(privateKey, default(DSAParameters));
|
||||
}
|
||||
Array.Clear(privateKey, 0, privateKey.Length);
|
||||
}
|
||||
else if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.2"))
|
||||
{
|
||||
PKCS8.EncryptedPrivateKeyInfo encryptedPrivateKeyInfo = new PKCS8.EncryptedPrivateKeyInfo(asn2.Value);
|
||||
byte[] array = this.Decrypt(encryptedPrivateKeyInfo.Algorithm, encryptedPrivateKeyInfo.Salt, encryptedPrivateKeyInfo.IterationCount, encryptedPrivateKeyInfo.EncryptedData);
|
||||
PKCS8.PrivateKeyInfo privateKeyInfo2 = new PKCS8.PrivateKeyInfo(array);
|
||||
byte[] privateKey2 = privateKeyInfo2.PrivateKey;
|
||||
byte b = privateKey2[0];
|
||||
if (b != 2)
|
||||
{
|
||||
if (b == 48)
|
||||
{
|
||||
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeRSA(privateKey2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeDSA(privateKey2, default(DSAParameters));
|
||||
}
|
||||
Array.Clear(privateKey2, 0, privateKey2.Length);
|
||||
Array.Clear(array, 0, array.Length);
|
||||
}
|
||||
if (asymmetricAlgorithm != null && this.CompareAsymmetricAlgorithm(asymmetricAlgorithm, aa) && asn.Count == 3)
|
||||
{
|
||||
ASN1 asn3 = asn[2];
|
||||
for (int i = 0; i < asn3.Count; i++)
|
||||
{
|
||||
ASN1 asn4 = asn3[i];
|
||||
ASN1 asn5 = asn4[0];
|
||||
string text = ASN1Convert.ToOid(asn5);
|
||||
ArrayList arrayList = new ArrayList();
|
||||
ASN1 asn6 = asn4[1];
|
||||
for (int j = 0; j < asn6.Count; j++)
|
||||
{
|
||||
ASN1 asn7 = asn6[j];
|
||||
arrayList.Add(asn7.Value);
|
||||
}
|
||||
dictionary.Add(text, arrayList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
// Token: 0x060009E4 RID: 2532 RVA: 0x0002B7AC File Offset: 0x000299AC
|
||||
public IDictionary GetAttributes(X509Certificate cert)
|
||||
{
|
||||
IDictionary dictionary = new Hashtable();
|
||||
foreach (object obj in this._safeBags)
|
||||
{
|
||||
SafeBag safeBag = (SafeBag)obj;
|
||||
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.3"))
|
||||
{
|
||||
ASN1 asn = safeBag.ASN1;
|
||||
ASN1 asn2 = asn[1];
|
||||
PKCS7.ContentInfo contentInfo = new PKCS7.ContentInfo(asn2.Value);
|
||||
X509Certificate x509Certificate = new X509Certificate(contentInfo.Content[0].Value);
|
||||
if (this.Compare(cert.RawData, x509Certificate.RawData) && asn.Count == 3)
|
||||
{
|
||||
ASN1 asn3 = asn[2];
|
||||
for (int i = 0; i < asn3.Count; i++)
|
||||
{
|
||||
ASN1 asn4 = asn3[i];
|
||||
ASN1 asn5 = asn4[0];
|
||||
string text = ASN1Convert.ToOid(asn5);
|
||||
ArrayList arrayList = new ArrayList();
|
||||
ASN1 asn6 = asn4[1];
|
||||
for (int j = 0; j < asn6.Count; j++)
|
||||
{
|
||||
ASN1 asn7 = asn6[j];
|
||||
arrayList.Add(asn7.Value);
|
||||
}
|
||||
dictionary.Add(text, arrayList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
// Token: 0x060009E5 RID: 2533 RVA: 0x0002B924 File Offset: 0x00029B24
|
||||
public void SaveToFile(string filename)
|
||||
{
|
||||
if (filename == null)
|
||||
{
|
||||
throw new ArgumentNullException("filename");
|
||||
}
|
||||
using (FileStream fileStream = File.Create(filename))
|
||||
{
|
||||
byte[] bytes = this.GetBytes();
|
||||
fileStream.Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060009E6 RID: 2534 RVA: 0x0002B98C File Offset: 0x00029B8C
|
||||
public object Clone()
|
||||
{
|
||||
PKCS12 pkcs;
|
||||
if (this._password != null)
|
||||
{
|
||||
pkcs = new PKCS12(this.GetBytes(), Encoding.BigEndianUnicode.GetString(this._password));
|
||||
}
|
||||
else
|
||||
{
|
||||
pkcs = new PKCS12(this.GetBytes());
|
||||
}
|
||||
pkcs.IterationCount = this.IterationCount;
|
||||
return pkcs;
|
||||
}
|
||||
|
||||
// Token: 0x17000125 RID: 293
|
||||
// (get) Token: 0x060009E7 RID: 2535 RVA: 0x0002B9E0 File Offset: 0x00029BE0
|
||||
// (set) Token: 0x060009E8 RID: 2536 RVA: 0x0002B9E8 File Offset: 0x00029BE8
|
||||
public static int MaximumPasswordLength
|
||||
{
|
||||
get
|
||||
{
|
||||
return PKCS12.password_max_length;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value < 32)
|
||||
{
|
||||
string text = Locale.GetText("Maximum password length cannot be less than {0}.", new object[] { 32 });
|
||||
throw new ArgumentOutOfRangeException(text);
|
||||
}
|
||||
PKCS12.password_max_length = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060009E9 RID: 2537 RVA: 0x0002BA28 File Offset: 0x00029C28
|
||||
private static byte[] LoadFile(string filename)
|
||||
{
|
||||
byte[] array = null;
|
||||
using (FileStream fileStream = File.OpenRead(filename))
|
||||
{
|
||||
array = new byte[fileStream.Length];
|
||||
fileStream.Read(array, 0, array.Length);
|
||||
fileStream.Close();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x060009EA RID: 2538 RVA: 0x0002BA8C File Offset: 0x00029C8C
|
||||
public static PKCS12 LoadFromFile(string filename)
|
||||
{
|
||||
if (filename == null)
|
||||
{
|
||||
throw new ArgumentNullException("filename");
|
||||
}
|
||||
return new PKCS12(PKCS12.LoadFile(filename));
|
||||
}
|
||||
|
||||
// Token: 0x060009EB RID: 2539 RVA: 0x0002BAAC File Offset: 0x00029CAC
|
||||
public static PKCS12 LoadFromFile(string filename, string password)
|
||||
{
|
||||
if (filename == null)
|
||||
{
|
||||
throw new ArgumentNullException("filename");
|
||||
}
|
||||
return new PKCS12(PKCS12.LoadFile(filename), password);
|
||||
}
|
||||
|
||||
// Token: 0x04000244 RID: 580
|
||||
public const string pbeWithSHAAnd128BitRC4 = "1.2.840.113549.1.12.1.1";
|
||||
|
||||
// Token: 0x04000245 RID: 581
|
||||
public const string pbeWithSHAAnd40BitRC4 = "1.2.840.113549.1.12.1.2";
|
||||
|
||||
// Token: 0x04000246 RID: 582
|
||||
public const string pbeWithSHAAnd3KeyTripleDESCBC = "1.2.840.113549.1.12.1.3";
|
||||
|
||||
// Token: 0x04000247 RID: 583
|
||||
public const string pbeWithSHAAnd2KeyTripleDESCBC = "1.2.840.113549.1.12.1.4";
|
||||
|
||||
// Token: 0x04000248 RID: 584
|
||||
public const string pbeWithSHAAnd128BitRC2CBC = "1.2.840.113549.1.12.1.5";
|
||||
|
||||
// Token: 0x04000249 RID: 585
|
||||
public const string pbeWithSHAAnd40BitRC2CBC = "1.2.840.113549.1.12.1.6";
|
||||
|
||||
// Token: 0x0400024A RID: 586
|
||||
public const string keyBag = "1.2.840.113549.1.12.10.1.1";
|
||||
|
||||
// Token: 0x0400024B RID: 587
|
||||
public const string pkcs8ShroudedKeyBag = "1.2.840.113549.1.12.10.1.2";
|
||||
|
||||
// Token: 0x0400024C RID: 588
|
||||
public const string certBag = "1.2.840.113549.1.12.10.1.3";
|
||||
|
||||
// Token: 0x0400024D RID: 589
|
||||
public const string crlBag = "1.2.840.113549.1.12.10.1.4";
|
||||
|
||||
// Token: 0x0400024E RID: 590
|
||||
public const string secretBag = "1.2.840.113549.1.12.10.1.5";
|
||||
|
||||
// Token: 0x0400024F RID: 591
|
||||
public const string safeContentsBag = "1.2.840.113549.1.12.10.1.6";
|
||||
|
||||
// Token: 0x04000250 RID: 592
|
||||
public const string x509Certificate = "1.2.840.113549.1.9.22.1";
|
||||
|
||||
// Token: 0x04000251 RID: 593
|
||||
public const string sdsiCertificate = "1.2.840.113549.1.9.22.2";
|
||||
|
||||
// Token: 0x04000252 RID: 594
|
||||
public const string x509Crl = "1.2.840.113549.1.9.23.1";
|
||||
|
||||
// Token: 0x04000253 RID: 595
|
||||
public const int CryptoApiPasswordLimit = 32;
|
||||
|
||||
// Token: 0x04000254 RID: 596
|
||||
private static int recommendedIterationCount = 2000;
|
||||
|
||||
// Token: 0x04000255 RID: 597
|
||||
private byte[] _password;
|
||||
|
||||
// Token: 0x04000256 RID: 598
|
||||
private ArrayList _keyBags;
|
||||
|
||||
// Token: 0x04000257 RID: 599
|
||||
private ArrayList _secretBags;
|
||||
|
||||
// Token: 0x04000258 RID: 600
|
||||
private X509CertificateCollection _certs;
|
||||
|
||||
// Token: 0x04000259 RID: 601
|
||||
private bool _keyBagsChanged;
|
||||
|
||||
// Token: 0x0400025A RID: 602
|
||||
private bool _secretBagsChanged;
|
||||
|
||||
// Token: 0x0400025B RID: 603
|
||||
private bool _certsChanged;
|
||||
|
||||
// Token: 0x0400025C RID: 604
|
||||
private int _iterations;
|
||||
|
||||
// Token: 0x0400025D RID: 605
|
||||
private ArrayList _safeBags;
|
||||
|
||||
// Token: 0x0400025E RID: 606
|
||||
private RandomNumberGenerator _rng;
|
||||
|
||||
// Token: 0x0400025F RID: 607
|
||||
private static int password_max_length = int.MaxValue;
|
||||
|
||||
// Token: 0x020000B7 RID: 183
|
||||
public class DeriveBytes
|
||||
{
|
||||
// Token: 0x17000126 RID: 294
|
||||
// (get) Token: 0x060009EE RID: 2542 RVA: 0x0002BB28 File Offset: 0x00029D28
|
||||
// (set) Token: 0x060009EF RID: 2543 RVA: 0x0002BB30 File Offset: 0x00029D30
|
||||
public string HashName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._hashName;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._hashName = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000127 RID: 295
|
||||
// (get) Token: 0x060009F0 RID: 2544 RVA: 0x0002BB3C File Offset: 0x00029D3C
|
||||
// (set) Token: 0x060009F1 RID: 2545 RVA: 0x0002BB44 File Offset: 0x00029D44
|
||||
public int IterationCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._iterations;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._iterations = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000128 RID: 296
|
||||
// (get) Token: 0x060009F2 RID: 2546 RVA: 0x0002BB50 File Offset: 0x00029D50
|
||||
// (set) Token: 0x060009F3 RID: 2547 RVA: 0x0002BB64 File Offset: 0x00029D64
|
||||
public byte[] Password
|
||||
{
|
||||
get
|
||||
{
|
||||
return (byte[])this._password.Clone();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
this._password = new byte[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
this._password = (byte[])value.Clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000129 RID: 297
|
||||
// (get) Token: 0x060009F4 RID: 2548 RVA: 0x0002BB9C File Offset: 0x00029D9C
|
||||
// (set) Token: 0x060009F5 RID: 2549 RVA: 0x0002BBB0 File Offset: 0x00029DB0
|
||||
public byte[] Salt
|
||||
{
|
||||
get
|
||||
{
|
||||
return (byte[])this._salt.Clone();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
this._salt = (byte[])value.Clone();
|
||||
}
|
||||
else
|
||||
{
|
||||
this._salt = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060009F6 RID: 2550 RVA: 0x0002BBD8 File Offset: 0x00029DD8
|
||||
private void Adjust(byte[] a, int aOff, byte[] b)
|
||||
{
|
||||
int num = (int)((b[b.Length - 1] & byte.MaxValue) + (a[aOff + b.Length - 1] & byte.MaxValue) + 1);
|
||||
a[aOff + b.Length - 1] = (byte)num;
|
||||
num >>= 8;
|
||||
for (int i = b.Length - 2; i >= 0; i--)
|
||||
{
|
||||
num += (int)((b[i] & byte.MaxValue) + (a[aOff + i] & byte.MaxValue));
|
||||
a[aOff + i] = (byte)num;
|
||||
num >>= 8;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060009F7 RID: 2551 RVA: 0x0002BC50 File Offset: 0x00029E50
|
||||
private byte[] Derive(byte[] diversifier, int n)
|
||||
{
|
||||
HashAlgorithm hashAlgorithm = HashAlgorithm.Create(this._hashName);
|
||||
int num = hashAlgorithm.HashSize >> 3;
|
||||
int num2 = 64;
|
||||
byte[] array = new byte[n];
|
||||
byte[] array2;
|
||||
if (this._salt != null && this._salt.Length != 0)
|
||||
{
|
||||
array2 = new byte[num2 * ((this._salt.Length + num2 - 1) / num2)];
|
||||
for (int num3 = 0; num3 != array2.Length; num3++)
|
||||
{
|
||||
array2[num3] = this._salt[num3 % this._salt.Length];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
array2 = new byte[0];
|
||||
}
|
||||
byte[] array3;
|
||||
if (this._password != null && this._password.Length != 0)
|
||||
{
|
||||
array3 = new byte[num2 * ((this._password.Length + num2 - 1) / num2)];
|
||||
for (int num4 = 0; num4 != array3.Length; num4++)
|
||||
{
|
||||
array3[num4] = this._password[num4 % this._password.Length];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
array3 = new byte[0];
|
||||
}
|
||||
byte[] array4 = new byte[array2.Length + array3.Length];
|
||||
Buffer.BlockCopy(array2, 0, array4, 0, array2.Length);
|
||||
Buffer.BlockCopy(array3, 0, array4, array2.Length, array3.Length);
|
||||
byte[] array5 = new byte[num2];
|
||||
int num5 = (n + num - 1) / num;
|
||||
for (int i = 1; i <= num5; i++)
|
||||
{
|
||||
hashAlgorithm.TransformBlock(diversifier, 0, diversifier.Length, diversifier, 0);
|
||||
hashAlgorithm.TransformFinalBlock(array4, 0, array4.Length);
|
||||
byte[] array6 = hashAlgorithm.Hash;
|
||||
hashAlgorithm.Initialize();
|
||||
for (int num6 = 1; num6 != this._iterations; num6++)
|
||||
{
|
||||
array6 = hashAlgorithm.ComputeHash(array6, 0, array6.Length);
|
||||
}
|
||||
for (int num7 = 0; num7 != array5.Length; num7++)
|
||||
{
|
||||
array5[num7] = array6[num7 % array6.Length];
|
||||
}
|
||||
for (int num8 = 0; num8 != array4.Length / num2; num8++)
|
||||
{
|
||||
this.Adjust(array4, num8 * num2, array5);
|
||||
}
|
||||
if (i == num5)
|
||||
{
|
||||
Buffer.BlockCopy(array6, 0, array, (i - 1) * num, array.Length - (i - 1) * num);
|
||||
}
|
||||
else
|
||||
{
|
||||
Buffer.BlockCopy(array6, 0, array, (i - 1) * num, array6.Length);
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x060009F8 RID: 2552 RVA: 0x0002BE90 File Offset: 0x0002A090
|
||||
public byte[] DeriveKey(int size)
|
||||
{
|
||||
return this.Derive(PKCS12.DeriveBytes.keyDiversifier, size);
|
||||
}
|
||||
|
||||
// Token: 0x060009F9 RID: 2553 RVA: 0x0002BEA0 File Offset: 0x0002A0A0
|
||||
public byte[] DeriveIV(int size)
|
||||
{
|
||||
return this.Derive(PKCS12.DeriveBytes.ivDiversifier, size);
|
||||
}
|
||||
|
||||
// Token: 0x060009FA RID: 2554 RVA: 0x0002BEB0 File Offset: 0x0002A0B0
|
||||
public byte[] DeriveMAC(int size)
|
||||
{
|
||||
return this.Derive(PKCS12.DeriveBytes.macDiversifier, size);
|
||||
}
|
||||
|
||||
// Token: 0x04000268 RID: 616
|
||||
private static byte[] keyDiversifier = new byte[]
|
||||
{
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1
|
||||
};
|
||||
|
||||
// Token: 0x04000269 RID: 617
|
||||
private static byte[] ivDiversifier = new byte[]
|
||||
{
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2
|
||||
};
|
||||
|
||||
// Token: 0x0400026A RID: 618
|
||||
private static byte[] macDiversifier = new byte[]
|
||||
{
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
3, 3, 3, 3
|
||||
};
|
||||
|
||||
// Token: 0x0400026B RID: 619
|
||||
private string _hashName;
|
||||
|
||||
// Token: 0x0400026C RID: 620
|
||||
private int _iterations;
|
||||
|
||||
// Token: 0x0400026D RID: 621
|
||||
private byte[] _password;
|
||||
|
||||
// Token: 0x0400026E RID: 622
|
||||
private byte[] _salt;
|
||||
|
||||
// Token: 0x020000B8 RID: 184
|
||||
public enum Purpose
|
||||
{
|
||||
// Token: 0x04000270 RID: 624
|
||||
Key,
|
||||
// Token: 0x04000271 RID: 625
|
||||
IV,
|
||||
// Token: 0x04000272 RID: 626
|
||||
MAC
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.X509
|
||||
{
|
||||
// Token: 0x020000B3 RID: 179
|
||||
internal class PKCS5
|
||||
{
|
||||
// Token: 0x0400023A RID: 570
|
||||
public const string pbeWithMD2AndDESCBC = "1.2.840.113549.1.5.1";
|
||||
|
||||
// Token: 0x0400023B RID: 571
|
||||
public const string pbeWithMD5AndDESCBC = "1.2.840.113549.1.5.3";
|
||||
|
||||
// Token: 0x0400023C RID: 572
|
||||
public const string pbeWithMD2AndRC2CBC = "1.2.840.113549.1.5.4";
|
||||
|
||||
// Token: 0x0400023D RID: 573
|
||||
public const string pbeWithMD5AndRC2CBC = "1.2.840.113549.1.5.6";
|
||||
|
||||
// Token: 0x0400023E RID: 574
|
||||
public const string pbeWithSHA1AndDESCBC = "1.2.840.113549.1.5.10";
|
||||
|
||||
// Token: 0x0400023F RID: 575
|
||||
public const string pbeWithSHA1AndRC2CBC = "1.2.840.113549.1.5.11";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.X509
|
||||
{
|
||||
// Token: 0x020000B4 RID: 180
|
||||
internal class PKCS9
|
||||
{
|
||||
// Token: 0x04000240 RID: 576
|
||||
public const string friendlyName = "1.2.840.113549.1.9.20";
|
||||
|
||||
// Token: 0x04000241 RID: 577
|
||||
public const string localKeyId = "1.2.840.113549.1.9.21";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.X509
|
||||
{
|
||||
// Token: 0x020000B5 RID: 181
|
||||
internal class SafeBag
|
||||
{
|
||||
// Token: 0x060009B2 RID: 2482 RVA: 0x00027F90 File Offset: 0x00026190
|
||||
public SafeBag(string bagOID, ASN1 asn1)
|
||||
{
|
||||
this._bagOID = bagOID;
|
||||
this._asn1 = asn1;
|
||||
}
|
||||
|
||||
// Token: 0x1700011D RID: 285
|
||||
// (get) Token: 0x060009B3 RID: 2483 RVA: 0x00027FA8 File Offset: 0x000261A8
|
||||
public string BagOID
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._bagOID;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700011E RID: 286
|
||||
// (get) Token: 0x060009B4 RID: 2484 RVA: 0x00027FB0 File Offset: 0x000261B0
|
||||
public ASN1 ASN1
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._asn1;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x04000242 RID: 578
|
||||
private string _bagOID;
|
||||
|
||||
// Token: 0x04000243 RID: 579
|
||||
private ASN1 _asn1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,457 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using Mono.Security.Cryptography;
|
||||
|
||||
namespace Mono.Security.X509
|
||||
{
|
||||
// Token: 0x020000B9 RID: 185
|
||||
internal sealed class X501
|
||||
{
|
||||
// Token: 0x060009FB RID: 2555 RVA: 0x0002BEC0 File Offset: 0x0002A0C0
|
||||
private X501()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060009FD RID: 2557 RVA: 0x0002C044 File Offset: 0x0002A244
|
||||
public static string ToString(ASN1 seq)
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (int i = 0; i < seq.Count; i++)
|
||||
{
|
||||
ASN1 asn = seq[i];
|
||||
X501.AppendEntry(stringBuilder, asn, true);
|
||||
if (i < seq.Count - 1)
|
||||
{
|
||||
stringBuilder.Append(", ");
|
||||
}
|
||||
}
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
// Token: 0x060009FE RID: 2558 RVA: 0x0002C0A0 File Offset: 0x0002A2A0
|
||||
public static string ToString(ASN1 seq, bool reversed, string separator, bool quotes)
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
if (reversed)
|
||||
{
|
||||
for (int i = seq.Count - 1; i >= 0; i--)
|
||||
{
|
||||
ASN1 asn = seq[i];
|
||||
X501.AppendEntry(stringBuilder, asn, quotes);
|
||||
if (i > 0)
|
||||
{
|
||||
stringBuilder.Append(separator);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int j = 0; j < seq.Count; j++)
|
||||
{
|
||||
ASN1 asn2 = seq[j];
|
||||
X501.AppendEntry(stringBuilder, asn2, quotes);
|
||||
if (j < seq.Count - 1)
|
||||
{
|
||||
stringBuilder.Append(separator);
|
||||
}
|
||||
}
|
||||
}
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
// Token: 0x060009FF RID: 2559 RVA: 0x0002C13C File Offset: 0x0002A33C
|
||||
private static void AppendEntry(StringBuilder sb, ASN1 entry, bool quotes)
|
||||
{
|
||||
for (int i = 0; i < entry.Count; i++)
|
||||
{
|
||||
ASN1 asn = entry[i];
|
||||
ASN1 asn2 = asn[1];
|
||||
if (asn2 != null)
|
||||
{
|
||||
ASN1 asn3 = asn[0];
|
||||
if (asn3 != null)
|
||||
{
|
||||
if (asn3.CompareValue(X501.countryName))
|
||||
{
|
||||
sb.Append("C=");
|
||||
}
|
||||
else if (asn3.CompareValue(X501.organizationName))
|
||||
{
|
||||
sb.Append("O=");
|
||||
}
|
||||
else if (asn3.CompareValue(X501.organizationalUnitName))
|
||||
{
|
||||
sb.Append("OU=");
|
||||
}
|
||||
else if (asn3.CompareValue(X501.commonName))
|
||||
{
|
||||
sb.Append("CN=");
|
||||
}
|
||||
else if (asn3.CompareValue(X501.localityName))
|
||||
{
|
||||
sb.Append("L=");
|
||||
}
|
||||
else if (asn3.CompareValue(X501.stateOrProvinceName))
|
||||
{
|
||||
sb.Append("S=");
|
||||
}
|
||||
else if (asn3.CompareValue(X501.streetAddress))
|
||||
{
|
||||
sb.Append("STREET=");
|
||||
}
|
||||
else if (asn3.CompareValue(X501.domainComponent))
|
||||
{
|
||||
sb.Append("DC=");
|
||||
}
|
||||
else if (asn3.CompareValue(X501.userid))
|
||||
{
|
||||
sb.Append("UID=");
|
||||
}
|
||||
else if (asn3.CompareValue(X501.email))
|
||||
{
|
||||
sb.Append("E=");
|
||||
}
|
||||
else if (asn3.CompareValue(X501.dnQualifier))
|
||||
{
|
||||
sb.Append("dnQualifier=");
|
||||
}
|
||||
else if (asn3.CompareValue(X501.title))
|
||||
{
|
||||
sb.Append("T=");
|
||||
}
|
||||
else if (asn3.CompareValue(X501.surname))
|
||||
{
|
||||
sb.Append("SN=");
|
||||
}
|
||||
else if (asn3.CompareValue(X501.givenName))
|
||||
{
|
||||
sb.Append("G=");
|
||||
}
|
||||
else if (asn3.CompareValue(X501.initial))
|
||||
{
|
||||
sb.Append("I=");
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append("OID.");
|
||||
sb.Append(ASN1Convert.ToOid(asn3));
|
||||
sb.Append("=");
|
||||
}
|
||||
string text;
|
||||
if (asn2.Tag == 30)
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (int j = 1; j < asn2.Value.Length; j += 2)
|
||||
{
|
||||
stringBuilder.Append((char)asn2.Value[j]);
|
||||
}
|
||||
text = stringBuilder.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (asn2.Tag == 20)
|
||||
{
|
||||
text = Encoding.UTF7.GetString(asn2.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
text = Encoding.UTF8.GetString(asn2.Value);
|
||||
}
|
||||
char[] array = new char[] { ',', '+', '"', '\\', '<', '>', ';' };
|
||||
if (quotes && (text.IndexOfAny(array, 0, text.Length) > 0 || text.StartsWith(" ") || text.EndsWith(" ")))
|
||||
{
|
||||
text = "\"" + text + "\"";
|
||||
}
|
||||
}
|
||||
sb.Append(text);
|
||||
if (i < entry.Count - 1)
|
||||
{
|
||||
sb.Append(", ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A00 RID: 2560 RVA: 0x0002C4B4 File Offset: 0x0002A6B4
|
||||
private static X520.AttributeTypeAndValue GetAttributeFromOid(string attributeType)
|
||||
{
|
||||
string text = attributeType.ToUpper(CultureInfo.InvariantCulture).Trim();
|
||||
string text2 = text;
|
||||
switch (text2)
|
||||
{
|
||||
case "C":
|
||||
return new X520.CountryName();
|
||||
case "O":
|
||||
return new X520.OrganizationName();
|
||||
case "OU":
|
||||
return new X520.OrganizationalUnitName();
|
||||
case "CN":
|
||||
return new X520.CommonName();
|
||||
case "L":
|
||||
return new X520.LocalityName();
|
||||
case "S":
|
||||
case "ST":
|
||||
return new X520.StateOrProvinceName();
|
||||
case "E":
|
||||
return new X520.EmailAddress();
|
||||
case "DC":
|
||||
return new X520.DomainComponent();
|
||||
case "UID":
|
||||
return new X520.UserId();
|
||||
case "DNQUALIFIER":
|
||||
return new X520.DnQualifier();
|
||||
case "T":
|
||||
return new X520.Title();
|
||||
case "SN":
|
||||
return new X520.Surname();
|
||||
case "G":
|
||||
return new X520.GivenName();
|
||||
case "I":
|
||||
return new X520.Initial();
|
||||
}
|
||||
if (text.StartsWith("OID."))
|
||||
{
|
||||
return new X520.Oid(text.Substring(4));
|
||||
}
|
||||
if (X501.IsOid(text))
|
||||
{
|
||||
return new X520.Oid(text);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x06000A01 RID: 2561 RVA: 0x0002C684 File Offset: 0x0002A884
|
||||
private static bool IsOid(string oid)
|
||||
{
|
||||
bool flag;
|
||||
try
|
||||
{
|
||||
ASN1 asn = ASN1Convert.FromOid(oid);
|
||||
flag = asn.Tag == 6;
|
||||
}
|
||||
catch
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x06000A02 RID: 2562 RVA: 0x0002C6D8 File Offset: 0x0002A8D8
|
||||
private static X520.AttributeTypeAndValue ReadAttribute(string value, ref int pos)
|
||||
{
|
||||
while (value[pos] == ' ' && pos < value.Length)
|
||||
{
|
||||
pos++;
|
||||
}
|
||||
int num = value.IndexOf('=', pos);
|
||||
if (num == -1)
|
||||
{
|
||||
string text = Locale.GetText("No attribute found.");
|
||||
throw new FormatException(text);
|
||||
}
|
||||
string text2 = value.Substring(pos, num - pos);
|
||||
X520.AttributeTypeAndValue attributeFromOid = X501.GetAttributeFromOid(text2);
|
||||
if (attributeFromOid == null)
|
||||
{
|
||||
string text3 = Locale.GetText("Unknown attribute '{0}'.");
|
||||
throw new FormatException(string.Format(text3, text2));
|
||||
}
|
||||
pos = num + 1;
|
||||
return attributeFromOid;
|
||||
}
|
||||
|
||||
// Token: 0x06000A03 RID: 2563 RVA: 0x0002C76C File Offset: 0x0002A96C
|
||||
private static bool IsHex(char c)
|
||||
{
|
||||
if (char.IsDigit(c))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
char c2 = char.ToUpper(c, CultureInfo.InvariantCulture);
|
||||
return c2 >= 'A' && c2 <= 'F';
|
||||
}
|
||||
|
||||
// Token: 0x06000A04 RID: 2564 RVA: 0x0002C7A8 File Offset: 0x0002A9A8
|
||||
private static string ReadHex(string value, ref int pos)
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.Append(value[pos++]);
|
||||
stringBuilder.Append(value[pos]);
|
||||
if (pos < value.Length - 4 && value[pos + 1] == '\\' && X501.IsHex(value[pos + 2]))
|
||||
{
|
||||
pos += 2;
|
||||
stringBuilder.Append(value[pos++]);
|
||||
stringBuilder.Append(value[pos]);
|
||||
}
|
||||
byte[] array = CryptoConvert.FromHex(stringBuilder.ToString());
|
||||
return Encoding.UTF8.GetString(array);
|
||||
}
|
||||
|
||||
// Token: 0x06000A05 RID: 2565 RVA: 0x0002C858 File Offset: 0x0002AA58
|
||||
private static int ReadEscaped(StringBuilder sb, string value, int pos)
|
||||
{
|
||||
char c = value[pos];
|
||||
switch (c)
|
||||
{
|
||||
case ';':
|
||||
case '<':
|
||||
case '=':
|
||||
case '>':
|
||||
break;
|
||||
default:
|
||||
if (c != '"' && c != '#' && c != '+' && c != ',' && c != '\\')
|
||||
{
|
||||
if (pos >= value.Length - 2)
|
||||
{
|
||||
string text = Locale.GetText("Malformed escaped value '{0}'.");
|
||||
throw new FormatException(string.Format(text, value.Substring(pos)));
|
||||
}
|
||||
sb.Append(X501.ReadHex(value, ref pos));
|
||||
return pos;
|
||||
}
|
||||
break;
|
||||
}
|
||||
sb.Append(value[pos]);
|
||||
return pos;
|
||||
}
|
||||
|
||||
// Token: 0x06000A06 RID: 2566 RVA: 0x0002C900 File Offset: 0x0002AB00
|
||||
private static int ReadQuoted(StringBuilder sb, string value, int pos)
|
||||
{
|
||||
int num = pos;
|
||||
while (pos <= value.Length)
|
||||
{
|
||||
char c = value[pos];
|
||||
if (c == '"')
|
||||
{
|
||||
return pos;
|
||||
}
|
||||
if (c == '\\')
|
||||
{
|
||||
return X501.ReadEscaped(sb, value, pos);
|
||||
}
|
||||
sb.Append(value[pos]);
|
||||
pos++;
|
||||
}
|
||||
string text = Locale.GetText("Malformed quoted value '{0}'.");
|
||||
throw new FormatException(string.Format(text, value.Substring(num)));
|
||||
}
|
||||
|
||||
// Token: 0x06000A07 RID: 2567 RVA: 0x0002C980 File Offset: 0x0002AB80
|
||||
private static string ReadValue(string value, ref int pos)
|
||||
{
|
||||
int num = pos;
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
while (pos < value.Length)
|
||||
{
|
||||
char c = value[pos];
|
||||
switch (c)
|
||||
{
|
||||
case ';':
|
||||
case '<':
|
||||
case '=':
|
||||
case '>':
|
||||
{
|
||||
string text = Locale.GetText("Malformed value '{0}' contains '{1}' outside quotes.");
|
||||
throw new FormatException(string.Format(text, value.Substring(num), value[pos]));
|
||||
}
|
||||
default:
|
||||
if (c != '"')
|
||||
{
|
||||
if (c == '#' || c == '+')
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
if (c == ',')
|
||||
{
|
||||
pos++;
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
if (c != '\\')
|
||||
{
|
||||
stringBuilder.Append(value[pos]);
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = X501.ReadEscaped(stringBuilder, value, ++pos);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = X501.ReadQuoted(stringBuilder, value, ++pos);
|
||||
}
|
||||
pos++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
// Token: 0x06000A08 RID: 2568 RVA: 0x0002CA88 File Offset: 0x0002AC88
|
||||
public static ASN1 FromString(string rdn)
|
||||
{
|
||||
if (rdn == null)
|
||||
{
|
||||
throw new ArgumentNullException("rdn");
|
||||
}
|
||||
int i = 0;
|
||||
ASN1 asn = new ASN1(48);
|
||||
while (i < rdn.Length)
|
||||
{
|
||||
X520.AttributeTypeAndValue attributeTypeAndValue = X501.ReadAttribute(rdn, ref i);
|
||||
attributeTypeAndValue.Value = X501.ReadValue(rdn, ref i);
|
||||
ASN1 asn2 = new ASN1(49);
|
||||
asn2.Add(attributeTypeAndValue.GetASN1());
|
||||
asn.Add(asn2);
|
||||
}
|
||||
return asn;
|
||||
}
|
||||
|
||||
// Token: 0x04000273 RID: 627
|
||||
private static byte[] countryName = new byte[] { 85, 4, 6 };
|
||||
|
||||
// Token: 0x04000274 RID: 628
|
||||
private static byte[] organizationName = new byte[] { 85, 4, 10 };
|
||||
|
||||
// Token: 0x04000275 RID: 629
|
||||
private static byte[] organizationalUnitName = new byte[] { 85, 4, 11 };
|
||||
|
||||
// Token: 0x04000276 RID: 630
|
||||
private static byte[] commonName = new byte[] { 85, 4, 3 };
|
||||
|
||||
// Token: 0x04000277 RID: 631
|
||||
private static byte[] localityName = new byte[] { 85, 4, 7 };
|
||||
|
||||
// Token: 0x04000278 RID: 632
|
||||
private static byte[] stateOrProvinceName = new byte[] { 85, 4, 8 };
|
||||
|
||||
// Token: 0x04000279 RID: 633
|
||||
private static byte[] streetAddress = new byte[] { 85, 4, 9 };
|
||||
|
||||
// Token: 0x0400027A RID: 634
|
||||
private static byte[] domainComponent = new byte[] { 9, 146, 38, 137, 147, 242, 44, 100, 1, 25 };
|
||||
|
||||
// Token: 0x0400027B RID: 635
|
||||
private static byte[] userid = new byte[] { 9, 146, 38, 137, 147, 242, 44, 100, 1, 1 };
|
||||
|
||||
// Token: 0x0400027C RID: 636
|
||||
private static byte[] email = new byte[] { 42, 134, 72, 134, 247, 13, 1, 9, 1 };
|
||||
|
||||
// Token: 0x0400027D RID: 637
|
||||
private static byte[] dnQualifier = new byte[] { 85, 4, 46 };
|
||||
|
||||
// Token: 0x0400027E RID: 638
|
||||
private static byte[] title = new byte[] { 85, 4, 12 };
|
||||
|
||||
// Token: 0x0400027F RID: 639
|
||||
private static byte[] surname = new byte[] { 85, 4, 4 };
|
||||
|
||||
// Token: 0x04000280 RID: 640
|
||||
private static byte[] givenName = new byte[] { 85, 4, 42 };
|
||||
|
||||
// Token: 0x04000281 RID: 641
|
||||
private static byte[] initial = new byte[] { 85, 4, 43 };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,713 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Mono.Security.X509
|
||||
{
|
||||
// Token: 0x020000BC RID: 188
|
||||
internal class X509Certificate : ISerializable
|
||||
{
|
||||
// Token: 0x06000A29 RID: 2601 RVA: 0x0002D4B8 File Offset: 0x0002B6B8
|
||||
public X509Certificate(byte[] data)
|
||||
{
|
||||
if (data != null)
|
||||
{
|
||||
if (data.Length > 0 && data[0] != 48)
|
||||
{
|
||||
try
|
||||
{
|
||||
data = X509Certificate.PEM("CERTIFICATE", data);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new CryptographicException(X509Certificate.encoding_error, ex);
|
||||
}
|
||||
}
|
||||
this.Parse(data);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A2A RID: 2602 RVA: 0x0002D52C File Offset: 0x0002B72C
|
||||
protected X509Certificate(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
this.Parse((byte[])info.GetValue("raw", typeof(byte[])));
|
||||
}
|
||||
|
||||
// Token: 0x06000A2C RID: 2604 RVA: 0x0002D574 File Offset: 0x0002B774
|
||||
private void Parse(byte[] data)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.decoder = new ASN1(data);
|
||||
if (this.decoder.Tag != 48)
|
||||
{
|
||||
throw new CryptographicException(X509Certificate.encoding_error);
|
||||
}
|
||||
if (this.decoder[0].Tag != 48)
|
||||
{
|
||||
throw new CryptographicException(X509Certificate.encoding_error);
|
||||
}
|
||||
ASN1 asn = this.decoder[0];
|
||||
int num = 0;
|
||||
ASN1 asn2 = this.decoder[0][num];
|
||||
this.version = 1;
|
||||
if (asn2.Tag == 160 && asn2.Count > 0)
|
||||
{
|
||||
this.version += (int)asn2[0].Value[0];
|
||||
num++;
|
||||
}
|
||||
ASN1 asn3 = this.decoder[0][num++];
|
||||
if (asn3.Tag != 2)
|
||||
{
|
||||
throw new CryptographicException(X509Certificate.encoding_error);
|
||||
}
|
||||
this.serialnumber = asn3.Value;
|
||||
Array.Reverse(this.serialnumber, 0, this.serialnumber.Length);
|
||||
num++;
|
||||
this.issuer = asn.Element(num++, 48);
|
||||
this.m_issuername = X501.ToString(this.issuer);
|
||||
ASN1 asn4 = asn.Element(num++, 48);
|
||||
ASN1 asn5 = asn4[0];
|
||||
this.m_from = ASN1Convert.ToDateTime(asn5);
|
||||
ASN1 asn6 = asn4[1];
|
||||
this.m_until = ASN1Convert.ToDateTime(asn6);
|
||||
this.subject = asn.Element(num++, 48);
|
||||
this.m_subject = X501.ToString(this.subject);
|
||||
ASN1 asn7 = asn.Element(num++, 48);
|
||||
ASN1 asn8 = asn7.Element(0, 48);
|
||||
ASN1 asn9 = asn8.Element(0, 6);
|
||||
this.m_keyalgo = ASN1Convert.ToOid(asn9);
|
||||
ASN1 asn10 = asn8[1];
|
||||
this.m_keyalgoparams = ((asn8.Count <= 1) ? null : asn10.GetBytes());
|
||||
ASN1 asn11 = asn7.Element(1, 3);
|
||||
int num2 = asn11.Length - 1;
|
||||
this.m_publickey = new byte[num2];
|
||||
Buffer.BlockCopy(asn11.Value, 1, this.m_publickey, 0, num2);
|
||||
byte[] value = this.decoder[2].Value;
|
||||
this.signature = new byte[value.Length - 1];
|
||||
Buffer.BlockCopy(value, 1, this.signature, 0, this.signature.Length);
|
||||
asn8 = this.decoder[1];
|
||||
asn9 = asn8.Element(0, 6);
|
||||
this.m_signaturealgo = ASN1Convert.ToOid(asn9);
|
||||
asn10 = asn8[1];
|
||||
if (asn10 != null)
|
||||
{
|
||||
this.m_signaturealgoparams = asn10.GetBytes();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_signaturealgoparams = null;
|
||||
}
|
||||
ASN1 asn12 = asn.Element(num, 129);
|
||||
if (asn12 != null)
|
||||
{
|
||||
num++;
|
||||
this.issuerUniqueID = asn12.Value;
|
||||
}
|
||||
ASN1 asn13 = asn.Element(num, 130);
|
||||
if (asn13 != null)
|
||||
{
|
||||
num++;
|
||||
this.subjectUniqueID = asn13.Value;
|
||||
}
|
||||
ASN1 asn14 = asn.Element(num, 163);
|
||||
if (asn14 != null && asn14.Count == 1)
|
||||
{
|
||||
this.extensions = new X509ExtensionCollection(asn14[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.extensions = new X509ExtensionCollection(null);
|
||||
}
|
||||
this.m_encodedcert = (byte[])data.Clone();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new CryptographicException(X509Certificate.encoding_error, ex);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A2D RID: 2605 RVA: 0x0002D904 File Offset: 0x0002BB04
|
||||
private byte[] GetUnsignedBigInteger(byte[] integer)
|
||||
{
|
||||
if (integer[0] == 0)
|
||||
{
|
||||
int num = integer.Length - 1;
|
||||
byte[] array = new byte[num];
|
||||
Buffer.BlockCopy(integer, 1, array, 0, num);
|
||||
return array;
|
||||
}
|
||||
return integer;
|
||||
}
|
||||
|
||||
// Token: 0x1700013A RID: 314
|
||||
// (get) Token: 0x06000A2E RID: 2606 RVA: 0x0002D934 File Offset: 0x0002BB34
|
||||
// (set) Token: 0x06000A2F RID: 2607 RVA: 0x0002DA78 File Offset: 0x0002BC78
|
||||
public DSA DSA
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.m_keyalgoparams == null)
|
||||
{
|
||||
throw new CryptographicException("Missing key algorithm parameters.");
|
||||
}
|
||||
if (this._dsa == null)
|
||||
{
|
||||
DSAParameters dsaparameters = default(DSAParameters);
|
||||
ASN1 asn = new ASN1(this.m_publickey);
|
||||
if (asn == null || asn.Tag != 2)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
dsaparameters.Y = this.GetUnsignedBigInteger(asn.Value);
|
||||
ASN1 asn2 = new ASN1(this.m_keyalgoparams);
|
||||
if (asn2 == null || asn2.Tag != 48 || asn2.Count < 3)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (asn2[0].Tag != 2 || asn2[1].Tag != 2 || asn2[2].Tag != 2)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
dsaparameters.P = this.GetUnsignedBigInteger(asn2[0].Value);
|
||||
dsaparameters.Q = this.GetUnsignedBigInteger(asn2[1].Value);
|
||||
dsaparameters.G = this.GetUnsignedBigInteger(asn2[2].Value);
|
||||
this._dsa = new DSACryptoServiceProvider(dsaparameters.Y.Length << 3);
|
||||
this._dsa.ImportParameters(dsaparameters);
|
||||
}
|
||||
return this._dsa;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._dsa = value;
|
||||
if (value != null)
|
||||
{
|
||||
this._rsa = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700013B RID: 315
|
||||
// (get) Token: 0x06000A30 RID: 2608 RVA: 0x0002DA90 File Offset: 0x0002BC90
|
||||
public X509ExtensionCollection Extensions
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.extensions;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700013C RID: 316
|
||||
// (get) Token: 0x06000A31 RID: 2609 RVA: 0x0002DA98 File Offset: 0x0002BC98
|
||||
public byte[] Hash
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.certhash == null)
|
||||
{
|
||||
string signaturealgo = this.m_signaturealgo;
|
||||
if (signaturealgo != null)
|
||||
{
|
||||
if (X509Certificate.<>f__switch$map13 == null)
|
||||
{
|
||||
X509Certificate.<>f__switch$map13 = new Dictionary<string, int>(5)
|
||||
{
|
||||
{ "1.2.840.113549.1.1.2", 0 },
|
||||
{ "1.2.840.113549.1.1.4", 1 },
|
||||
{ "1.2.840.113549.1.1.5", 2 },
|
||||
{ "1.3.14.3.2.29", 2 },
|
||||
{ "1.2.840.10040.4.3", 2 }
|
||||
};
|
||||
}
|
||||
int num;
|
||||
if (X509Certificate.<>f__switch$map13.TryGetValue(signaturealgo, out num))
|
||||
{
|
||||
HashAlgorithm hashAlgorithm;
|
||||
switch (num)
|
||||
{
|
||||
case 0:
|
||||
hashAlgorithm = HashAlgorithm.Create("MD2");
|
||||
break;
|
||||
case 1:
|
||||
hashAlgorithm = MD5.Create();
|
||||
break;
|
||||
case 2:
|
||||
hashAlgorithm = SHA1.Create();
|
||||
break;
|
||||
default:
|
||||
goto IL_BD;
|
||||
}
|
||||
if (this.decoder == null || this.decoder.Count < 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
byte[] bytes = this.decoder[0].GetBytes();
|
||||
this.certhash = hashAlgorithm.ComputeHash(bytes, 0, bytes.Length);
|
||||
goto IL_100;
|
||||
}
|
||||
}
|
||||
IL_BD:
|
||||
return null;
|
||||
}
|
||||
IL_100:
|
||||
return (byte[])this.certhash.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700013D RID: 317
|
||||
// (get) Token: 0x06000A32 RID: 2610 RVA: 0x0002DBB8 File Offset: 0x0002BDB8
|
||||
public virtual string IssuerName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_issuername;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700013E RID: 318
|
||||
// (get) Token: 0x06000A33 RID: 2611 RVA: 0x0002DBC0 File Offset: 0x0002BDC0
|
||||
public virtual string KeyAlgorithm
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_keyalgo;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700013F RID: 319
|
||||
// (get) Token: 0x06000A34 RID: 2612 RVA: 0x0002DBC8 File Offset: 0x0002BDC8
|
||||
// (set) Token: 0x06000A35 RID: 2613 RVA: 0x0002DBE8 File Offset: 0x0002BDE8
|
||||
public virtual byte[] KeyAlgorithmParameters
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.m_keyalgoparams == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (byte[])this.m_keyalgoparams.Clone();
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_keyalgoparams = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000140 RID: 320
|
||||
// (get) Token: 0x06000A36 RID: 2614 RVA: 0x0002DBF4 File Offset: 0x0002BDF4
|
||||
public virtual byte[] PublicKey
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.m_publickey == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (byte[])this.m_publickey.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000141 RID: 321
|
||||
// (get) Token: 0x06000A37 RID: 2615 RVA: 0x0002DC14 File Offset: 0x0002BE14
|
||||
// (set) Token: 0x06000A38 RID: 2616 RVA: 0x0002DCC0 File Offset: 0x0002BEC0
|
||||
public virtual RSA RSA
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._rsa == null)
|
||||
{
|
||||
RSAParameters rsaparameters = default(RSAParameters);
|
||||
ASN1 asn = new ASN1(this.m_publickey);
|
||||
ASN1 asn2 = asn[0];
|
||||
if (asn2 == null || asn2.Tag != 2)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
ASN1 asn3 = asn[1];
|
||||
if (asn3.Tag != 2)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
rsaparameters.Modulus = this.GetUnsignedBigInteger(asn2.Value);
|
||||
rsaparameters.Exponent = asn3.Value;
|
||||
int num = rsaparameters.Modulus.Length << 3;
|
||||
this._rsa = new RSACryptoServiceProvider(num);
|
||||
this._rsa.ImportParameters(rsaparameters);
|
||||
}
|
||||
return this._rsa;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
this._dsa = null;
|
||||
}
|
||||
this._rsa = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000142 RID: 322
|
||||
// (get) Token: 0x06000A39 RID: 2617 RVA: 0x0002DCD8 File Offset: 0x0002BED8
|
||||
public virtual byte[] RawData
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.m_encodedcert == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (byte[])this.m_encodedcert.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000143 RID: 323
|
||||
// (get) Token: 0x06000A3A RID: 2618 RVA: 0x0002DCF8 File Offset: 0x0002BEF8
|
||||
public virtual byte[] SerialNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.serialnumber == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (byte[])this.serialnumber.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000144 RID: 324
|
||||
// (get) Token: 0x06000A3B RID: 2619 RVA: 0x0002DD18 File Offset: 0x0002BF18
|
||||
public virtual byte[] Signature
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.signature == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
string signaturealgo = this.m_signaturealgo;
|
||||
if (signaturealgo != null)
|
||||
{
|
||||
if (X509Certificate.<>f__switch$map14 == null)
|
||||
{
|
||||
X509Certificate.<>f__switch$map14 = new Dictionary<string, int>(5)
|
||||
{
|
||||
{ "1.2.840.113549.1.1.2", 0 },
|
||||
{ "1.2.840.113549.1.1.4", 0 },
|
||||
{ "1.2.840.113549.1.1.5", 0 },
|
||||
{ "1.3.14.3.2.29", 0 },
|
||||
{ "1.2.840.10040.4.3", 1 }
|
||||
};
|
||||
}
|
||||
int num;
|
||||
if (X509Certificate.<>f__switch$map14.TryGetValue(signaturealgo, out num))
|
||||
{
|
||||
if (num == 0)
|
||||
{
|
||||
return (byte[])this.signature.Clone();
|
||||
}
|
||||
if (num == 1)
|
||||
{
|
||||
ASN1 asn = new ASN1(this.signature);
|
||||
if (asn == null || asn.Count != 2)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
byte[] value = asn[0].Value;
|
||||
byte[] value2 = asn[1].Value;
|
||||
byte[] array = new byte[40];
|
||||
int num2 = Math.Max(0, value.Length - 20);
|
||||
int num3 = Math.Max(0, 20 - value.Length);
|
||||
Buffer.BlockCopy(value, num2, array, num3, value.Length - num2);
|
||||
int num4 = Math.Max(0, value2.Length - 20);
|
||||
int num5 = Math.Max(20, 40 - value2.Length);
|
||||
Buffer.BlockCopy(value2, num4, array, num5, value2.Length - num4);
|
||||
return array;
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new CryptographicException("Unsupported hash algorithm: " + this.m_signaturealgo);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000145 RID: 325
|
||||
// (get) Token: 0x06000A3C RID: 2620 RVA: 0x0002DE88 File Offset: 0x0002C088
|
||||
public virtual string SignatureAlgorithm
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_signaturealgo;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000146 RID: 326
|
||||
// (get) Token: 0x06000A3D RID: 2621 RVA: 0x0002DE90 File Offset: 0x0002C090
|
||||
public virtual byte[] SignatureAlgorithmParameters
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.m_signaturealgoparams == null)
|
||||
{
|
||||
return this.m_signaturealgoparams;
|
||||
}
|
||||
return (byte[])this.m_signaturealgoparams.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000147 RID: 327
|
||||
// (get) Token: 0x06000A3E RID: 2622 RVA: 0x0002DEC0 File Offset: 0x0002C0C0
|
||||
public virtual string SubjectName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_subject;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000148 RID: 328
|
||||
// (get) Token: 0x06000A3F RID: 2623 RVA: 0x0002DEC8 File Offset: 0x0002C0C8
|
||||
public virtual DateTime ValidFrom
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_from;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000149 RID: 329
|
||||
// (get) Token: 0x06000A40 RID: 2624 RVA: 0x0002DED0 File Offset: 0x0002C0D0
|
||||
public virtual DateTime ValidUntil
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_until;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700014A RID: 330
|
||||
// (get) Token: 0x06000A41 RID: 2625 RVA: 0x0002DED8 File Offset: 0x0002C0D8
|
||||
public int Version
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.version;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700014B RID: 331
|
||||
// (get) Token: 0x06000A42 RID: 2626 RVA: 0x0002DEE0 File Offset: 0x0002C0E0
|
||||
public bool IsCurrent
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.WasCurrent(DateTime.UtcNow);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A43 RID: 2627 RVA: 0x0002DEF0 File Offset: 0x0002C0F0
|
||||
public bool WasCurrent(DateTime instant)
|
||||
{
|
||||
return instant > this.ValidFrom && instant <= this.ValidUntil;
|
||||
}
|
||||
|
||||
// Token: 0x1700014C RID: 332
|
||||
// (get) Token: 0x06000A44 RID: 2628 RVA: 0x0002DF20 File Offset: 0x0002C120
|
||||
public byte[] IssuerUniqueIdentifier
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.issuerUniqueID == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (byte[])this.issuerUniqueID.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700014D RID: 333
|
||||
// (get) Token: 0x06000A45 RID: 2629 RVA: 0x0002DF40 File Offset: 0x0002C140
|
||||
public byte[] SubjectUniqueIdentifier
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.subjectUniqueID == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (byte[])this.subjectUniqueID.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A46 RID: 2630 RVA: 0x0002DF60 File Offset: 0x0002C160
|
||||
internal bool VerifySignature(DSA dsa)
|
||||
{
|
||||
DSASignatureDeformatter dsasignatureDeformatter = new DSASignatureDeformatter(dsa);
|
||||
dsasignatureDeformatter.SetHashAlgorithm("SHA1");
|
||||
return dsasignatureDeformatter.VerifySignature(this.Hash, this.Signature);
|
||||
}
|
||||
|
||||
// Token: 0x06000A47 RID: 2631 RVA: 0x0002DF94 File Offset: 0x0002C194
|
||||
internal string GetHashNameFromOID(string oid)
|
||||
{
|
||||
switch (oid)
|
||||
{
|
||||
case "1.2.840.113549.1.1.2":
|
||||
return "MD2";
|
||||
case "1.2.840.113549.1.1.4":
|
||||
return "MD5";
|
||||
case "1.2.840.113549.1.1.5":
|
||||
case "1.3.14.3.2.29":
|
||||
return "SHA1";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x06000A48 RID: 2632 RVA: 0x0002E02C File Offset: 0x0002C22C
|
||||
internal bool VerifySignature(RSA rsa)
|
||||
{
|
||||
RSAPKCS1SignatureDeformatter rsapkcs1SignatureDeformatter = new RSAPKCS1SignatureDeformatter(rsa);
|
||||
string hashNameFromOID = this.GetHashNameFromOID(this.m_signaturealgo);
|
||||
if (hashNameFromOID == null)
|
||||
{
|
||||
throw new CryptographicException("Unsupported hash algorithm: " + this.m_signaturealgo);
|
||||
}
|
||||
rsapkcs1SignatureDeformatter.SetHashAlgorithm(hashNameFromOID);
|
||||
return rsapkcs1SignatureDeformatter.VerifySignature(this.Hash, this.Signature);
|
||||
}
|
||||
|
||||
// Token: 0x06000A49 RID: 2633 RVA: 0x0002E084 File Offset: 0x0002C284
|
||||
public bool VerifySignature(AsymmetricAlgorithm aa)
|
||||
{
|
||||
if (aa == null)
|
||||
{
|
||||
throw new ArgumentNullException("aa");
|
||||
}
|
||||
if (aa is RSA)
|
||||
{
|
||||
return this.VerifySignature(aa as RSA);
|
||||
}
|
||||
if (aa is DSA)
|
||||
{
|
||||
return this.VerifySignature(aa as DSA);
|
||||
}
|
||||
throw new NotSupportedException("Unknown Asymmetric Algorithm " + aa.ToString());
|
||||
}
|
||||
|
||||
// Token: 0x06000A4A RID: 2634 RVA: 0x0002E0E8 File Offset: 0x0002C2E8
|
||||
public bool CheckSignature(byte[] hash, string hashAlgorithm, byte[] signature)
|
||||
{
|
||||
RSACryptoServiceProvider rsacryptoServiceProvider = (RSACryptoServiceProvider)this.RSA;
|
||||
return rsacryptoServiceProvider.VerifyHash(hash, hashAlgorithm, signature);
|
||||
}
|
||||
|
||||
// Token: 0x1700014E RID: 334
|
||||
// (get) Token: 0x06000A4B RID: 2635 RVA: 0x0002E10C File Offset: 0x0002C30C
|
||||
public bool IsSelfSigned
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_issuername == this.m_subject && this.VerifySignature(this.RSA);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A4C RID: 2636 RVA: 0x0002E140 File Offset: 0x0002C340
|
||||
public ASN1 GetIssuerName()
|
||||
{
|
||||
return this.issuer;
|
||||
}
|
||||
|
||||
// Token: 0x06000A4D RID: 2637 RVA: 0x0002E148 File Offset: 0x0002C348
|
||||
public ASN1 GetSubjectName()
|
||||
{
|
||||
return this.subject;
|
||||
}
|
||||
|
||||
// Token: 0x06000A4E RID: 2638 RVA: 0x0002E150 File Offset: 0x0002C350
|
||||
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
info.AddValue("raw", this.m_encodedcert);
|
||||
}
|
||||
|
||||
// Token: 0x06000A4F RID: 2639 RVA: 0x0002E164 File Offset: 0x0002C364
|
||||
private static byte[] PEM(string type, byte[] data)
|
||||
{
|
||||
string @string = Encoding.ASCII.GetString(data);
|
||||
string text = string.Format("-----BEGIN {0}-----", type);
|
||||
string text2 = string.Format("-----END {0}-----", type);
|
||||
int num = @string.IndexOf(text) + text.Length;
|
||||
int num2 = @string.IndexOf(text2, num);
|
||||
string text3 = @string.Substring(num, num2 - num);
|
||||
return Convert.FromBase64String(text3);
|
||||
}
|
||||
|
||||
// Token: 0x04000292 RID: 658
|
||||
private ASN1 decoder;
|
||||
|
||||
// Token: 0x04000293 RID: 659
|
||||
private byte[] m_encodedcert;
|
||||
|
||||
// Token: 0x04000294 RID: 660
|
||||
private DateTime m_from;
|
||||
|
||||
// Token: 0x04000295 RID: 661
|
||||
private DateTime m_until;
|
||||
|
||||
// Token: 0x04000296 RID: 662
|
||||
private ASN1 issuer;
|
||||
|
||||
// Token: 0x04000297 RID: 663
|
||||
private string m_issuername;
|
||||
|
||||
// Token: 0x04000298 RID: 664
|
||||
private string m_keyalgo;
|
||||
|
||||
// Token: 0x04000299 RID: 665
|
||||
private byte[] m_keyalgoparams;
|
||||
|
||||
// Token: 0x0400029A RID: 666
|
||||
private ASN1 subject;
|
||||
|
||||
// Token: 0x0400029B RID: 667
|
||||
private string m_subject;
|
||||
|
||||
// Token: 0x0400029C RID: 668
|
||||
private byte[] m_publickey;
|
||||
|
||||
// Token: 0x0400029D RID: 669
|
||||
private byte[] signature;
|
||||
|
||||
// Token: 0x0400029E RID: 670
|
||||
private string m_signaturealgo;
|
||||
|
||||
// Token: 0x0400029F RID: 671
|
||||
private byte[] m_signaturealgoparams;
|
||||
|
||||
// Token: 0x040002A0 RID: 672
|
||||
private byte[] certhash;
|
||||
|
||||
// Token: 0x040002A1 RID: 673
|
||||
private RSA _rsa;
|
||||
|
||||
// Token: 0x040002A2 RID: 674
|
||||
private DSA _dsa;
|
||||
|
||||
// Token: 0x040002A3 RID: 675
|
||||
private int version;
|
||||
|
||||
// Token: 0x040002A4 RID: 676
|
||||
private byte[] serialnumber;
|
||||
|
||||
// Token: 0x040002A5 RID: 677
|
||||
private byte[] issuerUniqueID;
|
||||
|
||||
// Token: 0x040002A6 RID: 678
|
||||
private byte[] subjectUniqueID;
|
||||
|
||||
// Token: 0x040002A7 RID: 679
|
||||
private X509ExtensionCollection extensions;
|
||||
|
||||
// Token: 0x040002A8 RID: 680
|
||||
private static string encoding_error = Locale.GetText("Input data cannot be coded as a valid certificate.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace Mono.Security.X509
|
||||
{
|
||||
// Token: 0x020000BD RID: 189
|
||||
[Serializable]
|
||||
internal class X509CertificateCollection : CollectionBase, IEnumerable
|
||||
{
|
||||
// Token: 0x06000A50 RID: 2640 RVA: 0x0002E1C4 File Offset: 0x0002C3C4
|
||||
public X509CertificateCollection()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000A51 RID: 2641 RVA: 0x0002E1CC File Offset: 0x0002C3CC
|
||||
public X509CertificateCollection(X509Certificate[] value)
|
||||
{
|
||||
this.AddRange(value);
|
||||
}
|
||||
|
||||
// Token: 0x06000A52 RID: 2642 RVA: 0x0002E1DC File Offset: 0x0002C3DC
|
||||
public X509CertificateCollection(X509CertificateCollection value)
|
||||
{
|
||||
this.AddRange(value);
|
||||
}
|
||||
|
||||
// Token: 0x06000A53 RID: 2643 RVA: 0x0002E1EC File Offset: 0x0002C3EC
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return base.InnerList.GetEnumerator();
|
||||
}
|
||||
|
||||
// Token: 0x1700014F RID: 335
|
||||
public X509Certificate this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return (X509Certificate)base.InnerList[index];
|
||||
}
|
||||
set
|
||||
{
|
||||
base.InnerList[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A56 RID: 2646 RVA: 0x0002E220 File Offset: 0x0002C420
|
||||
public int Add(X509Certificate value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException("value");
|
||||
}
|
||||
return base.InnerList.Add(value);
|
||||
}
|
||||
|
||||
// Token: 0x06000A57 RID: 2647 RVA: 0x0002E240 File Offset: 0x0002C440
|
||||
public void AddRange(X509Certificate[] value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException("value");
|
||||
}
|
||||
for (int i = 0; i < value.Length; i++)
|
||||
{
|
||||
base.InnerList.Add(value[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A58 RID: 2648 RVA: 0x0002E284 File Offset: 0x0002C484
|
||||
public void AddRange(X509CertificateCollection value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException("value");
|
||||
}
|
||||
for (int i = 0; i < value.InnerList.Count; i++)
|
||||
{
|
||||
base.InnerList.Add(value[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A59 RID: 2649 RVA: 0x0002E2D4 File Offset: 0x0002C4D4
|
||||
public bool Contains(X509Certificate value)
|
||||
{
|
||||
return this.IndexOf(value) != -1;
|
||||
}
|
||||
|
||||
// Token: 0x06000A5A RID: 2650 RVA: 0x0002E2E4 File Offset: 0x0002C4E4
|
||||
public void CopyTo(X509Certificate[] array, int index)
|
||||
{
|
||||
base.InnerList.CopyTo(array, index);
|
||||
}
|
||||
|
||||
// Token: 0x06000A5B RID: 2651 RVA: 0x0002E2F4 File Offset: 0x0002C4F4
|
||||
public new X509CertificateCollection.X509CertificateEnumerator GetEnumerator()
|
||||
{
|
||||
return new X509CertificateCollection.X509CertificateEnumerator(this);
|
||||
}
|
||||
|
||||
// Token: 0x06000A5C RID: 2652 RVA: 0x0002E2FC File Offset: 0x0002C4FC
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.InnerList.GetHashCode();
|
||||
}
|
||||
|
||||
// Token: 0x06000A5D RID: 2653 RVA: 0x0002E30C File Offset: 0x0002C50C
|
||||
public int IndexOf(X509Certificate value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException("value");
|
||||
}
|
||||
byte[] hash = value.Hash;
|
||||
for (int i = 0; i < base.InnerList.Count; i++)
|
||||
{
|
||||
X509Certificate x509Certificate = (X509Certificate)base.InnerList[i];
|
||||
if (this.Compare(x509Certificate.Hash, hash))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Token: 0x06000A5E RID: 2654 RVA: 0x0002E374 File Offset: 0x0002C574
|
||||
public void Insert(int index, X509Certificate value)
|
||||
{
|
||||
base.InnerList.Insert(index, value);
|
||||
}
|
||||
|
||||
// Token: 0x06000A5F RID: 2655 RVA: 0x0002E384 File Offset: 0x0002C584
|
||||
public void Remove(X509Certificate value)
|
||||
{
|
||||
base.InnerList.Remove(value);
|
||||
}
|
||||
|
||||
// Token: 0x06000A60 RID: 2656 RVA: 0x0002E394 File Offset: 0x0002C594
|
||||
private bool Compare(byte[] array1, byte[] array2)
|
||||
{
|
||||
if (array1 == null && array2 == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (array1 == null || array2 == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (array1.Length != array2.Length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < array1.Length; i++)
|
||||
{
|
||||
if (array1[i] != array2[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x020000BE RID: 190
|
||||
public class X509CertificateEnumerator : IEnumerator
|
||||
{
|
||||
// Token: 0x06000A61 RID: 2657 RVA: 0x0002E3EC File Offset: 0x0002C5EC
|
||||
public X509CertificateEnumerator(X509CertificateCollection mappings)
|
||||
{
|
||||
this.enumerator = ((IEnumerable)mappings).GetEnumerator();
|
||||
}
|
||||
|
||||
// Token: 0x17000150 RID: 336
|
||||
// (get) Token: 0x06000A62 RID: 2658 RVA: 0x0002E400 File Offset: 0x0002C600
|
||||
object IEnumerator.Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.enumerator.Current;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A63 RID: 2659 RVA: 0x0002E410 File Offset: 0x0002C610
|
||||
bool IEnumerator.MoveNext()
|
||||
{
|
||||
return this.enumerator.MoveNext();
|
||||
}
|
||||
|
||||
// Token: 0x06000A64 RID: 2660 RVA: 0x0002E420 File Offset: 0x0002C620
|
||||
void IEnumerator.Reset()
|
||||
{
|
||||
this.enumerator.Reset();
|
||||
}
|
||||
|
||||
// Token: 0x17000151 RID: 337
|
||||
// (get) Token: 0x06000A65 RID: 2661 RVA: 0x0002E430 File Offset: 0x0002C630
|
||||
public X509Certificate Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return (X509Certificate)this.enumerator.Current;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A66 RID: 2662 RVA: 0x0002E444 File Offset: 0x0002C644
|
||||
public bool MoveNext()
|
||||
{
|
||||
return this.enumerator.MoveNext();
|
||||
}
|
||||
|
||||
// Token: 0x06000A67 RID: 2663 RVA: 0x0002E454 File Offset: 0x0002C654
|
||||
public void Reset()
|
||||
{
|
||||
this.enumerator.Reset();
|
||||
}
|
||||
|
||||
// Token: 0x040002AC RID: 684
|
||||
private IEnumerator enumerator;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
using System;
|
||||
using Mono.Security.X509.Extensions;
|
||||
|
||||
namespace Mono.Security.X509
|
||||
{
|
||||
// Token: 0x020000BF RID: 191
|
||||
internal class X509Chain
|
||||
{
|
||||
// Token: 0x06000A68 RID: 2664 RVA: 0x0002E464 File Offset: 0x0002C664
|
||||
public X509Chain()
|
||||
{
|
||||
this.certs = new X509CertificateCollection();
|
||||
}
|
||||
|
||||
// Token: 0x06000A69 RID: 2665 RVA: 0x0002E478 File Offset: 0x0002C678
|
||||
public X509Chain(X509CertificateCollection chain)
|
||||
: this()
|
||||
{
|
||||
this._chain = new X509CertificateCollection();
|
||||
this._chain.AddRange(chain);
|
||||
}
|
||||
|
||||
// Token: 0x17000152 RID: 338
|
||||
// (get) Token: 0x06000A6A RID: 2666 RVA: 0x0002E498 File Offset: 0x0002C698
|
||||
public X509CertificateCollection Chain
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._chain;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000153 RID: 339
|
||||
// (get) Token: 0x06000A6B RID: 2667 RVA: 0x0002E4A0 File Offset: 0x0002C6A0
|
||||
public X509Certificate Root
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._root;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000154 RID: 340
|
||||
// (get) Token: 0x06000A6C RID: 2668 RVA: 0x0002E4A8 File Offset: 0x0002C6A8
|
||||
public X509ChainStatusFlags Status
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._status;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000155 RID: 341
|
||||
// (get) Token: 0x06000A6D RID: 2669 RVA: 0x0002E4B0 File Offset: 0x0002C6B0
|
||||
// (set) Token: 0x06000A6E RID: 2670 RVA: 0x0002E4E8 File Offset: 0x0002C6E8
|
||||
public X509CertificateCollection TrustAnchors
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.roots == null)
|
||||
{
|
||||
this.roots = new X509CertificateCollection();
|
||||
this.roots.AddRange(X509StoreManager.TrustedRootCertificates);
|
||||
return this.roots;
|
||||
}
|
||||
return this.roots;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.roots = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A6F RID: 2671 RVA: 0x0002E4F4 File Offset: 0x0002C6F4
|
||||
public void LoadCertificate(X509Certificate x509)
|
||||
{
|
||||
this.certs.Add(x509);
|
||||
}
|
||||
|
||||
// Token: 0x06000A70 RID: 2672 RVA: 0x0002E504 File Offset: 0x0002C704
|
||||
public void LoadCertificates(X509CertificateCollection collection)
|
||||
{
|
||||
this.certs.AddRange(collection);
|
||||
}
|
||||
|
||||
// Token: 0x06000A71 RID: 2673 RVA: 0x0002E514 File Offset: 0x0002C714
|
||||
public X509Certificate FindByIssuerName(string issuerName)
|
||||
{
|
||||
foreach (X509Certificate x509Certificate in this.certs)
|
||||
{
|
||||
if (x509Certificate.IssuerName == issuerName)
|
||||
{
|
||||
return x509Certificate;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x06000A72 RID: 2674 RVA: 0x0002E594 File Offset: 0x0002C794
|
||||
public bool Build(X509Certificate leaf)
|
||||
{
|
||||
this._status = X509ChainStatusFlags.NoError;
|
||||
if (this._chain == null)
|
||||
{
|
||||
this._chain = new X509CertificateCollection();
|
||||
X509Certificate x509Certificate = leaf;
|
||||
X509Certificate x509Certificate2 = x509Certificate;
|
||||
while (x509Certificate != null && !x509Certificate.IsSelfSigned)
|
||||
{
|
||||
x509Certificate2 = x509Certificate;
|
||||
this._chain.Add(x509Certificate);
|
||||
x509Certificate = this.FindCertificateParent(x509Certificate);
|
||||
}
|
||||
this._root = this.FindCertificateRoot(x509Certificate2);
|
||||
}
|
||||
else
|
||||
{
|
||||
int count = this._chain.Count;
|
||||
if (count > 0)
|
||||
{
|
||||
if (this.IsParent(leaf, this._chain[0]))
|
||||
{
|
||||
int i;
|
||||
for (i = 1; i < count; i++)
|
||||
{
|
||||
if (!this.IsParent(this._chain[i - 1], this._chain[i]))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == count)
|
||||
{
|
||||
this._root = this.FindCertificateRoot(this._chain[count - 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this._root = this.FindCertificateRoot(leaf);
|
||||
}
|
||||
}
|
||||
if (this._chain != null && this._status == X509ChainStatusFlags.NoError)
|
||||
{
|
||||
foreach (X509Certificate x509Certificate3 in this._chain)
|
||||
{
|
||||
if (!this.IsValid(x509Certificate3))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!this.IsValid(leaf))
|
||||
{
|
||||
if (this._status == X509ChainStatusFlags.NotTimeNested)
|
||||
{
|
||||
this._status = X509ChainStatusFlags.NotTimeValid;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (this._root != null && !this.IsValid(this._root))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
IL_1A6:
|
||||
return this._status == X509ChainStatusFlags.NoError;
|
||||
}
|
||||
|
||||
// Token: 0x06000A73 RID: 2675 RVA: 0x0002E770 File Offset: 0x0002C970
|
||||
public void Reset()
|
||||
{
|
||||
this._status = X509ChainStatusFlags.NoError;
|
||||
this.roots = null;
|
||||
this.certs.Clear();
|
||||
if (this._chain != null)
|
||||
{
|
||||
this._chain.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A74 RID: 2676 RVA: 0x0002E7A4 File Offset: 0x0002C9A4
|
||||
private bool IsValid(X509Certificate cert)
|
||||
{
|
||||
if (!cert.IsCurrent)
|
||||
{
|
||||
this._status = X509ChainStatusFlags.NotTimeNested;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x06000A75 RID: 2677 RVA: 0x0002E7BC File Offset: 0x0002C9BC
|
||||
private X509Certificate FindCertificateParent(X509Certificate child)
|
||||
{
|
||||
foreach (X509Certificate x509Certificate in this.certs)
|
||||
{
|
||||
if (this.IsParent(child, x509Certificate))
|
||||
{
|
||||
return x509Certificate;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x06000A76 RID: 2678 RVA: 0x0002E838 File Offset: 0x0002CA38
|
||||
private X509Certificate FindCertificateRoot(X509Certificate potentialRoot)
|
||||
{
|
||||
if (potentialRoot == null)
|
||||
{
|
||||
this._status = X509ChainStatusFlags.PartialChain;
|
||||
return null;
|
||||
}
|
||||
if (this.IsTrusted(potentialRoot))
|
||||
{
|
||||
return potentialRoot;
|
||||
}
|
||||
foreach (X509Certificate x509Certificate in this.TrustAnchors)
|
||||
{
|
||||
if (this.IsParent(potentialRoot, x509Certificate))
|
||||
{
|
||||
return x509Certificate;
|
||||
}
|
||||
}
|
||||
if (potentialRoot.IsSelfSigned)
|
||||
{
|
||||
this._status = X509ChainStatusFlags.UntrustedRoot;
|
||||
return potentialRoot;
|
||||
}
|
||||
this._status = X509ChainStatusFlags.PartialChain;
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x06000A77 RID: 2679 RVA: 0x0002E8F4 File Offset: 0x0002CAF4
|
||||
private bool IsTrusted(X509Certificate potentialTrusted)
|
||||
{
|
||||
return this.TrustAnchors.Contains(potentialTrusted);
|
||||
}
|
||||
|
||||
// Token: 0x06000A78 RID: 2680 RVA: 0x0002E904 File Offset: 0x0002CB04
|
||||
private bool IsParent(X509Certificate child, X509Certificate parent)
|
||||
{
|
||||
if (child.IssuerName != parent.SubjectName)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (parent.Version > 2 && !this.IsTrusted(parent))
|
||||
{
|
||||
X509Extension x509Extension = parent.Extensions["2.5.29.19"];
|
||||
if (x509Extension != null)
|
||||
{
|
||||
BasicConstraintsExtension basicConstraintsExtension = new BasicConstraintsExtension(x509Extension);
|
||||
if (!basicConstraintsExtension.CertificateAuthority)
|
||||
{
|
||||
this._status = X509ChainStatusFlags.InvalidBasicConstraints;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this._status = X509ChainStatusFlags.InvalidBasicConstraints;
|
||||
}
|
||||
}
|
||||
if (!child.VerifySignature(parent.RSA))
|
||||
{
|
||||
this._status = X509ChainStatusFlags.NotSignatureValid;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x040002AD RID: 685
|
||||
private X509CertificateCollection roots;
|
||||
|
||||
// Token: 0x040002AE RID: 686
|
||||
private X509CertificateCollection certs;
|
||||
|
||||
// Token: 0x040002AF RID: 687
|
||||
private X509Certificate _root;
|
||||
|
||||
// Token: 0x040002B0 RID: 688
|
||||
private X509CertificateCollection _chain;
|
||||
|
||||
// Token: 0x040002B1 RID: 689
|
||||
private X509ChainStatusFlags _status;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.X509
|
||||
{
|
||||
// Token: 0x020000C0 RID: 192
|
||||
[Flags]
|
||||
[Serializable]
|
||||
internal enum X509ChainStatusFlags
|
||||
{
|
||||
// Token: 0x040002B3 RID: 691
|
||||
InvalidBasicConstraints = 1024,
|
||||
// Token: 0x040002B4 RID: 692
|
||||
NoError = 0,
|
||||
// Token: 0x040002B5 RID: 693
|
||||
NotSignatureValid = 8,
|
||||
// Token: 0x040002B6 RID: 694
|
||||
NotTimeNested = 2,
|
||||
// Token: 0x040002B7 RID: 695
|
||||
NotTimeValid = 1,
|
||||
// Token: 0x040002B8 RID: 696
|
||||
PartialChain = 65536,
|
||||
// Token: 0x040002B9 RID: 697
|
||||
UntrustedRoot = 32
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,546 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using Mono.Security.X509.Extensions;
|
||||
|
||||
namespace Mono.Security.X509
|
||||
{
|
||||
// Token: 0x020000BA RID: 186
|
||||
internal class X509Crl
|
||||
{
|
||||
// Token: 0x06000A09 RID: 2569 RVA: 0x0002CAF8 File Offset: 0x0002ACF8
|
||||
public X509Crl(byte[] crl)
|
||||
{
|
||||
if (crl == null)
|
||||
{
|
||||
throw new ArgumentNullException("crl");
|
||||
}
|
||||
this.encoded = (byte[])crl.Clone();
|
||||
this.Parse(this.encoded);
|
||||
}
|
||||
|
||||
// Token: 0x06000A0A RID: 2570 RVA: 0x0002CB3C File Offset: 0x0002AD3C
|
||||
private void Parse(byte[] crl)
|
||||
{
|
||||
string text = "Input data cannot be coded as a valid CRL.";
|
||||
try
|
||||
{
|
||||
ASN1 asn = new ASN1(this.encoded);
|
||||
if (asn.Tag != 48 || asn.Count != 3)
|
||||
{
|
||||
throw new CryptographicException(text);
|
||||
}
|
||||
ASN1 asn2 = asn[0];
|
||||
if (asn2.Tag != 48 || asn2.Count < 3)
|
||||
{
|
||||
throw new CryptographicException(text);
|
||||
}
|
||||
int num = 0;
|
||||
if (asn2[num].Tag == 2)
|
||||
{
|
||||
this.version = asn2[num++].Value[0] + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.version = 1;
|
||||
}
|
||||
this.signatureOID = ASN1Convert.ToOid(asn2[num++][0]);
|
||||
this.issuer = X501.ToString(asn2[num++]);
|
||||
this.thisUpdate = ASN1Convert.ToDateTime(asn2[num++]);
|
||||
ASN1 asn3 = asn2[num++];
|
||||
if (asn3.Tag == 23 || asn3.Tag == 24)
|
||||
{
|
||||
this.nextUpdate = ASN1Convert.ToDateTime(asn3);
|
||||
asn3 = asn2[num++];
|
||||
}
|
||||
this.entries = new ArrayList();
|
||||
if (asn3 != null && asn3.Tag == 48)
|
||||
{
|
||||
ASN1 asn4 = asn3;
|
||||
for (int i = 0; i < asn4.Count; i++)
|
||||
{
|
||||
this.entries.Add(new X509Crl.X509CrlEntry(asn4[i]));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
num--;
|
||||
}
|
||||
ASN1 asn5 = asn2[num];
|
||||
if (asn5 != null && asn5.Tag == 160 && asn5.Count == 1)
|
||||
{
|
||||
this.extensions = new X509ExtensionCollection(asn5[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.extensions = new X509ExtensionCollection(null);
|
||||
}
|
||||
string text2 = ASN1Convert.ToOid(asn[1][0]);
|
||||
if (this.signatureOID != text2)
|
||||
{
|
||||
throw new CryptographicException(text + " [Non-matching signature algorithms in CRL]");
|
||||
}
|
||||
byte[] value = asn[2].Value;
|
||||
this.signature = new byte[value.Length - 1];
|
||||
Buffer.BlockCopy(value, 1, this.signature, 0, this.signature.Length);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw new CryptographicException(text);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700012A RID: 298
|
||||
// (get) Token: 0x06000A0B RID: 2571 RVA: 0x0002CDBC File Offset: 0x0002AFBC
|
||||
public ArrayList Entries
|
||||
{
|
||||
get
|
||||
{
|
||||
return ArrayList.ReadOnly(this.entries);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700012B RID: 299
|
||||
public X509Crl.X509CrlEntry this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return (X509Crl.X509CrlEntry)this.entries[index];
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700012C RID: 300
|
||||
public X509Crl.X509CrlEntry this[byte[] serialNumber]
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.GetCrlEntry(serialNumber);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700012D RID: 301
|
||||
// (get) Token: 0x06000A0E RID: 2574 RVA: 0x0002CDEC File Offset: 0x0002AFEC
|
||||
public X509ExtensionCollection Extensions
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.extensions;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700012E RID: 302
|
||||
// (get) Token: 0x06000A0F RID: 2575 RVA: 0x0002CDF4 File Offset: 0x0002AFF4
|
||||
public byte[] Hash
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.hash_value == null)
|
||||
{
|
||||
ASN1 asn = new ASN1(this.encoded);
|
||||
byte[] bytes = asn[0].GetBytes();
|
||||
HashAlgorithm hashAlgorithm = HashAlgorithm.Create(this.GetHashName());
|
||||
this.hash_value = hashAlgorithm.ComputeHash(bytes);
|
||||
}
|
||||
return this.hash_value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700012F RID: 303
|
||||
// (get) Token: 0x06000A10 RID: 2576 RVA: 0x0002CE44 File Offset: 0x0002B044
|
||||
public string IssuerName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.issuer;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000130 RID: 304
|
||||
// (get) Token: 0x06000A11 RID: 2577 RVA: 0x0002CE4C File Offset: 0x0002B04C
|
||||
public DateTime NextUpdate
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.nextUpdate;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000131 RID: 305
|
||||
// (get) Token: 0x06000A12 RID: 2578 RVA: 0x0002CE54 File Offset: 0x0002B054
|
||||
public DateTime ThisUpdate
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.thisUpdate;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000132 RID: 306
|
||||
// (get) Token: 0x06000A13 RID: 2579 RVA: 0x0002CE5C File Offset: 0x0002B05C
|
||||
public string SignatureAlgorithm
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.signatureOID;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000133 RID: 307
|
||||
// (get) Token: 0x06000A14 RID: 2580 RVA: 0x0002CE64 File Offset: 0x0002B064
|
||||
public byte[] Signature
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.signature == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (byte[])this.signature.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000134 RID: 308
|
||||
// (get) Token: 0x06000A15 RID: 2581 RVA: 0x0002CE84 File Offset: 0x0002B084
|
||||
public byte[] RawData
|
||||
{
|
||||
get
|
||||
{
|
||||
return (byte[])this.encoded.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000135 RID: 309
|
||||
// (get) Token: 0x06000A16 RID: 2582 RVA: 0x0002CE98 File Offset: 0x0002B098
|
||||
public byte Version
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.version;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000136 RID: 310
|
||||
// (get) Token: 0x06000A17 RID: 2583 RVA: 0x0002CEA0 File Offset: 0x0002B0A0
|
||||
public bool IsCurrent
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.WasCurrent(DateTime.Now);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A18 RID: 2584 RVA: 0x0002CEB0 File Offset: 0x0002B0B0
|
||||
public bool WasCurrent(DateTime instant)
|
||||
{
|
||||
if (this.nextUpdate == DateTime.MinValue)
|
||||
{
|
||||
return instant >= this.thisUpdate;
|
||||
}
|
||||
return instant >= this.thisUpdate && instant <= this.nextUpdate;
|
||||
}
|
||||
|
||||
// Token: 0x06000A19 RID: 2585 RVA: 0x0002CF00 File Offset: 0x0002B100
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
return (byte[])this.encoded.Clone();
|
||||
}
|
||||
|
||||
// Token: 0x06000A1A RID: 2586 RVA: 0x0002CF14 File Offset: 0x0002B114
|
||||
private bool Compare(byte[] array1, byte[] array2)
|
||||
{
|
||||
if (array1 == null && array2 == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (array1 == null || array2 == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (array1.Length != array2.Length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < array1.Length; i++)
|
||||
{
|
||||
if (array1[i] != array2[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x06000A1B RID: 2587 RVA: 0x0002CF6C File Offset: 0x0002B16C
|
||||
public X509Crl.X509CrlEntry GetCrlEntry(X509Certificate x509)
|
||||
{
|
||||
if (x509 == null)
|
||||
{
|
||||
throw new ArgumentNullException("x509");
|
||||
}
|
||||
return this.GetCrlEntry(x509.SerialNumber);
|
||||
}
|
||||
|
||||
// Token: 0x06000A1C RID: 2588 RVA: 0x0002CF8C File Offset: 0x0002B18C
|
||||
public X509Crl.X509CrlEntry GetCrlEntry(byte[] serialNumber)
|
||||
{
|
||||
if (serialNumber == null)
|
||||
{
|
||||
throw new ArgumentNullException("serialNumber");
|
||||
}
|
||||
for (int i = 0; i < this.entries.Count; i++)
|
||||
{
|
||||
X509Crl.X509CrlEntry x509CrlEntry = (X509Crl.X509CrlEntry)this.entries[i];
|
||||
if (this.Compare(serialNumber, x509CrlEntry.SerialNumber))
|
||||
{
|
||||
return x509CrlEntry;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x06000A1D RID: 2589 RVA: 0x0002CFF0 File Offset: 0x0002B1F0
|
||||
public bool VerifySignature(X509Certificate x509)
|
||||
{
|
||||
if (x509 == null)
|
||||
{
|
||||
throw new ArgumentNullException("x509");
|
||||
}
|
||||
if (x509.Version >= 3)
|
||||
{
|
||||
X509Extension x509Extension = x509.Extensions["2.5.29.15"];
|
||||
if (x509Extension != null)
|
||||
{
|
||||
KeyUsageExtension keyUsageExtension = new KeyUsageExtension(x509Extension);
|
||||
if (!keyUsageExtension.Support(KeyUsages.cRLSign))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
x509Extension = x509.Extensions["2.5.29.19"];
|
||||
if (x509Extension != null)
|
||||
{
|
||||
BasicConstraintsExtension basicConstraintsExtension = new BasicConstraintsExtension(x509Extension);
|
||||
if (!basicConstraintsExtension.CertificateAuthority)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.issuer != x509.SubjectName)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
string text = this.signatureOID;
|
||||
if (text != null)
|
||||
{
|
||||
if (X509Crl.<>f__switch$map11 == null)
|
||||
{
|
||||
X509Crl.<>f__switch$map11 = new Dictionary<string, int>(1) { { "1.2.840.10040.4.3", 0 } };
|
||||
}
|
||||
int num;
|
||||
if (X509Crl.<>f__switch$map11.TryGetValue(text, out num))
|
||||
{
|
||||
if (num == 0)
|
||||
{
|
||||
return this.VerifySignature(x509.DSA);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.VerifySignature(x509.RSA);
|
||||
}
|
||||
|
||||
// Token: 0x06000A1E RID: 2590 RVA: 0x0002D0F4 File Offset: 0x0002B2F4
|
||||
private string GetHashName()
|
||||
{
|
||||
string text = this.signatureOID;
|
||||
switch (text)
|
||||
{
|
||||
case "1.2.840.113549.1.1.2":
|
||||
return "MD2";
|
||||
case "1.2.840.113549.1.1.4":
|
||||
return "MD5";
|
||||
case "1.2.840.10040.4.3":
|
||||
case "1.2.840.113549.1.1.5":
|
||||
return "SHA1";
|
||||
}
|
||||
throw new CryptographicException("Unsupported hash algorithm: " + this.signatureOID);
|
||||
}
|
||||
|
||||
// Token: 0x06000A1F RID: 2591 RVA: 0x0002D1A8 File Offset: 0x0002B3A8
|
||||
internal bool VerifySignature(DSA dsa)
|
||||
{
|
||||
if (this.signatureOID != "1.2.840.10040.4.3")
|
||||
{
|
||||
throw new CryptographicException("Unsupported hash algorithm: " + this.signatureOID);
|
||||
}
|
||||
DSASignatureDeformatter dsasignatureDeformatter = new DSASignatureDeformatter(dsa);
|
||||
dsasignatureDeformatter.SetHashAlgorithm("SHA1");
|
||||
ASN1 asn = new ASN1(this.signature);
|
||||
if (asn == null || asn.Count != 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
byte[] value = asn[0].Value;
|
||||
byte[] value2 = asn[1].Value;
|
||||
byte[] array = new byte[40];
|
||||
int num = Math.Max(0, value.Length - 20);
|
||||
int num2 = Math.Max(0, 20 - value.Length);
|
||||
Buffer.BlockCopy(value, num, array, num2, value.Length - num);
|
||||
int num3 = Math.Max(0, value2.Length - 20);
|
||||
int num4 = Math.Max(20, 40 - value2.Length);
|
||||
Buffer.BlockCopy(value2, num3, array, num4, value2.Length - num3);
|
||||
return dsasignatureDeformatter.VerifySignature(this.Hash, array);
|
||||
}
|
||||
|
||||
// Token: 0x06000A20 RID: 2592 RVA: 0x0002D2A0 File Offset: 0x0002B4A0
|
||||
internal bool VerifySignature(RSA rsa)
|
||||
{
|
||||
RSAPKCS1SignatureDeformatter rsapkcs1SignatureDeformatter = new RSAPKCS1SignatureDeformatter(rsa);
|
||||
rsapkcs1SignatureDeformatter.SetHashAlgorithm(this.GetHashName());
|
||||
return rsapkcs1SignatureDeformatter.VerifySignature(this.Hash, this.signature);
|
||||
}
|
||||
|
||||
// Token: 0x06000A21 RID: 2593 RVA: 0x0002D2D4 File Offset: 0x0002B4D4
|
||||
public bool VerifySignature(AsymmetricAlgorithm aa)
|
||||
{
|
||||
if (aa == null)
|
||||
{
|
||||
throw new ArgumentNullException("aa");
|
||||
}
|
||||
if (aa is RSA)
|
||||
{
|
||||
return this.VerifySignature(aa as RSA);
|
||||
}
|
||||
if (aa is DSA)
|
||||
{
|
||||
return this.VerifySignature(aa as DSA);
|
||||
}
|
||||
throw new NotSupportedException("Unknown Asymmetric Algorithm " + aa.ToString());
|
||||
}
|
||||
|
||||
// Token: 0x06000A22 RID: 2594 RVA: 0x0002D338 File Offset: 0x0002B538
|
||||
public static X509Crl CreateFromFile(string filename)
|
||||
{
|
||||
byte[] array = null;
|
||||
using (FileStream fileStream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
array = new byte[fileStream.Length];
|
||||
fileStream.Read(array, 0, array.Length);
|
||||
fileStream.Close();
|
||||
}
|
||||
return new X509Crl(array);
|
||||
}
|
||||
|
||||
// Token: 0x04000283 RID: 643
|
||||
private string issuer;
|
||||
|
||||
// Token: 0x04000284 RID: 644
|
||||
private byte version;
|
||||
|
||||
// Token: 0x04000285 RID: 645
|
||||
private DateTime thisUpdate;
|
||||
|
||||
// Token: 0x04000286 RID: 646
|
||||
private DateTime nextUpdate;
|
||||
|
||||
// Token: 0x04000287 RID: 647
|
||||
private ArrayList entries;
|
||||
|
||||
// Token: 0x04000288 RID: 648
|
||||
private string signatureOID;
|
||||
|
||||
// Token: 0x04000289 RID: 649
|
||||
private byte[] signature;
|
||||
|
||||
// Token: 0x0400028A RID: 650
|
||||
private X509ExtensionCollection extensions;
|
||||
|
||||
// Token: 0x0400028B RID: 651
|
||||
private byte[] encoded;
|
||||
|
||||
// Token: 0x0400028C RID: 652
|
||||
private byte[] hash_value;
|
||||
|
||||
// Token: 0x020000BB RID: 187
|
||||
public class X509CrlEntry
|
||||
{
|
||||
// Token: 0x06000A23 RID: 2595 RVA: 0x0002D3A4 File Offset: 0x0002B5A4
|
||||
internal X509CrlEntry(byte[] serialNumber, DateTime revocationDate, X509ExtensionCollection extensions)
|
||||
{
|
||||
this.sn = serialNumber;
|
||||
this.revocationDate = revocationDate;
|
||||
if (extensions == null)
|
||||
{
|
||||
this.extensions = new X509ExtensionCollection();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.extensions = extensions;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A24 RID: 2596 RVA: 0x0002D3D8 File Offset: 0x0002B5D8
|
||||
internal X509CrlEntry(ASN1 entry)
|
||||
{
|
||||
this.sn = entry[0].Value;
|
||||
Array.Reverse(this.sn);
|
||||
this.revocationDate = ASN1Convert.ToDateTime(entry[1]);
|
||||
this.extensions = new X509ExtensionCollection(entry[2]);
|
||||
}
|
||||
|
||||
// Token: 0x17000137 RID: 311
|
||||
// (get) Token: 0x06000A25 RID: 2597 RVA: 0x0002D42C File Offset: 0x0002B62C
|
||||
public byte[] SerialNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return (byte[])this.sn.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000138 RID: 312
|
||||
// (get) Token: 0x06000A26 RID: 2598 RVA: 0x0002D440 File Offset: 0x0002B640
|
||||
public DateTime RevocationDate
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.revocationDate;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000139 RID: 313
|
||||
// (get) Token: 0x06000A27 RID: 2599 RVA: 0x0002D448 File Offset: 0x0002B648
|
||||
public X509ExtensionCollection Extensions
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.extensions;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A28 RID: 2600 RVA: 0x0002D450 File Offset: 0x0002B650
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
ASN1 asn = new ASN1(48);
|
||||
asn.Add(new ASN1(2, this.sn));
|
||||
asn.Add(ASN1Convert.FromDateTime(this.revocationDate));
|
||||
if (this.extensions.Count > 0)
|
||||
{
|
||||
asn.Add(new ASN1(this.extensions.GetBytes()));
|
||||
}
|
||||
return asn.GetBytes();
|
||||
}
|
||||
|
||||
// Token: 0x0400028F RID: 655
|
||||
private byte[] sn;
|
||||
|
||||
// Token: 0x04000290 RID: 656
|
||||
private DateTime revocationDate;
|
||||
|
||||
// Token: 0x04000291 RID: 657
|
||||
private X509ExtensionCollection extensions;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace Mono.Security.X509
|
||||
{
|
||||
// Token: 0x020000C1 RID: 193
|
||||
internal class X509Extension
|
||||
{
|
||||
// Token: 0x06000A79 RID: 2681 RVA: 0x0002E9A0 File Offset: 0x0002CBA0
|
||||
protected X509Extension()
|
||||
{
|
||||
this.extnCritical = false;
|
||||
}
|
||||
|
||||
// Token: 0x06000A7A RID: 2682 RVA: 0x0002E9B0 File Offset: 0x0002CBB0
|
||||
public X509Extension(ASN1 asn1)
|
||||
{
|
||||
if (asn1.Tag != 48 || asn1.Count < 2)
|
||||
{
|
||||
throw new ArgumentException(Locale.GetText("Invalid X.509 extension."));
|
||||
}
|
||||
if (asn1[0].Tag != 6)
|
||||
{
|
||||
throw new ArgumentException(Locale.GetText("Invalid X.509 extension."));
|
||||
}
|
||||
this.extnOid = ASN1Convert.ToOid(asn1[0]);
|
||||
this.extnCritical = asn1[1].Tag == 1 && asn1[1].Value[0] == byte.MaxValue;
|
||||
this.extnValue = asn1[asn1.Count - 1];
|
||||
if (this.extnValue.Tag == 4 && this.extnValue.Length > 0 && this.extnValue.Count == 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
ASN1 asn2 = new ASN1(this.extnValue.Value);
|
||||
this.extnValue.Value = null;
|
||||
this.extnValue.Add(asn2);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
this.Decode();
|
||||
}
|
||||
|
||||
// Token: 0x06000A7B RID: 2683 RVA: 0x0002EAF0 File Offset: 0x0002CCF0
|
||||
public X509Extension(X509Extension extension)
|
||||
{
|
||||
if (extension == null)
|
||||
{
|
||||
throw new ArgumentNullException("extension");
|
||||
}
|
||||
if (extension.Value == null || extension.Value.Tag != 4 || extension.Value.Count != 1)
|
||||
{
|
||||
throw new ArgumentException(Locale.GetText("Invalid X.509 extension."));
|
||||
}
|
||||
this.extnOid = extension.Oid;
|
||||
this.extnCritical = extension.Critical;
|
||||
this.extnValue = extension.Value;
|
||||
this.Decode();
|
||||
}
|
||||
|
||||
// Token: 0x06000A7C RID: 2684 RVA: 0x0002EB7C File Offset: 0x0002CD7C
|
||||
protected virtual void Decode()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000A7D RID: 2685 RVA: 0x0002EB80 File Offset: 0x0002CD80
|
||||
protected virtual void Encode()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x17000156 RID: 342
|
||||
// (get) Token: 0x06000A7E RID: 2686 RVA: 0x0002EB84 File Offset: 0x0002CD84
|
||||
public ASN1 ASN1
|
||||
{
|
||||
get
|
||||
{
|
||||
ASN1 asn = new ASN1(48);
|
||||
asn.Add(ASN1Convert.FromOid(this.extnOid));
|
||||
if (this.extnCritical)
|
||||
{
|
||||
asn.Add(new ASN1(1, new byte[] { byte.MaxValue }));
|
||||
}
|
||||
this.Encode();
|
||||
asn.Add(this.extnValue);
|
||||
return asn;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000157 RID: 343
|
||||
// (get) Token: 0x06000A7F RID: 2687 RVA: 0x0002EBE8 File Offset: 0x0002CDE8
|
||||
public string Oid
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.extnOid;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000158 RID: 344
|
||||
// (get) Token: 0x06000A80 RID: 2688 RVA: 0x0002EBF0 File Offset: 0x0002CDF0
|
||||
// (set) Token: 0x06000A81 RID: 2689 RVA: 0x0002EBF8 File Offset: 0x0002CDF8
|
||||
public bool Critical
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.extnCritical;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.extnCritical = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000159 RID: 345
|
||||
// (get) Token: 0x06000A82 RID: 2690 RVA: 0x0002EC04 File Offset: 0x0002CE04
|
||||
public virtual string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.extnOid;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700015A RID: 346
|
||||
// (get) Token: 0x06000A83 RID: 2691 RVA: 0x0002EC0C File Offset: 0x0002CE0C
|
||||
public ASN1 Value
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.extnValue == null)
|
||||
{
|
||||
this.Encode();
|
||||
}
|
||||
return this.extnValue;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A84 RID: 2692 RVA: 0x0002EC28 File Offset: 0x0002CE28
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
X509Extension x509Extension = obj as X509Extension;
|
||||
if (x509Extension == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (this.extnCritical != x509Extension.extnCritical)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (this.extnOid != x509Extension.extnOid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (this.extnValue.Length != x509Extension.extnValue.Length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < this.extnValue.Length; i++)
|
||||
{
|
||||
if (this.extnValue[i] != x509Extension.extnValue[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x06000A85 RID: 2693 RVA: 0x0002ECD0 File Offset: 0x0002CED0
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
return this.ASN1.GetBytes();
|
||||
}
|
||||
|
||||
// Token: 0x06000A86 RID: 2694 RVA: 0x0002ECE0 File Offset: 0x0002CEE0
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return this.extnOid.GetHashCode();
|
||||
}
|
||||
|
||||
// Token: 0x06000A87 RID: 2695 RVA: 0x0002ECF0 File Offset: 0x0002CEF0
|
||||
private void WriteLine(StringBuilder sb, int n, int pos)
|
||||
{
|
||||
byte[] value = this.extnValue.Value;
|
||||
int num = pos;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
if (i < n)
|
||||
{
|
||||
sb.Append(value[num++].ToString("X2", CultureInfo.InvariantCulture));
|
||||
sb.Append(" ");
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append(" ");
|
||||
}
|
||||
}
|
||||
sb.Append(" ");
|
||||
num = pos;
|
||||
for (int j = 0; j < n; j++)
|
||||
{
|
||||
byte b = value[num++];
|
||||
if (b < 32)
|
||||
{
|
||||
sb.Append(".");
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append(Convert.ToChar(b));
|
||||
}
|
||||
}
|
||||
sb.Append(Environment.NewLine);
|
||||
}
|
||||
|
||||
// Token: 0x06000A88 RID: 2696 RVA: 0x0002EDC0 File Offset: 0x0002CFC0
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
int num = this.extnValue.Length >> 3;
|
||||
int num2 = this.extnValue.Length - (num << 3);
|
||||
int num3 = 0;
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
this.WriteLine(stringBuilder, 8, num3);
|
||||
num3 += 8;
|
||||
}
|
||||
this.WriteLine(stringBuilder, num2, num3);
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
// Token: 0x040002BA RID: 698
|
||||
protected string extnOid;
|
||||
|
||||
// Token: 0x040002BB RID: 699
|
||||
protected bool extnCritical;
|
||||
|
||||
// Token: 0x040002BC RID: 700
|
||||
protected ASN1 extnValue;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,222 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace Mono.Security.X509
|
||||
{
|
||||
// Token: 0x020000C2 RID: 194
|
||||
internal sealed class X509ExtensionCollection : CollectionBase, IEnumerable
|
||||
{
|
||||
// Token: 0x06000A89 RID: 2697 RVA: 0x0002EE28 File Offset: 0x0002D028
|
||||
public X509ExtensionCollection()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000A8A RID: 2698 RVA: 0x0002EE30 File Offset: 0x0002D030
|
||||
public X509ExtensionCollection(ASN1 asn1)
|
||||
: this()
|
||||
{
|
||||
this.readOnly = true;
|
||||
if (asn1 == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (asn1.Tag != 48)
|
||||
{
|
||||
throw new Exception("Invalid extensions format");
|
||||
}
|
||||
for (int i = 0; i < asn1.Count; i++)
|
||||
{
|
||||
X509Extension x509Extension = new X509Extension(asn1[i]);
|
||||
base.InnerList.Add(x509Extension);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A8B RID: 2699 RVA: 0x0002EE9C File Offset: 0x0002D09C
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return base.InnerList.GetEnumerator();
|
||||
}
|
||||
|
||||
// Token: 0x06000A8C RID: 2700 RVA: 0x0002EEAC File Offset: 0x0002D0AC
|
||||
public int Add(X509Extension extension)
|
||||
{
|
||||
if (extension == null)
|
||||
{
|
||||
throw new ArgumentNullException("extension");
|
||||
}
|
||||
if (this.readOnly)
|
||||
{
|
||||
throw new NotSupportedException("Extensions are read only");
|
||||
}
|
||||
return base.InnerList.Add(extension);
|
||||
}
|
||||
|
||||
// Token: 0x06000A8D RID: 2701 RVA: 0x0002EEE4 File Offset: 0x0002D0E4
|
||||
public void AddRange(X509Extension[] extension)
|
||||
{
|
||||
if (extension == null)
|
||||
{
|
||||
throw new ArgumentNullException("extension");
|
||||
}
|
||||
if (this.readOnly)
|
||||
{
|
||||
throw new NotSupportedException("Extensions are read only");
|
||||
}
|
||||
for (int i = 0; i < extension.Length; i++)
|
||||
{
|
||||
base.InnerList.Add(extension[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A8E RID: 2702 RVA: 0x0002EF3C File Offset: 0x0002D13C
|
||||
public void AddRange(X509ExtensionCollection collection)
|
||||
{
|
||||
if (collection == null)
|
||||
{
|
||||
throw new ArgumentNullException("collection");
|
||||
}
|
||||
if (this.readOnly)
|
||||
{
|
||||
throw new NotSupportedException("Extensions are read only");
|
||||
}
|
||||
for (int i = 0; i < collection.InnerList.Count; i++)
|
||||
{
|
||||
base.InnerList.Add(collection[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A8F RID: 2703 RVA: 0x0002EFA0 File Offset: 0x0002D1A0
|
||||
public bool Contains(X509Extension extension)
|
||||
{
|
||||
return this.IndexOf(extension) != -1;
|
||||
}
|
||||
|
||||
// Token: 0x06000A90 RID: 2704 RVA: 0x0002EFB0 File Offset: 0x0002D1B0
|
||||
public bool Contains(string oid)
|
||||
{
|
||||
return this.IndexOf(oid) != -1;
|
||||
}
|
||||
|
||||
// Token: 0x06000A91 RID: 2705 RVA: 0x0002EFC0 File Offset: 0x0002D1C0
|
||||
public void CopyTo(X509Extension[] extensions, int index)
|
||||
{
|
||||
if (extensions == null)
|
||||
{
|
||||
throw new ArgumentNullException("extensions");
|
||||
}
|
||||
base.InnerList.CopyTo(extensions, index);
|
||||
}
|
||||
|
||||
// Token: 0x06000A92 RID: 2706 RVA: 0x0002EFE0 File Offset: 0x0002D1E0
|
||||
public int IndexOf(X509Extension extension)
|
||||
{
|
||||
if (extension == null)
|
||||
{
|
||||
throw new ArgumentNullException("extension");
|
||||
}
|
||||
for (int i = 0; i < base.InnerList.Count; i++)
|
||||
{
|
||||
X509Extension x509Extension = (X509Extension)base.InnerList[i];
|
||||
if (x509Extension.Equals(extension))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Token: 0x06000A93 RID: 2707 RVA: 0x0002F03C File Offset: 0x0002D23C
|
||||
public int IndexOf(string oid)
|
||||
{
|
||||
if (oid == null)
|
||||
{
|
||||
throw new ArgumentNullException("oid");
|
||||
}
|
||||
for (int i = 0; i < base.InnerList.Count; i++)
|
||||
{
|
||||
X509Extension x509Extension = (X509Extension)base.InnerList[i];
|
||||
if (x509Extension.Oid == oid)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Token: 0x06000A94 RID: 2708 RVA: 0x0002F09C File Offset: 0x0002D29C
|
||||
public void Insert(int index, X509Extension extension)
|
||||
{
|
||||
if (extension == null)
|
||||
{
|
||||
throw new ArgumentNullException("extension");
|
||||
}
|
||||
base.InnerList.Insert(index, extension);
|
||||
}
|
||||
|
||||
// Token: 0x06000A95 RID: 2709 RVA: 0x0002F0BC File Offset: 0x0002D2BC
|
||||
public void Remove(X509Extension extension)
|
||||
{
|
||||
if (extension == null)
|
||||
{
|
||||
throw new ArgumentNullException("extension");
|
||||
}
|
||||
base.InnerList.Remove(extension);
|
||||
}
|
||||
|
||||
// Token: 0x06000A96 RID: 2710 RVA: 0x0002F0DC File Offset: 0x0002D2DC
|
||||
public void Remove(string oid)
|
||||
{
|
||||
if (oid == null)
|
||||
{
|
||||
throw new ArgumentNullException("oid");
|
||||
}
|
||||
int num = this.IndexOf(oid);
|
||||
if (num != -1)
|
||||
{
|
||||
base.InnerList.RemoveAt(num);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700015B RID: 347
|
||||
public X509Extension this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return (X509Extension)base.InnerList[index];
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700015C RID: 348
|
||||
public X509Extension this[string oid]
|
||||
{
|
||||
get
|
||||
{
|
||||
int num = this.IndexOf(oid);
|
||||
if (num == -1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (X509Extension)base.InnerList[num];
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A99 RID: 2713 RVA: 0x0002F15C File Offset: 0x0002D35C
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
if (base.InnerList.Count < 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
ASN1 asn = new ASN1(48);
|
||||
for (int i = 0; i < base.InnerList.Count; i++)
|
||||
{
|
||||
X509Extension x509Extension = (X509Extension)base.InnerList[i];
|
||||
asn.Add(x509Extension.ASN1);
|
||||
}
|
||||
return asn.GetBytes();
|
||||
}
|
||||
|
||||
// Token: 0x040002BD RID: 701
|
||||
private bool readOnly;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,315 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Mono.Security.X509.Extensions;
|
||||
|
||||
namespace Mono.Security.X509
|
||||
{
|
||||
// Token: 0x020000C3 RID: 195
|
||||
internal class X509Store
|
||||
{
|
||||
// Token: 0x06000A9A RID: 2714 RVA: 0x0002F1C8 File Offset: 0x0002D3C8
|
||||
internal X509Store(string path, bool crl)
|
||||
{
|
||||
this._storePath = path;
|
||||
this._crl = crl;
|
||||
}
|
||||
|
||||
// Token: 0x1700015D RID: 349
|
||||
// (get) Token: 0x06000A9B RID: 2715 RVA: 0x0002F1E0 File Offset: 0x0002D3E0
|
||||
public X509CertificateCollection Certificates
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._certificates == null)
|
||||
{
|
||||
this._certificates = this.BuildCertificatesCollection(this._storePath);
|
||||
}
|
||||
return this._certificates;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700015E RID: 350
|
||||
// (get) Token: 0x06000A9C RID: 2716 RVA: 0x0002F208 File Offset: 0x0002D408
|
||||
public ArrayList Crls
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!this._crl)
|
||||
{
|
||||
this._crls = new ArrayList();
|
||||
}
|
||||
if (this._crls == null)
|
||||
{
|
||||
this._crls = this.BuildCrlsCollection(this._storePath);
|
||||
}
|
||||
return this._crls;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700015F RID: 351
|
||||
// (get) Token: 0x06000A9D RID: 2717 RVA: 0x0002F244 File Offset: 0x0002D444
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._name == null)
|
||||
{
|
||||
int num = this._storePath.LastIndexOf(Path.DirectorySeparatorChar);
|
||||
this._name = this._storePath.Substring(num + 1);
|
||||
}
|
||||
return this._name;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A9E RID: 2718 RVA: 0x0002F288 File Offset: 0x0002D488
|
||||
public void Clear()
|
||||
{
|
||||
if (this._certificates != null)
|
||||
{
|
||||
this._certificates.Clear();
|
||||
}
|
||||
this._certificates = null;
|
||||
if (this._crls != null)
|
||||
{
|
||||
this._crls.Clear();
|
||||
}
|
||||
this._crls = null;
|
||||
}
|
||||
|
||||
// Token: 0x06000A9F RID: 2719 RVA: 0x0002F2D0 File Offset: 0x0002D4D0
|
||||
public void Import(X509Certificate certificate)
|
||||
{
|
||||
this.CheckStore(this._storePath, true);
|
||||
string text = Path.Combine(this._storePath, this.GetUniqueName(certificate));
|
||||
if (!File.Exists(text))
|
||||
{
|
||||
using (FileStream fileStream = File.Create(text))
|
||||
{
|
||||
byte[] rawData = certificate.RawData;
|
||||
fileStream.Write(rawData, 0, rawData.Length);
|
||||
fileStream.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000AA0 RID: 2720 RVA: 0x0002F358 File Offset: 0x0002D558
|
||||
public void Import(X509Crl crl)
|
||||
{
|
||||
this.CheckStore(this._storePath, true);
|
||||
string text = Path.Combine(this._storePath, this.GetUniqueName(crl));
|
||||
if (!File.Exists(text))
|
||||
{
|
||||
using (FileStream fileStream = File.Create(text))
|
||||
{
|
||||
byte[] rawData = crl.RawData;
|
||||
fileStream.Write(rawData, 0, rawData.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000AA1 RID: 2721 RVA: 0x0002F3D8 File Offset: 0x0002D5D8
|
||||
public void Remove(X509Certificate certificate)
|
||||
{
|
||||
string text = Path.Combine(this._storePath, this.GetUniqueName(certificate));
|
||||
if (File.Exists(text))
|
||||
{
|
||||
File.Delete(text);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000AA2 RID: 2722 RVA: 0x0002F40C File Offset: 0x0002D60C
|
||||
public void Remove(X509Crl crl)
|
||||
{
|
||||
string text = Path.Combine(this._storePath, this.GetUniqueName(crl));
|
||||
if (File.Exists(text))
|
||||
{
|
||||
File.Delete(text);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000AA3 RID: 2723 RVA: 0x0002F440 File Offset: 0x0002D640
|
||||
private string GetUniqueName(X509Certificate certificate)
|
||||
{
|
||||
byte[] array = this.GetUniqueName(certificate.Extensions);
|
||||
string text;
|
||||
if (array == null)
|
||||
{
|
||||
text = "tbp";
|
||||
array = certificate.Hash;
|
||||
}
|
||||
else
|
||||
{
|
||||
text = "ski";
|
||||
}
|
||||
return this.GetUniqueName(text, array, ".cer");
|
||||
}
|
||||
|
||||
// Token: 0x06000AA4 RID: 2724 RVA: 0x0002F488 File Offset: 0x0002D688
|
||||
private string GetUniqueName(X509Crl crl)
|
||||
{
|
||||
byte[] array = this.GetUniqueName(crl.Extensions);
|
||||
string text;
|
||||
if (array == null)
|
||||
{
|
||||
text = "tbp";
|
||||
array = crl.Hash;
|
||||
}
|
||||
else
|
||||
{
|
||||
text = "ski";
|
||||
}
|
||||
return this.GetUniqueName(text, array, ".crl");
|
||||
}
|
||||
|
||||
// Token: 0x06000AA5 RID: 2725 RVA: 0x0002F4D0 File Offset: 0x0002D6D0
|
||||
private byte[] GetUniqueName(X509ExtensionCollection extensions)
|
||||
{
|
||||
X509Extension x509Extension = extensions["2.5.29.14"];
|
||||
if (x509Extension == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
SubjectKeyIdentifierExtension subjectKeyIdentifierExtension = new SubjectKeyIdentifierExtension(x509Extension);
|
||||
return subjectKeyIdentifierExtension.Identifier;
|
||||
}
|
||||
|
||||
// Token: 0x06000AA6 RID: 2726 RVA: 0x0002F500 File Offset: 0x0002D700
|
||||
private string GetUniqueName(string method, byte[] name, string fileExtension)
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder(method);
|
||||
stringBuilder.Append("-");
|
||||
foreach (byte b in name)
|
||||
{
|
||||
stringBuilder.Append(b.ToString("X2", CultureInfo.InvariantCulture));
|
||||
}
|
||||
stringBuilder.Append(fileExtension);
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
// Token: 0x06000AA7 RID: 2727 RVA: 0x0002F560 File Offset: 0x0002D760
|
||||
private byte[] Load(string filename)
|
||||
{
|
||||
byte[] array = null;
|
||||
using (FileStream fileStream = File.OpenRead(filename))
|
||||
{
|
||||
array = new byte[fileStream.Length];
|
||||
fileStream.Read(array, 0, array.Length);
|
||||
fileStream.Close();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x06000AA8 RID: 2728 RVA: 0x0002F5C4 File Offset: 0x0002D7C4
|
||||
private X509Certificate LoadCertificate(string filename)
|
||||
{
|
||||
byte[] array = this.Load(filename);
|
||||
return new X509Certificate(array);
|
||||
}
|
||||
|
||||
// Token: 0x06000AA9 RID: 2729 RVA: 0x0002F5E4 File Offset: 0x0002D7E4
|
||||
private X509Crl LoadCrl(string filename)
|
||||
{
|
||||
byte[] array = this.Load(filename);
|
||||
return new X509Crl(array);
|
||||
}
|
||||
|
||||
// Token: 0x06000AAA RID: 2730 RVA: 0x0002F604 File Offset: 0x0002D804
|
||||
private bool CheckStore(string path, bool throwException)
|
||||
{
|
||||
bool flag;
|
||||
try
|
||||
{
|
||||
if (Directory.Exists(path))
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
flag = Directory.Exists(path);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (throwException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
flag = false;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x06000AAB RID: 2731 RVA: 0x0002F670 File Offset: 0x0002D870
|
||||
private X509CertificateCollection BuildCertificatesCollection(string storeName)
|
||||
{
|
||||
X509CertificateCollection x509CertificateCollection = new X509CertificateCollection();
|
||||
string text = Path.Combine(this._storePath, storeName);
|
||||
if (!this.CheckStore(text, false))
|
||||
{
|
||||
return x509CertificateCollection;
|
||||
}
|
||||
string[] files = Directory.GetFiles(text, "*.cer");
|
||||
if (files != null && files.Length > 0)
|
||||
{
|
||||
foreach (string text2 in files)
|
||||
{
|
||||
try
|
||||
{
|
||||
X509Certificate x509Certificate = this.LoadCertificate(text2);
|
||||
x509CertificateCollection.Add(x509Certificate);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
return x509CertificateCollection;
|
||||
}
|
||||
|
||||
// Token: 0x06000AAC RID: 2732 RVA: 0x0002F718 File Offset: 0x0002D918
|
||||
private ArrayList BuildCrlsCollection(string storeName)
|
||||
{
|
||||
ArrayList arrayList = new ArrayList();
|
||||
string text = Path.Combine(this._storePath, storeName);
|
||||
if (!this.CheckStore(text, false))
|
||||
{
|
||||
return arrayList;
|
||||
}
|
||||
string[] files = Directory.GetFiles(text, "*.crl");
|
||||
if (files != null && files.Length > 0)
|
||||
{
|
||||
foreach (string text2 in files)
|
||||
{
|
||||
try
|
||||
{
|
||||
X509Crl x509Crl = this.LoadCrl(text2);
|
||||
arrayList.Add(x509Crl);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
// Token: 0x040002BE RID: 702
|
||||
private string _storePath;
|
||||
|
||||
// Token: 0x040002BF RID: 703
|
||||
private X509CertificateCollection _certificates;
|
||||
|
||||
// Token: 0x040002C0 RID: 704
|
||||
private ArrayList _crls;
|
||||
|
||||
// Token: 0x040002C1 RID: 705
|
||||
private bool _crl;
|
||||
|
||||
// Token: 0x040002C2 RID: 706
|
||||
private string _name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
|
||||
namespace Mono.Security.X509
|
||||
{
|
||||
// Token: 0x020000C4 RID: 196
|
||||
internal sealed class X509StoreManager
|
||||
{
|
||||
// Token: 0x06000AAD RID: 2733 RVA: 0x0002F7C0 File Offset: 0x0002D9C0
|
||||
private X509StoreManager()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x17000160 RID: 352
|
||||
// (get) Token: 0x06000AAE RID: 2734 RVA: 0x0002F7C8 File Offset: 0x0002D9C8
|
||||
public static X509Stores CurrentUser
|
||||
{
|
||||
get
|
||||
{
|
||||
if (X509StoreManager._userStore == null)
|
||||
{
|
||||
string text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), ".mono");
|
||||
text = Path.Combine(text, "certs");
|
||||
X509StoreManager._userStore = new X509Stores(text);
|
||||
}
|
||||
return X509StoreManager._userStore;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000161 RID: 353
|
||||
// (get) Token: 0x06000AAF RID: 2735 RVA: 0x0002F810 File Offset: 0x0002DA10
|
||||
public static X509Stores LocalMachine
|
||||
{
|
||||
get
|
||||
{
|
||||
if (X509StoreManager._machineStore == null)
|
||||
{
|
||||
string text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), ".mono");
|
||||
text = Path.Combine(text, "certs");
|
||||
X509StoreManager._machineStore = new X509Stores(text);
|
||||
}
|
||||
return X509StoreManager._machineStore;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000162 RID: 354
|
||||
// (get) Token: 0x06000AB0 RID: 2736 RVA: 0x0002F858 File Offset: 0x0002DA58
|
||||
public static X509CertificateCollection IntermediateCACertificates
|
||||
{
|
||||
get
|
||||
{
|
||||
X509CertificateCollection x509CertificateCollection = new X509CertificateCollection();
|
||||
x509CertificateCollection.AddRange(X509StoreManager.CurrentUser.IntermediateCA.Certificates);
|
||||
x509CertificateCollection.AddRange(X509StoreManager.LocalMachine.IntermediateCA.Certificates);
|
||||
return x509CertificateCollection;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000163 RID: 355
|
||||
// (get) Token: 0x06000AB1 RID: 2737 RVA: 0x0002F898 File Offset: 0x0002DA98
|
||||
public static ArrayList IntermediateCACrls
|
||||
{
|
||||
get
|
||||
{
|
||||
ArrayList arrayList = new ArrayList();
|
||||
arrayList.AddRange(X509StoreManager.CurrentUser.IntermediateCA.Crls);
|
||||
arrayList.AddRange(X509StoreManager.LocalMachine.IntermediateCA.Crls);
|
||||
return arrayList;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000164 RID: 356
|
||||
// (get) Token: 0x06000AB2 RID: 2738 RVA: 0x0002F8D8 File Offset: 0x0002DAD8
|
||||
public static X509CertificateCollection TrustedRootCertificates
|
||||
{
|
||||
get
|
||||
{
|
||||
X509CertificateCollection x509CertificateCollection = new X509CertificateCollection();
|
||||
x509CertificateCollection.AddRange(X509StoreManager.CurrentUser.TrustedRoot.Certificates);
|
||||
x509CertificateCollection.AddRange(X509StoreManager.LocalMachine.TrustedRoot.Certificates);
|
||||
return x509CertificateCollection;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000165 RID: 357
|
||||
// (get) Token: 0x06000AB3 RID: 2739 RVA: 0x0002F918 File Offset: 0x0002DB18
|
||||
public static ArrayList TrustedRootCACrls
|
||||
{
|
||||
get
|
||||
{
|
||||
ArrayList arrayList = new ArrayList();
|
||||
arrayList.AddRange(X509StoreManager.CurrentUser.TrustedRoot.Crls);
|
||||
arrayList.AddRange(X509StoreManager.LocalMachine.TrustedRoot.Crls);
|
||||
return arrayList;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000166 RID: 358
|
||||
// (get) Token: 0x06000AB4 RID: 2740 RVA: 0x0002F958 File Offset: 0x0002DB58
|
||||
public static X509CertificateCollection UntrustedCertificates
|
||||
{
|
||||
get
|
||||
{
|
||||
X509CertificateCollection x509CertificateCollection = new X509CertificateCollection();
|
||||
x509CertificateCollection.AddRange(X509StoreManager.CurrentUser.Untrusted.Certificates);
|
||||
x509CertificateCollection.AddRange(X509StoreManager.LocalMachine.Untrusted.Certificates);
|
||||
return x509CertificateCollection;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x040002C3 RID: 707
|
||||
private static X509Stores _userStore;
|
||||
|
||||
// Token: 0x040002C4 RID: 708
|
||||
private static X509Stores _machineStore;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Mono.Security.X509
|
||||
{
|
||||
// Token: 0x020000C5 RID: 197
|
||||
internal class X509Stores
|
||||
{
|
||||
// Token: 0x06000AB5 RID: 2741 RVA: 0x0002F998 File Offset: 0x0002DB98
|
||||
internal X509Stores(string path)
|
||||
{
|
||||
this._storePath = path;
|
||||
}
|
||||
|
||||
// Token: 0x17000167 RID: 359
|
||||
// (get) Token: 0x06000AB6 RID: 2742 RVA: 0x0002F9A8 File Offset: 0x0002DBA8
|
||||
public X509Store Personal
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._personal == null)
|
||||
{
|
||||
string text = Path.Combine(this._storePath, "My");
|
||||
this._personal = new X509Store(text, false);
|
||||
}
|
||||
return this._personal;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000168 RID: 360
|
||||
// (get) Token: 0x06000AB7 RID: 2743 RVA: 0x0002F9E4 File Offset: 0x0002DBE4
|
||||
public X509Store OtherPeople
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._other == null)
|
||||
{
|
||||
string text = Path.Combine(this._storePath, "AddressBook");
|
||||
this._other = new X509Store(text, false);
|
||||
}
|
||||
return this._other;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000169 RID: 361
|
||||
// (get) Token: 0x06000AB8 RID: 2744 RVA: 0x0002FA20 File Offset: 0x0002DC20
|
||||
public X509Store IntermediateCA
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._intermediate == null)
|
||||
{
|
||||
string text = Path.Combine(this._storePath, "CA");
|
||||
this._intermediate = new X509Store(text, true);
|
||||
}
|
||||
return this._intermediate;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700016A RID: 362
|
||||
// (get) Token: 0x06000AB9 RID: 2745 RVA: 0x0002FA5C File Offset: 0x0002DC5C
|
||||
public X509Store TrustedRoot
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._trusted == null)
|
||||
{
|
||||
string text = Path.Combine(this._storePath, "Trust");
|
||||
this._trusted = new X509Store(text, true);
|
||||
}
|
||||
return this._trusted;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700016B RID: 363
|
||||
// (get) Token: 0x06000ABA RID: 2746 RVA: 0x0002FA98 File Offset: 0x0002DC98
|
||||
public X509Store Untrusted
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._untrusted == null)
|
||||
{
|
||||
string text = Path.Combine(this._storePath, "Disallowed");
|
||||
this._untrusted = new X509Store(text, false);
|
||||
}
|
||||
return this._untrusted;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000ABB RID: 2747 RVA: 0x0002FAD4 File Offset: 0x0002DCD4
|
||||
public void Clear()
|
||||
{
|
||||
if (this._personal != null)
|
||||
{
|
||||
this._personal.Clear();
|
||||
}
|
||||
this._personal = null;
|
||||
if (this._other != null)
|
||||
{
|
||||
this._other.Clear();
|
||||
}
|
||||
this._other = null;
|
||||
if (this._intermediate != null)
|
||||
{
|
||||
this._intermediate.Clear();
|
||||
}
|
||||
this._intermediate = null;
|
||||
if (this._trusted != null)
|
||||
{
|
||||
this._trusted.Clear();
|
||||
}
|
||||
this._trusted = null;
|
||||
if (this._untrusted != null)
|
||||
{
|
||||
this._untrusted.Clear();
|
||||
}
|
||||
this._untrusted = null;
|
||||
}
|
||||
|
||||
// Token: 0x06000ABC RID: 2748 RVA: 0x0002FB74 File Offset: 0x0002DD74
|
||||
public X509Store Open(string storeName, bool create)
|
||||
{
|
||||
if (storeName == null)
|
||||
{
|
||||
throw new ArgumentNullException("storeName");
|
||||
}
|
||||
string text = Path.Combine(this._storePath, storeName);
|
||||
if (!create && !Directory.Exists(text))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new X509Store(text, true);
|
||||
}
|
||||
|
||||
// Token: 0x040002C5 RID: 709
|
||||
private string _storePath;
|
||||
|
||||
// Token: 0x040002C6 RID: 710
|
||||
private X509Store _personal;
|
||||
|
||||
// Token: 0x040002C7 RID: 711
|
||||
private X509Store _other;
|
||||
|
||||
// Token: 0x040002C8 RID: 712
|
||||
private X509Store _intermediate;
|
||||
|
||||
// Token: 0x040002C9 RID: 713
|
||||
private X509Store _trusted;
|
||||
|
||||
// Token: 0x040002CA RID: 714
|
||||
private X509Store _untrusted;
|
||||
|
||||
// Token: 0x020000C6 RID: 198
|
||||
public class Names
|
||||
{
|
||||
// Token: 0x040002CB RID: 715
|
||||
public const string Personal = "My";
|
||||
|
||||
// Token: 0x040002CC RID: 716
|
||||
public const string OtherPeople = "AddressBook";
|
||||
|
||||
// Token: 0x040002CD RID: 717
|
||||
public const string IntermediateCA = "CA";
|
||||
|
||||
// Token: 0x040002CE RID: 718
|
||||
public const string TrustedRoot = "Trust";
|
||||
|
||||
// Token: 0x040002CF RID: 719
|
||||
public const string Untrusted = "Disallowed";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,306 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Mono.Security.X509
|
||||
{
|
||||
// Token: 0x020000C7 RID: 199
|
||||
internal class X520
|
||||
{
|
||||
// Token: 0x020000C8 RID: 200
|
||||
public abstract class AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000ABF RID: 2751 RVA: 0x0002FBCC File Offset: 0x0002DDCC
|
||||
protected AttributeTypeAndValue(string oid, int upperBound)
|
||||
{
|
||||
this.oid = oid;
|
||||
this.upperBound = upperBound;
|
||||
this.encoding = byte.MaxValue;
|
||||
}
|
||||
|
||||
// Token: 0x06000AC0 RID: 2752 RVA: 0x0002FBF0 File Offset: 0x0002DDF0
|
||||
protected AttributeTypeAndValue(string oid, int upperBound, byte encoding)
|
||||
{
|
||||
this.oid = oid;
|
||||
this.upperBound = upperBound;
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
// Token: 0x1700016C RID: 364
|
||||
// (get) Token: 0x06000AC1 RID: 2753 RVA: 0x0002FC10 File Offset: 0x0002DE10
|
||||
// (set) Token: 0x06000AC2 RID: 2754 RVA: 0x0002FC18 File Offset: 0x0002DE18
|
||||
public string Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.attrValue;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this.attrValue != null && this.attrValue.Length > this.upperBound)
|
||||
{
|
||||
string text = Locale.GetText("Value length bigger than upperbound ({0}).");
|
||||
throw new FormatException(string.Format(text, this.upperBound));
|
||||
}
|
||||
this.attrValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700016D RID: 365
|
||||
// (get) Token: 0x06000AC3 RID: 2755 RVA: 0x0002FC70 File Offset: 0x0002DE70
|
||||
public ASN1 ASN1
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.GetASN1();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000AC4 RID: 2756 RVA: 0x0002FC78 File Offset: 0x0002DE78
|
||||
internal ASN1 GetASN1(byte encoding)
|
||||
{
|
||||
byte b = encoding;
|
||||
if (b == 255)
|
||||
{
|
||||
b = this.SelectBestEncoding();
|
||||
}
|
||||
ASN1 asn = new ASN1(48);
|
||||
asn.Add(ASN1Convert.FromOid(this.oid));
|
||||
byte b2 = b;
|
||||
switch (b2)
|
||||
{
|
||||
case 19:
|
||||
asn.Add(new ASN1(19, Encoding.ASCII.GetBytes(this.attrValue)));
|
||||
break;
|
||||
default:
|
||||
if (b2 == 30)
|
||||
{
|
||||
asn.Add(new ASN1(30, Encoding.BigEndianUnicode.GetBytes(this.attrValue)));
|
||||
}
|
||||
break;
|
||||
case 22:
|
||||
asn.Add(new ASN1(22, Encoding.ASCII.GetBytes(this.attrValue)));
|
||||
break;
|
||||
}
|
||||
return asn;
|
||||
}
|
||||
|
||||
// Token: 0x06000AC5 RID: 2757 RVA: 0x0002FD48 File Offset: 0x0002DF48
|
||||
internal ASN1 GetASN1()
|
||||
{
|
||||
return this.GetASN1(this.encoding);
|
||||
}
|
||||
|
||||
// Token: 0x06000AC6 RID: 2758 RVA: 0x0002FD58 File Offset: 0x0002DF58
|
||||
public byte[] GetBytes(byte encoding)
|
||||
{
|
||||
return this.GetASN1(encoding).GetBytes();
|
||||
}
|
||||
|
||||
// Token: 0x06000AC7 RID: 2759 RVA: 0x0002FD68 File Offset: 0x0002DF68
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
return this.GetASN1().GetBytes();
|
||||
}
|
||||
|
||||
// Token: 0x06000AC8 RID: 2760 RVA: 0x0002FD78 File Offset: 0x0002DF78
|
||||
private byte SelectBestEncoding()
|
||||
{
|
||||
foreach (char c in this.attrValue)
|
||||
{
|
||||
char c2 = c;
|
||||
if (c2 == '@' || c2 == '_')
|
||||
{
|
||||
return 30;
|
||||
}
|
||||
if (c > '\u007f')
|
||||
{
|
||||
return 30;
|
||||
}
|
||||
}
|
||||
return 19;
|
||||
}
|
||||
|
||||
// Token: 0x040002D0 RID: 720
|
||||
private string oid;
|
||||
|
||||
// Token: 0x040002D1 RID: 721
|
||||
private string attrValue;
|
||||
|
||||
// Token: 0x040002D2 RID: 722
|
||||
private int upperBound;
|
||||
|
||||
// Token: 0x040002D3 RID: 723
|
||||
private byte encoding;
|
||||
}
|
||||
|
||||
// Token: 0x020000C9 RID: 201
|
||||
public class Name : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000AC9 RID: 2761 RVA: 0x0002FDD8 File Offset: 0x0002DFD8
|
||||
public Name()
|
||||
: base("2.5.4.41", 32768)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000CA RID: 202
|
||||
public class CommonName : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000ACA RID: 2762 RVA: 0x0002FDEC File Offset: 0x0002DFEC
|
||||
public CommonName()
|
||||
: base("2.5.4.3", 64)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000CB RID: 203
|
||||
public class SerialNumber : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000ACB RID: 2763 RVA: 0x0002FDFC File Offset: 0x0002DFFC
|
||||
public SerialNumber()
|
||||
: base("2.5.4.5", 64, 19)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000CC RID: 204
|
||||
public class LocalityName : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000ACC RID: 2764 RVA: 0x0002FE10 File Offset: 0x0002E010
|
||||
public LocalityName()
|
||||
: base("2.5.4.7", 128)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000CD RID: 205
|
||||
public class StateOrProvinceName : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000ACD RID: 2765 RVA: 0x0002FE24 File Offset: 0x0002E024
|
||||
public StateOrProvinceName()
|
||||
: base("2.5.4.8", 128)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000CE RID: 206
|
||||
public class OrganizationName : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000ACE RID: 2766 RVA: 0x0002FE38 File Offset: 0x0002E038
|
||||
public OrganizationName()
|
||||
: base("2.5.4.10", 64)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000CF RID: 207
|
||||
public class OrganizationalUnitName : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000ACF RID: 2767 RVA: 0x0002FE48 File Offset: 0x0002E048
|
||||
public OrganizationalUnitName()
|
||||
: base("2.5.4.11", 64)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000D0 RID: 208
|
||||
public class EmailAddress : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000AD0 RID: 2768 RVA: 0x0002FE58 File Offset: 0x0002E058
|
||||
public EmailAddress()
|
||||
: base("1.2.840.113549.1.9.1", 128, 22)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000D1 RID: 209
|
||||
public class DomainComponent : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000AD1 RID: 2769 RVA: 0x0002FE6C File Offset: 0x0002E06C
|
||||
public DomainComponent()
|
||||
: base("0.9.2342.19200300.100.1.25", int.MaxValue, 22)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000D2 RID: 210
|
||||
public class UserId : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000AD2 RID: 2770 RVA: 0x0002FE80 File Offset: 0x0002E080
|
||||
public UserId()
|
||||
: base("0.9.2342.19200300.100.1.1", 256)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000D3 RID: 211
|
||||
public class Oid : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000AD3 RID: 2771 RVA: 0x0002FE94 File Offset: 0x0002E094
|
||||
public Oid(string oid)
|
||||
: base(oid, int.MaxValue)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000D4 RID: 212
|
||||
public class Title : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000AD4 RID: 2772 RVA: 0x0002FEA4 File Offset: 0x0002E0A4
|
||||
public Title()
|
||||
: base("2.5.4.12", 64)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000D5 RID: 213
|
||||
public class CountryName : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000AD5 RID: 2773 RVA: 0x0002FEB4 File Offset: 0x0002E0B4
|
||||
public CountryName()
|
||||
: base("2.5.4.6", 2, 19)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000D6 RID: 214
|
||||
public class DnQualifier : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000AD6 RID: 2774 RVA: 0x0002FEC4 File Offset: 0x0002E0C4
|
||||
public DnQualifier()
|
||||
: base("2.5.4.46", 2, 19)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000D7 RID: 215
|
||||
public class Surname : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000AD7 RID: 2775 RVA: 0x0002FED4 File Offset: 0x0002E0D4
|
||||
public Surname()
|
||||
: base("2.5.4.4", 32768)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000D8 RID: 216
|
||||
public class GivenName : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000AD8 RID: 2776 RVA: 0x0002FEE8 File Offset: 0x0002E0E8
|
||||
public GivenName()
|
||||
: base("2.5.4.42", 16)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000D9 RID: 217
|
||||
public class Initial : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000AD9 RID: 2777 RVA: 0x0002FEF8 File Offset: 0x0002E0F8
|
||||
public Initial()
|
||||
: base("2.5.4.43", 5)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Xml
|
||||
{
|
||||
// Token: 0x020000EE RID: 238
|
||||
internal class DefaultHandler : SmallXmlParser.IContentHandler
|
||||
{
|
||||
// Token: 0x06000BDC RID: 3036 RVA: 0x00035AB0 File Offset: 0x00033CB0
|
||||
public void OnStartParsing(SmallXmlParser parser)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000BDD RID: 3037 RVA: 0x00035AB4 File Offset: 0x00033CB4
|
||||
public void OnEndParsing(SmallXmlParser parser)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000BDE RID: 3038 RVA: 0x00035AB8 File Offset: 0x00033CB8
|
||||
public void OnStartElement(string name, SmallXmlParser.IAttrList attrs)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000BDF RID: 3039 RVA: 0x00035ABC File Offset: 0x00033CBC
|
||||
public void OnEndElement(string name)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000BE0 RID: 3040 RVA: 0x00035AC0 File Offset: 0x00033CC0
|
||||
public void OnChars(string s)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000BE1 RID: 3041 RVA: 0x00035AC4 File Offset: 0x00033CC4
|
||||
public void OnIgnorableWhitespace(string s)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000BE2 RID: 3042 RVA: 0x00035AC8 File Offset: 0x00033CC8
|
||||
public void OnProcessingInstruction(string name, string text)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Security;
|
||||
|
||||
namespace Mono.Xml
|
||||
{
|
||||
// Token: 0x020000ED RID: 237
|
||||
internal class SecurityParser : SmallXmlParser, SmallXmlParser.IContentHandler
|
||||
{
|
||||
// Token: 0x06000BD1 RID: 3025 RVA: 0x00035998 File Offset: 0x00033B98
|
||||
public SecurityParser()
|
||||
{
|
||||
this.stack = new Stack();
|
||||
}
|
||||
|
||||
// Token: 0x06000BD2 RID: 3026 RVA: 0x000359AC File Offset: 0x00033BAC
|
||||
public void LoadXml(string xml)
|
||||
{
|
||||
this.root = null;
|
||||
this.stack.Clear();
|
||||
base.Parse(new StringReader(xml), this);
|
||||
}
|
||||
|
||||
// Token: 0x06000BD3 RID: 3027 RVA: 0x000359D0 File Offset: 0x00033BD0
|
||||
public SecurityElement ToXml()
|
||||
{
|
||||
return this.root;
|
||||
}
|
||||
|
||||
// Token: 0x06000BD4 RID: 3028 RVA: 0x000359D8 File Offset: 0x00033BD8
|
||||
public void OnStartParsing(SmallXmlParser parser)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000BD5 RID: 3029 RVA: 0x000359DC File Offset: 0x00033BDC
|
||||
public void OnProcessingInstruction(string name, string text)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000BD6 RID: 3030 RVA: 0x000359E0 File Offset: 0x00033BE0
|
||||
public void OnIgnorableWhitespace(string s)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000BD7 RID: 3031 RVA: 0x000359E4 File Offset: 0x00033BE4
|
||||
public void OnStartElement(string name, SmallXmlParser.IAttrList attrs)
|
||||
{
|
||||
SecurityElement securityElement = new SecurityElement(name);
|
||||
if (this.root == null)
|
||||
{
|
||||
this.root = securityElement;
|
||||
this.current = securityElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
SecurityElement securityElement2 = (SecurityElement)this.stack.Peek();
|
||||
securityElement2.AddChild(securityElement);
|
||||
}
|
||||
this.stack.Push(securityElement);
|
||||
this.current = securityElement;
|
||||
int length = attrs.Length;
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
this.current.AddAttribute(attrs.GetName(i), SecurityElement.Escape(attrs.GetValue(i)));
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000BD8 RID: 3032 RVA: 0x00035A78 File Offset: 0x00033C78
|
||||
public void OnEndElement(string name)
|
||||
{
|
||||
this.current = (SecurityElement)this.stack.Pop();
|
||||
}
|
||||
|
||||
// Token: 0x06000BD9 RID: 3033 RVA: 0x00035A90 File Offset: 0x00033C90
|
||||
public void OnChars(string ch)
|
||||
{
|
||||
this.current.Text = SecurityElement.Escape(ch);
|
||||
}
|
||||
|
||||
// Token: 0x06000BDA RID: 3034 RVA: 0x00035AA4 File Offset: 0x00033CA4
|
||||
public void OnEndParsing(SmallXmlParser parser)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0400033F RID: 831
|
||||
private SecurityElement root;
|
||||
|
||||
// Token: 0x04000340 RID: 832
|
||||
private SecurityElement current;
|
||||
|
||||
// Token: 0x04000341 RID: 833
|
||||
private Stack stack;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,781 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Mono.Xml
|
||||
{
|
||||
// Token: 0x020000EF RID: 239
|
||||
internal class SmallXmlParser
|
||||
{
|
||||
// Token: 0x06000BE4 RID: 3044 RVA: 0x00035B24 File Offset: 0x00033D24
|
||||
private Exception Error(string msg)
|
||||
{
|
||||
return new SmallXmlParserException(msg, this.line, this.column);
|
||||
}
|
||||
|
||||
// Token: 0x06000BE5 RID: 3045 RVA: 0x00035B38 File Offset: 0x00033D38
|
||||
private Exception UnexpectedEndError()
|
||||
{
|
||||
string[] array = new string[this.elementNames.Count];
|
||||
this.elementNames.CopyTo(array, 0);
|
||||
return this.Error(string.Format("Unexpected end of stream. Element stack content is {0}", string.Join(",", array)));
|
||||
}
|
||||
|
||||
// Token: 0x06000BE6 RID: 3046 RVA: 0x00035B80 File Offset: 0x00033D80
|
||||
private bool IsNameChar(char c, bool start)
|
||||
{
|
||||
if (c == '-' || c == '.')
|
||||
{
|
||||
return !start;
|
||||
}
|
||||
if (c == ':' || c == '_')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (c > 'Ā')
|
||||
{
|
||||
if (c == 'ۥ' || c == 'ۦ' || c == 'ՙ')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if ('ʻ' <= c && c <= 'ˁ')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
switch (char.GetUnicodeCategory(c))
|
||||
{
|
||||
case UnicodeCategory.UppercaseLetter:
|
||||
case UnicodeCategory.LowercaseLetter:
|
||||
case UnicodeCategory.TitlecaseLetter:
|
||||
case UnicodeCategory.OtherLetter:
|
||||
case UnicodeCategory.LetterNumber:
|
||||
return true;
|
||||
case UnicodeCategory.ModifierLetter:
|
||||
case UnicodeCategory.NonSpacingMark:
|
||||
case UnicodeCategory.SpacingCombiningMark:
|
||||
case UnicodeCategory.EnclosingMark:
|
||||
case UnicodeCategory.DecimalDigitNumber:
|
||||
return !start;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000BE7 RID: 3047 RVA: 0x00035C4C File Offset: 0x00033E4C
|
||||
private bool IsWhitespace(int c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 9:
|
||||
case 10:
|
||||
case 13:
|
||||
break;
|
||||
default:
|
||||
if (c != 32)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x06000BE8 RID: 3048 RVA: 0x00035C88 File Offset: 0x00033E88
|
||||
public void SkipWhitespaces()
|
||||
{
|
||||
this.SkipWhitespaces(false);
|
||||
}
|
||||
|
||||
// Token: 0x06000BE9 RID: 3049 RVA: 0x00035C94 File Offset: 0x00033E94
|
||||
private void HandleWhitespaces()
|
||||
{
|
||||
while (this.IsWhitespace(this.Peek()))
|
||||
{
|
||||
this.buffer.Append((char)this.Read());
|
||||
}
|
||||
if (this.Peek() != 60 && this.Peek() >= 0)
|
||||
{
|
||||
this.isWhitespace = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000BEA RID: 3050 RVA: 0x00035CEC File Offset: 0x00033EEC
|
||||
public void SkipWhitespaces(bool expected)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
int num = this.Peek();
|
||||
switch (num)
|
||||
{
|
||||
case 9:
|
||||
case 10:
|
||||
case 13:
|
||||
break;
|
||||
default:
|
||||
if (num != 32)
|
||||
{
|
||||
goto Block_0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
this.Read();
|
||||
if (expected)
|
||||
{
|
||||
expected = false;
|
||||
}
|
||||
}
|
||||
Block_0:
|
||||
if (expected)
|
||||
{
|
||||
throw this.Error("Whitespace is expected.");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000BEB RID: 3051 RVA: 0x00035D58 File Offset: 0x00033F58
|
||||
private int Peek()
|
||||
{
|
||||
return this.reader.Peek();
|
||||
}
|
||||
|
||||
// Token: 0x06000BEC RID: 3052 RVA: 0x00035D68 File Offset: 0x00033F68
|
||||
private int Read()
|
||||
{
|
||||
int num = this.reader.Read();
|
||||
if (num == 10)
|
||||
{
|
||||
this.resetColumn = true;
|
||||
}
|
||||
if (this.resetColumn)
|
||||
{
|
||||
this.line++;
|
||||
this.resetColumn = false;
|
||||
this.column = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.column++;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x06000BED RID: 3053 RVA: 0x00035DCC File Offset: 0x00033FCC
|
||||
public void Expect(int c)
|
||||
{
|
||||
int num = this.Read();
|
||||
if (num < 0)
|
||||
{
|
||||
throw this.UnexpectedEndError();
|
||||
}
|
||||
if (num != c)
|
||||
{
|
||||
throw this.Error(string.Format("Expected '{0}' but got {1}", (char)c, (char)num));
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000BEE RID: 3054 RVA: 0x00035E14 File Offset: 0x00034014
|
||||
private string ReadUntil(char until, bool handleReferences)
|
||||
{
|
||||
while (this.Peek() >= 0)
|
||||
{
|
||||
char c = (char)this.Read();
|
||||
if (c == until)
|
||||
{
|
||||
string text = this.buffer.ToString();
|
||||
this.buffer.Length = 0;
|
||||
return text;
|
||||
}
|
||||
if (handleReferences && c == '&')
|
||||
{
|
||||
this.ReadReference();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.buffer.Append(c);
|
||||
}
|
||||
}
|
||||
throw this.UnexpectedEndError();
|
||||
}
|
||||
|
||||
// Token: 0x06000BEF RID: 3055 RVA: 0x00035E8C File Offset: 0x0003408C
|
||||
public string ReadName()
|
||||
{
|
||||
int num = 0;
|
||||
if (this.Peek() < 0 || !this.IsNameChar((char)this.Peek(), true))
|
||||
{
|
||||
throw this.Error("XML name start character is expected.");
|
||||
}
|
||||
for (int i = this.Peek(); i >= 0; i = this.Peek())
|
||||
{
|
||||
char c = (char)i;
|
||||
if (!this.IsNameChar(c, false))
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (num == this.nameBuffer.Length)
|
||||
{
|
||||
char[] array = new char[num * 2];
|
||||
Array.Copy(this.nameBuffer, array, num);
|
||||
this.nameBuffer = array;
|
||||
}
|
||||
this.nameBuffer[num++] = c;
|
||||
this.Read();
|
||||
}
|
||||
if (num == 0)
|
||||
{
|
||||
throw this.Error("Valid XML name is expected.");
|
||||
}
|
||||
return new string(this.nameBuffer, 0, num);
|
||||
}
|
||||
|
||||
// Token: 0x06000BF0 RID: 3056 RVA: 0x00035F54 File Offset: 0x00034154
|
||||
public void Parse(TextReader input, SmallXmlParser.IContentHandler handler)
|
||||
{
|
||||
this.reader = input;
|
||||
this.handler = handler;
|
||||
handler.OnStartParsing(this);
|
||||
while (this.Peek() >= 0)
|
||||
{
|
||||
this.ReadContent();
|
||||
}
|
||||
this.HandleBufferedContent();
|
||||
if (this.elementNames.Count > 0)
|
||||
{
|
||||
throw this.Error(string.Format("Insufficient close tag: {0}", this.elementNames.Peek()));
|
||||
}
|
||||
handler.OnEndParsing(this);
|
||||
this.Cleanup();
|
||||
}
|
||||
|
||||
// Token: 0x06000BF1 RID: 3057 RVA: 0x00035FD0 File Offset: 0x000341D0
|
||||
private void Cleanup()
|
||||
{
|
||||
this.line = 1;
|
||||
this.column = 0;
|
||||
this.handler = null;
|
||||
this.reader = null;
|
||||
this.elementNames.Clear();
|
||||
this.xmlSpaces.Clear();
|
||||
this.attributes.Clear();
|
||||
this.buffer.Length = 0;
|
||||
this.xmlSpace = null;
|
||||
this.isWhitespace = false;
|
||||
}
|
||||
|
||||
// Token: 0x06000BF2 RID: 3058 RVA: 0x00036034 File Offset: 0x00034234
|
||||
public void ReadContent()
|
||||
{
|
||||
if (this.IsWhitespace(this.Peek()))
|
||||
{
|
||||
if (this.buffer.Length == 0)
|
||||
{
|
||||
this.isWhitespace = true;
|
||||
}
|
||||
this.HandleWhitespaces();
|
||||
}
|
||||
if (this.Peek() != 60)
|
||||
{
|
||||
this.ReadCharacters();
|
||||
return;
|
||||
}
|
||||
this.Read();
|
||||
int num = this.Peek();
|
||||
if (num != 33)
|
||||
{
|
||||
if (num != 47)
|
||||
{
|
||||
string text;
|
||||
if (num != 63)
|
||||
{
|
||||
this.HandleBufferedContent();
|
||||
text = this.ReadName();
|
||||
while (this.Peek() != 62 && this.Peek() != 47)
|
||||
{
|
||||
this.ReadAttribute(this.attributes);
|
||||
}
|
||||
this.handler.OnStartElement(text, this.attributes);
|
||||
this.attributes.Clear();
|
||||
this.SkipWhitespaces();
|
||||
if (this.Peek() == 47)
|
||||
{
|
||||
this.Read();
|
||||
this.handler.OnEndElement(text);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.elementNames.Push(text);
|
||||
this.xmlSpaces.Push(this.xmlSpace);
|
||||
}
|
||||
this.Expect(62);
|
||||
return;
|
||||
}
|
||||
this.HandleBufferedContent();
|
||||
this.Read();
|
||||
text = this.ReadName();
|
||||
this.SkipWhitespaces();
|
||||
string text2 = string.Empty;
|
||||
if (this.Peek() != 63)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
text2 += this.ReadUntil('?', false);
|
||||
if (this.Peek() == 62)
|
||||
{
|
||||
break;
|
||||
}
|
||||
text2 += "?";
|
||||
}
|
||||
}
|
||||
this.handler.OnProcessingInstruction(text, text2);
|
||||
this.Expect(62);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.HandleBufferedContent();
|
||||
if (this.elementNames.Count == 0)
|
||||
{
|
||||
throw this.UnexpectedEndError();
|
||||
}
|
||||
this.Read();
|
||||
string text = this.ReadName();
|
||||
this.SkipWhitespaces();
|
||||
string text3 = (string)this.elementNames.Pop();
|
||||
this.xmlSpaces.Pop();
|
||||
if (this.xmlSpaces.Count > 0)
|
||||
{
|
||||
this.xmlSpace = (string)this.xmlSpaces.Peek();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.xmlSpace = null;
|
||||
}
|
||||
if (text != text3)
|
||||
{
|
||||
throw this.Error(string.Format("End tag mismatch: expected {0} but found {1}", text3, text));
|
||||
}
|
||||
this.handler.OnEndElement(text);
|
||||
this.Expect(62);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Read();
|
||||
if (this.Peek() == 91)
|
||||
{
|
||||
this.Read();
|
||||
if (this.ReadName() != "CDATA")
|
||||
{
|
||||
throw this.Error("Invalid declaration markup");
|
||||
}
|
||||
this.Expect(91);
|
||||
this.ReadCDATASection();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.Peek() == 45)
|
||||
{
|
||||
this.ReadComment();
|
||||
return;
|
||||
}
|
||||
if (this.ReadName() != "DOCTYPE")
|
||||
{
|
||||
throw this.Error("Invalid declaration markup.");
|
||||
}
|
||||
throw this.Error("This parser does not support document type.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000BF3 RID: 3059 RVA: 0x0003630C File Offset: 0x0003450C
|
||||
private void HandleBufferedContent()
|
||||
{
|
||||
if (this.buffer.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (this.isWhitespace)
|
||||
{
|
||||
this.handler.OnIgnorableWhitespace(this.buffer.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.handler.OnChars(this.buffer.ToString());
|
||||
}
|
||||
this.buffer.Length = 0;
|
||||
this.isWhitespace = false;
|
||||
}
|
||||
|
||||
// Token: 0x06000BF4 RID: 3060 RVA: 0x0003637C File Offset: 0x0003457C
|
||||
private void ReadCharacters()
|
||||
{
|
||||
this.isWhitespace = false;
|
||||
for (;;)
|
||||
{
|
||||
int num = this.Peek();
|
||||
int num2 = num;
|
||||
if (num2 == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (num2 != 38)
|
||||
{
|
||||
if (num2 == 60)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.buffer.Append((char)this.Read());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Read();
|
||||
this.ReadReference();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000BF5 RID: 3061 RVA: 0x000363E8 File Offset: 0x000345E8
|
||||
private void ReadReference()
|
||||
{
|
||||
if (this.Peek() != 35)
|
||||
{
|
||||
string text = this.ReadName();
|
||||
this.Expect(59);
|
||||
string text2 = text;
|
||||
switch (text2)
|
||||
{
|
||||
case "amp":
|
||||
this.buffer.Append('&');
|
||||
return;
|
||||
case "quot":
|
||||
this.buffer.Append('"');
|
||||
return;
|
||||
case "apos":
|
||||
this.buffer.Append('\'');
|
||||
return;
|
||||
case "lt":
|
||||
this.buffer.Append('<');
|
||||
return;
|
||||
case "gt":
|
||||
this.buffer.Append('>');
|
||||
return;
|
||||
}
|
||||
throw this.Error("General non-predefined entity reference is not supported in this parser.");
|
||||
}
|
||||
this.Read();
|
||||
this.ReadCharacterReference();
|
||||
}
|
||||
|
||||
// Token: 0x06000BF6 RID: 3062 RVA: 0x0003651C File Offset: 0x0003471C
|
||||
private int ReadCharacterReference()
|
||||
{
|
||||
int num = 0;
|
||||
if (this.Peek() == 120)
|
||||
{
|
||||
this.Read();
|
||||
for (int i = this.Peek(); i >= 0; i = this.Peek())
|
||||
{
|
||||
if (48 <= i && i <= 57)
|
||||
{
|
||||
num <<= 4 + i - 48;
|
||||
}
|
||||
else if (65 <= i && i <= 70)
|
||||
{
|
||||
num <<= 4 + i - 65 + 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (97 > i || i > 102)
|
||||
{
|
||||
break;
|
||||
}
|
||||
num <<= 4 + i - 97 + 10;
|
||||
}
|
||||
this.Read();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int j = this.Peek(); j >= 0; j = this.Peek())
|
||||
{
|
||||
if (48 > j || j > 57)
|
||||
{
|
||||
break;
|
||||
}
|
||||
num <<= 4 + j - 48;
|
||||
this.Read();
|
||||
}
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x06000BF7 RID: 3063 RVA: 0x0003661C File Offset: 0x0003481C
|
||||
private void ReadAttribute(SmallXmlParser.AttrListImpl a)
|
||||
{
|
||||
this.SkipWhitespaces(true);
|
||||
if (this.Peek() == 47 || this.Peek() == 62)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string text = this.ReadName();
|
||||
this.SkipWhitespaces();
|
||||
this.Expect(61);
|
||||
this.SkipWhitespaces();
|
||||
int num = this.Read();
|
||||
string text2;
|
||||
if (num != 34)
|
||||
{
|
||||
if (num != 39)
|
||||
{
|
||||
throw this.Error("Invalid attribute value markup.");
|
||||
}
|
||||
text2 = this.ReadUntil('\'', true);
|
||||
}
|
||||
else
|
||||
{
|
||||
text2 = this.ReadUntil('"', true);
|
||||
}
|
||||
if (text == "xml:space")
|
||||
{
|
||||
this.xmlSpace = text2;
|
||||
}
|
||||
a.Add(text, text2);
|
||||
}
|
||||
|
||||
// Token: 0x06000BF8 RID: 3064 RVA: 0x000366CC File Offset: 0x000348CC
|
||||
private void ReadCDATASection()
|
||||
{
|
||||
int num = 0;
|
||||
while (this.Peek() >= 0)
|
||||
{
|
||||
char c = (char)this.Read();
|
||||
if (c == ']')
|
||||
{
|
||||
num++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (c == '>' && num > 1)
|
||||
{
|
||||
for (int i = num; i > 2; i--)
|
||||
{
|
||||
this.buffer.Append(']');
|
||||
}
|
||||
return;
|
||||
}
|
||||
for (int j = 0; j < num; j++)
|
||||
{
|
||||
this.buffer.Append(']');
|
||||
}
|
||||
num = 0;
|
||||
this.buffer.Append(c);
|
||||
}
|
||||
}
|
||||
throw this.UnexpectedEndError();
|
||||
}
|
||||
|
||||
// Token: 0x06000BF9 RID: 3065 RVA: 0x00036770 File Offset: 0x00034970
|
||||
private void ReadComment()
|
||||
{
|
||||
this.Expect(45);
|
||||
this.Expect(45);
|
||||
for (;;)
|
||||
{
|
||||
if (this.Read() == 45)
|
||||
{
|
||||
if (this.Read() == 45)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.Read() != 62)
|
||||
{
|
||||
throw this.Error("'--' is not allowed inside comment markup.");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x04000342 RID: 834
|
||||
private SmallXmlParser.IContentHandler handler;
|
||||
|
||||
// Token: 0x04000343 RID: 835
|
||||
private TextReader reader;
|
||||
|
||||
// Token: 0x04000344 RID: 836
|
||||
private Stack elementNames = new Stack();
|
||||
|
||||
// Token: 0x04000345 RID: 837
|
||||
private Stack xmlSpaces = new Stack();
|
||||
|
||||
// Token: 0x04000346 RID: 838
|
||||
private string xmlSpace;
|
||||
|
||||
// Token: 0x04000347 RID: 839
|
||||
private StringBuilder buffer = new StringBuilder(200);
|
||||
|
||||
// Token: 0x04000348 RID: 840
|
||||
private char[] nameBuffer = new char[30];
|
||||
|
||||
// Token: 0x04000349 RID: 841
|
||||
private bool isWhitespace;
|
||||
|
||||
// Token: 0x0400034A RID: 842
|
||||
private SmallXmlParser.AttrListImpl attributes = new SmallXmlParser.AttrListImpl();
|
||||
|
||||
// Token: 0x0400034B RID: 843
|
||||
private int line = 1;
|
||||
|
||||
// Token: 0x0400034C RID: 844
|
||||
private int column;
|
||||
|
||||
// Token: 0x0400034D RID: 845
|
||||
private bool resetColumn;
|
||||
|
||||
// Token: 0x020000F0 RID: 240
|
||||
public interface IContentHandler
|
||||
{
|
||||
// Token: 0x06000BFA RID: 3066
|
||||
void OnStartParsing(SmallXmlParser parser);
|
||||
|
||||
// Token: 0x06000BFB RID: 3067
|
||||
void OnEndParsing(SmallXmlParser parser);
|
||||
|
||||
// Token: 0x06000BFC RID: 3068
|
||||
void OnStartElement(string name, SmallXmlParser.IAttrList attrs);
|
||||
|
||||
// Token: 0x06000BFD RID: 3069
|
||||
void OnEndElement(string name);
|
||||
|
||||
// Token: 0x06000BFE RID: 3070
|
||||
void OnProcessingInstruction(string name, string text);
|
||||
|
||||
// Token: 0x06000BFF RID: 3071
|
||||
void OnChars(string text);
|
||||
|
||||
// Token: 0x06000C00 RID: 3072
|
||||
void OnIgnorableWhitespace(string text);
|
||||
}
|
||||
|
||||
// Token: 0x020000F1 RID: 241
|
||||
public interface IAttrList
|
||||
{
|
||||
// Token: 0x170001B8 RID: 440
|
||||
// (get) Token: 0x06000C01 RID: 3073
|
||||
int Length { get; }
|
||||
|
||||
// Token: 0x170001B9 RID: 441
|
||||
// (get) Token: 0x06000C02 RID: 3074
|
||||
bool IsEmpty { get; }
|
||||
|
||||
// Token: 0x06000C03 RID: 3075
|
||||
string GetName(int i);
|
||||
|
||||
// Token: 0x06000C04 RID: 3076
|
||||
string GetValue(int i);
|
||||
|
||||
// Token: 0x06000C05 RID: 3077
|
||||
string GetValue(string name);
|
||||
|
||||
// Token: 0x170001BA RID: 442
|
||||
// (get) Token: 0x06000C06 RID: 3078
|
||||
string[] Names { get; }
|
||||
|
||||
// Token: 0x170001BB RID: 443
|
||||
// (get) Token: 0x06000C07 RID: 3079
|
||||
string[] Values { get; }
|
||||
}
|
||||
|
||||
// Token: 0x020000F2 RID: 242
|
||||
private class AttrListImpl : SmallXmlParser.IAttrList
|
||||
{
|
||||
// Token: 0x170001BC RID: 444
|
||||
// (get) Token: 0x06000C09 RID: 3081 RVA: 0x000367F4 File Offset: 0x000349F4
|
||||
public int Length
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.attrNames.Count;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001BD RID: 445
|
||||
// (get) Token: 0x06000C0A RID: 3082 RVA: 0x00036804 File Offset: 0x00034A04
|
||||
public bool IsEmpty
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.attrNames.Count == 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000C0B RID: 3083 RVA: 0x00036814 File Offset: 0x00034A14
|
||||
public string GetName(int i)
|
||||
{
|
||||
return (string)this.attrNames[i];
|
||||
}
|
||||
|
||||
// Token: 0x06000C0C RID: 3084 RVA: 0x00036828 File Offset: 0x00034A28
|
||||
public string GetValue(int i)
|
||||
{
|
||||
return (string)this.attrValues[i];
|
||||
}
|
||||
|
||||
// Token: 0x06000C0D RID: 3085 RVA: 0x0003683C File Offset: 0x00034A3C
|
||||
public string GetValue(string name)
|
||||
{
|
||||
for (int i = 0; i < this.attrNames.Count; i++)
|
||||
{
|
||||
if ((string)this.attrNames[i] == name)
|
||||
{
|
||||
return (string)this.attrValues[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x170001BE RID: 446
|
||||
// (get) Token: 0x06000C0E RID: 3086 RVA: 0x00036894 File Offset: 0x00034A94
|
||||
public string[] Names
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string[])this.attrNames.ToArray(typeof(string));
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001BF RID: 447
|
||||
// (get) Token: 0x06000C0F RID: 3087 RVA: 0x000368B0 File Offset: 0x00034AB0
|
||||
public string[] Values
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string[])this.attrValues.ToArray(typeof(string));
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000C10 RID: 3088 RVA: 0x000368CC File Offset: 0x00034ACC
|
||||
internal void Clear()
|
||||
{
|
||||
this.attrNames.Clear();
|
||||
this.attrValues.Clear();
|
||||
}
|
||||
|
||||
// Token: 0x06000C11 RID: 3089 RVA: 0x000368E4 File Offset: 0x00034AE4
|
||||
internal void Add(string name, string value)
|
||||
{
|
||||
this.attrNames.Add(name);
|
||||
this.attrValues.Add(value);
|
||||
}
|
||||
|
||||
// Token: 0x0400034F RID: 847
|
||||
private ArrayList attrNames = new ArrayList();
|
||||
|
||||
// Token: 0x04000350 RID: 848
|
||||
private ArrayList attrValues = new ArrayList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Xml
|
||||
{
|
||||
// Token: 0x020000F3 RID: 243
|
||||
internal class SmallXmlParserException : SystemException
|
||||
{
|
||||
// Token: 0x06000C12 RID: 3090 RVA: 0x00036900 File Offset: 0x00034B00
|
||||
public SmallXmlParserException(string msg, int line, int column)
|
||||
: base(string.Format("{0}. At ({1},{2})", msg, line, column))
|
||||
{
|
||||
this.line = line;
|
||||
this.column = column;
|
||||
}
|
||||
|
||||
// Token: 0x170001C0 RID: 448
|
||||
// (get) Token: 0x06000C13 RID: 3091 RVA: 0x00036930 File Offset: 0x00034B30
|
||||
public int Line
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.line;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001C1 RID: 449
|
||||
// (get) Token: 0x06000C14 RID: 3092 RVA: 0x00036938 File Offset: 0x00034B38
|
||||
public int Column
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.column;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x04000351 RID: 849
|
||||
private int line;
|
||||
|
||||
// Token: 0x04000352 RID: 850
|
||||
private int column;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user