From e263b567f17a839b743e99042e6ef3dad8f9b3b1 Mon Sep 17 00:00:00 2001 From: David Hall Date: Mon, 13 May 2019 14:44:36 -0600 Subject: [PATCH] Added SecPkg structures --- PInvoke/Security/Schannel/Schannel.cs | 90 +++++++++++++++++++++++++++++++++++ PInvoke/Security/Secur32/credssp.cs | 19 ++++++++ 2 files changed, 109 insertions(+) diff --git a/PInvoke/Security/Schannel/Schannel.cs b/PInvoke/Security/Schannel/Schannel.cs index 2f33fb6a..f64cd4fb 100644 --- a/PInvoke/Security/Schannel/Schannel.cs +++ b/PInvoke/Security/Schannel/Schannel.cs @@ -836,6 +836,96 @@ namespace Vanara.PInvoke public IntPtr pSignatureAndHashAlgorithms; } + /// + /// The SecPkgCred_CipherStrengths structure holds the minimum and maximum strength permitted for the cipher used by the + /// specified Schannel credential. This structure is used by the QueryCredentialsAttributes function. + /// + // typedef struct _SecPkgCred_CipherStrengths { DWORD dwMinimumCipherStrength; DWORD dwMaximumCipherStrength;} + // SecPkgCred_CipherStrengths, *PSecPkgCred_CipherStrengths; https://msdn.microsoft.com/en-us/library/windows/desktop/aa380101(v=vs.85).aspx + [PInvokeData("Schannel.h", MSDNShortId = "aa380101")] + [StructLayout(LayoutKind.Sequential)] + public struct SecPkgCred_CipherStrengths + { + /// Minimum cipher strength allowed. + public uint dwMinimumCipherStrength; + + /// Maximum cipher strength allowed. + public uint dwMaximumCipherStrength; + } + + /// + /// The SecPkgCred_SupportedAlgs structure contains identifiers for algorithms permitted with a specified Schannel credential. + /// This structure is used by the QueryCredentialsAttributes function. + /// + // typedef struct _SecPkgCred_SupportedAlgs { DWORD cSupportedAlgs; ALG_ID *palgSupportedAlgs;} SecPkgCred_SupportedAlgs, + // *PSecPkgCred_SupportedAlgs; https://msdn.microsoft.com/en-us/library/windows/desktop/aa380102(v=vs.85).aspx + [PInvokeData("Schannel.h", MSDNShortId = "aa380102")] + [StructLayout(LayoutKind.Sequential)] + public struct SecPkgCred_SupportedAlgs + { + /// Number of elements in the palgSupportedAlgs array. + public uint cSupportedAlgs; + + /// Array of algorithm identifiers ( ALG_ID) allowed with a credential. + public IntPtr palgSupportedAlgs; + } + + /// + /// The SecPkgCred_SupportedProtocols structure indicates the protocols permitted with a specified Schannel credential. This + /// structure is used by the QueryCredentialsAttributes function. + /// + // typedef struct _SecPkgCred_SupportedProtocols { DWORD grbitProtocol;} SecPkgCred_SupportedProtocols, + // *PSecPkgCred_SupportedProtocols; https://msdn.microsoft.com/en-us/library/windows/desktop/aa380103(v=vs.85).aspx + [PInvokeData("Schannel.h", MSDNShortId = "aa380103")] + [StructLayout(LayoutKind.Sequential)] + public struct SecPkgCred_SupportedProtocols + { + /// + /// Flags representing the protocols supported with this credential. The following table lists the valid values. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// SP_PROT_TLS1_CLIENT + /// Transport Layer Security 1.0 client-side. + /// + /// + /// SP_PROT_TLS1_SERVER + /// Transport Layer Security 1.0 server-side. + /// + /// + /// SP_PROT_SSL3_CLIENT + /// Secure Sockets Layer 3.0 client-side. Superseded by SP_PROT_TLS1_CLIENT. + /// + /// + /// SP_PROT_SSL3_SERVER + /// Secure Sockets Layer 3.0 server-side. Superseded by SP_PROT_TLS1_SERVER. + /// + /// + /// SS_PROT_PCT1_CLIENT + /// Private Communications Technology 1.0 client-side. Obsolete. + /// + /// + /// SP_PROT_PCT1_SERVER + /// Private Communications Technology 1.0 server-side. Obsolete. + /// + /// + /// SP_PROT_SSL2_CLIENT + /// Secure Sockets Layer 2.0 client-side. Superseded by SP_PROT_TLS1_CLIENT. + /// + /// + /// SP_PROT_SSL2_SERVER + /// Secure Sockets Layer 2.0 server-side. Superseded by SP_PROT_TLS1_SERVER. + /// + /// + /// + /// + public SP_PROT grbitProtocol; + } + /// The X509Certificate structure represents an X.509 certificate. // https://docs.microsoft.com/en-us/windows/desktop/api/schannel/ns-schannel-_x509certificate typedef struct _X509Certificate { DWORD // Version; DWORD SerialNumber[4]; ALG_ID SignatureAlgorithm; FILETIME ValidFrom; FILETIME ValidUntil; PSTR pszIssuer; PSTR diff --git a/PInvoke/Security/Secur32/credssp.cs b/PInvoke/Security/Secur32/credssp.cs index 27fa3b35..03cc9c95 100644 --- a/PInvoke/Security/Secur32/credssp.cs +++ b/PInvoke/Security/Secur32/credssp.cs @@ -65,5 +65,24 @@ namespace Vanara.PInvoke public CREDSSP_CRED Cred; } + + /// + /// + /// The SecPkgContext_ClientCreds structure specifies client credentials when calling the QueryContextAttributes (CredSSP) function. + /// + /// This structure is supported only on the server. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/credssp/ns-credssp-_secpkgcontext_clientcreds typedef struct + // _SecPkgContext_ClientCreds { ULONG AuthBufferLen; PUCHAR AuthBuffer; } SecPkgContext_ClientCreds, *PSecPkgContext_ClientCreds; + [PInvokeData("credssp.h", MSDNShortId = "85ab1bf7-a4d9-4b0e-b1e3-cb938c3183d3")] + [StructLayout(LayoutKind.Sequential)] + public struct SecPkgContext_ClientCreds + { + /// The size, in characters, of the AuthBuffer buffer. + public uint AuthBufferLen; + + /// A pointer to a buffer that represents the client credentials. + public IntPtr AuthBuffer; + } } } \ No newline at end of file