summaryrefslogtreecommitdiff
path: root/indra/llmessage/llblowfishcipher.cpp
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2021-06-08 05:06:21 +0300
committerAndrey Lihatskiy <alihatskiy@productengine.com>2021-06-08 05:06:21 +0300
commit0a745b47880fb16b1db8cd3327377a383dbfe6a8 (patch)
treee96e11b0083858ce6f70d67f3ea818c13bc43b29 /indra/llmessage/llblowfishcipher.cpp
parent4cec2d689f9a7d1791f7ea3933cc1cdc59e972ab (diff)
Revert "Merge branch 'DRTVWR-520-apple-notarization' into DRTVWR-540-maint"
This reverts commit 681298dd726b2d00910fe71646147fadd1aba980, reversing changes made to 323f41f4892248762fc8505d8df17d70bd833cf3.
Diffstat (limited to 'indra/llmessage/llblowfishcipher.cpp')
-rw-r--r--indra/llmessage/llblowfishcipher.cpp28
1 files changed, 12 insertions, 16 deletions
diff --git a/indra/llmessage/llblowfishcipher.cpp b/indra/llmessage/llblowfishcipher.cpp
index 949d4cc0c7..0b5025a422 100644
--- a/indra/llmessage/llblowfishcipher.cpp
+++ b/indra/llmessage/llblowfishcipher.cpp
@@ -52,28 +52,24 @@ U32 LLBlowfishCipher::encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len)
if (src_len > dst_len) return 0;
// OpenSSL uses "cipher contexts" to hold encryption parameters.
- EVP_CIPHER_CTX *context = EVP_CIPHER_CTX_new();
- if (!context)
- {
- LL_WARNS() << "LLBlowfishCipher::encrypt EVP_CIPHER_CTX initiation failure" << LL_ENDL;
- return 0;
- }
+ EVP_CIPHER_CTX context;
+ EVP_CIPHER_CTX_init(&context);
// We want a blowfish cyclic block chain cipher, but need to set
// the key length before we pass in a key, so call EncryptInit
// first with NULLs.
- EVP_EncryptInit_ex(context, EVP_bf_cbc(), NULL, NULL, NULL);
- EVP_CIPHER_CTX_set_key_length(context, (int)mSecretSize);
+ EVP_EncryptInit_ex(&context, EVP_bf_cbc(), NULL, NULL, NULL);
+ EVP_CIPHER_CTX_set_key_length(&context, (int)mSecretSize);
// Complete initialization. Per EVP_EncryptInit man page, the
// cipher pointer must be NULL. Apparently initial_vector must
// be 8 bytes for blowfish, as this is the block size.
unsigned char initial_vector[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
- EVP_EncryptInit_ex(context, NULL, NULL, mSecret, initial_vector);
+ EVP_EncryptInit_ex(&context, NULL, NULL, mSecret, initial_vector);
- int blocksize = EVP_CIPHER_CTX_block_size(context);
- int keylen = EVP_CIPHER_CTX_key_length(context);
- int iv_length = EVP_CIPHER_CTX_iv_length(context);
+ int blocksize = EVP_CIPHER_CTX_block_size(&context);
+ int keylen = EVP_CIPHER_CTX_key_length(&context);
+ int iv_length = EVP_CIPHER_CTX_iv_length(&context);
LL_DEBUGS() << "LLBlowfishCipher blocksize " << blocksize
<< " keylen " << keylen
<< " iv_len " << iv_length
@@ -81,7 +77,7 @@ U32 LLBlowfishCipher::encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len)
int output_len = 0;
int temp_len = 0;
- if (!EVP_EncryptUpdate(context,
+ if (!EVP_EncryptUpdate(&context,
dst,
&output_len,
src,
@@ -93,18 +89,18 @@ U32 LLBlowfishCipher::encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len)
// There may be some final data left to encrypt if the input is
// not an exact multiple of the block size.
- if (!EVP_EncryptFinal_ex(context, (unsigned char*)(dst + output_len), &temp_len))
+ if (!EVP_EncryptFinal_ex(&context, (unsigned char*)(dst + output_len), &temp_len))
{
LL_WARNS() << "LLBlowfishCipher::encrypt EVP_EncryptFinal failure" << LL_ENDL;
goto ERROR;
}
output_len += temp_len;
- EVP_CIPHER_CTX_free(context);
+ EVP_CIPHER_CTX_cleanup(&context);
return output_len;
ERROR:
- EVP_CIPHER_CTX_free(context);
+ EVP_CIPHER_CTX_cleanup(&context);
return 0;
}