diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llmessage/llxorcipher.h (renamed from linden/indra/llmessage/llcrypto.h) | 61 |
1 files changed, 9 insertions, 52 deletions
diff --git a/linden/indra/llmessage/llcrypto.h b/linden/indra/llmessage/llxorcipher.h index b142d25..fbb879e 100644 --- a/linden/indra/llmessage/llcrypto.h +++ b/linden/indra/llmessage/llxorcipher.h | |||
@@ -1,8 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * @file llcrypto.h | 2 | * @file llxorcipher.h |
3 | * @brief llcrypto library module header. For now, all crypto classes | ||
4 | * are here, and as we grow the library, we can split these things | ||
5 | * out. | ||
6 | * | 3 | * |
7 | * Copyright (c) 2003-2007, Linden Research, Inc. | 4 | * Copyright (c) 2003-2007, Linden Research, Inc. |
8 | * | 5 | * |
@@ -27,50 +24,10 @@ | |||
27 | * COMPLETENESS OR PERFORMANCE. | 24 | * COMPLETENESS OR PERFORMANCE. |
28 | */ | 25 | */ |
29 | 26 | ||
30 | #ifndef LL_LLCRYPTO_H | 27 | #ifndef LLXORCIPHER_H |
31 | #define LL_LLCRYPTO_H | 28 | #define LLXORCIPHER_H |
32 | 29 | ||
33 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 30 | #include "llcipher.h" |
34 | // Class LLCipher | ||
35 | // | ||
36 | // Abstract base class for a cipher object. | ||
37 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
38 | |||
39 | class LLCipher | ||
40 | { | ||
41 | public: | ||
42 | virtual ~LLCipher() {} | ||
43 | |||
44 | // encrypt src and place result into dst. returns TRUE if | ||
45 | // encryption was successful, otherwise FALSE. | ||
46 | virtual BOOL encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len) = 0; | ||
47 | |||
48 | // decrypt src and place result into dst. returns TRUE if | ||
49 | // encryption was successful, otherwise FALSE. | ||
50 | virtual BOOL decrpyt(const U8* src, U32 src_len, U8* dst, U32 dst_len) = 0; | ||
51 | |||
52 | // returns the space required to encrypt for a unencrypted source | ||
53 | // buffer of length len. | ||
54 | virtual U32 requiredEncryptionSpace(U32 src_len) const = 0 ; | ||
55 | }; | ||
56 | |||
57 | |||
58 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
59 | // Class LLNullCipher | ||
60 | // | ||
61 | // A class which implements LLCipher, but does not transform src | ||
62 | // during encryption. | ||
63 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
64 | |||
65 | class LLNullCipher | ||
66 | { | ||
67 | public: | ||
68 | LLNullCipher() {} | ||
69 | virtual ~LLNullCipher() {} | ||
70 | virtual BOOL encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len); | ||
71 | virtual BOOL decrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len); | ||
72 | virtual U32 requiredEncryptionSpace(U32 src_len); | ||
73 | }; | ||
74 | 31 | ||
75 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 32 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
76 | // Class LLXORCipher | 33 | // Class LLXORCipher |
@@ -78,7 +35,7 @@ public: | |||
78 | // Implementation of LLCipher which encrypts using a XOR pad. | 35 | // Implementation of LLCipher which encrypts using a XOR pad. |
79 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 36 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
80 | 37 | ||
81 | class LLXORCipher | 38 | class LLXORCipher : public LLCipher |
82 | { | 39 | { |
83 | public: | 40 | public: |
84 | LLXORCipher(const U8* pad, U32 pad_len); | 41 | LLXORCipher(const U8* pad, U32 pad_len); |
@@ -87,9 +44,9 @@ public: | |||
87 | LLXORCipher& operator=(const LLXORCipher& cipher); | 44 | LLXORCipher& operator=(const LLXORCipher& cipher); |
88 | 45 | ||
89 | // Cipher functions | 46 | // Cipher functions |
90 | virtual BOOL encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len); | 47 | /*virtual*/ U32 encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len); |
91 | virtual BOOL decrypt(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); |
92 | virtual U32 requiredEncryptionSpace(U32 src_len); | 49 | /*virtual*/ U32 requiredEncryptionSpace(U32 src_len) const; |
93 | 50 | ||
94 | // special syntactic-sugar since xor can be performed in place. | 51 | // special syntactic-sugar since xor can be performed in place. |
95 | BOOL encrypt(U8* buf, U32 len) { return encrypt((const U8*)buf, len, buf, len); } | 52 | BOOL encrypt(U8* buf, U32 len) { return encrypt((const U8*)buf, len, buf, len); } |
@@ -108,4 +65,4 @@ protected: | |||
108 | U32 mPadLen; | 65 | U32 mPadLen; |
109 | }; | 66 | }; |
110 | 67 | ||
111 | #endif // LL_LLCRYPTO_H | 68 | #endif |