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

    r1126 r1265  
    120120    const pj_stun_realm_attr *arealm; 
    121121    const pj_stun_realm_attr *anonce; 
     122    pj_hmac_sha1_context ctx; 
    122123    pj_uint8_t digest[PJ_SHA1_DIGEST_SIZE]; 
    123124    pj_uint8_t md5_digest[16]; 
     
    328329    } 
    329330 
    330     /* Now calculate HMAC of the message */ 
    331     pj_hmac_sha1(pkt, amsgi_pos, (pj_uint8_t*)key.ptr, key.slen, digest); 
     331    /* Now calculate HMAC of the message, adding zero padding if necessary 
     332     * to make the input 64 bytes aligned. 
     333     */ 
     334    pj_hmac_sha1_init(&ctx, (pj_uint8_t*)key.ptr, key.slen); 
     335    pj_hmac_sha1_update(&ctx, pkt, amsgi_pos); 
     336    if (amsgi_pos & 0x3F) { 
     337        pj_uint8_t zeroes[64]; 
     338        pj_bzero(zeroes, sizeof(zeroes)); 
     339        pj_hmac_sha1_update(&ctx, zeroes, 64-(amsgi_pos & 0x3F)); 
     340    } 
     341    pj_hmac_sha1_final(&ctx, digest); 
    332342 
    333343    /* Compare HMACs */ 
Note: See TracChangeset for help on using the changeset viewer.