aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage/llblowfishcipher.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llmessage/llblowfishcipher.cpp')
-rw-r--r--linden/indra/llmessage/llblowfishcipher.cpp49
1 files changed, 28 insertions, 21 deletions
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 @@
7 * 7 *
8 * Copyright (c) 2007-2007, Linden Research, Inc. 8 * Copyright (c) 2007-2007, Linden Research, Inc.
9 * 9 *
10 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 11 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0 12 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement 13 * ("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)
84 << " iv_len " << iv_length 85 << " iv_len " << iv_length
85 << llendl; 86 << llendl;
86 87
87 int output_len = 0; 88 int output_len = 0;
88 if (!EVP_EncryptUpdate(&context, 89 int temp_len = 0;
89 dst, 90 if (!EVP_EncryptUpdate(&context,
90 &output_len, 91 dst,
91 src, 92 &output_len,
92 src_len)) 93 src,
93 { 94 src_len))
94 llwarns << "LLBlowfishCipher::encrypt EVP_EncryptUpdate failure" << llendl; 95 {
95 return 0; 96 llwarns << "LLBlowfishCipher::encrypt EVP_EncryptUpdate failure" << llendl;
96 } 97 goto ERROR;
97 98 }
98 // There may be some final data left to encrypt if the input is 99
99 // not an exact multiple of the block size. 100 // There may be some final data left to encrypt if the input is
100 int temp_len = 0; 101 // not an exact multiple of the block size.
101 if (!EVP_EncryptFinal_ex(&context, (unsigned char*)(dst + output_len), &temp_len)) 102 if (!EVP_EncryptFinal_ex(&context, (unsigned char*)(dst + output_len), &temp_len))
102 { 103 {
103 llwarns << "LLBlowfishCipher::encrypt EVP_EncryptFinal failure" << llendl; 104 llwarns << "LLBlowfishCipher::encrypt EVP_EncryptFinal failure" << llendl;
104 return 0; 105 goto ERROR;
105 } 106 }
106 output_len += temp_len; 107 output_len += temp_len;
107 return output_len; 108
109 EVP_CIPHER_CTX_cleanup(&context);
110 return output_len;
111
112ERROR:
113 EVP_CIPHER_CTX_cleanup(&context);
114 return 0;
108} 115}
109 116
110// virtual 117// virtual