1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-11-22 17:39: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_EX("SetServerCert", RPC_KEY_PAIR, StSetServerCert, 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("SetServerCipher", RPC_STR, StSetServerCipher, InRpcStr, OutRpcStr, FreeRpcStr)
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_EX("SetServerCert", RPC_KEY_PAIR, ScSetServerCert, 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("SetServerCipher", RPC_STR, ScSetServerCipher, InRpcStr, OutRpcStr, FreeRpcStr)
DECLARE_SC("CreateHub", RPC_CREATE_HUB, ScCreateHub, InRpcCreateHub, OutRpcCreateHub)
@ -8245,6 +8247,43 @@ UINT StGetServerCipher(ADMIN *a, RPC_STR *t)
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
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 StSetServerCert(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 StSetServerCipher(ADMIN *a, RPC_STR *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 ScSetServerCert(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 ScSetServerCipher(RPC *r, RPC_STR *t);
UINT ScCreateHub(RPC *r, RPC_CREATE_HUB *t);

View File

@ -8834,26 +8834,33 @@ UINT PsServerCipherGet(CONSOLE *c, char *cmd_name, wchar_t *str, void *param)
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"));
UniFormat(tmp, sizeof(tmp), L" %S", t.String);
c->Write(c, tmp);
c->Write(c, L"");
c->Write(c, _UU("CMD_ServerCipherGet_CIPHERS"));
ret = ScGetServerCipherList(ps->Rpc, &t);
for (i = 0;i < ciphers->NumTokens;i++)
if (ret == ERR_NO_ERROR)
{
UniFormat(tmp, sizeof(tmp), L" %S", ciphers->Token[i]);
c->Write(c, tmp);
ciphers = ParseToken(t.String, ";");
FreeRpcStr(&t);
c->Write(c, L"");
c->Write(c, _UU("CMD_ServerCipherGet_CIPHERS"));
for (i = 0; i < ciphers->NumTokens; i++)
{
UniFormat(tmp, sizeof(tmp), L" %S", ciphers->Token[i]);
c->Write(c, tmp);
}
FreeToken(ciphers);
}
FreeToken(ciphers);
FreeRpcStr(&t);
FreeParamValueList(o);
return 0;

View File

@ -17018,24 +17018,34 @@ void SmSslDlgInit(HWND hWnd, SM_SSL *s)
return;
}
// Set the encryption algorithm list
cipher_list = GetCipherList();
SetFont(hWnd, C_CIPHER, GetFont("Tahoma", 8, false, false, false, false));
CbSetHeight(hWnd, C_CIPHER, 18);
for (i = 0;i < cipher_list->NumTokens;i++)
{
wchar_t tmp[MAX_SIZE];
char *name = cipher_list->Token[i];
StrToUni(tmp, sizeof(tmp), name);
CbAddStr(hWnd, C_CIPHER, tmp, 0);
}
FreeToken(cipher_list);
if (s->p != NULL)
{
// Get the encryption algorithm name from the server
RPC_STR t;
Zero(&t, sizeof(t));
SetFont(hWnd, C_CIPHER, GetFont("Tahoma", 8, false, false, false, false));
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++)
{
wchar_t tmp[MAX_SIZE];
char *name = cipher_list->Token[i];
StrToUni(tmp, sizeof(tmp), name);
CbAddStr(hWnd, C_CIPHER, tmp, 0);
}
FreeToken(cipher_list);
}
// Get the current encryption algorithm's name from the server
if (CALL(hWnd, ScGetServerCipher(s->p->Rpc, &t)))
{
wchar_t tmp[MAX_SIZE];

View File

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