private static string GetGssApiDisplayStatus(Status majorStatus, Status minorStatus) { string majorError = GetGssApiDisplayStatus(majorStatus, isMinor: false); string minorError = GetGssApiDisplayStatus(minorStatus, isMinor: true); return((majorError != null && minorError != null) ? SRHelper.Format(SR.net_gssapi_operation_failed_detailed, majorError, minorError) : SRHelper.Format(SR.net_gssapi_operation_failed, majorStatus.ToString("x"), minorStatus.ToString("x"))); }
internal int Copy(byte[] destination, int offset) { Debug.Assert(destination != null, "target destination cannot be null"); Debug.Assert((offset >= 0 && offset < destination.Length) || destination.Length == 0, "invalid offset " + offset); if (_data == IntPtr.Zero || _length == 0) { return(0); } // Using Convert.ToInt32 to throw an exception in the unlikely event of too large value of _length int sourceLength = Convert.ToInt32(_length); int destinationAvailable = destination.Length - offset; // amount of space in the given buffer if (sourceLength > destinationAvailable) { throw new NetSecurityNative.GssApiException(SRHelper.Format(SR.net_context_buffer_too_small, sourceLength, destinationAvailable)); } Marshal.Copy(_data, destination, offset, sourceLength); return(sourceLength); }
public unsafe int QueryContextAttributes(SafeDeleteContext context, Interop.SspiCli.ContextAttribute attribute, byte[] buffer, Type handleType, out SafeHandle refHandle) { refHandle = null; if (handleType != null) { if (handleType == typeof(SafeFreeContextBuffer)) { refHandle = SafeFreeContextBuffer.CreateEmptyHandle(); } else if (handleType == typeof(SafeFreeCertContext)) { refHandle = new SafeFreeCertContext(); } else { throw new ArgumentException(SRHelper.Format(SR.SSPIInvalidHandleType, handleType.FullName), nameof(handleType)); } } fixed(byte *bufferPtr = buffer) { return(SafeFreeContextBuffer.QueryContextAttributes(context, attribute, bufferPtr, refHandle)); } }