Changeset 1479 for pjproject/trunk/pjnath/src/pjnath/stun_msg.c
- Timestamp:
- Oct 5, 2007 3:53:56 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjnath/src/pjnath/stun_msg.c
r1443 r1479 2146 2146 } 2147 2147 2148 #if PJ_STUN_OLD_STYLE_MI_FINGERPRINT 2149 /* 2150 * This is the old style MESSAGE-INTEGRITY and FINGERPRINT 2151 * calculation, used in rfc3489bis-06 and older. 2152 */ 2153 /* We MUST update the message length in the header NOW before 2154 * calculating MESSAGE-INTEGRITY and FINGERPRINT. 2155 * Note that length is not including the 20 bytes header. 2156 */ 2157 if (amsgint && afingerprint) { 2158 body_len = (pj_uint16_t)((buf - start) - 20 + 24 + 8); 2159 } else if (amsgint) { 2160 body_len = (pj_uint16_t)((buf - start) - 20 + 24); 2161 } else if (afingerprint) { 2162 body_len = (pj_uint16_t)((buf - start) - 20 + 8); 2163 } else { 2164 body_len = (pj_uint16_t)((buf - start) - 20); 2165 } 2166 #else 2148 2167 /* If MESSAGE-INTEGRITY is present, include the M-I attribute 2149 2168 * in message length before calculating M-I … … 2154 2173 body_len = (pj_uint16_t)((buf - start) - 20); 2155 2174 } 2175 #endif /* PJ_STUN_OLD_STYLE_MI_FINGERPRINT */ 2156 2176 2157 2177 /* hdr->length = pj_htons(length); */ … … 2188 2208 pj_hmac_sha1_init(&ctx, (pj_uint8_t*)key->ptr, key->slen); 2189 2209 pj_hmac_sha1_update(&ctx, (pj_uint8_t*)start, buf-start); 2210 #if PJ_STUN_OLD_STYLE_MI_FINGERPRINT 2190 2211 // These are obsoleted in rfc3489bis-08 2191 //if ((buf-start) & 0x3F) { 2192 // pj_uint8_t zeroes[64]; 2193 // pj_bzero(zeroes, sizeof(zeroes)); 2194 // pj_hmac_sha1_update(&ctx, zeroes, 64-((buf-start) & 0x3F)); 2195 //} 2212 if ((buf-start) & 0x3F) { 2213 pj_uint8_t zeroes[64]; 2214 pj_bzero(zeroes, sizeof(zeroes)); 2215 pj_hmac_sha1_update(&ctx, zeroes, 64-((buf-start) & 0x3F)); 2216 } 2217 #endif /* PJ_STUN_OLD_STYLE_MI_FINGERPRINT */ 2196 2218 pj_hmac_sha1_final(&ctx, amsgint->hmac); 2197 2219 … … 2208 2230 /* Calculate FINGERPRINT if present */ 2209 2231 if (afingerprint != NULL) { 2232 2233 #if !PJ_STUN_OLD_STYLE_MI_FINGERPRINT 2210 2234 /* Update message length */ 2211 2235 PUTVAL16H(start, 2, 2212 2236 (pj_uint16_t)(GETVAL16H(start, 2)+8)); 2237 #endif 2213 2238 2214 2239 afingerprint->value = pj_crc32_calc(start, buf-start);
Note: See TracChangeset
for help on using the changeset viewer.