Ignore:
Timestamp:
Oct 5, 2007 3:53:56 PM (17 years ago)
Author:
bennylp
Message:

Ticket #392: Added configuration to enable old, rfc3489bis-06 and older, style of MESSAGE-INTEGRITY and FINGERPRINT calculation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjnath/src/pjnath/stun_msg.c

    r1443 r1479  
    21462146    } 
    21472147 
     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 
    21482167    /* If MESSAGE-INTEGRITY is present, include the M-I attribute 
    21492168     * in message length before calculating M-I 
     
    21542173        body_len = (pj_uint16_t)((buf - start) - 20); 
    21552174    } 
     2175#endif  /* PJ_STUN_OLD_STYLE_MI_FINGERPRINT */ 
    21562176 
    21572177    /* hdr->length = pj_htons(length); */ 
     
    21882208        pj_hmac_sha1_init(&ctx, (pj_uint8_t*)key->ptr, key->slen); 
    21892209        pj_hmac_sha1_update(&ctx, (pj_uint8_t*)start, buf-start); 
     2210#if PJ_STUN_OLD_STYLE_MI_FINGERPRINT 
    21902211        // 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 */ 
    21962218        pj_hmac_sha1_final(&ctx, amsgint->hmac); 
    21972219 
     
    22082230    /* Calculate FINGERPRINT if present */ 
    22092231    if (afingerprint != NULL) { 
     2232 
     2233#if !PJ_STUN_OLD_STYLE_MI_FINGERPRINT 
    22102234        /* Update message length */ 
    22112235        PUTVAL16H(start, 2,  
    22122236                 (pj_uint16_t)(GETVAL16H(start, 2)+8)); 
     2237#endif 
    22132238 
    22142239        afingerprint->value = pj_crc32_calc(start, buf-start); 
Note: See TracChangeset for help on using the changeset viewer.