/// <summary> /// Queries the security package's expections regarding message/token/signature/padding buffer sizes. /// </summary> /// <returns></returns> private SecPkgContext_Sizes QueryBufferSizes() { SecPkgContext_Sizes sizes = new SecPkgContext_Sizes(); SecurityStatus status = SecurityStatus.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 = ContextNativeMethods.QueryContextAttributes_Sizes( ref this.ContextHandle.rawHandle, ContextQueryAttrib.Sizes, ref sizes ); this.ContextHandle.DangerousRelease(); } } if (status != SecurityStatus.OK) { throw new SspiException("Failed to query context buffer size attributes", status); } return(sizes); }
internal static extern SecurityStatus QueryContextAttributes_Sizes( ref RawSspiHandle contextHandle, ContextQueryAttrib attrib, ref SecPkgContext_Sizes sizes );
/// <summary> /// Queries the security package's expections regarding message/token/signature/padding buffer sizes. /// </summary> /// <returns></returns> private SecPkgContext_Sizes QueryBufferSizes() { SecPkgContext_Sizes sizes = new SecPkgContext_Sizes(); SecurityStatus status = SecurityStatus.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 = ContextNativeMethods.QueryContextAttributes_Sizes( ref this.ContextHandle.rawHandle, ContextQueryAttrib.Sizes, ref sizes ); this.ContextHandle.DangerousRelease(); } } if( status != SecurityStatus.OK ) { throw new SspiException( "Failed to query context buffer size attributes", status ); } return sizes; }