diff options
Diffstat (limited to 'linden/indra/llmessage/llxorcipher.h')
-rw-r--r-- | linden/indra/llmessage/llxorcipher.h | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/linden/indra/llmessage/llxorcipher.h b/linden/indra/llmessage/llxorcipher.h new file mode 100644 index 0000000..fbb879e --- /dev/null +++ b/linden/indra/llmessage/llxorcipher.h | |||
@@ -0,0 +1,68 @@ | |||
1 | /** | ||
2 | * @file llxorcipher.h | ||
3 | * | ||
4 | * Copyright (c) 2003-2007, Linden Research, Inc. | ||
5 | * | ||
6 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
7 | * to you under the terms of the GNU General Public License, version 2.0 | ||
8 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
9 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
10 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
11 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
12 | * | ||
13 | * There are special exceptions to the terms and conditions of the GPL as | ||
14 | * it is applied to this Source Code. View the full text of the exception | ||
15 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
16 | * online at http://secondlife.com/developers/opensource/flossexception | ||
17 | * | ||
18 | * By copying, modifying or distributing this software, you acknowledge | ||
19 | * that you have read and understood your obligations described above, | ||
20 | * and agree to abide by those obligations. | ||
21 | * | ||
22 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
23 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
24 | * COMPLETENESS OR PERFORMANCE. | ||
25 | */ | ||
26 | |||
27 | #ifndef LLXORCIPHER_H | ||
28 | #define LLXORCIPHER_H | ||
29 | |||
30 | #include "llcipher.h" | ||
31 | |||
32 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
33 | // Class LLXORCipher | ||
34 | // | ||
35 | // Implementation of LLCipher which encrypts using a XOR pad. | ||
36 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
37 | |||
38 | class LLXORCipher : public LLCipher | ||
39 | { | ||
40 | public: | ||
41 | LLXORCipher(const U8* pad, U32 pad_len); | ||
42 | LLXORCipher(const LLXORCipher& cipher); | ||
43 | virtual ~LLXORCipher(); | ||
44 | LLXORCipher& operator=(const LLXORCipher& cipher); | ||
45 | |||
46 | // Cipher functions | ||
47 | /*virtual*/ U32 encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len); | ||
48 | /*virtual*/ U32 decrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len); | ||
49 | /*virtual*/ U32 requiredEncryptionSpace(U32 src_len) const; | ||
50 | |||
51 | // special syntactic-sugar since xor can be performed in place. | ||
52 | BOOL encrypt(U8* buf, U32 len) { return encrypt((const U8*)buf, len, buf, len); } | ||
53 | BOOL decrypt(U8* buf, U32 len) { return decrypt((const U8*)buf, len, buf, len); } | ||
54 | |||
55 | #ifdef _DEBUG | ||
56 | // This function runs tests to make sure the crc is | ||
57 | // working. Returns TRUE if it is. | ||
58 | static BOOL testHarness(); | ||
59 | #endif | ||
60 | |||
61 | protected: | ||
62 | void init(const U8* pad, U32 pad_len); | ||
63 | U8* mPad; | ||
64 | U8* mHead; | ||
65 | U32 mPadLen; | ||
66 | }; | ||
67 | |||
68 | #endif | ||