mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2026-04-24 00:47:26 +00:00
Optimize OpenSSL backend to avoid redundant reinitialization
It is best to pass as few parameters to EVP_*Init_ex() as possible. Passing a key, IV, or cipher will cause redundant work to happen behind the scenes as OpenSSL doesn't check whether they have actually changed. This avoids a malloc()/free() and redoing AES key expansion for every message that is encrypted and decrypted.
This commit is contained in:
@@ -14,7 +14,7 @@ typedef struct _PLT_CRYPTO_CONTEXT {
|
||||
bool initialized;
|
||||
mbedtls_cipher_context_t ctx;
|
||||
#else
|
||||
bool initialized; // Used for CBC only
|
||||
bool initialized;
|
||||
EVP_CIPHER_CTX* ctx;
|
||||
#endif
|
||||
} PLT_CRYPTO_CONTEXT, *PPLT_CRYPTO_CONTEXT;
|
||||
|
||||
Reference in New Issue
Block a user