Ignore:
Timestamp:
May 11, 2007 10:37:14 AM (17 years ago)
Author:
bennylp
Message:

Fixed missing padding when calculating MESSAGE-INTEGRITY in STUN

File:
1 edited

Legend:

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

    r1239 r1265  
    21402140 
    21412141        pj_uint8_t md5_key_buf[16]; 
     2142        pj_hmac_sha1_context ctx; 
    21422143        pj_str_t key; 
    21432144 
     
    21822183        } 
    21832184 
    2184         /* Calculate HMAC-SHA1 digest */ 
    2185         pj_hmac_sha1((pj_uint8_t*)start, buf-start,  
    2186                      (pj_uint8_t*)key.ptr, key.slen, 
    2187                      amsgint->hmac); 
     2185        /* Calculate HMAC-SHA1 digest, add zero padding to input 
     2186         * if necessary to make the input 64 bytes aligned. 
     2187         */ 
     2188        pj_hmac_sha1_init(&ctx, (pj_uint8_t*)key.ptr, key.slen); 
     2189        pj_hmac_sha1_update(&ctx, (pj_uint8_t*)start, buf-start); 
     2190        if ((buf-start) & 0x3F) { 
     2191            pj_uint8_t zeroes[64]; 
     2192            pj_bzero(zeroes, sizeof(zeroes)); 
     2193            pj_hmac_sha1_update(&ctx, zeroes, 64-((buf-start) & 0x3F)); 
     2194        } 
     2195        pj_hmac_sha1_final(&ctx, amsgint->hmac); 
    21882196 
    21892197        /* Put this attribute in the message */ 
Note: See TracChangeset for help on using the changeset viewer.