initial commit

This commit is contained in:
i2p
2026-08-27 10:55:23 -06:00
commit d03dc0bce1
356 changed files with 18535 additions and 0 deletions
+66
View File
@@ -0,0 +1,66 @@
using System;
using System.IO;
namespace Intelix.Helper;
public static class ParseKeyBlob
{
public static BlobParsedData Parse(byte[] blobData)
{
using MemoryStream memoryStream = new MemoryStream(blobData);
using BinaryReader binaryReader = new BinaryReader(memoryStream);
uint count = binaryReader.ReadUInt32();
binaryReader.ReadBytes((int)count);
uint num = binaryReader.ReadUInt32();
_ = memoryStream.Position;
byte[] array = null;
byte[] iv = null;
byte[] ciphertext = null;
byte[] tag = null;
if (num == 32)
{
array = binaryReader.ReadBytes(32);
return new BlobParsedData
{
Flag = 32,
Iv = iv,
Ciphertext = ciphertext,
Tag = tag,
EncryptedAesKey = array
};
}
byte b = binaryReader.ReadByte();
switch (b)
{
case 1:
case 2:
iv = binaryReader.ReadBytes(12);
ciphertext = binaryReader.ReadBytes(32);
tag = binaryReader.ReadBytes(16);
return new BlobParsedData
{
Flag = b,
Iv = iv,
Ciphertext = ciphertext,
Tag = tag,
EncryptedAesKey = null
};
case 3:
case 35:
array = binaryReader.ReadBytes(32);
iv = binaryReader.ReadBytes(12);
ciphertext = binaryReader.ReadBytes(32);
tag = binaryReader.ReadBytes(16);
return new BlobParsedData
{
Flag = b,
Iv = iv,
Ciphertext = ciphertext,
Tag = tag,
EncryptedAesKey = array
};
default:
throw new Exception();
}
}
}