CERs around the handle usage in MakeSignature and VerifySignature
This commit is contained in:
@@ -279,13 +279,37 @@ namespace NSspi.Contexts
|
|||||||
|
|
||||||
using ( adapter = new SecureBufferAdapter( new[] { dataBuffer, signatureBuffer } ) )
|
using ( adapter = new SecureBufferAdapter( new[] { dataBuffer, signatureBuffer } ) )
|
||||||
{
|
{
|
||||||
// TODO CER
|
bool gotRef = false;
|
||||||
status = ContextNativeMethods.MakeSignature(
|
|
||||||
ref this.ContextHandle.rawHandle,
|
RuntimeHelpers.PrepareConstrainedRegions();
|
||||||
0,
|
try
|
||||||
adapter.Handle,
|
{
|
||||||
0
|
this.ContextHandle.DangerousAddRef( ref gotRef );
|
||||||
);
|
}
|
||||||
|
catch ( Exception )
|
||||||
|
{
|
||||||
|
if ( gotRef )
|
||||||
|
{
|
||||||
|
this.ContextHandle.DangerousRelease();
|
||||||
|
gotRef = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if ( gotRef )
|
||||||
|
{
|
||||||
|
status = ContextNativeMethods.MakeSignature(
|
||||||
|
ref this.ContextHandle.rawHandle,
|
||||||
|
0,
|
||||||
|
adapter.Handle,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
|
this.ContextHandle.DangerousRelease();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( status != SecurityStatus.OK )
|
if ( status != SecurityStatus.OK )
|
||||||
@@ -360,12 +384,37 @@ namespace NSspi.Contexts
|
|||||||
|
|
||||||
using ( adapter = new SecureBufferAdapter( new[] { dataBuffer, signatureBuffer } ) )
|
using ( adapter = new SecureBufferAdapter( new[] { dataBuffer, signatureBuffer } ) )
|
||||||
{
|
{
|
||||||
status = ContextNativeMethods.VerifySignature(
|
bool gotRef = false;
|
||||||
ref this.ContextHandle.rawHandle,
|
|
||||||
adapter.Handle,
|
RuntimeHelpers.PrepareConstrainedRegions();
|
||||||
0,
|
try
|
||||||
0
|
{
|
||||||
);
|
this.ContextHandle.DangerousAddRef( ref gotRef );
|
||||||
|
}
|
||||||
|
catch ( Exception )
|
||||||
|
{
|
||||||
|
if ( gotRef )
|
||||||
|
{
|
||||||
|
this.ContextHandle.DangerousRelease();
|
||||||
|
gotRef = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if ( gotRef )
|
||||||
|
{
|
||||||
|
status = ContextNativeMethods.VerifySignature(
|
||||||
|
ref this.ContextHandle.rawHandle,
|
||||||
|
adapter.Handle,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
|
this.ContextHandle.DangerousRelease();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( status == SecurityStatus.OK )
|
if ( status == SecurityStatus.OK )
|
||||||
|
|||||||
Reference in New Issue
Block a user