当前位置: 首页>>代码示例>>C#>>正文


C# SafeDeleteContext.DangerousRelease方法代码示例

本文整理汇总了C#中SafeDeleteContext.DangerousRelease方法的典型用法代码示例。如果您正苦于以下问题:C# SafeDeleteContext.DangerousRelease方法的具体用法?C# SafeDeleteContext.DangerousRelease怎么用?C# SafeDeleteContext.DangerousRelease使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SafeDeleteContext的用法示例。


在下文中一共展示了SafeDeleteContext.DangerousRelease方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EncryptMessage

        public int EncryptMessage(SafeDeleteContext context, Interop.Secur32.SecurityBufferDescriptor inputOutput, uint sequenceNumber)
        {
            int status = (int)Interop.SecurityStatus.InvalidHandle;
            bool ignore = false;

            context.DangerousAddRef(ref ignore);
            status = Interop.Secur32.EncryptMessage(ref context._handle, 0, inputOutput, sequenceNumber);
            context.DangerousRelease();

            return status;
        }
开发者ID:nnyamhon,项目名称:corefx,代码行数:11,代码来源:SSPIAuthType.cs

示例2: EncryptMessage

 public int EncryptMessage(SafeDeleteContext context, Interop.SspiCli.SecBufferDesc inputOutput, uint sequenceNumber)
 {
     try
     {
         bool ignore = false;
         context.DangerousAddRef(ref ignore);
         return Interop.SspiCli.EncryptMessage(ref context._handle, 0, inputOutput, sequenceNumber);
     }
     finally
     {
         context.DangerousRelease();
     }
 }
开发者ID:naamunds,项目名称:corefx,代码行数:13,代码来源:SSPISecureChannelType.cs

示例3: DecryptMessage

        public unsafe int DecryptMessage(SafeDeleteContext context, Interop.SspiCli.SecurityBufferDescriptor inputOutput, uint sequenceNumber)
        {
            int status = (int)Interop.SecurityStatus.InvalidHandle;
            uint qop = 0;

            try
            {
                bool ignore = false;
                context.DangerousAddRef(ref ignore);
                status = Interop.SspiCli.DecryptMessage(ref context._handle, inputOutput, sequenceNumber, &qop);
            }
            finally
            {
                context.DangerousRelease();
            }


            if (status == 0 && qop == Interop.SspiCli.SECQOP_WRAP_NO_ENCRYPT)
            {
                if (GlobalLog.IsEnabled)
                {
                    GlobalLog.Assert("SspiCli.DecryptMessage", "Expected qop = 0, returned value = " + qop.ToString("x", CultureInfo.InvariantCulture));
                }
                throw new InvalidOperationException(SR.net_auth_message_not_encrypted);
            }


            return status;
        }
开发者ID:GeneralRookie,项目名称:corefx,代码行数:29,代码来源:SSPIAuthType.cs

示例4: GetSecurityContextToken

        private static int GetSecurityContextToken(SafeDeleteContext phContext, out SecurityContextTokenHandle safeHandle)
        {
            safeHandle = null;

            try
            {
                bool ignore = false;
                phContext.DangerousAddRef(ref ignore);
                return Interop.SspiCli.QuerySecurityContextToken(ref phContext._handle, out safeHandle);
            }
            finally
            {
                phContext.DangerousRelease();
            }
        }
开发者ID:GeneralRookie,项目名称:corefx,代码行数:15,代码来源:SSPIAuthType.cs

示例5: VerifySignature

        public unsafe int VerifySignature(SafeDeleteContext context, Interop.SspiCli.SecurityBufferDescriptor inputOutput, uint sequenceNumber)
        {
            try
            {
                bool ignore = false;
                uint qop = 0;

                context.DangerousAddRef(ref ignore);
                return Interop.SspiCli.DecryptMessage(ref context._handle, inputOutput, sequenceNumber, &qop);
            }
            finally
            {
                context.DangerousRelease();
            }
        }
开发者ID:GeneralRookie,项目名称:corefx,代码行数:15,代码来源:SSPIAuthType.cs

示例6: MakeSignature

        public int MakeSignature(SafeDeleteContext context, Interop.SspiCli.SecurityBufferDescriptor inputOutput, uint sequenceNumber)
        {
            try
            {
                bool ignore = false;

                context.DangerousAddRef(ref ignore);

                return Interop.SspiCli.EncryptMessage(ref context._handle, Interop.SspiCli.SECQOP_WRAP_NO_ENCRYPT, inputOutput, sequenceNumber);
            }
            finally
            {
                context.DangerousRelease();
            }
        }
开发者ID:GeneralRookie,项目名称:corefx,代码行数:15,代码来源:SSPIAuthType.cs

示例7: DecryptMessage

        private unsafe int DecryptMessage(SafeDeleteContext context, Interop.Secur32.SecurityBufferDescriptor inputOutput,
            uint sequenceNumber)
        {
            int status = (int)Interop.SecurityStatus.InvalidHandle;

            try
            {
                bool ignore = false;
                context.DangerousAddRef(ref ignore);
                status = Interop.Secur32.DecryptMessage(ref context._handle, inputOutput, sequenceNumber, null);
                return status;
            }
            finally
            {
                context.DangerousRelease();
            }
        }
开发者ID:rainersigwald,项目名称:corefx,代码行数:17,代码来源:SSPISecureChannelType.cs

示例8: QueryContextConnectionInfo

 public int QueryContextConnectionInfo(SafeDeleteContext securityContext, out SslConnectionInfo connectionInfo)
 {
     bool gotReference = false;
     connectionInfo = null;
     try
     {
         securityContext.DangerousAddRef(ref gotReference);
         Interop.libssl.SSL_CIPHER cipher = Interop.OpenSsl.GetConnectionInfo(securityContext.DangerousGetHandle());
         connectionInfo =  new SslConnectionInfo(cipher);
         return 0;
     }
     catch
     {
         return -1;
     }
     finally
     {
         if (gotReference)
         {
             securityContext.DangerousRelease();
         }
     }
 }
开发者ID:TAdityaAnirudh,项目名称:corefx,代码行数:23,代码来源:SSPISecureChannelType.cs

示例9: EncryptDecryptHelper

 private SecurityStatus EncryptDecryptHelper(SafeDeleteContext securityContext, byte[] buffer, int offset, int size, int headerSize, int trailerSize, bool encrypt, out int resultSize)
 {
     bool gotReference = false;
     GCHandle inputHandle = new GCHandle();
     resultSize = 0;
     try
     {
         securityContext.DangerousAddRef(ref gotReference);
         inputHandle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
         IntPtr inputPtr = Marshal.UnsafeAddrOfPinnedArrayElement(buffer, 0);
         if (encrypt)
         {
             resultSize = Interop.OpenSsl.Encrypt(securityContext.DangerousGetHandle(), inputPtr, offset, size, buffer.Length);
         }
         else
         {
             resultSize = Interop.OpenSsl.Decrypt(securityContext.DangerousGetHandle(), inputPtr, size);
         }
         return ((size == 0) || (resultSize > 0)) ? SecurityStatus.OK : SecurityStatus.ContextExpired;
     }
     catch
     {
         return SecurityStatus.InternalError;
     }
     finally
     {
         if (inputHandle.IsAllocated)
         {
             inputHandle.Free();
         }
         if (gotReference)
         {
             securityContext.DangerousRelease();
         }
     }
 }
开发者ID:TAdityaAnirudh,项目名称:corefx,代码行数:36,代码来源:SSPISecureChannelType.cs

示例10: QueryContextRemoteCertificate

 public int QueryContextRemoteCertificate(SafeDeleteContext securityContext, out SafeFreeCertContext remoteCertContext)
 {
     bool gotReference = false;
     remoteCertContext = null;
     try
     {
         securityContext.DangerousAddRef(ref gotReference);
         IntPtr certPtr = Interop.OpenSsl.GetPeerCertificate(securityContext.DangerousGetHandle());
         remoteCertContext = new SafeFreeCertContext(certPtr);
         return 0;
     }
     catch
     {
         return -1;
     }
     finally
     {
         if (gotReference)
         {
             securityContext.DangerousRelease();
         }
     }
 }
开发者ID:TAdityaAnirudh,项目名称:corefx,代码行数:23,代码来源:SSPISecureChannelType.cs

示例11: GetSecurityContextToken

        private static int GetSecurityContextToken(SafeDeleteContext phContext, out SecurityContextTokenHandle safeHandle)
        {
            int status = (int)Interop.SecurityStatus.InvalidHandle;
            safeHandle = null;

            try
            {
                bool ignore = false;
                phContext.DangerousAddRef(ref ignore);
                status = Interop.Secur32.QuerySecurityContextToken(ref phContext._handle, out safeHandle);
            }
            finally
            {
                phContext.DangerousRelease();
            }

            return status;
        }
开发者ID:nnyamhon,项目名称:corefx,代码行数:18,代码来源:SSPIAuthType.cs

示例12: DecryptMessage

 public unsafe int DecryptMessage(SafeDeleteContext context, Interop.Secur32.SecurityBufferDescriptor inputOutput,
     uint sequenceNumber)
 {
     try
     {
         bool ignore = false;
         context.DangerousAddRef(ref ignore);
         return Interop.Secur32.DecryptMessage(ref context._handle, inputOutput, sequenceNumber, null);
     }
     finally
     {
         context.DangerousRelease();
     }
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:14,代码来源:SSPISecureChannelType.cs

示例13: EncryptDecryptHelper

        private SecurityStatus EncryptDecryptHelper(SafeDeleteContext securityContext, byte[] buffer, int offset, int size, int headerSize, int trailerSize, bool encrypt, out int resultSize)
        {
            bool gotReference = false;
            resultSize = 0;
            try
            {
                securityContext.DangerousAddRef(ref gotReference);

                Interop.libssl.SslErrorCode errorCode = Interop.libssl.SslErrorCode.SSL_ERROR_NONE;

                unsafe
                {
                    fixed (byte* bufferPtr = buffer)
                    {
                        IntPtr inputPtr = new IntPtr(bufferPtr);

                        IntPtr scHandle = securityContext.DangerousGetHandle();

                        resultSize = encrypt ?
                            Interop.OpenSsl.Encrypt(scHandle, inputPtr, offset, size, buffer.Length, out errorCode) :
                            Interop.OpenSsl.Decrypt(scHandle, inputPtr, size, out errorCode);
                    }
                }

                switch (errorCode)
                {
                    case Interop.libssl.SslErrorCode.SSL_ERROR_RENEGOTIATE:
                        return SecurityStatus.Renegotiate;
                    case Interop.libssl.SslErrorCode.SSL_ERROR_ZERO_RETURN:
                        return SecurityStatus.ContextExpired;
                    case Interop.libssl.SslErrorCode.SSL_ERROR_NONE:
                    case Interop.libssl.SslErrorCode.SSL_ERROR_WANT_READ:
                        return SecurityStatus.OK;
                    default:
                        return SecurityStatus.InternalError;
                }
            }
            catch (Exception ex)
            {
                Debug.Fail("Exception Caught. - " + ex);
                return SecurityStatus.InternalError;
            }
            finally
            {
                if (gotReference)
                {
                    securityContext.DangerousRelease();
                }
            }
        }
开发者ID:fuwei199006,项目名称:corefx,代码行数:50,代码来源:SSPISecureChannelType.cs

示例14: DecryptMessage

        public unsafe int DecryptMessage(SafeDeleteContext context, ref Interop.SspiCli.SecBufferDesc inputOutput, uint sequenceNumber)
        {
            int status = (int)Interop.SECURITY_STATUS.InvalidHandle;
            uint qop = 0;

            try
            {
                bool ignore = false;
                context.DangerousAddRef(ref ignore);
                status = Interop.SspiCli.DecryptMessage(ref context._handle, ref inputOutput, sequenceNumber, &qop);
            }
            finally
            {
                context.DangerousRelease();
            }

            if (status == 0 && qop == Interop.SspiCli.SECQOP_WRAP_NO_ENCRYPT)
            {
                NetEventSource.Fail(this, $"Expected qop = 0, returned value = {qop}");
                throw new InvalidOperationException(SR.net_auth_message_not_encrypted);
            }

            return status;
        }
开发者ID:dotnet,项目名称:corefx,代码行数:24,代码来源:SSPIAuthType.cs

示例15: EncryptDecryptHelper

        private SecurityStatus EncryptDecryptHelper(SafeDeleteContext securityContext, byte[] buffer, int offset, int size, int headerSize, int trailerSize, bool encrypt, out int resultSize)
        {
            bool gotReference = false;
            resultSize = 0;
            try
            {
                securityContext.DangerousAddRef(ref gotReference);

                unsafe
                {
                    fixed (byte* bufferPtr = buffer)
                    {
                        IntPtr inputPtr = new IntPtr(bufferPtr);

                        IntPtr scHandle = securityContext.DangerousGetHandle();

                        resultSize = encrypt ?
                            Interop.OpenSsl.Encrypt(scHandle, inputPtr, offset, size, buffer.Length) :
                            Interop.OpenSsl.Decrypt(scHandle, inputPtr, size);
                    }
                }

                return ((size == 0) || (resultSize > 0)) ? SecurityStatus.OK : SecurityStatus.ContextExpired;
            }
            catch (Exception ex)
            {
                Debug.Fail("Exception Caught. - " + ex);
                return SecurityStatus.InternalError;
            }
            finally
            {
                if (gotReference)
                {
                    securityContext.DangerousRelease();
                }
            }
        }
开发者ID:nnyamhon,项目名称:corefx,代码行数:37,代码来源:SSPISecureChannelType.cs


注:本文中的SafeDeleteContext.DangerousRelease方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。