Mercurial > audlegacy-plugins
annotate src/daap/xmms2-daap/daap_md5.c @ 2601:f9ccfae6a5f6
Oops, forgot to link scrobbler plugin with libaudutil. Fixed.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 21 May 2008 09:08:05 +0300 |
parents | 776dd8fc2b38 |
children | f1b6f1b2cdb3 |
rev | line source |
---|---|
1407
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
1 /** @file daap_md5.c |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
2 * |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
3 * Implementation of DAAP (iTunes Music Sharing) hashing, parsing, connection |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
4 * Slightly modified for use in XMMS2 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
5 * |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
6 * Copyright (C) 2004,2005 Charles Schmidt <cschmidt2@emich.edu> |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
7 * |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
8 * This program is free software; you can redistribute it and/or modify |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
11 * (at your option) any later version. |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
12 * |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
16 * GNU General Public License for more details. |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
17 * |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
19 * along with this program; if not, write to the Free Software |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
21 * |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
22 */ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
23 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
24 #include <stdio.h> |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
25 #include <string.h> |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
26 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
27 #include "daap_md5.h" |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
28 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
29 /* hashing - based on/copied from libopendaap |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
30 * Copyright (c) 2004 David Hammerton |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
31 */ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
32 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
33 typedef struct { |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
34 guint32 buf[4]; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
35 guint32 bits[2]; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
36 unsigned char in[64]; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
37 int version; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
38 } MD5_CTX; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
39 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
40 /* |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
41 * This code implements the MD5 message-digest algorithm. |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
42 * The algorithm is due to Ron Rivest. This code was |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
43 * written by Colin Plumb in 1993, no copyright is claimed. |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
44 * This code is in the public domain; do with it what you wish. |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
45 * |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
46 * Equivalent code is available from RSA Data Security, Inc. |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
47 * This code has been tested against that, and is equivalent, |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
48 * except that you don't need to include two pages of legalese |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
49 * with every copy. |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
50 * |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
51 * To compute the message digest of a chunk of bytes, declare an MD5Context |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
52 * structure, pass it to OpenDaap_MD5Init, call OpenDaap_MD5Update as needed |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
53 * on buffers full of bytes, and then call OpenDaap_MD5Final, which will fill |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
54 * a supplied 16-byte array with the digest. |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
55 */ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
56 static void |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
57 MD5Transform (guint32 buf[4], |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
58 guint32 const in[16], |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
59 gint version); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
60 /* for some reason we still have to reverse bytes on bigendian machines |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
61 * I don't really know why... but otherwise it fails.. |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
62 * Any MD5 gurus out there know why??? |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
63 */ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
64 #if 0 //ndef WORDS_BIGENDIAN /* was: HIGHFIRST */ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
65 #define byteReverse (buf, len) /* Nothing */ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
66 #else |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
67 static void |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
68 byteReverse (unsigned char *buf, |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
69 unsigned longs); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
70 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
71 #ifndef ASM_MD5 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
72 /* |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
73 * Note: this code is harmless on little-endian machines. |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
74 */ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
75 static void |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
76 byteReverse (unsigned char *buf, |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
77 unsigned longs) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
78 { |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
79 guint32 t; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
80 do { |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
81 t = (guint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 | |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
82 ((unsigned) buf[1] << 8 | buf[0]); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
83 *(guint32 *) buf = t; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
84 buf += 4; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
85 } while (--longs); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
86 } |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
87 #endif /* ! ASM_MD5 */ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
88 #endif /* #if 0 */ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
89 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
90 static void |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
91 OpenDaap_MD5Init (MD5_CTX *ctx, |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
92 gint version) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
93 { |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
94 memset (ctx, 0, sizeof (MD5_CTX)); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
95 ctx->buf[0] = 0x67452301; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
96 ctx->buf[1] = 0xefcdab89; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
97 ctx->buf[2] = 0x98badcfe; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
98 ctx->buf[3] = 0x10325476; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
99 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
100 ctx->bits[0] = 0; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
101 ctx->bits[1] = 0; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
102 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
103 ctx->version = version; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
104 } |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
105 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
106 static void |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
107 OpenDaap_MD5Update (MD5_CTX *ctx, |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
108 unsigned char const *buf, |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
109 unsigned int len) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
110 { |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
111 guint32 t; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
112 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
113 /* Update bitcount */ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
114 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
115 t = ctx->bits[0]; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
116 if ((ctx->bits[0] = t + ((guint32) len << 3)) < t) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
117 ctx->bits[1]++; /* Carry from low to high */ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
118 ctx->bits[1] += len >> 29; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
119 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
120 t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
121 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
122 /* Handle any leading odd-sized chunks */ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
123 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
124 if (t) { |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
125 unsigned char *p = (unsigned char *) ctx->in + t; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
126 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
127 t = 64 - t; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
128 if (len < t) { |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
129 memcpy (p, buf, len); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
130 return; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
131 } |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
132 memcpy (p, buf, t); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
133 byteReverse (ctx->in, 16); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
134 MD5Transform (ctx->buf, (guint32 *) ctx->in, ctx->version); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
135 buf += t; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
136 len -= t; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
137 } |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
138 /* Process data in 64-byte chunks */ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
139 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
140 while (len >= 64) { |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
141 memcpy (ctx->in, buf, 64); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
142 byteReverse (ctx->in, 16); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
143 MD5Transform (ctx->buf, (guint32 *) ctx->in, ctx->version); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
144 buf += 64; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
145 len -= 64; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
146 } |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
147 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
148 /* Handle any remaining bytes of data. */ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
149 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
150 memcpy (ctx->in, buf, len); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
151 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
152 } |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
153 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
154 static void |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
155 OpenDaap_MD5Final (MD5_CTX *ctx, |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
156 unsigned char digest[16]) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
157 { |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
158 unsigned count; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
159 unsigned char *p; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
160 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
161 /* Compute number of bytes mod 64 */ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
162 count = (ctx->bits[0] >> 3) & 0x3F; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
163 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
164 /* Set the first char of padding to 0x80. This is safe since there is |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
165 always at least one byte free */ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
166 p = ctx->in + count; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
167 *p++ = 0x80; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
168 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
169 /* Bytes of padding needed to make 64 bytes */ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
170 count = 64 - 1 - count; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
171 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
172 /* Pad out to 56 mod 64 */ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
173 if (count < 8) { |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
174 /* Two lots of padding: Pad the first block to 64 bytes */ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
175 memset (p, 0, count); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
176 byteReverse (ctx->in, 16); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
177 MD5Transform (ctx->buf, (guint32 *) ctx->in, ctx->version); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
178 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
179 /* Now fill the next block with 56 bytes */ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
180 memset (ctx->in, 0, 56); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
181 } else { |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
182 /* Pad block to 56 bytes */ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
183 memset (p, 0, count - 8); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
184 } |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
185 byteReverse (ctx->in, 14); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
186 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
187 /* Append length in bits and transform */ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
188 ((guint32 *) ctx->in)[14] = ctx->bits[0]; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
189 ((guint32 *) ctx->in)[15] = ctx->bits[1]; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
190 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
191 MD5Transform (ctx->buf, (guint32 *) ctx->in, ctx->version); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
192 byteReverse ((unsigned char *) ctx->buf, 4); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
193 memcpy (digest, ctx->buf, 16); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
194 memset (ctx, 0, sizeof (ctx)); /* In case it's sensitive */ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
195 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
196 return; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
197 } |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
198 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
199 #ifndef ASM_MD5 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
200 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
201 /* The four core functions - F1 is optimized somewhat */ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
202 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
203 /* #define F1(x, y, z) (x & y | ~x & z) */ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
204 #define F1(x, y, z) (z ^ (x & (y ^ z))) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
205 #define F2(x, y, z) F1 (z, x, y) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
206 #define F3(x, y, z) (x ^ y ^ z) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
207 #define F4(x, y, z) (y ^ (x | ~z)) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
208 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
209 /* This is the central step in the MD5 algorithm. */ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
210 #define MD5STEP(f, w, x, y, z, data, s) \ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
211 ( w += f (x, y, z) + data, w = w<<s | w>>(32-s), w += x ) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
212 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
213 /* |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
214 * The core of the MD5 algorithm, this alters an existing MD5 hash to reflect |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
215 * the addition of 16 longwords of new data. OpenDaap_MD5Update blocks the |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
216 * data and converts bytes into longwords for this routine. |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
217 */ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
218 static void |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
219 MD5Transform (guint32 buf[4], |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
220 guint32 const in[16], |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
221 gint version) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
222 { |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
223 guint32 a, b, c, d; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
224 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
225 a = buf[0]; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
226 b = buf[1]; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
227 c = buf[2]; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
228 d = buf[3]; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
229 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
230 MD5STEP (F1, a, b, c, d, in[0] + 0xd76aa478, 7); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
231 MD5STEP (F1, d, a, b, c, in[1] + 0xe8c7b756, 12); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
232 MD5STEP (F1, c, d, a, b, in[2] + 0x242070db, 17); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
233 MD5STEP (F1, b, c, d, a, in[3] + 0xc1bdceee, 22); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
234 MD5STEP (F1, a, b, c, d, in[4] + 0xf57c0faf, 7); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
235 MD5STEP (F1, d, a, b, c, in[5] + 0x4787c62a, 12); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
236 MD5STEP (F1, c, d, a, b, in[6] + 0xa8304613, 17); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
237 MD5STEP (F1, b, c, d, a, in[7] + 0xfd469501, 22); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
238 MD5STEP (F1, a, b, c, d, in[8] + 0x698098d8, 7); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
239 MD5STEP (F1, d, a, b, c, in[9] + 0x8b44f7af, 12); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
240 MD5STEP (F1, c, d, a, b, in[10] + 0xffff5bb1, 17); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
241 MD5STEP (F1, b, c, d, a, in[11] + 0x895cd7be, 22); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
242 MD5STEP (F1, a, b, c, d, in[12] + 0x6b901122, 7); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
243 MD5STEP (F1, d, a, b, c, in[13] + 0xfd987193, 12); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
244 MD5STEP (F1, c, d, a, b, in[14] + 0xa679438e, 17); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
245 MD5STEP (F1, b, c, d, a, in[15] + 0x49b40821, 22); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
246 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
247 MD5STEP (F2, a, b, c, d, in[1] + 0xf61e2562, 5); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
248 MD5STEP (F2, d, a, b, c, in[6] + 0xc040b340, 9); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
249 MD5STEP (F2, c, d, a, b, in[11] + 0x265e5a51, 14); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
250 MD5STEP (F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
251 MD5STEP (F2, a, b, c, d, in[5] + 0xd62f105d, 5); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
252 MD5STEP (F2, d, a, b, c, in[10] + 0x02441453, 9); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
253 MD5STEP (F2, c, d, a, b, in[15] + 0xd8a1e681, 14); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
254 MD5STEP (F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
255 MD5STEP (F2, a, b, c, d, in[9] + 0x21e1cde6, 5); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
256 MD5STEP (F2, d, a, b, c, in[14] + 0xc33707d6, 9); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
257 MD5STEP (F2, c, d, a, b, in[3] + 0xf4d50d87, 14); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
258 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
259 if (version == 1) { |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
260 MD5STEP (F2, b, c, d, a, in[8] + 0x445a14ed, 20); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
261 } else { |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
262 MD5STEP (F2, b, c, d, a, in[8] + 0x455a14ed, 20); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
263 } |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
264 MD5STEP (F2, a, b, c, d, in[13] + 0xa9e3e905, 5); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
265 MD5STEP (F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
266 MD5STEP (F2, c, d, a, b, in[7] + 0x676f02d9, 14); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
267 MD5STEP (F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
268 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
269 MD5STEP (F3, a, b, c, d, in[5] + 0xfffa3942, 4); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
270 MD5STEP (F3, d, a, b, c, in[8] + 0x8771f681, 11); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
271 MD5STEP (F3, c, d, a, b, in[11] + 0x6d9d6122, 16); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
272 MD5STEP (F3, b, c, d, a, in[14] + 0xfde5380c, 23); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
273 MD5STEP (F3, a, b, c, d, in[1] + 0xa4beea44, 4); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
274 MD5STEP (F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
275 MD5STEP (F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
276 MD5STEP (F3, b, c, d, a, in[10] + 0xbebfbc70, 23); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
277 MD5STEP (F3, a, b, c, d, in[13] + 0x289b7ec6, 4); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
278 MD5STEP (F3, d, a, b, c, in[0] + 0xeaa127fa, 11); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
279 MD5STEP (F3, c, d, a, b, in[3] + 0xd4ef3085, 16); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
280 MD5STEP (F3, b, c, d, a, in[6] + 0x04881d05, 23); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
281 MD5STEP (F3, a, b, c, d, in[9] + 0xd9d4d039, 4); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
282 MD5STEP (F3, d, a, b, c, in[12] + 0xe6db99e5, 11); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
283 MD5STEP (F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
284 MD5STEP (F3, b, c, d, a, in[2] + 0xc4ac5665, 23); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
285 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
286 MD5STEP (F4, a, b, c, d, in[0] + 0xf4292244, 6); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
287 MD5STEP (F4, d, a, b, c, in[7] + 0x432aff97, 10); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
288 MD5STEP (F4, c, d, a, b, in[14] + 0xab9423a7, 15); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
289 MD5STEP (F4, b, c, d, a, in[5] + 0xfc93a039, 21); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
290 MD5STEP (F4, a, b, c, d, in[12] + 0x655b59c3, 6); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
291 MD5STEP (F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
292 MD5STEP (F4, c, d, a, b, in[10] + 0xffeff47d, 15); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
293 MD5STEP (F4, b, c, d, a, in[1] + 0x85845dd1, 21); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
294 MD5STEP (F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
295 MD5STEP (F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
296 MD5STEP (F4, c, d, a, b, in[6] + 0xa3014314, 15); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
297 MD5STEP (F4, b, c, d, a, in[13] + 0x4e0811a1, 21); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
298 MD5STEP (F4, a, b, c, d, in[4] + 0xf7537e82, 6); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
299 MD5STEP (F4, d, a, b, c, in[11] + 0xbd3af235, 10); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
300 MD5STEP (F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
301 MD5STEP (F4, b, c, d, a, in[9] + 0xeb86d391, 21); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
302 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
303 buf[0] += a; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
304 buf[1] += b; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
305 buf[2] += c; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
306 buf[3] += d; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
307 } |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
308 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
309 #endif |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
310 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
311 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
312 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
313 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
314 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
315 static int staticHashDone = 0; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
316 static unsigned char staticHash_42[256*65] = {0}; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
317 static unsigned char staticHash_45[256*65] = {0}; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
318 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
319 static const char hexchars[] = "0123456789ABCDEF"; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
320 static char ac[] = "Dpqzsjhiu!3114!Bqqmf!Dpnqvufs-!Jod/"; /* +1 */ |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
321 static gboolean ac_unfudged = FALSE; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
322 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
323 static void |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
324 DigestToString (const unsigned char *digest, |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
325 char *string) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
326 { |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
327 int i; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
328 for (i = 0; i < 16; i++) { |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
329 unsigned char tmp = digest[i]; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
330 string[i*2+1] = hexchars[tmp & 0x0f]; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
331 string[i*2] = hexchars[(tmp >> 4) & 0x0f]; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
332 } |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
333 } |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
334 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
335 static void |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
336 GenerateStatic_42 () { |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
337 MD5_CTX ctx; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
338 unsigned char *p = staticHash_42; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
339 int i; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
340 unsigned char buf[16]; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
341 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
342 for (i = 0; i < 256; i++) { |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
343 OpenDaap_MD5Init (&ctx, 0); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
344 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
345 #define MD5_STRUPDATE(str) OpenDaap_MD5Update(&ctx, (unsigned char const *)str, strlen (str)) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
346 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
347 if ((i & 0x80) != 0) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
348 MD5_STRUPDATE ("Accept-Language"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
349 else |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
350 MD5_STRUPDATE ("user-agent"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
351 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
352 if ((i & 0x40) != 0) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
353 MD5_STRUPDATE ("max-age"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
354 else |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
355 MD5_STRUPDATE ("Authorization"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
356 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
357 if ((i & 0x20) != 0) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
358 MD5_STRUPDATE ("Client-DAAP-Version"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
359 else |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
360 MD5_STRUPDATE ("Accept-Encoding"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
361 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
362 if ((i & 0x10) != 0) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
363 MD5_STRUPDATE ("daap.protocolversion"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
364 else |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
365 MD5_STRUPDATE ("daap.songartist"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
366 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
367 if ((i & 0x08) != 0) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
368 MD5_STRUPDATE ("daap.songcomposer"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
369 else |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
370 MD5_STRUPDATE ("daap.songdatemodified"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
371 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
372 if ((i & 0x04) != 0) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
373 MD5_STRUPDATE ("daap.songdiscnumber"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
374 else |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
375 MD5_STRUPDATE ("daap.songdisabled"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
376 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
377 if ((i & 0x02) != 0) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
378 MD5_STRUPDATE ("playlist-item-spec"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
379 else |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
380 MD5_STRUPDATE ("revision-number"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
381 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
382 if ((i & 0x01) != 0) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
383 MD5_STRUPDATE ("session-id"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
384 else |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
385 MD5_STRUPDATE ("content-codes"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
386 #undef MD5_STRUPDATE |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
387 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
388 OpenDaap_MD5Final (&ctx, buf); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
389 DigestToString (buf, (char *)p); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
390 p += 65; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
391 } |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
392 } |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
393 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
394 static void GenerateStatic_45 () |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
395 { |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
396 MD5_CTX ctx; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
397 unsigned char *p = staticHash_45; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
398 int i; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
399 unsigned char buf[16]; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
400 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
401 for (i = 0; i < 256; i++) { |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
402 OpenDaap_MD5Init (&ctx, 1); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
403 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
404 #define MD5_STRUPDATE(str) OpenDaap_MD5Update(&ctx, (unsigned char const *)str, strlen (str)) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
405 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
406 if ((i & 0x40) != 0) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
407 MD5_STRUPDATE ("eqwsdxcqwesdc"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
408 else |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
409 MD5_STRUPDATE ("op[;lm,piojkmn"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
410 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
411 if ((i & 0x20) != 0) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
412 MD5_STRUPDATE ("876trfvb 34rtgbvc"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
413 else |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
414 MD5_STRUPDATE ("=-0ol.,m3ewrdfv"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
415 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
416 if ((i & 0x10) != 0) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
417 MD5_STRUPDATE ("87654323e4rgbv "); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
418 else |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
419 MD5_STRUPDATE ("1535753690868867974342659792"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
420 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
421 if ((i & 0x08) != 0) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
422 MD5_STRUPDATE ("Song Name"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
423 else |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
424 MD5_STRUPDATE ("DAAP-CLIENT-ID:"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
425 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
426 if ((i & 0x04) != 0) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
427 MD5_STRUPDATE ("111222333444555"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
428 else |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
429 MD5_STRUPDATE ("4089961010"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
430 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
431 if ((i & 0x02) != 0) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
432 MD5_STRUPDATE ("playlist-item-spec"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
433 else |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
434 MD5_STRUPDATE ("revision-number"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
435 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
436 if ((i & 0x01) != 0) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
437 MD5_STRUPDATE ("session-id"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
438 else |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
439 MD5_STRUPDATE ("content-codes"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
440 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
441 if ((i & 0x80) != 0) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
442 MD5_STRUPDATE ("IUYHGFDCXWEDFGHN"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
443 else |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
444 MD5_STRUPDATE ("iuytgfdxwerfghjm"); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
445 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
446 #undef MD5_STRUPDATE |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
447 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
448 OpenDaap_MD5Final (&ctx, buf); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
449 DigestToString (buf, (char *)p); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
450 p += 65; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
451 } |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
452 } |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
453 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
454 void |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
455 daap_hash_generate (short version_major, |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
456 const guchar *url, |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
457 guchar hash_select, |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
458 guchar *out, |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
459 gint request_id) |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
460 { |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
461 unsigned char buf[16]; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
462 MD5_CTX ctx; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
463 int i; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
464 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
465 unsigned char *hashTable = (version_major == 3) ? |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
466 staticHash_45 : staticHash_42; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
467 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
468 if (!staticHashDone) { |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
469 GenerateStatic_42 (); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
470 GenerateStatic_45 (); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
471 staticHashDone = 1; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
472 } |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
473 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
474 OpenDaap_MD5Init (&ctx, (version_major == 3) ? 1 : 0); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
475 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
476 OpenDaap_MD5Update (&ctx, url, strlen ((const gchar*)url)); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
477 if (ac_unfudged == FALSE) { |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
478 for (i = 0; i < strlen (ac); i++) { |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
479 ac[i] = ac[i]-1; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
480 } |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
481 ac_unfudged = TRUE; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
482 } |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
483 OpenDaap_MD5Update (&ctx, (const guchar*)ac, strlen (ac)); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
484 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
485 OpenDaap_MD5Update (&ctx, &hashTable[hash_select * 65], 32); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
486 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
487 if (request_id && version_major == 3) { |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
488 char scribble[20]; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
489 sprintf (scribble, "%u", request_id); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
490 OpenDaap_MD5Update (&ctx, (const guchar*)scribble, strlen (scribble)); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
491 } |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
492 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
493 OpenDaap_MD5Final (&ctx, buf); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
494 DigestToString (buf, (char *)out); |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
495 |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
496 return; |
776dd8fc2b38
DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff
changeset
|
497 } |