private DnsResourceDataNextDomainSecure3(DnsSecNSec3HashAlgorithm hashAlgorithm, DnsSecNSec3Flags flags, ushort iterations, DataSegment salt,
                                                 DataSegment nextHashedOwnerName, DnsTypeBitmaps typeBitmaps)
            : base(hashAlgorithm, flags, iterations, salt)
        {
            if (nextHashedOwnerName.Length > byte.MaxValue)
            {
                throw new ArgumentOutOfRangeException("nextHashedOwnerName", nextHashedOwnerName.Length,
                                                      string.Format(CultureInfo.InvariantCulture, "Cannot bigger than {0}.", byte.MaxValue));
            }

            NextHashedOwnerName = nextHashedOwnerName;
            _typeBitmaps        = typeBitmaps;
        }
        internal override DnsResourceData CreateInstance(DnsDatagram dns, int offsetInDns, int length)
        {
            DnsDomainName nextDomainName;
            int           nextDomainNameLength;

            if (!DnsDomainName.TryParse(dns, offsetInDns, length, out nextDomainName, out nextDomainNameLength))
            {
                return(null);
            }
            offsetInDns += nextDomainNameLength;
            length      -= nextDomainNameLength;

            DnsTypeBitmaps typeBitmaps = DnsTypeBitmaps.CreateInstance(dns.Buffer, dns.StartOffset + offsetInDns, length);

            if (typeBitmaps == null)
            {
                return(null);
            }

            return(new DnsResourceDataNextDomainSecure(nextDomainName, typeBitmaps));
        }
        internal override DnsResourceData CreateInstance(DataSegment data)
        {
            DnsSecNSec3HashAlgorithm hashAlgorithm;
            DnsSecNSec3Flags         flags;
            ushort      iterations;
            DataSegment salt;

            if (!TryReadParameters(data, out hashAlgorithm, out flags, out iterations, out salt))
            {
                return(null);
            }

            int nextHashedOwnerNameLengthOffset = GetParametersLength(salt.Length);

            if (data.Length - nextHashedOwnerNameLengthOffset < sizeof(byte))
            {
                return(null);
            }
            int nextHashedOwnerNameOffset = nextHashedOwnerNameLengthOffset + sizeof(byte);
            int nextHashedOwnerNameLength = data[nextHashedOwnerNameLengthOffset];

            if (data.Length - nextHashedOwnerNameOffset < nextHashedOwnerNameLength)
            {
                return(null);
            }
            DataSegment nextHashedOwnerName = data.Subsegment(nextHashedOwnerNameOffset, nextHashedOwnerNameLength);

            int            typeBitmapsOffset = nextHashedOwnerNameOffset + nextHashedOwnerNameLength;
            DnsTypeBitmaps typeBitmaps       = DnsTypeBitmaps.CreateInstance(data.Buffer, data.StartOffset + typeBitmapsOffset, data.Length - typeBitmapsOffset);

            if (typeBitmaps == null)
            {
                return(null);
            }

            return(new DnsResourceDataNextDomainSecure3(hashAlgorithm, flags, iterations, salt, nextHashedOwnerName, typeBitmaps));
        }
 private DnsResourceDataNextDomainSecure(DnsDomainName nextDomainName, DnsTypeBitmaps typeBitmaps)
 {
     NextDomainName = nextDomainName;
     _typeBitmaps   = typeBitmaps;
 }