mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
libfreerdp-core: NLA cleanup
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -17,10 +17,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FREERDP_CORE_CREDSSP_H
|
||||
#define FREERDP_CORE_CREDSSP_H
|
||||
#ifndef FREERDP_CORE_NLA_H
|
||||
#define FREERDP_CORE_NLA_H
|
||||
|
||||
typedef struct rdp_credssp rdpCredssp;
|
||||
typedef struct rdp_nla rdpNla;
|
||||
|
||||
#include <freerdp/api.h>
|
||||
#include <freerdp/freerdp.h>
|
||||
@@ -35,32 +35,46 @@ typedef struct rdp_credssp rdpCredssp;
|
||||
|
||||
#include "transport.h"
|
||||
|
||||
struct rdp_credssp
|
||||
struct rdp_nla
|
||||
{
|
||||
BOOL server;
|
||||
int send_seq_num;
|
||||
int recv_seq_num;
|
||||
int sendSeqNum;
|
||||
int recvSeqNum;
|
||||
freerdp* instance;
|
||||
CtxtHandle context;
|
||||
LPTSTR SspiModule;
|
||||
rdpSettings* settings;
|
||||
rdpTransport* transport;
|
||||
UINT32 cbMaxToken;
|
||||
ULONG fContextReq;
|
||||
ULONG pfContextAttr;
|
||||
BOOL haveContext;
|
||||
BOOL haveInputBuffer;
|
||||
BOOL havePubKeyAuth;
|
||||
SECURITY_STATUS status;
|
||||
CredHandle credentials;
|
||||
TimeStamp expiration;
|
||||
PSecPkgInfo pPackageInfo;
|
||||
SecBuffer inputBuffer;
|
||||
SecBuffer outputBuffer;
|
||||
SecBufferDesc inputBufferDesc;
|
||||
SecBufferDesc outputBufferDesc;
|
||||
SecBuffer negoToken;
|
||||
SecBuffer pubKeyAuth;
|
||||
SecBuffer authInfo;
|
||||
SecBuffer PublicKey;
|
||||
SecBuffer ts_credentials;
|
||||
CryptoRc4 rc4_seal_state;
|
||||
SecBuffer tsCredentials;
|
||||
CryptoRc4 rc4SealState;
|
||||
LPTSTR ServicePrincipalName;
|
||||
SEC_WINNT_AUTH_IDENTITY identity;
|
||||
PSecurityFunctionTable table;
|
||||
SecPkgContext_Sizes ContextSizes;
|
||||
};
|
||||
|
||||
int credssp_authenticate(rdpCredssp* credssp);
|
||||
LPTSTR credssp_make_spn(const char* ServiceClass, const char* hostname);
|
||||
int nla_authenticate(rdpNla* nla);
|
||||
LPTSTR nla_make_spn(const char* ServiceClass, const char* hostname);
|
||||
|
||||
rdpCredssp* credssp_new(freerdp* instance, rdpTransport* transport, rdpSettings* settings);
|
||||
void credssp_free(rdpCredssp* credssp);
|
||||
rdpNla* nla_new(freerdp* instance, rdpTransport* transport, rdpSettings* settings);
|
||||
void nla_free(rdpNla* nla);
|
||||
|
||||
#endif /* FREERDP_CORE_CREDSSP_H */
|
||||
#endif /* FREERDP_CORE_NLA_H */
|
||||
|
||||
@@ -460,10 +460,10 @@ static int peer_recv_callback(rdpTransport* transport, wStream* s, void* extra)
|
||||
|
||||
if (rdp->nego->SelectedProtocol & PROTOCOL_NLA)
|
||||
{
|
||||
sspi_CopyAuthIdentity(&client->identity, &(rdp->nego->transport->credssp->identity));
|
||||
sspi_CopyAuthIdentity(&client->identity, &(rdp->nego->transport->nla->identity));
|
||||
IFCALLRET(client->Logon, client->authenticated, client, &client->identity, TRUE);
|
||||
credssp_free(rdp->nego->transport->credssp);
|
||||
rdp->nego->transport->credssp = NULL;
|
||||
nla_free(rdp->nego->transport->nla);
|
||||
rdp->nego->transport->nla = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -158,9 +158,9 @@ BOOL transport_connect_tls(rdpTransport* transport)
|
||||
|
||||
BOOL transport_connect_nla(rdpTransport* transport)
|
||||
{
|
||||
rdpNla* nla;
|
||||
freerdp* instance;
|
||||
rdpSettings* settings;
|
||||
rdpCredssp* credSsp;
|
||||
settings = transport->settings;
|
||||
instance = (freerdp*) settings->instance;
|
||||
|
||||
@@ -172,28 +172,28 @@ BOOL transport_connect_nla(rdpTransport* transport)
|
||||
if (!settings->Authentication)
|
||||
return TRUE;
|
||||
|
||||
if (!transport->credssp)
|
||||
if (!transport->nla)
|
||||
{
|
||||
transport->credssp = credssp_new(instance, transport, settings);
|
||||
transport->nla = nla_new(instance, transport, settings);
|
||||
|
||||
if (!transport->credssp)
|
||||
if (!transport->nla)
|
||||
return FALSE;
|
||||
|
||||
transport_set_nla_mode(transport, TRUE);
|
||||
|
||||
if (settings->AuthenticationServiceClass)
|
||||
{
|
||||
transport->credssp->ServicePrincipalName =
|
||||
credssp_make_spn(settings->AuthenticationServiceClass, settings->ServerHostname);
|
||||
transport->nla->ServicePrincipalName =
|
||||
nla_make_spn(settings->AuthenticationServiceClass, settings->ServerHostname);
|
||||
|
||||
if (!transport->credssp->ServicePrincipalName)
|
||||
if (!transport->nla->ServicePrincipalName)
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
credSsp = transport->credssp;
|
||||
nla = transport->nla;
|
||||
|
||||
if (credssp_authenticate(credSsp) < 0)
|
||||
if (nla_authenticate(nla) < 0)
|
||||
{
|
||||
if (!connectErrorCode)
|
||||
connectErrorCode = AUTHENTICATIONERROR;
|
||||
@@ -206,14 +206,14 @@ BOOL transport_connect_nla(rdpTransport* transport)
|
||||
WLog_ERR(TAG, "Authentication failure, check credentials."
|
||||
"If credentials are valid, the NTLMSSP implementation may be to blame.");
|
||||
transport_set_nla_mode(transport, FALSE);
|
||||
credssp_free(credSsp);
|
||||
transport->credssp = NULL;
|
||||
nla_free(nla);
|
||||
transport->nla = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
transport_set_nla_mode(transport, FALSE);
|
||||
credssp_free(credSsp);
|
||||
transport->credssp = NULL;
|
||||
nla_free(nla);
|
||||
transport->nla = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -308,23 +308,23 @@ BOOL transport_accept_nla(rdpTransport* transport)
|
||||
if (!settings->Authentication)
|
||||
return TRUE;
|
||||
|
||||
if (!transport->credssp)
|
||||
if (!transport->nla)
|
||||
{
|
||||
transport->credssp = credssp_new(instance, transport, settings);
|
||||
transport->nla = nla_new(instance, transport, settings);
|
||||
transport_set_nla_mode(transport, TRUE);
|
||||
}
|
||||
|
||||
if (credssp_authenticate(transport->credssp) < 0)
|
||||
if (nla_authenticate(transport->nla) < 0)
|
||||
{
|
||||
WLog_ERR(TAG, "client authentication failure");
|
||||
transport_set_nla_mode(transport, FALSE);
|
||||
credssp_free(transport->credssp);
|
||||
transport->credssp = NULL;
|
||||
nla_free(transport->nla);
|
||||
transport->nla = NULL;
|
||||
tls_set_alert_code(transport->tls, TLS_ALERT_LEVEL_FATAL, TLS_ALERT_DESCRIPTION_ACCESS_DENIED);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* don't free credssp module yet, we need to copy the credentials from it first */
|
||||
/* don't free nla module yet, we need to copy the credentials from it first */
|
||||
transport_set_nla_mode(transport, FALSE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ struct rdp_transport
|
||||
rdpTsg* tsg;
|
||||
rdpTls* tls;
|
||||
rdpContext* context;
|
||||
rdpCredssp* credssp;
|
||||
rdpNla* nla;
|
||||
rdpSettings* settings;
|
||||
void* ReceiveExtra;
|
||||
wStream* ReceiveBuffer;
|
||||
|
||||
Reference in New Issue
Block a user