Changeset 1479 for pjproject/trunk
- Timestamp:
- Oct 5, 2007 3:53:56 PM (17 years ago)
- Location:
- pjproject/trunk/pjnath
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjnath/include/pjnath/config.h
r1450 r1479 112 112 */ 113 113 #ifndef PJ_STUN_MAX_PKT_LEN 114 # define PJ_STUN_MAX_PKT_LEN 512114 # define PJ_STUN_MAX_PKT_LEN 800 115 115 #endif 116 116 … … 129 129 #ifndef PJ_STUN_STRING_ATTR_PAD_CHR 130 130 # define PJ_STUN_STRING_ATTR_PAD_CHR 0 131 #endif 132 133 134 /** 135 * Enable pre-RFC3489bis-07 style of STUN MESSAGE-INTEGRITY and FINGERPRINT 136 * calculation. By default this should be disabled since the calculation is 137 * not backward compatible with current STUN specification. 138 */ 139 #ifndef PJ_STUN_OLD_STYLE_MI_FINGERPRINT 140 # define PJ_STUN_OLD_STYLE_MI_FINGERPRINT 0 131 141 #endif 132 142 -
pjproject/trunk/pjnath/src/pjnath/stun_auth.c
r1439 r1479 343 343 pj_hmac_sha1_init(&ctx, (pj_uint8_t*)key.ptr, key.slen); 344 344 345 #if PJ_STUN_OLD_STYLE_MI_FINGERPRINT 346 /* Pre rfc3489bis-06 style of calculation */ 347 pj_hmac_sha1_update(&ctx, pkt, 20); 348 #else 345 349 /* First calculate HMAC for the header. 346 350 * The calculation is different depending on whether FINGERPRINT attribute … … 355 359 pj_hmac_sha1_update(&ctx, pkt, 20); 356 360 } 361 #endif /* PJ_STUN_OLD_STYLE_MI_FINGERPRINT */ 357 362 358 363 /* Now update with the message body */ 359 364 pj_hmac_sha1_update(&ctx, pkt+20, amsgi_pos); 365 #if PJ_STUN_OLD_STYLE_MI_FINGERPRINT 360 366 // This is no longer necessary as per rfc3489bis-08 361 //if (amsgi_pos & 0x3F) { 362 // pj_uint8_t zeroes[64]; 363 // pj_bzero(zeroes, sizeof(zeroes)); 364 // pj_hmac_sha1_update(&ctx, zeroes, 64-(amsgi_pos & 0x3F)); 365 //} 367 if ((amsgi_pos+20) & 0x3F) { 368 pj_uint8_t zeroes[64]; 369 pj_bzero(zeroes, sizeof(zeroes)); 370 pj_hmac_sha1_update(&ctx, zeroes, 64-((amsgi_pos+20) & 0x3F)); 371 } 372 #endif 366 373 pj_hmac_sha1_final(&ctx, digest); 367 374 … … 475 482 pj_hmac_sha1_init(&ctx, (pj_uint8_t*)key->ptr, key->slen); 476 483 484 #if PJ_STUN_OLD_STYLE_MI_FINGERPRINT 485 /* Pre rfc3489bis-06 style of calculation */ 486 pj_hmac_sha1_update(&ctx, pkt, 20); 487 #else 477 488 /* First calculate HMAC for the header. 478 489 * The calculation is different depending on whether FINGERPRINT attribute … … 487 498 pj_hmac_sha1_update(&ctx, pkt, 20); 488 499 } 500 #endif /* PJ_STUN_OLD_STYLE_MI_FINGERPRINT */ 489 501 490 502 /* Now update with the message body */ 491 503 pj_hmac_sha1_update(&ctx, pkt+20, amsgi_pos); 504 #if PJ_STUN_OLD_STYLE_MI_FINGERPRINT 492 505 // This is no longer necessary as per rfc3489bis-08 493 //if (amsgi_pos & 0x3F) { 494 // pj_uint8_t zeroes[64]; 495 // pj_bzero(zeroes, sizeof(zeroes)); 496 // pj_hmac_sha1_update(&ctx, zeroes, 64-(amsgi_pos & 0x3F)); 497 //} 506 if ((amsgi_pos+20) & 0x3F) { 507 pj_uint8_t zeroes[64]; 508 pj_bzero(zeroes, sizeof(zeroes)); 509 pj_hmac_sha1_update(&ctx, zeroes, 64-((amsgi_pos+20) & 0x3F)); 510 } 511 #endif 498 512 pj_hmac_sha1_final(&ctx, digest); 499 513 -
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); -
pjproject/trunk/pjnath/src/pjnath/stun_session.c
r1414 r1479 561 561 int dst_port; 562 562 const pj_sockaddr *dst = (const pj_sockaddr*)addr; 563 char buf[ 512];563 char buf[800]; 564 564 565 565 if (dst->addr.sa_family == pj_AF_INET()) {
Note: See TracChangeset
for help on using the changeset viewer.