Changeset 11333


Ignore:
Timestamp:
Oct 17, 2010, 6:32:55 PM (11 years ago)
Author:
charles
Message:

(trunk libT) #3638 "fewer crypto calls when creating peer-ids, session ids, announcer keys, etc" -- fixed.

Location:
trunk/libtransmission
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/announcer.c

    r11280 r11333  
    316316     * This is immutable for the life of the tracker object.
    317317     * The +1 is for '\0' */
    318     char key_param[KEYLEN + 1];
     318    unsigned char key_param[KEYLEN + 1];
    319319}
    320320tr_tracker_item;
     
    335335
    336336static void
    337 generateKeyParam( char * msg, size_t msglen )
     337generateKeyParam( unsigned char * msg, size_t msglen )
    338338{
    339339    size_t i;
     
    341341    const int poolSize = 36;
    342342
     343    tr_cryptoRandBuf( msg, msglen );
    343344    for( i=0; i<msglen; ++i )
    344         *msg++ = pool[tr_cryptoRandInt( poolSize )];
    345     *msg = '\0';
     345        msg[i] = pool[ msg[i] % poolSize ];
     346    msg[msglen] = '\0';
    346347}
    347348
  • trunk/libtransmission/crypto.c

    r10998 r11333  
    377377
    378378    size_t i;
    379     char salt[saltval_len];
     379    unsigned char salt[saltval_len];
    380380    uint8_t sha[SHA_DIGEST_LENGTH];
    381381    char buf[2*SHA_DIGEST_LENGTH + saltval_len + 2];
    382382
     383    tr_cryptoRandBuf( salt, saltval_len );
    383384    for( i=0; i<saltval_len; ++i )
    384         salt[i] = salter[ tr_cryptoRandInt( salter_len ) ];
     385        salt[i] = salter[ salt[i] % salter_len ];
    385386
    386387    tr_sha1( sha, plaintext, strlen( plaintext ), salt, saltval_len, NULL );
  • trunk/libtransmission/rpc-server.c

    r11183 r11333  
    101101        const char * pool = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    102102        const size_t pool_size = strlen( pool );
    103         char * buf = tr_new( char, n+1 );
    104 
     103        unsigned char * buf = tr_new( unsigned char, n+1 );
     104
     105        tr_cryptoRandBuf( buf, n );
    105106        for( i=0; i<n; ++i )
    106             buf[i] = pool[ tr_cryptoRandInt( pool_size ) ];
     107            buf[i] = pool[ buf[i] % pool_size ];
    107108        buf[n] = '\0';
    108109
    109110        tr_free( server->sessionId );
    110         server->sessionId = buf;
     111        server->sessionId = (char*) buf;
    111112        server->sessionIdExpiresAt = now + (60*60); /* expire in an hour */
    112113    }
  • trunk/libtransmission/session.c

    r11299 r11333  
    8888    memcpy( buf, PEERID_PREFIX, 8 );
    8989
    90     for( i = 8; i < 19; ++i )
    91     {
    92         val = tr_cryptoRandInt( base );
     90    tr_cryptoRandBuf( buf+8, 11 );
     91    for( i=8; i<19; ++i ) {
     92        val = buf[i] % base;
    9393        total += val;
    9494        buf[i] = pool[val];
Note: See TracChangeset for help on using the changeset viewer.