本文整理汇总了C#中SafeDeleteContext.DangerousAddRef方法的典型用法代码示例。如果您正苦于以下问题:C# SafeDeleteContext.DangerousAddRef方法的具体用法?C# SafeDeleteContext.DangerousAddRef怎么用?C# SafeDeleteContext.DangerousAddRef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SafeDeleteContext
的用法示例。
在下文中一共展示了SafeDeleteContext.DangerousAddRef方法的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;
}
示例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();
}
}
示例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;
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
}
示例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();
}
}
}
示例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();
}
}
}
示例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;
}
示例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();
}
}
示例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();
}
}
}
示例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;
}
示例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();
}
}
}