Exemple #1
0
 /// <inheritdoc />
 public override void WriteData(WireWriter writer)
 {
     writer.WriteDomainName(PrimaryName);
     writer.WriteDomainName(Mailbox);
     writer.WriteUInt32(SerialNumber);
     writer.WriteTimeSpan32(Refresh);
     writer.WriteTimeSpan32(Retry);
     writer.WriteTimeSpan32(Expire);
     writer.WriteTimeSpan32(Minimum);
 }
Exemple #2
0
 /// <inheritdoc />
 public override void WriteData(WireWriter writer)
 {
     writer.WriteDomainName(Algorithm);
     writer.WriteDateTime48(TimeSigned);
     writer.WriteTimeSpan16(Fudge);
     writer.WriteUint16LengthPrefixedBytes(MAC);
     writer.WriteUInt16(OriginalMessageId);
     writer.WriteUInt16((ushort)Error);
     writer.WriteUint16LengthPrefixedBytes(OtherData);
 }
Exemple #3
0
 /// <inheritdoc />
 public override void WriteData(WireWriter writer)
 {
     writer.WriteDomainName(Algorithm);
     writer.WriteDateTime32(Inception);
     writer.WriteDateTime32(Expiration);
     writer.WriteUInt16((ushort)Mode);
     writer.WriteUInt16((ushort)Error);
     writer.WriteUint16LengthPrefixedBytes(Key);
     writer.WriteUint16LengthPrefixedBytes(OtherData);
 }
        /// <inheritdoc />
        public override void Write(WireWriter writer)
        {
            writer.WriteDomainName(Name);
            writer.WriteUInt16((ushort)Type);
            writer.WriteUInt16((ushort)Class);
            writer.WriteTimeSpan32(TTL);

            writer.PushLengthPrefixedScope();
            WriteData(writer);
            writer.PopLengthPrefixedScope();
        }
Exemple #5
0
 /// <inheritdoc />
 public override void WriteData(WireWriter writer)
 {
     writer.WriteUInt16((ushort)TypeCovered);
     writer.WriteByte((byte)Algorithm);
     writer.WriteByte(Labels);
     writer.WriteTimeSpan32(OriginalTTL);
     writer.WriteDateTime32(SignatureExpiration);
     writer.WriteDateTime32(SignatureInception);
     writer.WriteUInt16(KeyTag);
     writer.WriteDomainName(SignerName, uncompressed: true);
     writer.WriteBytes(Signature);
 }
Exemple #6
0
        /// <inheritdoc />
        public override void Write(WireWriter writer)
        {
            writer.WriteDomainName(Name);
            writer.WriteUInt16((ushort)Type);

            var classValue = (ushort)Class;

            if (QU)
            {
                classValue = (ushort)(classValue | 0x01 << 15);
            }

            writer.WriteUInt16((ushort)classValue);
        }
Exemple #7
0
        /// <summary>
        ///   Creates a new instance of the <see cref="DSRecord"/> class
        ///   from the specified <see cref="DNSKEYRecord"/>.
        /// </summary>
        /// <param name="key">
        ///   The dns key to use.
        /// </param>
        /// <param name="force">
        ///   If <b>true</b>, key usage checks are ignored.
        /// </param>
        /// <exception cref="ArgumentException">
        ///   Both <see cref="DNSKEYFlags.ZoneKey"/> and <see cref="DNSKEYFlags.SecureEntryPoint"/>
        ///   must be set.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///   The <see cref="ResourceRecord.Name"/> of the <paramref name="key"/> is missing.
        /// </exception>
        public DSRecord(DNSKEYRecord key, bool force = false)
            : this()
        {
            // Check the key.
            if (!force)
            {
                if ((key.Flags & DNSKEYFlags.ZoneKey) == DNSKEYFlags.None)
                {
                    throw new ArgumentException("ZoneKey must be set.", "key");
                }
                if ((key.Flags & DNSKEYFlags.SecureEntryPoint) == DNSKEYFlags.None)
                {
                    throw new ArgumentException("SecureEntryPoint must be set.", "key");
                }
            }

            byte[] digest;
            using (var ms = new MemoryStream())
                using (var hasher = DigestRegistry.Create(key.Algorithm))
                {
                    var writer = new WireWriter(ms)
                    {
                        CanonicalForm = true
                    };
                    writer.WriteDomainName(key.Name);
                    key.WriteData(writer);
                    ms.Position = 0;
                    digest      = hasher.ComputeHash(ms);
                }
            Algorithm     = key.Algorithm;
            Class         = key.Class;
            KeyTag        = key.KeyTag();
            Name          = key.Name;
            TTL           = key.TTL;
            Digest        = digest;
            HashAlgorithm = DigestType.Sha1;
        }
Exemple #8
0
 /// <inheritdoc />
 public override void WriteData(WireWriter writer)
 {
     writer.WriteDomainName(NextOwnerName, uncompressed: true);
     writer.WriteBitmap(Types.Select(t => (ushort)t));
 }