Code
·
41 lines
·
977 bytes
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/*
*/
using MailSharp.DNS.Records;
namespace MailSharp.DNS.Records;
public record RecordDNSKEY : DnsRecord
{
public ushort Flags { get; init; }
public byte Protocol { get; init; }
public byte Algorithm { get; init; }
public byte[] PublicKey{ get; init; }
public bool ZoneKey => (Flags & 0x0100) == 0x0100;
public bool SecureEntryPoint => (Flags & 0x0001) == 0x0001;
public RecordDNSKEY(RecordReader rr) : base(rr)
{
// re-read length
ushort rdLength= rr.ReadUInt16(-2);
Flags = rr.ReadUInt16();
Protocol = rr.ReadByte();
Algorithm = rr.ReadByte();
PublicKey = rr.ReadBytes(rdLength - 4);
}
public override string ToString()
{
// Flags altijd als decimaal getal (geen 256/257 truc meer sinds RFC 8624 sectie 3.1)
// Protocol altijd 3
// Public key altijd Base64 (geen spaties, geen newlines)
string base64 = PublicKey.Length == 0
? "."
: Convert.ToBase64String(PublicKey);
return $"{Flags} {Protocol} {Algorithm} {base64}";
}
}