/// <inheritdoc /> public override void ReadData(WireReader reader, int length) { var end = reader.Position + length; HashAlgorithm = (DigestType)reader.ReadByte(); Flags = (NSEC3Flags)reader.ReadByte(); Iterations = reader.ReadUInt16(); Salt = reader.ReadByteLengthPrefixedBytes(); NextHashedOwnerName = reader.ReadByteLengthPrefixedBytes(); while (reader.Position < end) { Types.AddRange(reader.ReadBitmap().Select(t => (DnsType)t)); } }
/// <inheritdoc /> public override void ReadData(WireReader reader, int length) { var end = reader.Position + length; HashAlgorithm = (DigestType)reader.ReadByte(); Flags = reader.ReadByte(); Iterations = reader.ReadUInt16(); Salt = reader.ReadByteLengthPrefixedBytes(); }
public void Roundtrip() { var someBytes = new byte[] { 1, 2, 3 }; var someDate = new DateTime(1997, 1, 21, 3, 4, 5, DateTimeKind.Utc); var ms = new MemoryStream(); var writer = new WireWriter(ms); writer.WriteDomainName("emanon.org"); writer.WriteString("alpha"); writer.WriteTimeSpan32(TimeSpan.FromHours(3)); writer.WriteUInt16(ushort.MaxValue); writer.WriteUInt32(uint.MaxValue); writer.WriteUInt48(0XFFFFFFFFFFFFul); writer.WriteBytes(someBytes); writer.WriteByteLengthPrefixedBytes(someBytes); writer.WriteByteLengthPrefixedBytes(null); writer.WriteIPAddress(IPAddress.Parse("127.0.0.1")); writer.WriteIPAddress(IPAddress.Parse("2406:e001:13c7:1:7173:ef8:852f:25cb")); writer.WriteDateTime32(someDate); writer.WriteDateTime48(someDate); ms.Position = 0; var reader = new WireReader(ms); Assert.AreEqual("emanon.org", reader.ReadDomainName()); Assert.AreEqual("alpha", reader.ReadString()); Assert.AreEqual(TimeSpan.FromHours(3), reader.ReadTimeSpan32()); Assert.AreEqual(ushort.MaxValue, reader.ReadUInt16()); Assert.AreEqual(uint.MaxValue, reader.ReadUInt32()); Assert.AreEqual(0XFFFFFFFFFFFFul, reader.ReadUInt48()); CollectionAssert.AreEqual(someBytes, reader.ReadBytes(3)); CollectionAssert.AreEqual(someBytes, reader.ReadByteLengthPrefixedBytes()); CollectionAssert.AreEqual(new byte[0], reader.ReadByteLengthPrefixedBytes()); Assert.AreEqual(IPAddress.Parse("127.0.0.1"), reader.ReadIPAddress()); Assert.AreEqual(IPAddress.Parse("2406:e001:13c7:1:7173:ef8:852f:25cb"), reader.ReadIPAddress(16)); Assert.AreEqual(someDate, reader.ReadDateTime32()); Assert.AreEqual(someDate, reader.ReadDateTime48()); }