-
Notifications
You must be signed in to change notification settings - Fork 7
/
Asn1Serializer.cs
55 lines (47 loc) · 1.99 KB
/
Asn1Serializer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Collections.Generic;
using System.Security.Cryptography.Asn1;
using System.Text;
namespace zivillian.ldap.Asn1.Generated
{
public static class Asn1Serializer
{
public static void Deserialize(byte[] data)
{
Asn1LdapMessage.Decode(data, AsnEncodingRules.BER);
}
public static void DeserializeDeleteRequest(ReadOnlyMemory<byte> data)
{
var reader = new AsnReader(data.Slice(9), AsnEncodingRules.BER);
reader.ReadOctetString(new Asn1Tag(TagClass.Application, 10));
reader.ThrowIfNotEmpty();
}
public static void DeserializeBindRequest(ReadOnlyMemory<byte> data)
{
Asn1BindRequest.Decode(new Asn1Tag(TagClass.Application, 0), data.Slice(9), AsnEncodingRules.BER);
}
public static void DeserializeUnbindRequest(ReadOnlyMemory<byte> data)
{
var reader = new AsnReader(data.Slice(9), AsnEncodingRules.BER);
reader.ReadNull(new Asn1Tag(TagClass.Application, 2));
reader.ThrowIfNotEmpty();
}
public static void DeserializeBindResponse(ReadOnlyMemory<byte> data)
{
Asn1BindResponse.Decode(new Asn1Tag(TagClass.Application, 1), data.Slice(5), AsnEncodingRules.BER);
}
public static void DeserializeSearchRequest(ReadOnlyMemory<byte> data)
{
Asn1SearchRequest.Decode(new Asn1Tag(TagClass.Application, 3), data.Slice(9), AsnEncodingRules.BER);
}
public static void DeserializeSearchRequestPartial(ReadOnlyMemory<byte> data)
{
var reader = new AsnReader(data.Slice(9), AsnEncodingRules.BER);
Asn1SearchRequest.Decode(reader, new Asn1Tag(TagClass.Application, 3), out _);
}
public static void DeserializeSearchResEntry(ReadOnlyMemory<byte> data)
{
Asn1SearchResultEntry.Decode(new Asn1Tag(TagClass.Application, 4), data.Slice(7), AsnEncodingRules.BER);
}
}
}