internal override SafeBuffer ToBuffer(DisposableList list, string package)
        {
            if (!AuthenticationPackage.CheckSChannel(package) &&
                !AuthenticationPackage.CheckCredSSP(package))
            {
                throw new ArgumentException("Can only use SchannelCredentials for the Schannel or CredSSP package.", nameof(package));
            }
            SCHANNEL_CRED creds = new SCHANNEL_CRED
            {
                dwVersion               = SCHANNEL_CRED.SCHANNEL_CRED_VERSION,
                dwSessionLifespan       = SessionLifespan,
                dwFlags                 = Flags,
                grbitEnabledProtocols   = Protocols,
                dwMinimumCipherStrength = MinimumCipherStrength,
                dwMaximumCipherStrength = MaximumCipherStrength
            };

            if (_certs.Count > 0)
            {
                IntPtr[] cred_handles = _certs.Select(c => c.Handle).ToArray();
                var      array_buffer = list.AddResource(cred_handles.ToBuffer());
                creds.cCreds = cred_handles.Length;
                creds.paCred = array_buffer.DangerousGetHandle();
            }
            if (_alg_types.Count > 0)
            {
                creds.cSupportedAlgs    = _alg_types.Count;
                creds.palgSupportedAlgs = list.AddResource(_alg_types.Select(a => (int)a).ToArray().ToBuffer()).DangerousGetHandle();
            }

            return(creds.ToBuffer());
        }
Exemplo n.º 2
0
 internal static extern unsafe int AcquireCredentialsHandleW(
     [In] string principal,
     [In] string moduleName,
     [In] int usage,
     [In] void *logonID,
     [In] ref SCHANNEL_CRED authData,
     [In] void *keyCallback,
     [In] void *keyArgument,
     ref CredHandle handlePtr,
     [Out] out long timeStamp
     );
Exemplo n.º 3
0
        internal override SafeBuffer ToBuffer(DisposableList list, string package)
        {
            if (!AuthenticationPackage.CheckSChannel(package) &&
                !AuthenticationPackage.CheckCredSSP(package))
            {
                throw new ArgumentException("Can only use SchannelCredentials for the Schannel or CredSSP package.", nameof(package));
            }
            SCHANNEL_CRED creds = new SCHANNEL_CRED
            {
                dwVersion         = SCHANNEL_CRED.SCHANNEL_CRED_VERSION,
                dwSessionLifespan = SessionLifespan,
                dwFlags           = Flags
            };

            if (_certs.Count > 0)
            {
                IntPtr[] cred_handles = _certs.Select(c => c.Handle).ToArray();
                var      array_buffer = list.AddResource(cred_handles.ToBuffer());
                creds.cCreds = cred_handles.Length;
                creds.paCred = array_buffer.DangerousGetHandle();
            }

            return(creds.ToBuffer());
        }