Exemple #1
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();
            }
        }
Exemple #2
0
        public unsafe static SecurityStatus SafeVerifySignature(
            SafeCtxtHandle context,
            ref SecBufferDescEx message,
            int sequence)
        {
            try
            {
                message.Pin();

                int qop;

                var error = Secur32Dll.VerifySignature(
                    ref context.Handle,
                    ref message.SecBufferDesc,
                    sequence,
                    out qop);

                return(Convert(error));
            }
            catch
            {
                return(SecurityStatus.SEC_E_UNKNOW_ERROR);
            }
            finally
            {
                message.Free();
            }
        }
Exemple #3
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.SEC_E_UNKNOW_ERROR);
            }
            finally
            {
                message.Free();
            }
        }
Exemple #4
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.SEC_E_UNKNOW_ERROR);
            }
            finally
            {
                input.Free();
                output.Free();
            }
        }
Exemple #5
0
        public static SecurityStatus SafeMakeSignature(SafeCtxtHandle context, ref SecBufferDescEx message, int sequence)
        {
            SecurityStatus result;

            try
            {
                message.Pin();
                int error = Secur32Dll.MakeSignature(ref context.Handle, 0, ref message.SecBufferDesc, sequence);
                result = Sspi.Convert(error);
            }
            catch
            {
                result = (SecurityStatus)4294967295u;
            }
            finally
            {
                message.Free();
            }
            return(result);
        }
Exemple #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)
        {
            int  contextAttr;
            long timeStamp;

            return(SafeAcceptSecurityContext(
                       ref credential,
                       ref context,
                       ref input,
                       contextReq,
                       targetDataRep,
                       ref newContext,
                       ref output,
                       out contextAttr,
                       out timeStamp));
        }
Exemple #7
0
        public unsafe static 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)
        {
            SecurityStatus result;

            try
            {
                input.Pin();
                output.Pin();
                try
                {
                    fixed(IntPtr *ptr = (IntPtr *)(&context.Handle))
                    {
                        int error = Secur32Dll.AcceptSecurityContext(ref credential.Handle, context.IsInvalid ? null : ((void *)ptr), ref input.SecBufferDesc, contextReq, (int)targetDataRep, ref newContext.Handle, ref output.SecBufferDesc, out contextAttr, out timeStamp);

                        result = Sspi.Convert(error);
                    }
                }
                finally
                {
                    IntPtr *ptr = null;
                }
            }
            catch
            {
                contextAttr = 0;
                timeStamp   = 0L;
                result      = (SecurityStatus)4294967295u;
            }
            finally
            {
                input.Free();
                output.Free();
            }
            return(result);
        }
Exemple #8
0
        public static SecurityStatus SafeAcceptSecurityContext(ref SafeCredHandle credential, ref SafeCtxtHandle context, ref SecBufferDescEx input, int contextReq, TargetDataRep targetDataRep, ref SafeCtxtHandle newContext, ref SecBufferDescEx output)
        {
            int  num;
            long num2;

            return(Sspi.SafeAcceptSecurityContext(ref credential, ref context, ref input, contextReq, targetDataRep, ref newContext, ref output, out num, out num2));
        }
Exemple #9
0
        public unsafe static SecurityStatus SafeDecryptMessage(ref SafeCtxtHandle context, ref SecBufferDescEx message, uint MessageSeqNo, void *pfQOP)
        {
            SecurityStatus result;

            try
            {
                message.Pin();
                int error = Secur32Dll.DecryptMessage(ref context.Handle, ref message.SecBufferDesc, MessageSeqNo, pfQOP);
                result = Sspi.Convert(error);
            }
            catch
            {
                result = (SecurityStatus)4294967295u;
            }
            finally
            {
                message.Free();
            }
            return(result);
        }