aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage/llxorcipher.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:50 -0500
committerJacek Antonelli2008-08-15 23:44:50 -0500
commit89fe5dab825a62a0e3fd8d248cbc91c65eb2a426 (patch)
treebcff14b7888d04a2fec799c59369f6095224bd08 /linden/indra/llmessage/llxorcipher.cpp
parentSecond Life viewer sources 1.13.3.2 (diff)
downloadmeta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.zip
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.gz
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.bz2
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.xz
Second Life viewer sources 1.14.0.0
Diffstat (limited to '')
-rw-r--r--linden/indra/llmessage/llxorcipher.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/linden/indra/llmessage/llxorcipher.cpp b/linden/indra/llmessage/llxorcipher.cpp
index 7a72866..3c3f690 100644
--- a/linden/indra/llmessage/llxorcipher.cpp
+++ b/linden/indra/llmessage/llxorcipher.cpp
@@ -27,7 +27,8 @@
27 27
28#include "linden_common.h" 28#include "linden_common.h"
29 29
30#include "llcrypto.h" 30#include "llxorcipher.h"
31
31#include "llerror.h" 32#include "llerror.h"
32 33
33///---------------------------------------------------------------------------- 34///----------------------------------------------------------------------------
@@ -63,25 +64,26 @@ LLXORCipher& LLXORCipher::operator=(const LLXORCipher& cipher)
63 return *this; 64 return *this;
64} 65}
65 66
66BOOL LLXORCipher::encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len) 67U32 LLXORCipher::encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len)
67{ 68{
68 if(!src || !src_len || !dst || !dst_len || !mPad) return FALSE; 69 if(!src || !src_len || !dst || !dst_len || !mPad) return 0;
69 U8* pad_end = mPad + mPadLen; 70 U8* pad_end = mPad + mPadLen;
70 while(src_len--) 71 U32 count = src_len;
72 while(count--)
71 { 73 {
72 *dst++ = *src++ ^ *mHead++; 74 *dst++ = *src++ ^ *mHead++;
73 if(mHead >= pad_end) mHead = mPad; 75 if(mHead >= pad_end) mHead = mPad;
74 } 76 }
75 return TRUE; 77 return src_len;
76} 78}
77 79
78BOOL LLXORCipher::decrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len) 80U32 LLXORCipher::decrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len)
79{ 81{
80 // xor is a symetric cipher, thus, just call the other function. 82 // xor is a symetric cipher, thus, just call the other function.
81 return encrypt(src, src_len, dst, dst_len); 83 return encrypt(src, src_len, dst, dst_len);
82} 84}
83 85
84U32 LLXORCipher::requiredEncryptionSpace(U32 len) 86U32 LLXORCipher::requiredEncryptionSpace(U32 len) const
85{ 87{
86 return len; 88 return len;
87} 89}