internal DnsResourceDataNextDomainSecure3Base(DnsSecNSec3HashAlgorithm hashAlgorithm, DnsSecNSec3Flags flags, ushort iterations, DataSegment salt)
        {
            if (salt.Length > byte.MaxValue)
                throw new ArgumentOutOfRangeException("salt", salt.Length, string.Format(CultureInfo.InvariantCulture, "Cannot bigger than {0}.", byte.MaxValue));

            HashAlgorithm = hashAlgorithm;
            Flags = flags;
            Iterations = iterations;
            Salt = salt;
        }
        internal static bool TryReadParameters(DataSegment data, out DnsSecNSec3HashAlgorithm hashAlgorithm, out DnsSecNSec3Flags flags, out ushort iterations, out DataSegment salt)
        {
            if (data.Length < ConstantPartLength)
            {
                hashAlgorithm = DnsSecNSec3HashAlgorithm.Sha1;
                flags = DnsSecNSec3Flags.None;
                iterations = 0;
                salt = null;
                return false;
            }

            hashAlgorithm = (DnsSecNSec3HashAlgorithm)data[Offset.HashAlgorithm];
            flags = (DnsSecNSec3Flags)data[Offset.Flags];
            iterations = data.ReadUShort(Offset.Iterations, Endianity.Big);
            
            int saltLength = data[Offset.SaltLength];
            if (data.Length - Offset.Salt < saltLength)
            {
                salt = null;
                return false;
            }
            salt = data.Subsegment(Offset.Salt, saltLength);
            return true;
        }