protected internal override void EncodeRecordData(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames) { DnsMessageBase.EncodeUShort(messageData, ref currentPosition, Flags); messageData[currentPosition++] = Protocol; messageData[currentPosition++] = (byte)Algorithm; DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, PublicKey); }
protected internal override void EncodeRecordData(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames) { messageData[currentPosition++] = (byte)CertificateUsage; messageData[currentPosition++] = (byte)Selector; messageData[currentPosition++] = (byte)MatchingType; DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, CertificateAssociation); }
protected internal override void EncodeRecordData(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames) { foreach (AddressPrefix addressPrefix in Prefixes) { DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)addressPrefix.AddressFamily); messageData[currentPosition++] = addressPrefix.Prefix; // no increment of position pointer, just set 1 bit if (addressPrefix.IsNegated) { messageData[currentPosition] = 128; } byte[] addressData = addressPrefix.Address.GetNetworkAddress(addressPrefix.Prefix).GetAddressBytes(); int length = addressData.Length; for (; length > 0; length--) { if (addressData[length - 1] != 0) { break; } } messageData[currentPosition++] |= (byte)length; DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, addressData, length); } }
protected internal override void EncodeRecordData(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames) { DnsMessageBase.EncodeUShort(messageData, ref currentPosition, KeyTag); messageData[currentPosition++] = (byte)Algorithm; messageData[currentPosition++] = (byte)DigestType; DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, Digest); }
internal byte[] GetNSec3Hash(NSec3HashAlgorithm algorithm, int iterations, byte[] salt) { IDigest digest; switch (algorithm) { case NSec3HashAlgorithm.Sha1: digest = new Sha1Digest(); break; default: throw new NotSupportedException(); } byte[] buffer = new byte[Math.Max(MaximumRecordDataLength + 1, digest.GetDigestSize()) + salt.Length]; int length = 0; DnsMessageBase.EncodeDomainName(buffer, 0, ref length, this, null, true); for (int i = 0; i <= iterations; i++) { DnsMessageBase.EncodeByteArray(buffer, ref length, salt); digest.BlockUpdate(buffer, 0, length); digest.DoFinal(buffer, 0); length = digest.GetDigestSize(); } byte[] res = new byte[length]; Buffer.BlockCopy(buffer, 0, res, 0, length); return(res); }
protected internal override void EncodeRecordData(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames) { messageData[currentPosition++] = (byte)HashAlgorithm; messageData[currentPosition++] = Flags; DnsMessageBase.EncodeUShort(messageData, ref currentPosition, Iterations); messageData[currentPosition++] = (byte)Salt.Length; DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, Salt); }
protected override void EncodePublicKey(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames) { DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)Prime.Length); DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, Prime); DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)Generator.Length); DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, Generator); DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)PublicValue.Length); DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, PublicValue); }
internal override void EncodeData(Span <byte> messageData, ref int currentPosition) { DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)(Family == AddressFamily.InterNetwork ? 1 : 2)); messageData[currentPosition++] = SourceNetmask; messageData[currentPosition++] = ScopeNetmask; byte[] data = Address.GetAddressBytes(); DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, data, GetAddressLength()); }
internal override void EncodeData(Span <byte> messageData, ref int currentPosition) { messageData[currentPosition++] = Version; messageData[currentPosition++] = Sequence; DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, PrimaryMacAddress.GetAddressBytes()); if (WakeupMacAddress != null) { DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, WakeupMacAddress.GetAddressBytes()); } DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, Password); }
private void EncodeRecordData(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames, byte[] mac) { DnsMessageBase.EncodeDomainName(messageData, offset, ref currentPosition, TSigAlgorithmHelper.GetDomainName(Algorithm), false, domainNames); EncodeDateTime(messageData, ref currentPosition, TimeSigned); DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)Fudge.TotalSeconds); DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)mac.Length); DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, mac); DnsMessageBase.EncodeUShort(messageData, ref currentPosition, OriginalID); DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)Error); DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)OtherData.Length); DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, OtherData); }
protected internal override void EncodeRecordData(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames) { messageData[currentPosition++] = (byte)Hit.Length; messageData[currentPosition++] = (byte)Algorithm; DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)PublicKey.Length); DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, Hit); DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, PublicKey); foreach (string server in RendezvousServers) { DnsMessageBase.EncodeDomainName(messageData, offset, ref currentPosition, server, false, domainNames); } }
protected internal override void EncodeRecordData(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames) { DnsMessageBase.EncodeDomainName(messageData, offset, ref currentPosition, TSigAlgorithmHelper.GetDomainName(Algorithm), false, domainNames); EncodeDateTime(messageData, ref currentPosition, Inception); EncodeDateTime(messageData, ref currentPosition, Expiration); DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)Mode); DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)Error); DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)Key.Length); DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, Key); DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)OtherData.Length); DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, OtherData); }
protected internal override void EncodeRecordData(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames) { DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)TypeCovered); messageData[currentPosition++] = (byte)Algorithm; messageData[currentPosition++] = Labels; DnsMessageBase.EncodeInt(messageData, ref currentPosition, OriginalTimeToLive); EncodeDateTime(messageData, ref currentPosition, SignatureExpiration); EncodeDateTime(messageData, ref currentPosition, SignatureInception); DnsMessageBase.EncodeUShort(messageData, ref currentPosition, KeyTag); DnsMessageBase.EncodeDomainName(messageData, offset, ref currentPosition, SignersName, false, null); DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, Signature); }
protected internal override void EncodeRecordData(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames) { DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, Address.GetAddressBytes()); messageData[currentPosition++] = (byte)Protocol; foreach (ushort port in Ports) { int octetPosition = port / 8 + currentPosition; int bitPos = port % 8; byte octet = messageData[octetPosition]; octet |= (byte)(1 << Math.Abs(bitPos - 7)); messageData[octetPosition] = octet; } currentPosition += Ports.Max() / 8 + 1; }
internal static void EncodeTypeBitmap(byte[] messageData, ref int currentPosition, List <RecordType> types) { int windowEnd = 255; byte[] windowData = new byte[32]; int windowLength = 0; foreach (ushort type in types.Select(t => (ushort)t)) { if (type > windowEnd) { if (windowLength > 0) { messageData[currentPosition++] = (byte)(windowEnd / 256); messageData[currentPosition++] = (byte)windowLength; DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, windowData, windowLength); } windowEnd = (type / 256 + 1) * 256 - 1; windowLength = 0; } int typeLower = type % 256; int octetPos = typeLower / 8; int bitPos = typeLower % 8; while (windowLength <= octetPos) { windowData[windowLength] = 0; windowLength++; } byte octet = windowData[octetPos]; octet |= (byte)(1 << Math.Abs(bitPos - 7)); windowData[octetPos] = octet; } if (windowLength > 0) { messageData[currentPosition++] = (byte)(windowEnd / 256); messageData[currentPosition++] = (byte)windowLength; DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, windowData, windowLength); } }
protected internal override void EncodeRecordData(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames) { messageData[currentPosition++] = Precedence; messageData[currentPosition++] = (byte)GatewayType; messageData[currentPosition++] = (byte)Algorithm; switch (GatewayType) { case IpSecGatewayType.IpV4: case IpSecGatewayType.IpV6: byte[] addressBuffer = IPAddress.Parse(Gateway).GetAddressBytes(); DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, addressBuffer); break; case IpSecGatewayType.Domain: DnsMessageBase.EncodeDomainName(messageData, offset, ref currentPosition, Gateway, false, domainNames); break; } DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, PublicKey); }
protected override void EncodePublicKey(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames) { DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, PublicKey); }
protected internal override void EncodeRecordData(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames) { DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, Address.GetAddressBytes()); }
internal override void EncodeData(Span <byte> messageData, ref int currentPosition) { DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, ClientCookie); DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, ServerCookie); }
internal override void EncodeData(Span <byte> messageData, ref int currentPosition) { DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, Payload); }
internal override void EncodeData(byte[] messageData, ref int currentPosition) { DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, Data); }