Exemplo n.º 1
0
        /// <summary>
        /// Queries the security package's expections regarding message/token/signature/padding buffer sizes.
        /// </summary>
        /// <returns></returns>
        private CSecPkgContext_Sizes QueryBufferSizes()
        {
            CSecPkgContext_Sizes sizes  = new CSecPkgContext_Sizes();
            CSecurityStatus      status = CSecurityStatus.InternalError;
            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 = CContextNativeMethods.QueryContextAttributes_Sizes(
                        ref this.ContextHandle.rawHandle,
                        CContextQueryAttrib.Sizes,
                        ref sizes
                        );
                    this.ContextHandle.DangerousRelease();
                }
            }

            if (status != CSecurityStatus.OK)
            {
                throw new CSSPIException("Failed to query context buffer size attributes", status);
            }

            return(sizes);
        }
Exemplo n.º 2
0
 internal static extern CSecurityStatus QueryContextAttributes_Sizes(
     ref CRawSspiHandle contextHandle,
     CContextQueryAttrib attrib,
     ref CSecPkgContext_Sizes sizes
     );