mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-02-10 13:52:16 +00:00
32 lines
993 B
C#
32 lines
993 B
C#
using System.Collections.Generic;
|
|
|
|
namespace BinaryObjectScanner.ASN1
|
|
{
|
|
/// <summary>
|
|
/// ASN.1 Parser
|
|
/// </summary>
|
|
public static class AbstractSyntaxNotationOne
|
|
{
|
|
/// <summary>
|
|
/// Parse a byte array into a DER-encoded ASN.1 structure
|
|
/// </summary>
|
|
/// <param name="data">Byte array representing the data</param>
|
|
/// <param name="pointer">Current pointer into the data</param>
|
|
/// <returns></returns>
|
|
public static List<TypeLengthValue> Parse(byte[] data, int pointer)
|
|
{
|
|
// Create the output list to return
|
|
var topLevelValues = new List<TypeLengthValue>();
|
|
|
|
// Loop through the data and return all top-level values
|
|
while (pointer < data.Length)
|
|
{
|
|
var topLevelValue = new TypeLengthValue(data, ref pointer);
|
|
topLevelValues.Add(topLevelValue);
|
|
}
|
|
|
|
return topLevelValues;
|
|
}
|
|
}
|
|
}
|