Beispiel #1
0
        public unsafe byte[] QueryContextAttributeSession()
        {
            SecPkgContext_SessionKey pBuffer = default;
            SecStatus status;

            byte[] bytes = null;

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
            }
            finally
            {
                try
                {
                    status = QueryContextAttributesSession(ref this.securityContext, SecurityContextAttribute.SECPKG_ATTR_SESSION_KEY, ref pBuffer);

                    if (status == SecStatus.SEC_E_OK)
                    {
                        bytes = new Span <byte>(pBuffer.SessionKey, (int)pBuffer.SessionKeyLength).ToArray();
                    }
                }
                finally
                {
                    ThrowIfError(FreeContextBuffer(pBuffer.SessionKey));
                }
            }

            if (status != SecStatus.SEC_E_UNSUPPORTED_FUNCTION && status > SecStatus.SEC_E_ERROR)
            {
                throw new Win32Exception((int)status);
            }

            return(bytes);
        }
Beispiel #2
0
 private static extern uint QueryContextAttributes(
     ref SecHandle phContext,
     uint ulAttribute,
     out SecPkgContext_SessionKey value);
Beispiel #3
0
 internal static extern SecStatus QueryContextAttributesSession(
     ref SECURITY_HANDLE phContext,
     SecurityContextAttribute ulAttribute,
     ref SecPkgContext_SessionKey pBuffer
     );
Beispiel #4
0
 public static extern int QueryContextAttributes(
     ref SECURITY_HANDLE phContext,
     uint ulAttribute,
     out SecPkgContext_SessionKey pSessKeyOut);