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_auth.c

    r1439 r1479  
    343343    pj_hmac_sha1_init(&ctx, (pj_uint8_t*)key.ptr, key.slen); 
    344344 
     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 
    345349    /* First calculate HMAC for the header. 
    346350     * The calculation is different depending on whether FINGERPRINT attribute 
     
    355359        pj_hmac_sha1_update(&ctx, pkt, 20); 
    356360    } 
     361#endif  /* PJ_STUN_OLD_STYLE_MI_FINGERPRINT */ 
    357362 
    358363    /* Now update with the message body */ 
    359364    pj_hmac_sha1_update(&ctx, pkt+20, amsgi_pos); 
     365#if PJ_STUN_OLD_STYLE_MI_FINGERPRINT 
    360366    // 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 
    366373    pj_hmac_sha1_final(&ctx, digest); 
    367374 
     
    475482    pj_hmac_sha1_init(&ctx, (pj_uint8_t*)key->ptr, key->slen); 
    476483 
     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 
    477488    /* First calculate HMAC for the header. 
    478489     * The calculation is different depending on whether FINGERPRINT attribute 
     
    487498        pj_hmac_sha1_update(&ctx, pkt, 20); 
    488499    } 
     500#endif  /* PJ_STUN_OLD_STYLE_MI_FINGERPRINT */ 
    489501 
    490502    /* Now update with the message body */ 
    491503    pj_hmac_sha1_update(&ctx, pkt+20, amsgi_pos); 
     504#if PJ_STUN_OLD_STYLE_MI_FINGERPRINT 
    492505    // 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 
    498512    pj_hmac_sha1_final(&ctx, digest); 
    499513 
Note: See TracChangeset for help on using the changeset viewer.