dblock/waffle — pull request #122 by kentcb (2014-07-29 03:59:35+00:00)
Title: Fixes for #114.

Where relevant, tokens are obtained in a loop with an increasing buffer size as long as SEC_E_BUFFER_TOO_SMALL or SEC_E_INSUFFICIENT_MEMORY is returned.

As discussed in the [forum](https://groups.google.com/d/msg/waffle-users/-G_0xZpAm84/cywnO8ALVJcJ), there is still a case that is not dealt with here. Namely, if the buffer size is too small then `TestNegotiate()` will fail with:
```
System.ComponentModel.Win32Exception : Not enough memory is available to complete this request
WindowsSecurityContext.cs(143,0): at Waffle.Windows.AuthProvider.WindowsSecurityContext..ctor(String username, WindowsCredentialsHandle credentials, String securityPackage, Int32 fContextReq, Int32 targetDataRep)
```
It only fails on the second call to `InitializeSecurityContext()`.