mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2025-12-08 19:21:31 +03:00
Refactor Base64 functions, encode/decode using OpenSSL's EVP interface
Our own implementation works fine, however we should use OpenSSL's one since we already link to the library. Base64Decode() and Base64Encode() return the required buffer size when "dst" is NULL. This allows to efficiently allocate a buffer, without wasting memory or risking an overflow. Base64FromBin() and Base64ToBin() perform all steps, returning a heap-allocated buffer with the data in it.
This commit is contained in:
@ -806,9 +806,6 @@ static UINT SmDdnsGetKey(char *key, SM_DDNS *d){
|
||||
|
||||
void SmDDnsDlgInit(HWND hWnd, SM_DDNS *d)
|
||||
{
|
||||
char key[20];
|
||||
char encodedkey[20 * 4 + 32];
|
||||
|
||||
// Validate arguments
|
||||
if (hWnd == NULL || d == NULL)
|
||||
{
|
||||
@ -845,10 +842,15 @@ void SmDDnsDlgInit(HWND hWnd, SM_DDNS *d)
|
||||
|
||||
Hide(hWnd, B_PROXY);
|
||||
|
||||
if(SmDdnsGetKey(key, d) == ERR_NO_ERROR){
|
||||
encodedkey[ B64_Encode(encodedkey, key, 20) ] = 0;
|
||||
SetTextA(hWnd, E_KEY, encodedkey);
|
||||
}else{
|
||||
char key[20];
|
||||
if (SmDdnsGetKey(key, d) == ERR_NO_ERROR)
|
||||
{
|
||||
char *encoded_key = Base64FromBin(NULL, key, sizeof(key));
|
||||
SetTextA(hWnd, E_KEY, encoded_key);
|
||||
Free(encoded_key);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetText(hWnd, E_KEY, _UU("SM_DDNS_KEY_ERR"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user