/// <summary>
        /// Decode the specified PAC_TYPE buffer into an instance of PacInfoBuffer,
        /// according to specified PAC_INFO_BUFFER native structure.
        /// </summary>
        /// <param name="nativePacInfoBuffer">The specified PAC_INFO_BUFFER native structure.</param>
        /// <param name="buffer">The specified PAC_TYPE buffer.</param>
        /// <returns>The decoded instance of PacInfoBuffer.</returns>
        static internal PacInfoBuffer DecodeBuffer(PAC_INFO_BUFFER nativePacInfoBuffer, byte[] buffer)
        {
            PacInfoBuffer pacInfoBuffer = CreatePacInfoBuffer(nativePacInfoBuffer.ulType);

            pacInfoBuffer.DecodeBuffer(
                buffer,
                (int)nativePacInfoBuffer.Offset,
                (int)nativePacInfoBuffer.cbBufferSize);

            return(pacInfoBuffer);
        }
示例#2
0
        /// <summary>
        /// Construct an instance of current class by decoding specified bytes.
        /// </summary>
        /// <param name="buffer">The specified bytes.</param>
        internal PacType(byte[] buffer)
        {
            NativePacType  = PacUtility.MemoryToObject <PACTYPE>(buffer);
            pacInfoBuffers = new PacInfoBuffer[NativePacType.Buffers.Length];

            for (int i = 0; i < NativePacType.Buffers.Length; ++i)
            {
                if (NativePacType.Buffers[i].cbBufferSize > 0)
                {
                    PacInfoBuffers[i] = PacInfoBuffer.DecodeBuffer(
                        NativePacType.Buffers[i],
                        buffer);
                }
                else
                {
                    PacInfoBuffers[i] = null;
                }
            }
        }
 /// <summary>
 /// In constructor, initialize the member PacInfoBuffer array.
 /// </summary>
 /// <param name="serverSignatureType">The specified
 /// Server Signature Type.</param>
 /// <param name="kdcSignatureType">The specified
 /// KDC Signature Type.</param>
 /// <param name="buffers">PacInfoBuffers not including signatures.</param>
 private void InitializePacInfoBuffers(
     PAC_SIGNATURE_DATA_SignatureType_Values serverSignatureType,
     PAC_SIGNATURE_DATA_SignatureType_Values kdcSignatureType,
     PacInfoBuffer[] buffers)
 {
     // allocate 2 more buffers for server signature and KDC signature.
     pacInfoBuffers = new PacInfoBuffer[buffers.Length + 2];
     for (int i = 0; i < buffers.Length; i++)
     {
         pacInfoBuffers[i] = buffers[i];
     }
     // construct a n empty server signature
     PacServerSignature serverSign = new PacServerSignature();
     serverSign.NativePacSignatureData.SignatureType = serverSignatureType;
     serverSign.NativePacSignatureData.Signature = new byte[0];
     pacInfoBuffers[pacInfoBuffers.Length - 2] = serverSign;
     // construct a n empty KDC signature
     PacKdcSignature kdcSign = new PacKdcSignature();
     kdcSign.NativePacSignatureData.SignatureType = kdcSignatureType;
     kdcSign.NativePacSignatureData.Signature = new byte[0];
     pacInfoBuffers[pacInfoBuffers.Length - 1] = kdcSign;
 }