public static int UnsealMessage( SSPIInterface SecModule, ref long context, int QOP, SecurityBufferClass[] input, int sequenceNumber) { GCHandle[] handleIn = PinBuffers(input); SecurityBufferDescriptor sdcInOut = new SecurityBufferDescriptor(input); int errorCode = SecModule.UnsealMessage(ref context, ref sdcInOut, QOP, sequenceNumber); SecurityBufferClass[] result = sdcInOut.marshall(); for (int k = 0; k < input.Length; k++) { input[k] = result[k]; } sdcInOut.FreeAllBuffers(0); FreeGCHandles(handleIn); return(errorCode); }
private static int AcceptSecurityContext( SSPIInterface SecModule, long credential, long context, int requirements, Endianness datarep, SecurityBufferClass[] inputBuffers, ref long newContext, SecurityBufferClass[] outputBuffers, out int attributes, out long timestamp ) { GlobalLog.Enter("AcceptSecurityContext#2"); GCHandle[] handleIn = null; GCHandle[] handleOut = null; if (inputBuffers != null) { handleIn = PinBuffers(inputBuffers); } if (outputBuffers != null) { handleOut = PinBuffers(outputBuffers); } int errorCode = 0; SecurityBufferDescriptor outSecurityBufferDescriptor = new SecurityBufferDescriptor(outputBuffers); if (inputBuffers == null) { errorCode = SecModule.AcceptSecurityContext( ref credential, 0, 0, requirements, (int)datarep, ref newContext, ref outSecurityBufferDescriptor, out attributes, out timestamp); } else { SecurityBufferDescriptor inSecurityBufferDescriptor = new SecurityBufferDescriptor(inputBuffers); errorCode = SecModule.AcceptSecurityContext( ref credential, ref context, ref inSecurityBufferDescriptor, requirements, (int)datarep, ref newContext, ref outSecurityBufferDescriptor, out attributes, out timestamp); } SecurityBufferClass[] result = outSecurityBufferDescriptor.marshall(); outSecurityBufferDescriptor.FreeAllBuffers(requirements); FreeGCHandles(handleIn); FreeGCHandles(handleOut); GlobalLog.Leave("AcceptSecurityContext#2"); return(errorCode); }
InitializeSecurityContext(SSPIInterface SecModule, long credential, long context, string targetName, int requirements, Endianness datarep, SecurityBufferClass[] inputBuffers, ref long newContext, SecurityBufferClass[] outputBuffers, ref int attributes, ref long timestamp ) { GlobalLog.Enter("InitializeSecurityContext#2"); GlobalLog.Print("SSPIWrapper::InitializeSecurityContext#2()"); GCHandle[] handleOut = null; GCHandle[] handleIn = null; if (outputBuffers != null) { handleOut = PinBuffers(outputBuffers); } int errorCode = 0; SecurityBufferDescriptor outSecurityBufferDescriptor = new SecurityBufferDescriptor(outputBuffers); if (inputBuffers == null) { GlobalLog.Print("SSPIWrapper::InitializeSecurityContext#2(): inputBuffers == null"); errorCode = SecModule.InitializeSecurityContext( ref credential, IntPtr.Zero, targetName, requirements, 0, (int)datarep, IntPtr.Zero, 0, ref newContext, ref outSecurityBufferDescriptor, ref attributes, ref timestamp ); } else { handleIn = PinBuffers(inputBuffers); SecurityBufferDescriptor inSecurityBufferDescriptor = new SecurityBufferDescriptor(inputBuffers); errorCode = SecModule.InitializeSecurityContext( ref credential, ref context, targetName, requirements, 0, (int)datarep, ref inSecurityBufferDescriptor, 0, ref newContext, ref outSecurityBufferDescriptor, ref attributes, ref timestamp ); inSecurityBufferDescriptor.FreeAllBuffers(0); } if ((errorCode == 0) || (errorCode == (int)SecurityStatus.ContinueNeeded)) { SecurityBufferClass[] result = outSecurityBufferDescriptor.marshall(); for (int k = 0; k < outputBuffers.Length; k++) { outputBuffers[k] = result[k]; } } outSecurityBufferDescriptor.FreeAllBuffers(requirements); if (handleOut != null) { FreeGCHandles(handleOut); } if (handleIn != null) { FreeGCHandles(handleIn); } GlobalLog.Leave("InitializeSecurityContext#2"); return(errorCode); }