From b2afb8800bb033a04bb3ecdf0363068d56648ef1 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Fri, 15 Aug 2008 23:44:54 -0500 Subject: Second Life viewer sources 1.15.0.2 --- linden/indra/llmessage/llblowfishcipher.cpp | 49 ++++++++++++++++------------- 1 file changed, 28 insertions(+), 21 deletions(-) (limited to 'linden/indra/llmessage/llblowfishcipher.cpp') diff --git a/linden/indra/llmessage/llblowfishcipher.cpp b/linden/indra/llmessage/llblowfishcipher.cpp index f9a68ab..1772078 100644 --- a/linden/indra/llmessage/llblowfishcipher.cpp +++ b/linden/indra/llmessage/llblowfishcipher.cpp @@ -7,6 +7,7 @@ * * Copyright (c) 2007-2007, Linden Research, Inc. * + * Second Life Viewer Source Code * The source code in this file ("Source Code") is provided by Linden Lab * to you under the terms of the GNU General Public License, version 2.0 * ("GPL"), unless you have obtained a separate licensing agreement @@ -84,27 +85,33 @@ U32 LLBlowfishCipher::encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len) << " iv_len " << iv_length << llendl; - int output_len = 0; - if (!EVP_EncryptUpdate(&context, - dst, - &output_len, - src, - src_len)) - { - llwarns << "LLBlowfishCipher::encrypt EVP_EncryptUpdate failure" << llendl; - return 0; - } - - // There may be some final data left to encrypt if the input is - // not an exact multiple of the block size. - int temp_len = 0; - if (!EVP_EncryptFinal_ex(&context, (unsigned char*)(dst + output_len), &temp_len)) - { - llwarns << "LLBlowfishCipher::encrypt EVP_EncryptFinal failure" << llendl; - return 0; - } - output_len += temp_len; - return output_len; + int output_len = 0; + int temp_len = 0; + if (!EVP_EncryptUpdate(&context, + dst, + &output_len, + src, + src_len)) + { + llwarns << "LLBlowfishCipher::encrypt EVP_EncryptUpdate failure" << llendl; + goto ERROR; + } + + // 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)) + { + llwarns << "LLBlowfishCipher::encrypt EVP_EncryptFinal failure" << llendl; + goto ERROR; + } + output_len += temp_len; + + EVP_CIPHER_CTX_cleanup(&context); + return output_len; + +ERROR: + EVP_CIPHER_CTX_cleanup(&context); + return 0; } // virtual -- cgit v1.1