Changeset 2939


Ignore:
Timestamp:
Aug 29, 2007, 12:46:10 PM (15 years ago)
Author:
charles
Message:

encrypt PadC

Location:
branches/encryption/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/encryption/libtransmission/handshake.c

    r2938 r2939  
    474474        crypto_provide = htonl( crypto_provide );
    475475        tr_cryptoEncrypt( handshake->crypto, sizeof(crypto_provide), &crypto_provide, &crypto_provide );
    476 fprintf( stderr, "crypto_provide is [%d]\n", crypto_provide );
    477476        evbuffer_add( outbuf, &crypto_provide, sizeof(crypto_provide) );
    478477
     
    485484        /* padc */
    486485        for( i=0; i<len; ++i ) pad[i] = tr_rand( UCHAR_MAX );
     486        tr_cryptoEncrypt( handshake->crypto, len, pad, pad );
    487487        evbuffer_add( outbuf, pad, len );
    488488    }
     
    519519    uint8_t tmp[VC_LENGTH];
    520520
     521static int drained = 0;
     522
    521523    /* note: this works w/o having to `unwind' the buffer if
    522524     * we read too much, but it is pretty brute-force.
     
    524526    for( ;; )
    525527    {
    526         if( EVBUFFER_LENGTH(inbuf) < VC_LENGTH )
     528        if( EVBUFFER_LENGTH(inbuf) < VC_LENGTH ) {
     529            fprintf( stderr, "not enough bytes... returning read_more\n" );
    527530            return READ_MORE;
     531        }
    528532
    529533        memcpy( tmp, EVBUFFER_DATA(inbuf), key_len );
     
    534538
    535539        evbuffer_drain( inbuf, 1 );
    536     }
    537 
     540        fprintf( stderr, "drained %d\n", ++drained );
     541    }
     542
     543    fprintf( stderr, "got it!\n" );
    538544    evbuffer_drain( inbuf, key_len );
    539545    setState( handshake, AWAITING_CRYPTO_SELECT );
  • branches/encryption/libtransmission/peer-connection.c

    r2938 r2939  
    7474        const int ret = (*c->canRead)( e, c->userData );
    7575        switch( ret ) {
    76             case READ_DONE: return;
    77             case READ_AGAIN: continue;
    78             case READ_MORE: tr_peerConnectionSetIOMode( c, EV_READ ); return;
     76            case READ_DONE: return; fprintf( stderr, "READ_DONE\n"); break;
     77            case READ_AGAIN: fprintf( stderr, "READ_AGAIN: going again w/o reading more data"); continue; break;
     78            case READ_MORE: fprintf( stderr, "READ_MORE: waiting for more...\n" ); tr_peerConnectionSetIOMode( c, EV_READ ); return; break;
    7979        }
    8080    }
  • branches/encryption/libtransmission/trevent.c

    r2936 r2939  
    127127            read( fd, &buf, sizeof(char*) );
    128128            read( fd, &buflen, sizeof(size_t) );
    129             fprintf( stderr, "bufev is %p, buflen is %d, buf is %p\n", bufev, (int)buflen, buf );
    130129            bufferevent_enable( bufev, EV_WRITE );
    131130            bufferevent_disable( bufev, EV_READ );
     
    274273
    275274    tr_lockLock( lock );
    276 fprintf( stderr, "writing to bufev %p: %d bytes starting at %p\n", bufev, (int)buflen, local );
    277275    tr_dbg( "writing bufferevent_write pipe" );
    278276    write( fd, &ch, 1 );
Note: See TracChangeset for help on using the changeset viewer.