Mercurial > mplayer.hg
annotate libvo/md5sum.c @ 17925:caa86b1793fe
Move audio_delay to a property and add a few read only properties to
query samplerate, format, etc.
author | albeu |
---|---|
date | Wed, 22 Mar 2006 23:05:13 +0000 |
parents | 401b440a6d76 |
children | 0783dd397f74 |
rev | line source |
---|---|
13395
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
1 /* ========================================================================== ** |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
2 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
3 * MD5.c |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
4 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
5 * Copyright: |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
6 * Copyright (C) 2003, 2004 by Christopher R. Hertel |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
7 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
8 * Email: crh@ubiqx.mn.org |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
9 * |
15164
31109192db12
Mark imported files from uCIFS library as changed for GPL ¡ø2a compliance.
diego
parents:
13395
diff
changeset
|
10 * Modified for use with MPlayer, detailed CVS changelog at |
31109192db12
Mark imported files from uCIFS library as changed for GPL ¡ø2a compliance.
diego
parents:
13395
diff
changeset
|
11 * http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/ |
13395
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
12 * $Id$ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
13 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
14 * -------------------------------------------------------------------------- ** |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
15 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
16 * Description: |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
17 * Implements the MD5 hash algorithm, as described in RFC 1321. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
18 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
19 * -------------------------------------------------------------------------- ** |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
20 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
21 * License: |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
22 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
23 * This library is free software; you can redistribute it and/or |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
24 * modify it under the terms of the GNU Lesser General Public |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
25 * License as published by the Free Software Foundation; either |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
26 * version 2.1 of the License, or (at your option) any later version. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
27 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
28 * This library is distributed in the hope that it will be useful, |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
31 * Lesser General Public License for more details. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
32 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
33 * You should have received a copy of the GNU Lesser General Public |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
34 * License along with this library; if not, write to the Free Software |
17367
401b440a6d76
Update licensing information: The FSF changed postal address.
diego
parents:
15164
diff
changeset
|
35 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
13395
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
36 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
37 * -------------------------------------------------------------------------- ** |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
38 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
39 * Notes: |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
40 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
41 * None of this will make any sense unless you're studying RFC 1321 as you |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
42 * read the code. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
43 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
44 * MD5 is described in RFC 1321. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
45 * The MD*4* algorithm is described in RFC 1320 (that's 1321 - 1). |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
46 * MD5 is very similar to MD4, but not quite similar enough to justify |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
47 * putting the two into a single module. Besides, I wanted to add a few |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
48 * extra functions to this one to expand its usability. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
49 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
50 * There are three primary motivations for this particular implementation. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
51 * 1) Programmer's pride. I wanted to be able to say I'd done it, and I |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
52 * wanted to learn from the experience. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
53 * 2) Portability. I wanted an implementation that I knew to be portable |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
54 * to a reasonable number platforms. In particular, the algorithm is |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
55 * designed with little-endian platforms in mind, but I wanted an |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
56 * endian-agnostic implementation. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
57 * 3) Compactness. While not an overriding goal, I thought it worth-while |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
58 * to see if I could reduce the overall size of the result. This is in |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
59 * keeping with my hopes that this library will be suitable for use in |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
60 * some embedded environments. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
61 * Beyond that, cleanliness and clarity are always worth pursuing. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
62 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
63 * As mentioned above, the code really only makes sense if you are familiar |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
64 * with the MD5 algorithm or are using RFC 1321 as a guide. This code is |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
65 * quirky, however, so you'll want to be reading carefully. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
66 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
67 * Yeah...most of the comments are cut-and-paste from my MD4 implementation. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
68 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
69 * -------------------------------------------------------------------------- ** |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
70 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
71 * References: |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
72 * IETF RFC 1321: The MD5 Message-Digest Algorithm |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
73 * Ron Rivest. IETF, April, 1992 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
74 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
75 * ========================================================================== ** |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
76 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
77 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
78 /* #include "MD5.h" Line of original code */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
79 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
80 #include "md5sum.h" /* Added this line */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
81 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
82 /* -------------------------------------------------------------------------- ** |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
83 * Static Constants: |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
84 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
85 * K[][] - In round one, the values of k (which are used to index |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
86 * particular four-byte sequences in the input) are simply |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
87 * sequential. In later rounds, however, they are a bit more |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
88 * varied. Rather than calculate the values of k (which may |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
89 * or may not be possible--I haven't though about it) the |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
90 * values are stored in this array. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
91 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
92 * S[][] - In each round there is a left rotate operation performed as |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
93 * part of the 16 permutations. The number of bits varies in |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
94 * a repeating patter. This array keeps track of the patterns |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
95 * used in each round. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
96 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
97 * T[][] - There are four rounds of 16 permutations for a total of 64. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
98 * In each of these 64 permutation operations, a different |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
99 * constant value is added to the mix. The constants are |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
100 * based on the sine function...read RFC 1321 for more detail. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
101 * In any case, the correct constants are stored in the T[][] |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
102 * array. They're divided up into four groups of 16. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
103 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
104 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
105 static const uint8_t K[3][16] = |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
106 { |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
107 /* Round 1: skipped (since it is simply sequential). */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
108 { 1, 6, 11, 0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12 }, /* R2 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
109 { 5, 8, 11, 14, 1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15, 2 }, /* R3 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
110 { 0, 7, 14, 5, 12, 3, 10, 1, 8, 15, 6, 13, 4, 11, 2, 9 } /* R4 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
111 }; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
112 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
113 static const uint8_t S[4][4] = |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
114 { |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
115 { 7, 12, 17, 22 }, /* Round 1 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
116 { 5, 9, 14, 20 }, /* Round 2 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
117 { 4, 11, 16, 23 }, /* Round 3 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
118 { 6, 10, 15, 21 } /* Round 4 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
119 }; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
120 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
121 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
122 static const uint32_t T[4][16] = |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
123 { |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
124 { 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, /* Round 1 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
125 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
126 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
127 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821 }, |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
128 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
129 { 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, /* Round 2 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
130 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8, |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
131 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
132 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a }, |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
133 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
134 { 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, /* Round 3 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
135 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70, |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
136 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05, |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
137 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665 }, |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
138 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
139 { 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, /* Round 4 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
140 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1, |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
141 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
142 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391 }, |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
143 }; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
144 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
145 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
146 /* -------------------------------------------------------------------------- ** |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
147 * Macros: |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
148 * md5F(), md5G(), md5H(), and md5I() are described in RFC 1321. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
149 * All of these operations are bitwise, and so not impacted by endian-ness. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
150 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
151 * GetLongByte() |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
152 * Extract one byte from a (32-bit) longword. A value of 0 for <idx> |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
153 * indicates the lowest order byte, while 3 indicates the highest order |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
154 * byte. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
155 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
156 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
157 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
158 #define md5F( X, Y, Z ) ( ((X) & (Y)) | ((~(X)) & (Z)) ) |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
159 #define md5G( X, Y, Z ) ( ((X) & (Z)) | ((Y) & (~(Z))) ) |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
160 #define md5H( X, Y, Z ) ( (X) ^ (Y) ^ (Z) ) |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
161 #define md5I( X, Y, Z ) ( (Y) ^ ((X) | (~(Z))) ) |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
162 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
163 #define GetLongByte( L, idx ) ((uchar)(( L >> (((idx) & 0x03) << 3) ) & 0xFF)) |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
164 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
165 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
166 /* -------------------------------------------------------------------------- ** |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
167 * Static Functions: |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
168 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
169 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
170 static void Permute( uint32_t ABCD[4], const uchar block[64] ) |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
171 /* ------------------------------------------------------------------------ ** |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
172 * Permute the ABCD "registers" using the 64-byte <block> as a driver. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
173 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
174 * Input: ABCD - Pointer to an array of four unsigned longwords. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
175 * block - An array of bytes, 64 bytes in size. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
176 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
177 * Output: none. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
178 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
179 * Notes: The MD5 algorithm operates on a set of four longwords stored |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
180 * (conceptually) in four "registers". It is easy to imagine a |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
181 * simple MD4/5 chip that would operate this way. In any case, |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
182 * the mangling of the contents of those registers is driven by |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
183 * the input message. The message is chopped and finally padded |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
184 * into 64-byte chunks and each chunk is used to manipulate the |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
185 * contents of the registers. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
186 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
187 * The MD5 Algorithm calls for padding the input to ensure that |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
188 * it is a multiple of 64 bytes in length. The last 16 bytes |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
189 * of the padding space are used to store the message length |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
190 * (the length of the original message, before padding, expressed |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
191 * in terms of bits). If there is not enough room for 16 bytes |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
192 * worth of bitcount (eg., if the original message was 122 bytes |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
193 * long) then the block is padded to the end with zeros and |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
194 * passed to this function. Then *another* block is filled with |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
195 * zeros except for the last 16 bytes which contain the length. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
196 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
197 * Oh... and the algorithm requires that there be at least one |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
198 * padding byte. The first padding byte has a value of 0x80, |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
199 * and any others are 0x00. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
200 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
201 * ------------------------------------------------------------------------ ** |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
202 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
203 { |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
204 int round; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
205 int i, j; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
206 uint8_t s; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
207 uint32_t a, b, c, d; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
208 uint32_t KeepABCD[4]; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
209 uint32_t X[16]; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
210 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
211 /* Store the current ABCD values for later re-use. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
212 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
213 for( i = 0; i < 4; i++ ) |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
214 KeepABCD[i] = ABCD[i]; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
215 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
216 /* Convert the input block into an array of unsigned longs, taking care |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
217 * to read the block in Little Endian order (the algorithm assumes this). |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
218 * The uint32_t values are then handled in host order. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
219 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
220 for( i = 0, j = 0; i < 16; i++ ) |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
221 { |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
222 X[i] = (uint32_t)block[j++]; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
223 X[i] |= ((uint32_t)block[j++] << 8); |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
224 X[i] |= ((uint32_t)block[j++] << 16); |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
225 X[i] |= ((uint32_t)block[j++] << 24); |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
226 } |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
227 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
228 /* This loop performs the four rounds of permutations. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
229 * The rounds are each very similar. The differences are in three areas: |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
230 * - The function (F, G, H, or I) used to perform bitwise permutations |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
231 * on the registers, |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
232 * - The order in which values from X[] are chosen. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
233 * - Changes to the number of bits by which the registers are rotated. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
234 * This implementation uses a switch statement to deal with some of the |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
235 * differences between rounds. Other differences are handled by storing |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
236 * values in arrays and using the round number to select the correct set |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
237 * of values. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
238 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
239 * (My implementation appears to be a poor compromise between speed, size, |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
240 * and clarity. Ugh. [crh]) |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
241 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
242 for( round = 0; round < 4; round++ ) |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
243 { |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
244 for( i = 0; i < 16; i++ ) |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
245 { |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
246 j = (4 - (i % 4)) & 0x3; /* <j> handles the rotation of ABCD. */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
247 s = S[round][i%4]; /* <s> is the bit shift for this iteration. */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
248 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
249 b = ABCD[(j+1) & 0x3]; /* Copy the b,c,d values per ABCD rotation. */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
250 c = ABCD[(j+2) & 0x3]; /* This isn't really necessary, it just looks */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
251 d = ABCD[(j+3) & 0x3]; /* clean & will hopefully be optimized away. */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
252 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
253 /* The actual perumation function. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
254 * This is broken out to minimize the code within the switch(). |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
255 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
256 switch( round ) |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
257 { |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
258 case 0: |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
259 /* round 1 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
260 a = md5F( b, c, d ) + X[i]; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
261 break; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
262 case 1: |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
263 /* round 2 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
264 a = md5G( b, c, d ) + X[ K[0][i] ]; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
265 break; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
266 case 2: |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
267 /* round 3 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
268 a = md5H( b, c, d ) + X[ K[1][i] ]; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
269 break; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
270 default: |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
271 /* round 4 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
272 a = md5I( b, c, d ) + X[ K[2][i] ]; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
273 break; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
274 } |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
275 a = 0xFFFFFFFF & ( ABCD[j] + a + T[round][i] ); |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
276 ABCD[j] = b + (0xFFFFFFFF & (( a << s ) | ( a >> (32 - s) ))); |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
277 } |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
278 } |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
279 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
280 /* Use the stored original A, B, C, D values to perform |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
281 * one last convolution. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
282 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
283 for( i = 0; i < 4; i++ ) |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
284 ABCD[i] = 0xFFFFFFFF & ( ABCD[i] + KeepABCD[i] ); |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
285 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
286 } /* Permute */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
287 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
288 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
289 /* -------------------------------------------------------------------------- ** |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
290 * Functions: |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
291 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
292 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
293 auth_md5Ctx *auth_md5InitCtx( auth_md5Ctx *ctx ) |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
294 /* ------------------------------------------------------------------------ ** |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
295 * Initialize an MD5 context. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
296 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
297 * Input: ctx - A pointer to the MD5 context structure to be initialized. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
298 * Contexts are typically created thusly: |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
299 * ctx = (auth_md5Ctx *)malloc( sizeof(auth_md5Ctx) ); |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
300 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
301 * Output: A pointer to the initialized context (same as <ctx>). |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
302 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
303 * Notes: The purpose of the context is to make it possible to generate |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
304 * an MD5 Message Digest in stages, rather than having to pass a |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
305 * single large block to a single MD5 function. The context |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
306 * structure keeps track of various bits of state information. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
307 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
308 * Once the context is initialized, the blocks of message data |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
309 * are passed to the <auth_md5SumCtx()> function. Once the |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
310 * final bit of data has been handed to <auth_md5SumCtx()> the |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
311 * context can be closed out by calling <auth_md5CloseCtx()>, |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
312 * which also calculates the final MD5 result. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
313 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
314 * Don't forget to free an allocated context structure when |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
315 * you've finished using it. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
316 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
317 * See Also: <auth_md5SumCtx()>, <auth_md5CloseCtx()> |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
318 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
319 * ------------------------------------------------------------------------ ** |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
320 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
321 { |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
322 ctx->len = 0; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
323 ctx->b_used = 0; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
324 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
325 ctx->ABCD[0] = 0x67452301; /* The array ABCD[] contains the four 4-byte */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
326 ctx->ABCD[1] = 0xefcdab89; /* "registers" that are manipulated to */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
327 ctx->ABCD[2] = 0x98badcfe; /* produce the MD5 digest. The input acts */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
328 ctx->ABCD[3] = 0x10325476; /* upon the registers, not the other way */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
329 /* 'round. The initial values are those */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
330 /* given in RFC 1321 (pg. 4). Note, however, that RFC 1321 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
331 /* provides these values as bytes, not as longwords, and the */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
332 /* bytes are arranged in little-endian order as if they were */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
333 /* the bytes of (little endian) 32-bit ints. That's */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
334 /* confusing as all getout (to me, anyway). The values given */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
335 /* here are provided as 32-bit values in C language format, */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
336 /* so they are endian-agnostic. */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
337 return( ctx ); |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
338 } /* auth_md5InitCtx */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
339 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
340 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
341 auth_md5Ctx *auth_md5SumCtx( auth_md5Ctx *ctx, |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
342 const uchar *src, |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
343 const int len ) |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
344 /* ------------------------------------------------------------------------ ** |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
345 * Build an MD5 Message Digest within the given context. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
346 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
347 * Input: ctx - Pointer to the context in which the MD5 sum is being |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
348 * built. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
349 * src - A chunk of source data. This will be used to drive |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
350 * the MD5 algorithm. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
351 * len - The number of bytes in <src>. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
352 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
353 * Output: A pointer to the updated context (same as <ctx>). |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
354 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
355 * See Also: <auth_md5InitCtx()>, <auth_md5CloseCtx()>, <auth_md5Sum()> |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
356 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
357 * ------------------------------------------------------------------------ ** |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
358 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
359 { |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
360 int i; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
361 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
362 /* Add the new block's length to the total length. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
363 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
364 ctx->len += (uint32_t)len; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
365 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
366 /* Copy the new block's data into the context block. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
367 * Call the Permute() function whenever the context block is full. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
368 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
369 for( i = 0; i < len; i++ ) |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
370 { |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
371 ctx->block[ ctx->b_used ] = src[i]; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
372 (ctx->b_used)++; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
373 if( 64 == ctx->b_used ) |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
374 { |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
375 Permute( ctx->ABCD, ctx->block ); |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
376 ctx->b_used = 0; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
377 } |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
378 } |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
379 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
380 /* Return the updated context. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
381 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
382 return( ctx ); |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
383 } /* auth_md5SumCtx */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
384 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
385 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
386 auth_md5Ctx *auth_md5CloseCtx( auth_md5Ctx *ctx, uchar *dst ) |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
387 /* ------------------------------------------------------------------------ ** |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
388 * Close an MD5 Message Digest context and generate the final MD5 sum. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
389 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
390 * Input: ctx - Pointer to the context in which the MD5 sum is being |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
391 * built. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
392 * dst - A pointer to at least 16 bytes of memory, which will |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
393 * receive the finished MD5 sum. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
394 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
395 * Output: A pointer to the closed context (same as <ctx>). |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
396 * You might use this to free a malloc'd context structure. :) |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
397 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
398 * Notes: The context (<ctx>) is returned in an undefined state. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
399 * It must be re-initialized before re-use. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
400 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
401 * See Also: <auth_md5InitCtx()>, <auth_md5SumCtx()> |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
402 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
403 * ------------------------------------------------------------------------ ** |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
404 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
405 { |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
406 int i; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
407 uint32_t l; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
408 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
409 /* Add the required 0x80 padding initiator byte. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
410 * The auth_md5SumCtx() function always permutes and resets the context |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
411 * block when it gets full, so we know that there must be at least one |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
412 * free byte in the context block. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
413 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
414 ctx->block[ctx->b_used] = 0x80; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
415 (ctx->b_used)++; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
416 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
417 /* Zero out any remaining free bytes in the context block. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
418 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
419 for( i = ctx->b_used; i < 64; i++ ) |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
420 ctx->block[i] = 0; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
421 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
422 /* We need 8 bytes to store the length field. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
423 * If we don't have 8, call Permute() and reset the context block. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
424 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
425 if( 56 < ctx->b_used ) |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
426 { |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
427 Permute( ctx->ABCD, ctx->block ); |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
428 for( i = 0; i < 64; i++ ) |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
429 ctx->block[i] = 0; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
430 } |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
431 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
432 /* Add the total length and perform the final perumation. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
433 * Note: The 60'th byte is read from the *original* <ctx->len> value |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
434 * and shifted to the correct position. This neatly avoids |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
435 * any MAXINT numeric overflow issues. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
436 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
437 l = ctx->len << 3; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
438 for( i = 0; i < 4; i++ ) |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
439 ctx->block[56+i] |= GetLongByte( l, i ); |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
440 ctx->block[60] = ((GetLongByte( ctx->len, 3 ) & 0xE0) >> 5); /* See Above! */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
441 Permute( ctx->ABCD, ctx->block ); |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
442 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
443 /* Now copy the result into the output buffer and we're done. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
444 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
445 for( i = 0; i < 4; i++ ) |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
446 { |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
447 dst[ 0+i] = GetLongByte( ctx->ABCD[0], i ); |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
448 dst[ 4+i] = GetLongByte( ctx->ABCD[1], i ); |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
449 dst[ 8+i] = GetLongByte( ctx->ABCD[2], i ); |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
450 dst[12+i] = GetLongByte( ctx->ABCD[3], i ); |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
451 } |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
452 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
453 /* Return the context. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
454 * This is done for compatibility with the other auth_md5*Ctx() functions. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
455 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
456 return( ctx ); |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
457 } /* auth_md5CloseCtx */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
458 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
459 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
460 uchar *auth_md5Sum( uchar *dst, const uchar *src, const int len ) |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
461 /* ------------------------------------------------------------------------ ** |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
462 * Compute an MD5 message digest. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
463 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
464 * Input: dst - Destination buffer into which the result will be written. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
465 * Must be 16 bytes, minimum. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
466 * src - Source data block to be MD5'd. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
467 * len - The length, in bytes, of the source block. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
468 * (Note that the length is given in bytes, not bits.) |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
469 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
470 * Output: A pointer to <dst>, which will contain the calculated 16-byte |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
471 * MD5 message digest. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
472 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
473 * Notes: This function is a shortcut. It takes a single input block. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
474 * For more drawn-out operations, see <auth_md5InitCtx()>. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
475 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
476 * This function is interface-compatible with the |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
477 * <auth_md4Sum()> function in the MD4 module. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
478 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
479 * The MD5 algorithm is designed to work on data with an |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
480 * arbitrary *bit* length. Most implementations, this one |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
481 * included, handle the input data in byte-sized chunks. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
482 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
483 * The MD5 algorithm does much of its work using four-byte |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
484 * words, and so can be tuned for speed based on the endian-ness |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
485 * of the host. This implementation is intended to be |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
486 * endian-neutral, which may make it a teeny bit slower than |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
487 * others. ...maybe. |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
488 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
489 * See Also: <auth_md5InitCtx()> |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
490 * |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
491 * ------------------------------------------------------------------------ ** |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
492 */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
493 { |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
494 auth_md5Ctx ctx[1]; |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
495 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
496 (void)auth_md5InitCtx( ctx ); /* Open a context. */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
497 (void)auth_md5SumCtx( ctx, src, len ); /* Pass only one block. */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
498 (void)auth_md5CloseCtx( ctx, dst ); /* Close the context. */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
499 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
500 return( dst ); /* Makes life easy. */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
501 } /* auth_md5Sum */ |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
502 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
503 |
07708ec98d87
New MD5 sum video output driver. For every frame, it calculates the MD5 sum
ivo
parents:
diff
changeset
|
504 /* ========================================================================== */ |