Ignore:
Timestamp:
2008-06-22T19:21:06Z (16 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
dfbb056
Parents:
fab3d2d
Message:

From the department of over-engineering, now cached packet IDs are full
MD5 hashes instead of a known MD5 hash with a number. Just to make it
harder to confuse BitlBee by sending it faked responses to packets.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/jabber.c

    rfab3d2d r89d736a  
    3333#include "jabber.h"
    3434#include "md5.h"
    35 #include "base64.h"
    3635
    3736GSList *jabber_connections;
     
    241240}
    242241
     242/* This generates an unfinished md5_state_t variable. Every time we generate
     243   an ID, we finish the state by adding a sequence number and take the hash. */
    243244static void jabber_generate_id_hash( struct jabber_data *jd )
    244245{
    245         md5_state_t id_hash;
    246         md5_byte_t binbuf[16];
     246        md5_byte_t binbuf[4];
    247247        char *s;
    248248       
    249         md5_init( &id_hash );
    250         md5_append( &id_hash, (unsigned char *) jd->username, strlen( jd->username ) );
    251         md5_append( &id_hash, (unsigned char *) jd->server, strlen( jd->server ) );
     249        md5_init( &jd->cached_id_prefix );
     250        md5_append( &jd->cached_id_prefix, (unsigned char *) jd->username, strlen( jd->username ) );
     251        md5_append( &jd->cached_id_prefix, (unsigned char *) jd->server, strlen( jd->server ) );
    252252        s = set_getstr( &jd->ic->acc->set, "resource" );
    253         md5_append( &id_hash, (unsigned char *) s, strlen( s ) );
    254         random_bytes( binbuf, 16 );
    255         md5_append( &id_hash, binbuf, 16 );
    256         md5_finish( &id_hash, binbuf );
    257        
    258         s = base64_encode( binbuf, 9 );
    259         jd->cached_id_prefix = g_strdup_printf( "%s%s", JABBER_CACHED_ID, s );
    260         g_free( s );
     253        md5_append( &jd->cached_id_prefix, (unsigned char *) s, strlen( s ) );
     254        random_bytes( binbuf, 4 );
     255        md5_append( &jd->cached_id_prefix, binbuf, 4 );
    261256}
    262257
     
    289284        xt_free( jd->xt );
    290285       
    291         g_free( jd->cached_id_prefix );
    292286        g_free( jd->away_message );
    293287        g_free( jd->username );
Note: See TracChangeset for help on using the changeset viewer.