Beispiel #1
0
 public unsafe static SecurityStatus SafeQueryContextAttributes(
     ref SafeCtxtHandle context,
     out SecPkgContextStreamSizes streamSizes)
 {
     fixed(void *buffer = &streamSizes)
     return(SafeQueryContextAttributes(ref context, UlAttribute.SecpkgAttrStreamSizes, buffer));
 }
Beispiel #2
0
 public unsafe static void QueryContextAttributes(
     ref SafeCtxtHandle context,
     out SecPkgContextStreamSizes streamSizes)
 {
     fixed(void *buffer = &streamSizes)
     QueryContextAttributes(ref context, UlAttribute.SecpkgAttrStreamSizes, buffer);
 }
Beispiel #3
0
        public unsafe static void EncryptMessage(
            ref SafeCtxtHandle context,
            ref SecBufferDescEx message,
            uint messageSeqNo,
            void *pfQop)
        {
            try
            {
                message.Pin();

                int error = Secur32Dll.EncryptMessage(
                    ref context._Handle,
                    pfQop,
                    ref message._SecBufferDesc,
                    messageSeqNo);

                if (error != 0)
                {
                    throw new SspiException(error, @"EncryptMessage");
                }
            }
            finally
            {
                message.Free();
            }
        }
Beispiel #4
0
        public unsafe static SecurityStatus SafeDecryptMessage(
            ref SafeCtxtHandle context,
            ref SecBufferDescEx message,
            uint messageSeqNo,
            void *pfQop)
        {
            try
            {
                message.Pin();

                int error = Secur32Dll.DecryptMessage(
                    ref context._Handle,
                    ref message._SecBufferDesc,
                    messageSeqNo,
                    pfQop);

                return(Convert(error));
            }
            catch
            {
                return(SecurityStatus.SecEUnknowError);
            }
            finally
            {
                message.Free();
            }
        }
Beispiel #5
0
        public unsafe static void QueryContextAttributes(
            ref SafeCtxtHandle context,
            UlAttribute attribute,
            void *buffer)
        {
            int error = Secur32Dll.QueryContextAttributesA(
                ref context._Handle,
                (uint)attribute,
                buffer);

            if (error != 0)
            {
                throw new SspiException(error, @"QueryContextAttributesA");
            }
        }
Beispiel #6
0
        public static unsafe SecurityStatus SafeAcceptSecurityContext(
            ref SafeCredHandle credential,
            ref SafeCtxtHandle context,
            ref SecBufferDescEx input,
            int contextReq,
            TargetDataRep targetDataRep,
            ref SafeCtxtHandle newContext,
            ref SecBufferDescEx output,
            out int contextAttr,
            out long timeStamp)
        {
            try
            {
                input.Pin();
                output.Pin();

                fixed(void *fixedContext = &context._Handle)
                {
                    int error = Secur32Dll.AcceptSecurityContext(
                        ref credential._Handle,
                        (context.IsInvalid) ? null : fixedContext,
                        ref input._SecBufferDesc,
                        contextReq,
                        (int)targetDataRep,
                        ref newContext._Handle,
                        ref output._SecBufferDesc,
                        out contextAttr,
                        out timeStamp);

                    return(Convert(error));
                }
            }
            catch
            {
                contextAttr = 0;
                timeStamp   = 0;
                return(SecurityStatus.SecEUnknowError);
            }
            finally
            {
                input.Free();
                output.Free();
            }
        }
Beispiel #7
0
        public unsafe static SecurityStatus SafeQueryContextAttributes(
            ref SafeCtxtHandle context,
            UlAttribute attribute,
            void *buffer)
        {
            try
            {
                int error = Secur32Dll.QueryContextAttributesA(
                    ref context._Handle,
                    (uint)attribute,
                    buffer);

                return(Convert(error));
            }
            catch
            {
                return(SecurityStatus.SecEUnknowError);
            }
        }