Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 5
0
 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);
 }
Ejemplo n.º 6
0
 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);
 }
Ejemplo n.º 7
0
        internal override void EncodeData(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());
        }
Ejemplo n.º 8
0
 internal override void EncodeData(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);
 }
Ejemplo n.º 9
0
 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);
 }
Ejemplo n.º 10
0
 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);
     }
 }
Ejemplo n.º 11
0
 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);
 }
Ejemplo n.º 12
0
 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);
 }
Ejemplo n.º 13
0
        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;
        }
Ejemplo n.º 14
0
        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);
            }
        }
Ejemplo n.º 15
0
        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);
        }
Ejemplo n.º 16
0
 protected internal override void EncodeRecordData(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames)
 {
     DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, RecordData);
 }
Ejemplo n.º 17
0
 internal override void EncodeData(byte[] messageData, ref int currentPosition)
 {
     DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, Payload);
 }
Ejemplo n.º 18
0
 protected override void EncodePublicKey(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames)
 {
     DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, PublicKey);
 }