diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llmath/llmd5.h | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/llmath/llmd5.h')
-rw-r--r-- | linden/indra/llmath/llmd5.h | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/linden/indra/llmath/llmd5.h b/linden/indra/llmath/llmd5.h new file mode 100644 index 0000000..1874b45 --- /dev/null +++ b/linden/indra/llmath/llmd5.h | |||
@@ -0,0 +1,145 @@ | |||
1 | /** | ||
2 | * @file llmd5.h | ||
3 | * | ||
4 | * Copyright (c) 2001-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 LL_LLMD5_H | ||
28 | #define LL_LLMD5_H | ||
29 | |||
30 | // LLMD5.CC - source code for the C++/object oriented translation and | ||
31 | // modification of MD5. | ||
32 | |||
33 | // Translation and modification (c) 1995 by Mordechai T. Abzug | ||
34 | |||
35 | // This translation/ modification is provided "as is," without express or | ||
36 | // implied warranty of any kind. | ||
37 | |||
38 | // The translator/ modifier does not claim (1) that MD5 will do what you think | ||
39 | // it does; (2) that this translation/ modification is accurate; or (3) that | ||
40 | // this software is "merchantible." (Language for this disclaimer partially | ||
41 | // copied from the disclaimer below). | ||
42 | |||
43 | /* based on: | ||
44 | |||
45 | MD5.H - header file for MD5C.C | ||
46 | MDDRIVER.C - test driver for MD2, MD4 and MD5 | ||
47 | |||
48 | Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All | ||
49 | rights reserved. | ||
50 | |||
51 | License to copy and use this software is granted provided that it | ||
52 | is identified as the "RSA Data Security, Inc. MD5 Message-Digest | ||
53 | Algorithm" in all material mentioning or referencing this software | ||
54 | or this function. | ||
55 | |||
56 | License is also granted to make and use derivative works provided | ||
57 | that such works are identified as "derived from the RSA Data | ||
58 | Security, Inc. MD5 Message-Digest Algorithm" in all material | ||
59 | mentioning or referencing the derived work. | ||
60 | |||
61 | RSA Data Security, Inc. makes no representations concerning either | ||
62 | the merchantability of this software or the suitability of this | ||
63 | software for any particular purpose. It is provided "as is" | ||
64 | without express or implied warranty of any kind. | ||
65 | |||
66 | These notices must be retained in any copies of any part of this | ||
67 | documentation and/or software. | ||
68 | |||
69 | */ | ||
70 | |||
71 | #include <stdio.h> | ||
72 | #include <iosfwd> | ||
73 | |||
74 | // use for the raw digest output | ||
75 | const int MD5RAW_BYTES = 16; | ||
76 | |||
77 | // use for outputting hex digests | ||
78 | const int MD5HEX_STR_SIZE = 33; // char hex[MD5HEX_STR_SIZE]; with null | ||
79 | const int MD5HEX_STR_BYTES = 32; // message system fixed size | ||
80 | |||
81 | class LLMD5 { | ||
82 | // first, some types: | ||
83 | typedef unsigned int uint4; // assumes integer is 4 words long | ||
84 | typedef unsigned short int uint2; // assumes short integer is 2 words long | ||
85 | typedef unsigned char uint1; // assumes char is 1 word long | ||
86 | |||
87 | public: | ||
88 | // methods for controlled operation: | ||
89 | LLMD5 (); // simple initializer | ||
90 | void update (const uint1 *input, const uint4 input_length); | ||
91 | void update (std::istream& stream); | ||
92 | void update (FILE *file); | ||
93 | void update (llifstream& stream); | ||
94 | void finalize (); | ||
95 | |||
96 | // constructors for special circumstances. All these constructors finalize | ||
97 | // the MD5 context. | ||
98 | LLMD5 (const unsigned char *string); // digest string, finalize | ||
99 | LLMD5 (std::istream& stream); // digest stream, finalize | ||
100 | LLMD5 (FILE *file); // digest file, close, finalize | ||
101 | LLMD5 (llifstream& stream); // digest stream, close, finalize | ||
102 | LLMD5 (const unsigned char *string, const unsigned int number); | ||
103 | |||
104 | // methods to acquire finalized result | ||
105 | void raw_digest(unsigned char *array); // provide 16-byte array for binary data | ||
106 | void hex_digest(char *string); // provide 33-byte array for ascii-hex string | ||
107 | friend std::ostream& operator<< (std::ostream&, LLMD5 context); | ||
108 | |||
109 | |||
110 | |||
111 | private: | ||
112 | |||
113 | |||
114 | // next, the private data: | ||
115 | uint4 state[4]; | ||
116 | uint4 count[2]; // number of *bits*, mod 2^64 | ||
117 | uint1 buffer[64]; // input buffer | ||
118 | uint1 digest[16]; | ||
119 | uint1 finalized; | ||
120 | |||
121 | // last, the private methods, mostly static: | ||
122 | void init (); // called by all constructors | ||
123 | void transform (const uint1 *buffer); // does the real update work. Note | ||
124 | // that length is implied to be 64. | ||
125 | |||
126 | static void encode (uint1 *dest, const uint4 *src, const uint4 length); | ||
127 | static void decode (uint4 *dest, const uint1 *src, const uint4 length); | ||
128 | |||
129 | static inline uint4 rotate_left (uint4 x, uint4 n); | ||
130 | static inline uint4 F (uint4 x, uint4 y, uint4 z); | ||
131 | static inline uint4 G (uint4 x, uint4 y, uint4 z); | ||
132 | static inline uint4 H (uint4 x, uint4 y, uint4 z); | ||
133 | static inline uint4 I (uint4 x, uint4 y, uint4 z); | ||
134 | static inline void FF (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, | ||
135 | uint4 s, uint4 ac); | ||
136 | static inline void GG (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, | ||
137 | uint4 s, uint4 ac); | ||
138 | static inline void HH (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, | ||
139 | uint4 s, uint4 ac); | ||
140 | static inline void II (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, | ||
141 | uint4 s, uint4 ac); | ||
142 | |||
143 | }; | ||
144 | |||
145 | #endif // LL_LLMD5_H | ||