Create a similar SafeDecryptMessage that handles the CER crud.

Change the Safe*Message methods to order the parameters the same (even though the Win32 API doesn't..) and to take in the SecureBufferAdapter instead of its handle.
This commit is contained in:
antiduh
2014-06-25 01:08:29 +00:00
parent 2b52e1d84f
commit 26888a8b7b
2 changed files with 51 additions and 34 deletions

View File

@@ -101,37 +101,12 @@ namespace NSspi
using( adapter = new SecureBufferAdapter( new[] { trailerBuffer, dataBuffer, paddingBuffer } ) )
{
bool gotRef = false;
RuntimeHelpers.PrepareConstrainedRegions();
try
{
this.ContextHandle.DangerousAddRef( ref gotRef );
}
catch( Exception )
{
if( gotRef )
{
this.ContextHandle.DangerousRelease();
gotRef = false;
}
throw;
}
finally
{
if( gotRef )
{
status = ContextNativeMethods.EncryptMessage(
ref this.ContextHandle.rawHandle,
0,
adapter.Handle,
0
);
this.ContextHandle.DangerousRelease();
}
}
status = ContextNativeMethods.SafeEncryptMessage(
this.ContextHandle,
0,
adapter,
0
);
}
if( status != SecurityStatus.OK )
@@ -245,7 +220,7 @@ namespace NSspi
status = ContextNativeMethods.SafeDecryptMessage(
this.ContextHandle,
0,
adapter.Handle,
adapter,
0
);
}