diff options
author | Jacek Antonelli | 2008-09-06 18:24:57 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-09-06 18:25:07 -0500 |
commit | 798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch) | |
tree | 1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/llcommon/llmd5.h | |
parent | Second Life viewer sources 1.20.15 (diff) | |
download | meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2 meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz |
Second Life viewer sources 1.21.0-RC
Diffstat (limited to 'linden/indra/llcommon/llmd5.h')
-rw-r--r-- | linden/indra/llcommon/llmd5.h | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/linden/indra/llcommon/llmd5.h b/linden/indra/llcommon/llmd5.h new file mode 100644 index 0000000..6d21b31 --- /dev/null +++ b/linden/indra/llcommon/llmd5.h | |||
@@ -0,0 +1,133 @@ | |||
1 | /** | ||
2 | * @file llmd5.h | ||
3 | * | ||
4 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | ||
5 | * | ||
6 | * Copyright (c) 2001-2008, Linden Research, Inc. | ||
7 | * | ||
8 | * Second Life Viewer Source Code | ||
9 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
10 | * to you under the terms of the GNU General Public License, version 2.0 | ||
11 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
12 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
13 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
14 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
15 | * | ||
16 | * There are special exceptions to the terms and conditions of the GPL as | ||
17 | * it is applied to this Source Code. View the full text of the exception | ||
18 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
19 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
20 | * | ||
21 | * By copying, modifying or distributing this software, you acknowledge | ||
22 | * that you have read and understood your obligations described above, | ||
23 | * and agree to abide by those obligations. | ||
24 | * | ||
25 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
26 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
27 | * COMPLETENESS OR PERFORMANCE. | ||
28 | * $/LicenseInfo$ | ||
29 | */ | ||
30 | |||
31 | #ifndef LL_LLMD5_H | ||
32 | #define LL_LLMD5_H | ||
33 | |||
34 | // LLMD5.CC - source code for the C++/object oriented translation and | ||
35 | // modification of MD5. | ||
36 | |||
37 | // Translation and modification (c) 1995 by Mordechai T. Abzug | ||
38 | |||
39 | // This translation/ modification is provided "as is," without express or | ||
40 | // implied warranty of any kind. | ||
41 | |||
42 | // The translator/ modifier does not claim (1) that MD5 will do what you think | ||
43 | // it does; (2) that this translation/ modification is accurate; or (3) that | ||
44 | // this software is "merchantible." (Language for this disclaimer partially | ||
45 | // copied from the disclaimer below). | ||
46 | |||
47 | /* based on: | ||
48 | |||
49 | MD5.H - header file for MD5C.C | ||
50 | MDDRIVER.C - test driver for MD2, MD4 and MD5 | ||
51 | |||
52 | Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All | ||
53 | rights reserved. | ||
54 | |||
55 | License to copy and use this software is granted provided that it | ||
56 | is identified as the "RSA Data Security, Inc. MD5 Message-Digest | ||
57 | Algorithm" in all material mentioning or referencing this software | ||
58 | or this function. | ||
59 | |||
60 | License is also granted to make and use derivative works provided | ||
61 | that such works are identified as "derived from the RSA Data | ||
62 | Security, Inc. MD5 Message-Digest Algorithm" in all material | ||
63 | mentioning or referencing the derived work. | ||
64 | |||
65 | RSA Data Security, Inc. makes no representations concerning either | ||
66 | the merchantability of this software or the suitability of this | ||
67 | software for any particular purpose. It is provided "as is" | ||
68 | without express or implied warranty of any kind. | ||
69 | |||
70 | These notices must be retained in any copies of any part of this | ||
71 | documentation and/or software. | ||
72 | |||
73 | */ | ||
74 | |||
75 | // use for the raw digest output | ||
76 | const int MD5RAW_BYTES = 16; | ||
77 | |||
78 | // use for outputting hex digests | ||
79 | const int MD5HEX_STR_SIZE = 33; // char hex[MD5HEX_STR_SIZE]; with null | ||
80 | const int MD5HEX_STR_BYTES = 32; // message system fixed size | ||
81 | |||
82 | class LLMD5 { | ||
83 | // first, some types: | ||
84 | typedef unsigned int uint4; // assumes integer is 4 words long | ||
85 | typedef unsigned short int uint2; // assumes short integer is 2 words long | ||
86 | typedef unsigned char uint1; // assumes char is 1 word long | ||
87 | |||
88 | // how many bytes to grab at a time when checking files | ||
89 | static const int BLOCK_LEN; | ||
90 | |||
91 | public: | ||
92 | // methods for controlled operation: | ||
93 | LLMD5 (); // simple initializer | ||
94 | void update (const uint1 *input, const uint4 input_length); | ||
95 | void update (std::istream& stream); | ||
96 | void update (FILE *file); | ||
97 | void finalize (); | ||
98 | |||
99 | // constructors for special circumstances. All these constructors finalize | ||
100 | // the MD5 context. | ||
101 | LLMD5 (const unsigned char *string); // digest string, finalize | ||
102 | LLMD5 (std::istream& stream); // digest stream, finalize | ||
103 | LLMD5 (FILE *file); // digest file, close, finalize | ||
104 | LLMD5 (const unsigned char *string, const unsigned int number); | ||
105 | |||
106 | // methods to acquire finalized result | ||
107 | void raw_digest(unsigned char *array); // provide 16-byte array for binary data | ||
108 | void hex_digest(char *string); // provide 33-byte array for ascii-hex string | ||
109 | friend std::ostream& operator<< (std::ostream&, LLMD5 context); | ||
110 | |||
111 | |||
112 | |||
113 | private: | ||
114 | |||
115 | |||
116 | // next, the private data: | ||
117 | uint4 state[4]; | ||
118 | uint4 count[2]; // number of *bits*, mod 2^64 | ||
119 | uint1 buffer[64]; // input buffer | ||
120 | uint1 digest[16]; | ||
121 | uint1 finalized; | ||
122 | |||
123 | // last, the private methods, mostly static: | ||
124 | void init (); // called by all constructors | ||
125 | void transform (const uint1 *buffer); // does the real update work. Note | ||
126 | // that length is implied to be 64. | ||
127 | |||
128 | static void encode (uint1 *dest, const uint4 *src, const uint4 length); | ||
129 | static void decode (uint4 *dest, const uint1 *src, const uint4 length); | ||
130 | |||
131 | }; | ||
132 | |||
133 | #endif // LL_LLMD5_H | ||