1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-11-23 01:49:53 +03:00

Cedar: retrieve the list of available encryption algorithms from the server

This commit is contained in:
Davide Beatrici 2019-01-01 20:31:13 +01:00
parent 422076d6c9
commit d62421adcb
5 changed files with 86 additions and 27 deletions

View File

@ -456,6 +456,7 @@ PACK *AdminDispatch(RPC *rpc, char *name, PACK *p)
DECLARE_RPC("GetFarmConnectionStatus", RPC_FARM_CONNECTION_STATUS, StGetFarmConnectionStatus, InRpcFarmConnectionStatus, OutRpcFarmConnectionStatus) DECLARE_RPC("GetFarmConnectionStatus", RPC_FARM_CONNECTION_STATUS, StGetFarmConnectionStatus, InRpcFarmConnectionStatus, OutRpcFarmConnectionStatus)
DECLARE_RPC_EX("SetServerCert", RPC_KEY_PAIR, StSetServerCert, InRpcKeyPair, OutRpcKeyPair, FreeRpcKeyPair) DECLARE_RPC_EX("SetServerCert", RPC_KEY_PAIR, StSetServerCert, InRpcKeyPair, OutRpcKeyPair, FreeRpcKeyPair)
DECLARE_RPC_EX("GetServerCert", RPC_KEY_PAIR, StGetServerCert, InRpcKeyPair, OutRpcKeyPair, FreeRpcKeyPair) DECLARE_RPC_EX("GetServerCert", RPC_KEY_PAIR, StGetServerCert, InRpcKeyPair, OutRpcKeyPair, FreeRpcKeyPair)
DECLARE_RPC_EX("GetServerCipherList", RPC_STR, StGetServerCipherList, InRpcStr, OutRpcStr, FreeRpcStr)
DECLARE_RPC_EX("GetServerCipher", RPC_STR, StGetServerCipher, InRpcStr, OutRpcStr, FreeRpcStr) DECLARE_RPC_EX("GetServerCipher", RPC_STR, StGetServerCipher, InRpcStr, OutRpcStr, FreeRpcStr)
DECLARE_RPC_EX("SetServerCipher", RPC_STR, StSetServerCipher, InRpcStr, OutRpcStr, FreeRpcStr) DECLARE_RPC_EX("SetServerCipher", RPC_STR, StSetServerCipher, InRpcStr, OutRpcStr, FreeRpcStr)
DECLARE_RPC("CreateHub", RPC_CREATE_HUB, StCreateHub, InRpcCreateHub, OutRpcCreateHub) DECLARE_RPC("CreateHub", RPC_CREATE_HUB, StCreateHub, InRpcCreateHub, OutRpcCreateHub)
@ -635,6 +636,7 @@ DECLARE_SC_EX("EnumFarmMember", RPC_ENUM_FARM, ScEnumFarmMember, InRpcEnumFarm,
DECLARE_SC("GetFarmConnectionStatus", RPC_FARM_CONNECTION_STATUS, ScGetFarmConnectionStatus, InRpcFarmConnectionStatus, OutRpcFarmConnectionStatus) DECLARE_SC("GetFarmConnectionStatus", RPC_FARM_CONNECTION_STATUS, ScGetFarmConnectionStatus, InRpcFarmConnectionStatus, OutRpcFarmConnectionStatus)
DECLARE_SC_EX("SetServerCert", RPC_KEY_PAIR, ScSetServerCert, InRpcKeyPair, OutRpcKeyPair, FreeRpcKeyPair) DECLARE_SC_EX("SetServerCert", RPC_KEY_PAIR, ScSetServerCert, InRpcKeyPair, OutRpcKeyPair, FreeRpcKeyPair)
DECLARE_SC_EX("GetServerCert", RPC_KEY_PAIR, ScGetServerCert, InRpcKeyPair, OutRpcKeyPair, FreeRpcKeyPair) DECLARE_SC_EX("GetServerCert", RPC_KEY_PAIR, ScGetServerCert, InRpcKeyPair, OutRpcKeyPair, FreeRpcKeyPair)
DECLARE_SC_EX("GetServerCipherList", RPC_STR, ScGetServerCipherList, InRpcStr, OutRpcStr, FreeRpcStr)
DECLARE_SC_EX("GetServerCipher", RPC_STR, ScGetServerCipher, InRpcStr, OutRpcStr, FreeRpcStr) DECLARE_SC_EX("GetServerCipher", RPC_STR, ScGetServerCipher, InRpcStr, OutRpcStr, FreeRpcStr)
DECLARE_SC_EX("SetServerCipher", RPC_STR, ScSetServerCipher, InRpcStr, OutRpcStr, FreeRpcStr) DECLARE_SC_EX("SetServerCipher", RPC_STR, ScSetServerCipher, InRpcStr, OutRpcStr, FreeRpcStr)
DECLARE_SC("CreateHub", RPC_CREATE_HUB, ScCreateHub, InRpcCreateHub, OutRpcCreateHub) DECLARE_SC("CreateHub", RPC_CREATE_HUB, ScCreateHub, InRpcCreateHub, OutRpcCreateHub)
@ -8245,6 +8247,43 @@ UINT StGetServerCipher(ADMIN *a, RPC_STR *t)
return ERR_NO_ERROR; return ERR_NO_ERROR;
} }
// Get list of available ciphers for SSL
UINT StGetServerCipherList(ADMIN *a, RPC_STR *t)
{
SERVER *s = a->Server;
CEDAR *c = s->Cedar;
FreeRpcStr(t);
Zero(t, sizeof(RPC_STR));
Lock(c->lock);
{
UINT i;
TOKEN_LIST *ciphers = GetCipherList();
if (ciphers->NumTokens > 0)
{
UINT size = StrSize(ciphers->Token[0]);
t->String = Malloc(size);
StrCat(t->String, size, ciphers->Token[0]);
i = 1;
for (; i < ciphers->NumTokens; i++)
{
// We use StrSize() because we need the extra space for ';'
size += StrSize(ciphers->Token[i]);
t->String = ReAlloc(t->String, size);
StrCat(t->String, size, ";");
StrCat(t->String, size, ciphers->Token[i]);
}
}
FreeToken(ciphers);
}
Unlock(c->lock);
return ERR_NO_ERROR;
}
// Get the server certification // Get the server certification
UINT StGetServerCert(ADMIN *a, RPC_KEY_PAIR *t) UINT StGetServerCert(ADMIN *a, RPC_KEY_PAIR *t)
{ {

View File

@ -1038,6 +1038,7 @@ UINT StEnumFarmMember(ADMIN *a, RPC_ENUM_FARM *t);
UINT StGetFarmConnectionStatus(ADMIN *a, RPC_FARM_CONNECTION_STATUS *t); UINT StGetFarmConnectionStatus(ADMIN *a, RPC_FARM_CONNECTION_STATUS *t);
UINT StSetServerCert(ADMIN *a, RPC_KEY_PAIR *t); UINT StSetServerCert(ADMIN *a, RPC_KEY_PAIR *t);
UINT StGetServerCert(ADMIN *a, RPC_KEY_PAIR *t); UINT StGetServerCert(ADMIN *a, RPC_KEY_PAIR *t);
UINT StGetServerCipherList(ADMIN *a, RPC_STR *t);
UINT StGetServerCipher(ADMIN *a, RPC_STR *t); UINT StGetServerCipher(ADMIN *a, RPC_STR *t);
UINT StSetServerCipher(ADMIN *a, RPC_STR *t); UINT StSetServerCipher(ADMIN *a, RPC_STR *t);
UINT StCreateHub(ADMIN *a, RPC_CREATE_HUB *t); UINT StCreateHub(ADMIN *a, RPC_CREATE_HUB *t);
@ -1181,6 +1182,7 @@ UINT ScEnumFarmMember(RPC *r, RPC_ENUM_FARM *t);
UINT ScGetFarmConnectionStatus(RPC *r, RPC_FARM_CONNECTION_STATUS *t); UINT ScGetFarmConnectionStatus(RPC *r, RPC_FARM_CONNECTION_STATUS *t);
UINT ScSetServerCert(RPC *r, RPC_KEY_PAIR *t); UINT ScSetServerCert(RPC *r, RPC_KEY_PAIR *t);
UINT ScGetServerCert(RPC *r, RPC_KEY_PAIR *t); UINT ScGetServerCert(RPC *r, RPC_KEY_PAIR *t);
UINT ScGetServerCipherList(RPC *r, RPC_STR *t);
UINT ScGetServerCipher(RPC *r, RPC_STR *t); UINT ScGetServerCipher(RPC *r, RPC_STR *t);
UINT ScSetServerCipher(RPC *r, RPC_STR *t); UINT ScSetServerCipher(RPC *r, RPC_STR *t);
UINT ScCreateHub(RPC *r, RPC_CREATE_HUB *t); UINT ScCreateHub(RPC *r, RPC_CREATE_HUB *t);

View File

@ -8834,13 +8834,21 @@ UINT PsServerCipherGet(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
return ret; return ret;
} }
ciphers = GetCipherList(); UniFormat(tmp, sizeof(tmp), L" %S", t.String);
FreeRpcStr(&t);
Zero(&t, sizeof(RPC_STR));
c->Write(c, _UU("CMD_ServerCipherGet_SERVER")); c->Write(c, _UU("CMD_ServerCipherGet_SERVER"));
UniFormat(tmp, sizeof(tmp), L" %S", t.String);
c->Write(c, tmp); c->Write(c, tmp);
ret = ScGetServerCipherList(ps->Rpc, &t);
if (ret == ERR_NO_ERROR)
{
ciphers = ParseToken(t.String, ";");
FreeRpcStr(&t);
c->Write(c, L""); c->Write(c, L"");
c->Write(c, _UU("CMD_ServerCipherGet_CIPHERS")); c->Write(c, _UU("CMD_ServerCipherGet_CIPHERS"));
@ -8851,8 +8859,7 @@ UINT PsServerCipherGet(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
} }
FreeToken(ciphers); FreeToken(ciphers);
}
FreeRpcStr(&t);
FreeParamValueList(o); FreeParamValueList(o);

View File

@ -17018,10 +17018,22 @@ void SmSslDlgInit(HWND hWnd, SM_SSL *s)
return; return;
} }
// Set the encryption algorithm list if (s->p != NULL)
cipher_list = GetCipherList(); {
RPC_STR t;
Zero(&t, sizeof(t));
SetFont(hWnd, C_CIPHER, GetFont("Tahoma", 8, false, false, false, false)); SetFont(hWnd, C_CIPHER, GetFont("Tahoma", 8, false, false, false, false));
CbSetHeight(hWnd, C_CIPHER, 18); CbSetHeight(hWnd, C_CIPHER, 18);
// Get the list of available encryption algorithms from the server
if (ScGetServerCipherList(s->p->Rpc, &t) == ERR_NO_ERROR)
{
cipher_list = ParseToken(t.String, ";");
FreeRpcStr(&t);
Zero(&t, sizeof(t));
for (i = 0; i < cipher_list->NumTokens; i++) for (i = 0; i < cipher_list->NumTokens; i++)
{ {
wchar_t tmp[MAX_SIZE]; wchar_t tmp[MAX_SIZE];
@ -17029,13 +17041,11 @@ void SmSslDlgInit(HWND hWnd, SM_SSL *s)
StrToUni(tmp, sizeof(tmp), name); StrToUni(tmp, sizeof(tmp), name);
CbAddStr(hWnd, C_CIPHER, tmp, 0); CbAddStr(hWnd, C_CIPHER, tmp, 0);
} }
FreeToken(cipher_list);
if (s->p != NULL) FreeToken(cipher_list);
{ }
// Get the encryption algorithm name from the server
RPC_STR t; // Get the current encryption algorithm's name from the server
Zero(&t, sizeof(t));
if (CALL(hWnd, ScGetServerCipher(s->p->Rpc, &t))) if (CALL(hWnd, ScGetServerCipher(s->p->Rpc, &t)))
{ {
wchar_t tmp[MAX_SIZE]; wchar_t tmp[MAX_SIZE];

View File

@ -16602,7 +16602,8 @@ TOKEN_LIST *GetCipherList()
ciphers->NumTokens++; ciphers->NumTokens++;
if (ciphers->Token != NULL) { if (ciphers->Token != NULL)
{
ciphers->Token = ReAlloc(ciphers->Token, sizeof(char *) * ciphers->NumTokens); ciphers->Token = ReAlloc(ciphers->Token, sizeof(char *) * ciphers->NumTokens);
} }
else else