aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-02-03 15:23:22 +1000
committerDavid Walter Seikel2014-02-03 15:23:22 +1000
commitd056a17f05a1f90708f554651475e116a2ddbd68 (patch)
tree07fa4f1cca2a25548b8d2d6b4752b07d8efbd2ff /linden/indra/llmessage
parentUpdating tree and volume LOD. These go to eleven. (diff)
parentFix up OTR prefs to not crash. (diff)
downloadmeta-impy-d056a17f05a1f90708f554651475e116a2ddbd68.zip
meta-impy-d056a17f05a1f90708f554651475e116a2ddbd68.tar.gz
meta-impy-d056a17f05a1f90708f554651475e116a2ddbd68.tar.bz2
meta-impy-d056a17f05a1f90708f554651475e116a2ddbd68.tar.xz
Merge branch 'next' of github.com:onefang/meta-impy into nextHEADnext
Diffstat (limited to '')
-rw-r--r--linden/indra/llmessage/llblowfishcipher.cpp68
-rw-r--r--linden/indra/llmessage/llhttpassetstorage.cpp3
2 files changed, 62 insertions, 9 deletions
diff --git a/linden/indra/llmessage/llblowfishcipher.cpp b/linden/indra/llmessage/llblowfishcipher.cpp
index f24d103..3eebfad 100644
--- a/linden/indra/llmessage/llblowfishcipher.cpp
+++ b/linden/indra/llmessage/llblowfishcipher.cpp
@@ -73,13 +73,13 @@ U32 LLBlowfishCipher::encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len)
73 unsigned char initial_vector[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; 73 unsigned char initial_vector[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
74 EVP_EncryptInit_ex(&context, NULL, NULL, mSecret, initial_vector); 74 EVP_EncryptInit_ex(&context, NULL, NULL, mSecret, initial_vector);
75 75
76 int blocksize = EVP_CIPHER_CTX_block_size(&context); 76// int blocksize = EVP_CIPHER_CTX_block_size(&context);
77 int keylen = EVP_CIPHER_CTX_key_length(&context); 77// int keylen = EVP_CIPHER_CTX_key_length(&context);
78 int iv_length = EVP_CIPHER_CTX_iv_length(&context); 78// int iv_length = EVP_CIPHER_CTX_iv_length(&context);
79 lldebugs << "LLBlowfishCipher blocksize " << blocksize 79// lldebugs << "LLBlowfishCipher blocksize " << blocksize
80 << " keylen " << keylen 80// << " keylen " << keylen
81 << " iv_len " << iv_length 81// << " iv_len " << iv_length
82 << llendl; 82// << llendl;
83 83
84 int output_len = 0; 84 int output_len = 0;
85 int temp_len = 0; 85 int temp_len = 0;
@@ -113,7 +113,59 @@ ERROR:
113// virtual 113// virtual
114U32 LLBlowfishCipher::decrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len) 114U32 LLBlowfishCipher::decrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len)
115{ 115{
116 llerrs << "LLBlowfishCipher decrypt unsupported" << llendl; 116 if (!src || !src_len || !dst || !dst_len) return 0;
117 if (src_len > dst_len) return 0;
118
119 // OpenSSL uses "cipher contexts" to hold encryption parameters.
120 EVP_CIPHER_CTX context;
121 EVP_CIPHER_CTX_init(&context);
122
123 // We want a blowfish cyclic block chain cipher, but need to set
124 // the key length before we pass in a key, so call EncryptInit
125 // first with NULLs.
126 EVP_DecryptInit_ex(&context, EVP_bf_cbc(), NULL, NULL, NULL);
127 EVP_CIPHER_CTX_set_key_length(&context, (int)mSecretSize);
128
129 // Complete initialization. Per EVP_EncryptInit man page, the
130 // cipher pointer must be NULL. Apparently initial_vector must
131 // be 8 bytes for blowfish, as this is the block size.
132 unsigned char initial_vector[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
133 EVP_DecryptInit_ex(&context, NULL, NULL, mSecret, initial_vector);
134
135// int blocksize = EVP_CIPHER_CTX_block_size(&context);
136// int keylen = EVP_CIPHER_CTX_key_length(&context);
137// int iv_length = EVP_CIPHER_CTX_iv_length(&context);
138// lldebugs << "LLBlowfishCipher blocksize " << blocksize
139// << " keylen " << keylen
140// << " iv_len " << iv_length
141// << llendl;
142
143 int output_len = 0;
144 int temp_len = 0;
145 if (!EVP_DecryptUpdate(&context,
146 dst,
147 &output_len,
148 src,
149 src_len))
150 {
151 llwarns << "LLBlowfishCipher::decrypt EVP_DecryptUpdate failure" << llendl;
152 goto ERROR;
153 }
154
155 // There may be some final data left to decrypt if the input is
156 // not an exact multiple of the block size.
157 if (!EVP_DecryptFinal_ex(&context, (unsigned char*)(dst + output_len), &temp_len))
158 {
159 llwarns << "LLBlowfishCipher::decrypt EVP_DecryptFinal failure" << llendl;
160 goto ERROR;
161 }
162 output_len += temp_len;
163
164 EVP_CIPHER_CTX_cleanup(&context);
165 return output_len;
166
167ERROR:
168 EVP_CIPHER_CTX_cleanup(&context);
117 return 0; 169 return 0;
118} 170}
119 171
diff --git a/linden/indra/llmessage/llhttpassetstorage.cpp b/linden/indra/llmessage/llhttpassetstorage.cpp
index 49dbdbd..fcdb354 100644
--- a/linden/indra/llmessage/llhttpassetstorage.cpp
+++ b/linden/indra/llmessage/llhttpassetstorage.cpp
@@ -743,7 +743,8 @@ LLAssetRequest* LLHTTPAssetStorage::findNextRequest(LLAssetStorage::request_list
743 request_list_t::iterator running_end = running.end(); 743 request_list_t::iterator running_end = running.end();
744 744
745 request_list_t::iterator pending_iter = pending.begin(); 745 request_list_t::iterator pending_iter = pending.begin();
746 request_list_t::iterator pending_end = pending.end(); 746 // FIXME onefang - I assume this was being used to speed up the for(), but this is just a quick pass to get rid of warnings. Try to understand it later.
747 //request_list_t::iterator pending_end = pending.end();
747 // Loop over all pending requests until we miss finding it in the running list. 748 // Loop over all pending requests until we miss finding it in the running list.
748 for (; pending_iter != pending.end(); ++pending_iter) 749 for (; pending_iter != pending.end(); ++pending_iter)
749 { 750 {