Ejemplo n.º 1
0
        internal override DnsResourceData CreateInstance(DataSegment data)
        {
            if (data.Length < ConstantPartLength)
            {
                return(null);
            }

            bool                      authenticationProhibited  = data.ReadBool(Offset.AuthenticationProhibited, Mask.AuthenticationProhibited);
            bool                      confidentialityProhibited = data.ReadBool(Offset.ConfidentialityProhibited, Mask.ConfidentialityProhibited);
            bool                      experimental     = data.ReadBool(Offset.Experimental, Mask.Experimental);
            bool                      isFlagsExtension = data.ReadBool(Offset.IsFlagsExtension, Mask.IsFlagsExtension);
            bool                      userAssociated   = data.ReadBool(Offset.UserAssociated, Mask.UserAssociated);
            bool                      ipSec            = data.ReadBool(Offset.IpSec, Mask.IpSec);
            bool                      email            = data.ReadBool(Offset.Email, Mask.Email);
            DnsKeyNameType            nameType         = (DnsKeyNameType)(data[Offset.NameType] & Mask.NameType);
            DnsKeySignatoryAttributes signatory        = (DnsKeySignatoryAttributes)(data[Offset.Signatory] & Mask.Signatory);
            DnsKeyProtocol            protocol         = (DnsKeyProtocol)data[Offset.Protocol];
            DnsAlgorithm              algorithm        = (DnsAlgorithm)data[Offset.Algorithm];
            ushort?                   flagsExtension   = (isFlagsExtension ? ((ushort?)data.ReadUShort(Offset.FlagsExtension, Endianity.Big)) : null);
            int         publicKeyOffset = Offset.FlagsExtension + (isFlagsExtension ? sizeof(ushort) : 0);
            DataSegment publicKey       = data.Subsegment(publicKeyOffset, data.Length - publicKeyOffset);

            return(new DnsResourceDataKey(authenticationProhibited, confidentialityProhibited, experimental, userAssociated, ipSec, email, nameType, signatory,
                                          protocol, algorithm, flagsExtension, publicKey));
        }
Ejemplo n.º 2
0
 public DnsResourceDataKey(bool authenticationProhibited, bool confidentialityProhibited, bool experimental, bool userAssociated, bool ipSec,
                           bool email, DnsKeyNameType nameType, DnsKeySignatoryAttributes signatory, DnsKeyProtocol protocol, DnsAlgorithm algorithm,
                           ushort?flagsExtension, DataSegment publicKey)
 {
     AuthenticationProhibited  = authenticationProhibited;
     ConfidentialityProhibited = confidentialityProhibited;
     Experimental   = experimental;
     UserAssociated = userAssociated;
     IpSec          = ipSec;
     Email          = email;
     FlagsExtension = flagsExtension;
     NameType       = nameType;
     Signatory      = signatory;
     Protocol       = protocol;
     Algorithm      = algorithm;
     PublicKey      = publicKey;
 }
        internal override DnsResourceData CreateInstance(DataSegment data)
        {
            if (data.Length < 4)
            {
                return((DnsResourceData)null);
            }
            bool                      authenticationProhibited  = data.ReadBool(0, (byte)sbyte.MinValue);
            bool                      confidentialityProhibited = data.ReadBool(0, (byte)64);
            bool                      experimental   = data.ReadBool(0, (byte)32);
            bool                      flag           = data.ReadBool(0, (byte)16);
            bool                      userAssociated = data.ReadBool(0, (byte)4);
            bool                      ipSec          = data.ReadBool(1, (byte)sbyte.MinValue);
            bool                      email          = data.ReadBool(1, (byte)64);
            DnsKeyNameType            nameType       = (DnsKeyNameType)((uint)data[0] & 3U);
            DnsKeySignatoryAttributes signatory      = (DnsKeySignatoryAttributes)((uint)data[1] & 15U);
            DnsKeyProtocol            protocol       = (DnsKeyProtocol)data[2];
            DnsAlgorithm              algorithm      = (DnsAlgorithm)data[3];
            ushort?                   flagsExtension = flag ? new ushort?(data.ReadUShort(4, Endianity.Big)) : new ushort?();
            int         offset    = 4 + (flag ? 2 : 0);
            DataSegment publicKey = data.Subsegment(offset, data.Length - offset);

            return((DnsResourceData) new DnsResourceDataKey(authenticationProhibited, confidentialityProhibited, experimental, userAssociated, ipSec, email, nameType, signatory, protocol, algorithm, flagsExtension, publicKey));
        }