annotate extensions/app_sip/md5.c @ 1414:f6f12521c2aa

Fix strict-aliasing warnings with gcc 4.8 Rewrite IN6_ADDR_V4MAP() to not rely upon aliasing rules. Add test for IN6_ADDR_V4MAP() and IN6_ADDR_V4UNMAP(). Rewrite MD5Final() to not rely upon aliasing rules. (Not tested)
author Luke Mewburn <luke@mewburn.net>
date Tue, 18 Feb 2020 19:01:49 +1100
parents 0fa8207cc91a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
360
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
1 /*********************************************************************************/
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
2 /* freeDiameter author note:
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
3 * The content from this file comes directly from the hostap project.
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
4 * It is redistributed under the terms of the BSD license, as allowed
972
ce3cacbbccc9 Fix some typos.
Thomas Klausner <tk@giga.or.at>
parents: 433
diff changeset
5 * by the original copyright reproduced below.
360
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
6 * In addition to this notice, only the #include directives have been modified.
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
7 */
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
8
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
9 /*********************************************************************************/
433
0d08a9ab2212 Corrected name mistakes on app_sip
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 409
diff changeset
10 #include"app_sip.h"
360
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
11
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
12 /*
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
13 * MD5 hash implementation and interface functions
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
14 * Copyright (c) 2003-2005, Jouni Malinen <j@w1.fi>
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
15 *
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
16 * This program is free software; you can redistribute it and/or modify
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
17 * it under the terms of the GNU General Public License version 2 as
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
18 * published by the Free Software Foundation.
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
19 *
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
20 * Alternatively, this software may be distributed under the terms of BSD
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
21 * license.
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
22 *
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
23 * See README and COPYING for more details.
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
24 */
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
25 void CvtHex(
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
26 IN HASH Bin,
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
27 OUT HASHHEX Hex
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
28 )
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
29 {
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
30 unsigned short i;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
31 unsigned char j;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
32
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
33 for (i = 0; i < HASHLEN; i++) {
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
34 j = (Bin[i] >> 4) & 0xf;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
35 if (j <= 9)
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
36 Hex[i*2] = (j + '0');
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
37 else
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
38 Hex[i*2] = (j + 'a' - 10);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
39 j = Bin[i] & 0xf;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
40 if (j <= 9)
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
41 Hex[i*2+1] = (j + '0');
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
42 else
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
43 Hex[i*2+1] = (j + 'a' - 10);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
44 }
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
45 Hex[HASHHEXLEN] = '\0';
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
46 }
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
47
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
48 // calculate H(A1) as per spec
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
49 void DigestCalcHA1(char * pszAlg,char * pszUserName,char * pszRealm,char * pszPassword,char * pszNonce,char * pszCNonce,HASHHEX SessionKey)
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
50 {
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
51 MD5_CTX Md5Ctx;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
52 HASH HA1;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
53
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
54 MD5Init(&Md5Ctx);
409
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
55 MD5Update(&Md5Ctx, (const unsigned char *)pszUserName, strlen(pszUserName));
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
56 MD5Update(&Md5Ctx, (const unsigned char *)":", 1);
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
57 MD5Update(&Md5Ctx, (const unsigned char *)pszRealm, strlen(pszRealm));
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
58 MD5Update(&Md5Ctx, (const unsigned char *)":", 1);
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
59 MD5Update(&Md5Ctx, (const unsigned char *)pszPassword, strlen(pszPassword));
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
60 MD5Final((unsigned char *)HA1, &Md5Ctx);
360
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
61 if (strcmp(pszAlg, "md5-sess") == 0) {
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
62 MD5Init(&Md5Ctx);
409
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
63 MD5Update(&Md5Ctx, (const unsigned char *)HA1, HASHLEN);
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
64 MD5Update(&Md5Ctx, (const unsigned char *)":", 1);
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
65 MD5Update(&Md5Ctx, (const unsigned char *)pszNonce, strlen(pszNonce));
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
66 MD5Update(&Md5Ctx, (const unsigned char *)":", 1);
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
67 MD5Update(&Md5Ctx, (const unsigned char *)pszCNonce, strlen(pszCNonce));
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
68 MD5Final((unsigned char *)HA1, &Md5Ctx);
360
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
69 }
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
70 CvtHex(HA1, SessionKey);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
71 }
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
72
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
73 // calculate request-digest as SIP Digest spec RFC5090
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
74 void DigestCalcResponse(HASHHEX HA1,char * pszNonce,char * pszNonceCount,char * pszCNonce,char * pszQop,char * pszMethod,char * pszDigestUri,HASHHEX HEntity,HASHHEX Response)
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
75 {
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
76 MD5_CTX Md5Ctx;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
77 HASH HA2;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
78 HASH RespHash;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
79 HASHHEX HA2Hex;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
80
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
81 // calculate H(A2)
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
82 MD5Init(&Md5Ctx);
409
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
83 MD5Update(&Md5Ctx, (const unsigned char *)pszMethod, strlen(pszMethod));
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
84 MD5Update(&Md5Ctx, (const unsigned char *)":", 1);
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
85 MD5Update(&Md5Ctx, (const unsigned char *)pszDigestUri, strlen(pszDigestUri));
360
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
86 if (strcmp(pszQop, "auth-int") == 0) {
409
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
87 MD5Update(&Md5Ctx, (const unsigned char *)":", 1);
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
88 MD5Update(&Md5Ctx, (const unsigned char *)HEntity, HASHHEXLEN);
360
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
89 }
409
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
90 MD5Final((unsigned char *)HA2, &Md5Ctx);
360
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
91 CvtHex(HA2, HA2Hex);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
92
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
93 // calculate response
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
94 MD5Init(&Md5Ctx);
409
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
95 MD5Update(&Md5Ctx, (const unsigned char *)HA1, HASHHEXLEN);
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
96 MD5Update(&Md5Ctx, (const unsigned char *)":", 1);
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
97 MD5Update(&Md5Ctx,(const unsigned char *) pszNonce, strlen(pszNonce));
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
98 MD5Update(&Md5Ctx, (const unsigned char *)":", 1);
360
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
99 if (*pszQop) {
409
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
100 MD5Update(&Md5Ctx, (const unsigned char *)pszNonceCount, strlen(pszNonceCount));
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
101 MD5Update(&Md5Ctx, (const unsigned char *)":", 1);
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
102 MD5Update(&Md5Ctx, (const unsigned char *)pszCNonce, strlen(pszCNonce));
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
103 MD5Update(&Md5Ctx, (const unsigned char *)":", 1);
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
104 MD5Update(&Md5Ctx, (const unsigned char *)pszQop, strlen(pszQop));
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
105 MD5Update(&Md5Ctx, (const unsigned char *)":", 1);
360
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
106 }
409
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
107 MD5Update(&Md5Ctx, (const unsigned char *)HA2Hex, HASHHEXLEN);
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
108 MD5Final((unsigned char *)RespHash, &Md5Ctx);
360
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
109 CvtHex(RespHash, Response);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
110 }
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
111 // calculate Digest_response_Auth as per SIP Digest spec RFC5090
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
112 void DigestCalcResponseAuth(HASHHEX HA1,char * pszNonce,char * pszNonceCount,char * pszCNonce,char * pszQop,char * pszMethod,char * pszDigestUri,HASHHEX HEntity,HASHHEX Response)
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
113 {
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
114 MD5_CTX Md5Ctx;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
115 HASH HA2;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
116 HASH RespHash;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
117 HASHHEX HA2Hex;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
118
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
119 // calculate H(A2)
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
120 MD5Init(&Md5Ctx);
409
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
121 MD5Update(&Md5Ctx, (const unsigned char *)":", 1);
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
122 MD5Update(&Md5Ctx, (const unsigned char *)pszDigestUri, strlen(pszDigestUri));
360
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
123 if (strcmp(pszQop, "auth-int") == 0) {
409
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
124 MD5Update(&Md5Ctx, (const unsigned char *)":", 1);
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
125 MD5Update(&Md5Ctx, (const unsigned char *)HEntity, HASHHEXLEN);
360
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
126 }
409
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
127 MD5Final((unsigned char *)HA2, &Md5Ctx);
360
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
128 CvtHex(HA2, HA2Hex);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
129
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
130 // calculate response
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
131 MD5Init(&Md5Ctx);
409
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
132 MD5Update(&Md5Ctx, (const unsigned char *)HA1, HASHHEXLEN);
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
133 MD5Update(&Md5Ctx, (const unsigned char *)":", 1);
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
134 MD5Update(&Md5Ctx, (const unsigned char *)pszNonce, strlen(pszNonce));
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
135 MD5Update(&Md5Ctx, (const unsigned char *)":", 1);
360
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
136 if (*pszQop) {
409
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
137 MD5Update(&Md5Ctx, (const unsigned char *)pszNonceCount, strlen(pszNonceCount));
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
138 MD5Update(&Md5Ctx, (const unsigned char *)":", 1);
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
139 MD5Update(&Md5Ctx, (const unsigned char *)pszCNonce, strlen(pszCNonce));
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
140 MD5Update(&Md5Ctx, (const unsigned char *)":", 1);
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
141 MD5Update(&Md5Ctx, (const unsigned char *)pszQop, strlen(pszQop));
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
142 MD5Update(&Md5Ctx, (const unsigned char *)":", 1);
360
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
143 }
409
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
144 MD5Update(&Md5Ctx, (const unsigned char *)HA2Hex, HASHHEXLEN);
c2fb5b26bfcb Fix for ticket 8
Alexandre Westfahl <awestfahl@freediameter.net>
parents: 360
diff changeset
145 MD5Final((unsigned char *)RespHash, &Md5Ctx);
360
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
146 CvtHex(RespHash, Response);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
147 }
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
148
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
149
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
150
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
151
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
152
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
153 static void MD5Transform(u32 buf[4], u32 const in[16]);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
154
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
155
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
156
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
157
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
158 /**
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
159 * md5_vector - MD5 hash for data vector
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
160 * @num_elem: Number of elements in the data vector
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
161 * @addr: Pointers to the data areas
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
162 * @len: Lengths of the data blocks
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
163 * @mac: Buffer for the hash
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
164 */
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
165 void md5_vector(size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac)
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
166 {
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
167 MD5_CTX ctx;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
168 size_t i;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
169
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
170 MD5Init(&ctx);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
171 for (i = 0; i < num_elem; i++)
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
172 MD5Update(&ctx, addr[i], len[i]);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
173 MD5Final(mac, &ctx);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
174 }
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
175
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
176
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
177 /* ===== start - public domain MD5 implementation ===== */
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
178 /*
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
179 * This code implements the MD5 message-digest algorithm.
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
180 * The algorithm is due to Ron Rivest. This code was
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
181 * written by Colin Plumb in 1993, no copyright is claimed.
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
182 * This code is in the public domain; do with it what you wish.
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
183 *
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
184 * Equivalent code is available from RSA Data Security, Inc.
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
185 * This code has been tested against that, and is equivalent,
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
186 * except that you don't need to include two pages of legalese
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
187 * with every copy.
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
188 *
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
189 * To compute the message digest of a chunk of bytes, declare an
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
190 * MD5Context structure, pass it to MD5Init, call MD5Update as
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
191 * needed on buffers full of bytes, and then call MD5Final, which
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
192 * will fill a supplied 16-byte array with the digest.
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
193 */
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
194
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
195 #ifndef WORDS_BIGENDIAN
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
196 #define byteReverse(buf, len) /* Nothing */
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
197 #else
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
198 /*
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
199 * Note: this code is harmless on little-endian machines.
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
200 */
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
201 static void byteReverse(unsigned char *buf, unsigned longs)
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
202 {
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
203 u32 t;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
204 do {
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
205 t = (u32) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
206 ((unsigned) buf[1] << 8 | buf[0]);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
207 *(u32 *) buf = t;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
208 buf += 4;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
209 } while (--longs);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
210 }
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
211 #endif
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
212
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
213 /*
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
214 * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
215 * initialization constants.
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
216 */
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
217 void MD5Init(struct MD5Context *ctx)
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
218 {
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
219 ctx->buf[0] = 0x67452301;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
220 ctx->buf[1] = 0xefcdab89;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
221 ctx->buf[2] = 0x98badcfe;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
222 ctx->buf[3] = 0x10325476;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
223
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
224 ctx->bits[0] = 0;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
225 ctx->bits[1] = 0;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
226 }
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
227
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
228 /*
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
229 * Update context to reflect the concatenation of another buffer full
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
230 * of bytes.
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
231 */
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
232 void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
233 {
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
234 u32 t;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
235
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
236 /* Update bitcount */
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
237
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
238 t = ctx->bits[0];
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
239 if ((ctx->bits[0] = t + ((u32) len << 3)) < t)
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
240 ctx->bits[1]++; /* Carry from low to high */
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
241 ctx->bits[1] += len >> 29;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
242
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
243 t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
244
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
245 /* Handle any leading odd-sized chunks */
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
246
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
247 if (t) {
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
248 unsigned char *p = (unsigned char *) ctx->in + t;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
249
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
250 t = 64 - t;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
251 if (len < t) {
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
252 os_memcpy(p, buf, len);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
253 return;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
254 }
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
255 os_memcpy(p, buf, t);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
256 byteReverse(ctx->in, 16);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
257 MD5Transform(ctx->buf, (u32 *) ctx->in);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
258 buf += t;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
259 len -= t;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
260 }
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
261 /* Process data in 64-byte chunks */
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
262
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
263 while (len >= 64) {
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
264 os_memcpy(ctx->in, buf, 64);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
265 byteReverse(ctx->in, 16);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
266 MD5Transform(ctx->buf, (u32 *) ctx->in);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
267 buf += 64;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
268 len -= 64;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
269 }
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
270
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
271 /* Handle any remaining bytes of data. */
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
272
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
273 os_memcpy(ctx->in, buf, len);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
274 }
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
275
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
276 /*
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
277 * Final wrapup - pad to 64-byte boundary with the bit pattern
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
278 * 1 0* (64-bit count of bits processed, MSB-first)
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
279 */
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
280 void MD5Final(unsigned char digest[16], struct MD5Context *ctx)
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
281 {
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
282 unsigned count;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
283 unsigned char *p;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
284
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
285 /* Compute number of bytes mod 64 */
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
286 count = (ctx->bits[0] >> 3) & 0x3F;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
287
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
288 /* Set the first char of padding to 0x80. This is safe since there is
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
289 always at least one byte free */
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
290 p = ctx->in + count;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
291 *p++ = 0x80;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
292
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
293 /* Bytes of padding needed to make 64 bytes */
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
294 count = 64 - 1 - count;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
295
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
296 /* Pad out to 56 mod 64 */
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
297 if (count < 8) {
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
298 /* Two lots of padding: Pad the first block to 64 bytes */
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
299 os_memset(p, 0, count);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
300 byteReverse(ctx->in, 16);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
301 MD5Transform(ctx->buf, (u32 *) ctx->in);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
302
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
303 /* Now fill the next block with 56 bytes */
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
304 os_memset(ctx->in, 0, 56);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
305 } else {
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
306 /* Pad block to 56 bytes */
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
307 os_memset(p, 0, count - 8);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
308 }
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
309 byteReverse(ctx->in, 14);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
310
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
311 /* Append length in bits and transform */
1414
f6f12521c2aa Fix strict-aliasing warnings with gcc 4.8
Luke Mewburn <luke@mewburn.net>
parents: 1291
diff changeset
312 os_memcpy(&ctx->in[56], &ctx->bits[0], 8);
360
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
313
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
314 MD5Transform(ctx->buf, (u32 *) ctx->in);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
315 byteReverse((unsigned char *) ctx->buf, 4);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
316 os_memcpy(digest, ctx->buf, 16);
1291
0fa8207cc91a Fix a few mistakes
Sebastien Decugis <sdecugis@freediameter.net>
parents: 972
diff changeset
317 os_memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
360
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
318 }
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
319
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
320 /* The four core functions - F1 is optimized somewhat */
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
321
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
322 /* #define F1(x, y, z) (x & y | ~x & z) */
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
323 #define F1(x, y, z) (z ^ (x & (y ^ z)))
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
324 #define F2(x, y, z) F1(z, x, y)
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
325 #define F3(x, y, z) (x ^ y ^ z)
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
326 #define F4(x, y, z) (y ^ (x | ~z))
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
327
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
328 /* This is the central step in the MD5 algorithm. */
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
329 #define MD5STEP(f, w, x, y, z, data, s) \
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
330 ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
331
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
332 /*
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
333 * The core of the MD5 algorithm, this alters an existing MD5 hash to
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
334 * reflect the addition of 16 longwords of new data. MD5Update blocks
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
335 * the data and converts bytes into longwords for this routine.
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
336 */
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
337 static void MD5Transform(u32 buf[4], u32 const in[16])
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
338 {
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
339 register u32 a, b, c, d;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
340
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
341 a = buf[0];
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
342 b = buf[1];
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
343 c = buf[2];
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
344 d = buf[3];
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
345
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
346 MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
347 MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
348 MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
349 MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
350 MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
351 MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
352 MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
353 MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
354 MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
355 MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
356 MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
357 MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
358 MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
359 MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
360 MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
361 MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
362
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
363 MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
364 MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
365 MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
366 MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
367 MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
368 MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
369 MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
370 MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
371 MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
372 MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
373 MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
374 MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
375 MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
376 MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
377 MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
378 MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
379
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
380 MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
381 MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
382 MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
383 MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
384 MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
385 MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
386 MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
387 MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
388 MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
389 MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
390 MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
391 MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
392 MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
393 MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
394 MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
395 MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
396
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
397 MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
398 MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
399 MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
400 MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
401 MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
402 MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
403 MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
404 MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
405 MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
406 MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
407 MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
408 MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
409 MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
410 MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
411 MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
412 MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
413
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
414 buf[0] += a;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
415 buf[1] += b;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
416 buf[2] += c;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
417 buf[3] += d;
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
418 }
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
419 /* ===== end - public domain MD5 implementation ===== */
1740bee6c821 Initial App_SIP import
Alexandre Westfahl <awestfahl@freediameter.net>
parents:
diff changeset
420
"Welcome to our mercurial repository"