Exemple #1
0
        internal static CountedOctetString Decode(KeytabDecodeBuffer buffer)
        {
            CountedOctetString octStr = new CountedOctetString();

            octStr.Length = buffer.DecodeUInt16();
            octStr.Data   = buffer.DecodeByteArray(octStr.Length);
            return(octStr);
        }
Exemple #2
0
        public static KeyBlock Decode(KeytabDecodeBuffer buffer)
        {
            KeyBlock keyBlock = new KeyBlock();

            keyBlock.type = buffer.DecodeUInt16();
            keyBlock.Data = CountedOctetString.Decode(buffer);
            return(keyBlock);
        }
Exemple #3
0
        public static Keytab Decode(byte[] buffer)
        {
            List <KeytabEntry> entryList    = new List <KeytabEntry>();
            KeytabDecodeBuffer decodeBuffer = new KeytabDecodeBuffer(buffer);
            Keytab             keytab       = new Keytab();

            keytab.FormatVersion = decodeBuffer.DecodeUInt16();  //0x502, or 0x501
            keytab.entries       = new KeytabEntry[1];
            while (!decodeBuffer.EOS)
            {
                entryList.Add(KeytabEntry.Decode(decodeBuffer, keytab.FormatVersion));
            }
            keytab.entries = new KeytabEntry[entryList.Count];
            for (int i = 0; i < entryList.Count; i++)
            {
                keytab.entries[i] = entryList[i];
            }
            return(keytab);
        }
Exemple #4
0
        /// <summary>
        /// Reference: http://www.gnu.org/software/shishi/manual/html_node/The-Keytab-Binary-File-Format.html
        /// </summary>
        public static KeytabEntry Decode(KeytabDecodeBuffer buffer, ushort formatVersion)
        {
            KeytabEntry entry = new KeytabEntry();

            entry.Size       = buffer.DecodeInt32();
            buffer.EntrySize = entry.Size;

            //* sub 1 if version 0x501 *
            entry.NumComponents = buffer.DecodeUInt16();
            if (formatVersion == 0x501)
            {
                entry.NumComponents--;
            }
            entry.Realm      = CountedOctetString.Decode(buffer);
            entry.Components = new CountedOctetString[entry.NumComponents];
            for (int i = 0; i < entry.NumComponents; i++)
            {
                entry.Components[i] = CountedOctetString.Decode(buffer);
            }

            // not present if version 0x501
            if (formatVersion != 0x501)
            {
                entry.NameType = buffer.DecodeUInt32();
            }
            entry.TimeStamp = buffer.DecodeUInt32();
            entry.Vno8      = buffer.DecodeByte();
            entry.Key       = KeyBlock.Decode(buffer);
            if (buffer.EntrySize >= 4)
            {
                entry.Vno = buffer.DecodeUInt32();
            }
            if (buffer.EntrySize > 0)
            {
                buffer.MoveIndexToNext();
            }
            return(entry);
        }
        /// <summary>
        /// Reference: http://www.gnu.org/software/shishi/manual/html_node/The-Keytab-Binary-File-Format.html
        /// </summary>
        public static KeytabEntry Decode(KeytabDecodeBuffer buffer, ushort formatVersion)
        {
            KeytabEntry entry = new KeytabEntry();
            entry.Size = buffer.DecodeInt32();
            buffer.EntrySize = entry.Size;

            //* sub 1 if version 0x501 *
            entry.NumComponents = buffer.DecodeUInt16();
            if (formatVersion == 0x501)
            {
                entry.NumComponents--;
            }
            entry.Realm = CountedOctetString.Decode(buffer);
            entry.Components = new CountedOctetString[entry.NumComponents];
            for (int i = 0; i < entry.NumComponents; i++)
            {
                entry.Components[i] = CountedOctetString.Decode(buffer);
            }

            // not present if version 0x501
            if (formatVersion != 0x501)
            {
                entry.NameType = buffer.DecodeUInt32();
            }
            entry.TimeStamp = buffer.DecodeUInt32();
            entry.Vno8 = buffer.DecodeByte();
            entry.Key = KeyBlock.Decode(buffer);
            if (buffer.EntrySize >= 4)
            {
                entry.Vno = buffer.DecodeUInt32();
            }
            if (buffer.EntrySize > 0)
            {
                buffer.MoveIndexToNext();
            }
            return entry;
        }
 public static Keytab Decode(byte[] buffer)
 {
     List<KeytabEntry> entryList = new List<KeytabEntry>();
     KeytabDecodeBuffer decodeBuffer = new KeytabDecodeBuffer(buffer);
     Keytab keytab = new Keytab();
     keytab.FormatVersion = decodeBuffer.DecodeUInt16();  //0x502, or 0x501
     keytab.entries = new KeytabEntry[1];
     while (!decodeBuffer.EOS)
     {
         entryList.Add(KeytabEntry.Decode(decodeBuffer, keytab.FormatVersion));
     }
     keytab.entries = new KeytabEntry[entryList.Count];
     for (int i = 0; i < entryList.Count; i++)
     {
         keytab.entries[i] = entryList[i];
     }
     return keytab;
 }
 public static KeyBlock Decode(KeytabDecodeBuffer buffer)
 {
     KeyBlock keyBlock = new KeyBlock();
     keyBlock.type = buffer.DecodeUInt16();
     keyBlock.Data = CountedOctetString.Decode(buffer);
     return keyBlock;
 }
 internal static CountedOctetString Decode(KeytabDecodeBuffer buffer)
 {
     CountedOctetString octStr = new CountedOctetString();
     octStr.Length = buffer.DecodeUInt16();
     octStr.Data = buffer.DecodeByteArray(octStr.Length);
     return octStr;
 }