Changeset 2938
- Timestamp:
- Aug 29, 2007, 12:24:34 PM (15 years ago)
- Location:
- branches/encryption/libtransmission
- Files:
-
- 8 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/encryption/libtransmission/Makefile.am
r2936 r2938 13 13 clients.c \ 14 14 completion.c \ 15 crypto.c \ 15 16 dirname.c \ 16 encryption.c \17 17 fastresume.c \ 18 18 fdlimit.c \ … … 50 50 choking.h \ 51 51 clients.h \ 52 crypto.h \ 52 53 completion.h \ 53 encryption.h \54 54 fastresume.h \ 55 55 fdlimit.h \ -
branches/encryption/libtransmission/crypto.c
r2936 r2938 8 8 * the Transmission project. 9 9 * 10 * $Id :$10 * $Id$ 11 11 */ 12 12 … … 22 22 23 23 #include <event.h> 24 #include " encryption.h"24 #include "crypto.h" 25 25 #include "utils.h" 26 26 … … 50 50 } 51 51 SHA1_Final( setme, &sha ); 52 53 54 }55 56 void57 tr_sha1_buf( struct evbuffer * outbuf,58 const void * content1,59 int content1_len,60 ... )61 {62 uint8_t shabuf[SHA_DIGEST_LENGTH];63 va_list vl;64 SHA_CTX sha;65 66 SHA1_Init( &sha );67 SHA1_Update( &sha, content1, content1_len );68 69 va_start( vl, content1_len );70 for( ;; ) {71 const void * content = (const void*) va_arg( vl, const void* );72 const int content_len = content ? (int) va_arg( vl, int ) : -1;73 if( content==NULL || content_len<1 )74 break;75 SHA1_Update( &sha, content, content_len );76 }77 SHA1_Final( shabuf, &sha );78 79 evbuffer_add( outbuf, shabuf, SHA_DIGEST_LENGTH );80 52 } 81 53 … … 102 74 static const uint8_t dh_G[] = { 2 }; 103 75 104 struct tr_ encryption76 struct tr_crypto 105 77 { 106 78 DH * dh; … … 120 92 **/ 121 93 122 tr_ encryption*123 tr_ encryptionNew( const uint8_t * torrentHash,124 94 tr_crypto * 95 tr_cryptoNew( const uint8_t * torrentHash, 96 int isIncoming ) 125 97 { 126 98 int len, offset; 127 tr_ encryption * e;128 129 e = tr_new0( tr_encryption, 1 );130 e->isIncoming = isIncoming ? 1 : 0;131 tr_ encryptionSetTorrentHash( e, torrentHash );132 133 e->dh = DH_new( );134 e->dh->p = BN_bin2bn( dh_P, sizeof(dh_P), NULL );135 e->dh->g = BN_bin2bn( dh_G, sizeof(dh_G), NULL );136 DH_generate_key( e->dh );99 tr_crypto * crypto; 100 101 crypto = tr_new0( tr_crypto, 1 ); 102 crypto->isIncoming = isIncoming ? 1 : 0; 103 tr_cryptoSetTorrentHash( crypto, torrentHash ); 104 105 crypto->dh = DH_new( ); 106 crypto->dh->p = BN_bin2bn( dh_P, sizeof(dh_P), NULL ); 107 crypto->dh->g = BN_bin2bn( dh_G, sizeof(dh_G), NULL ); 108 DH_generate_key( crypto->dh ); 137 109 138 110 // DH can generate key sizes that are smaller than the size of 139 111 // P with exponentially decreasing probability, in which case 140 112 // the msb's of myPublicKey need to be zeroed appropriately. 141 len = DH_size( e->dh );113 len = DH_size( crypto->dh ); 142 114 offset = KEY_LEN - len; 143 115 assert( len <= KEY_LEN ); 144 memset( e->myPublicKey, 0, offset );145 BN_bn2bin( e->dh->pub_key, e->myPublicKey + offset );146 147 return e;148 } 149 150 void 151 tr_ encryptionFree( tr_encryption * e)152 { 153 assert( e!= NULL );154 assert( e->dh != NULL );155 156 DH_free( e->dh );157 tr_free( e);116 memset( crypto->myPublicKey, 0, offset ); 117 BN_bn2bin( crypto->dh->pub_key, crypto->myPublicKey + offset ); 118 119 return crypto; 120 } 121 122 void 123 tr_cryptoFree( tr_crypto * crypto ) 124 { 125 assert( crypto != NULL ); 126 assert( crypto->dh != NULL ); 127 128 DH_free( crypto->dh ); 129 tr_free( crypto ); 158 130 } 159 131 … … 163 135 164 136 const uint8_t* 165 tr_ encryptionComputeSecret( tr_encryption * e,166 const uint8_t* peerPublicKey )137 tr_cryptoComputeSecret( tr_crypto * crypto, 138 const uint8_t * peerPublicKey ) 167 139 { 168 140 int len, offset; 169 141 uint8_t secret[KEY_LEN]; 170 142 BIGNUM * bn = BN_bin2bn( peerPublicKey, KEY_LEN, NULL ); 171 assert( DH_size( e->dh) == KEY_LEN );172 173 len = DH_compute_key( secret, bn, e->dh );143 assert( DH_size(crypto->dh) == KEY_LEN ); 144 145 len = DH_compute_key( secret, bn, crypto->dh ); 174 146 assert( len <= KEY_LEN ); 175 147 offset = KEY_LEN - len; 176 memset( e->mySecret, 0, offset );177 memcpy( e->mySecret + offset, secret, len );178 e->mySecretIsSet = 1;148 memset( crypto->mySecret, 0, offset ); 149 memcpy( crypto->mySecret + offset, secret, len ); 150 crypto->mySecretIsSet = 1; 179 151 180 152 BN_free( bn ); 181 153 182 return e->mySecret;154 return crypto->mySecret; 183 155 } 184 156 185 157 const uint8_t* 186 tr_ encryptionGetMyPublicKey( const tr_encryption * e, int * setme_len )158 tr_cryptoGetMyPublicKey( const tr_crypto * crypto, int * setme_len ) 187 159 { 188 160 *setme_len = KEY_LEN; 189 return e->myPublicKey;161 return crypto->myPublicKey; 190 162 } 191 163 … … 195 167 196 168 static void 197 initRC4( tr_ encryption * e, RC4_KEY * setme, const char * key )169 initRC4( tr_crypto * crypto, RC4_KEY * setme, const char * key ) 198 170 { 199 171 SHA_CTX sha; 200 172 uint8_t buf[SHA_DIGEST_LENGTH]; 201 173 202 assert( e->torrentHashIsSet );203 assert( e->mySecretIsSet );174 assert( crypto->torrentHashIsSet ); 175 assert( crypto->mySecretIsSet ); 204 176 205 177 SHA1_Init( &sha ); 206 178 SHA1_Update( &sha, key, 4 ); 207 SHA1_Update( &sha, e->mySecret, KEY_LEN );208 SHA1_Update( &sha, e->torrentHash, SHA_DIGEST_LENGTH );179 SHA1_Update( &sha, crypto->mySecret, KEY_LEN ); 180 SHA1_Update( &sha, crypto->torrentHash, SHA_DIGEST_LENGTH ); 209 181 SHA1_Final( buf, &sha ); 210 182 RC4_set_key( setme, SHA_DIGEST_LENGTH, buf ); … … 212 184 213 185 void 214 tr_ encryptionDecryptInit( tr_encryption * encryption)186 tr_cryptoDecryptInit( tr_crypto * crypto ) 215 187 { 216 188 unsigned char discard[1024]; 217 const char * txt = encryption->isIncoming ? "keyA" : "keyB";218 initRC4( encryption, &encryption->dec_key, txt );219 RC4( & encryption->dec_key, sizeof(discard), discard, discard );220 } 221 222 void 223 tr_ encryptionDecrypt( tr_encryption * encryption,224 size_tbuf_len,225 const void* buf_in,226 void* buf_out )227 { 228 RC4( & encryption->dec_key, buf_len,189 const char * txt = crypto->isIncoming ? "keyA" : "keyB"; 190 initRC4( crypto, &crypto->dec_key, txt ); 191 RC4( &crypto->dec_key, sizeof(discard), discard, discard ); 192 } 193 194 void 195 tr_cryptoDecrypt( tr_crypto * crypto, 196 size_t buf_len, 197 const void * buf_in, 198 void * buf_out ) 199 { 200 RC4( &crypto->dec_key, buf_len, 229 201 (const unsigned char*)buf_in, 230 202 (unsigned char*)buf_out ); … … 232 204 233 205 void 234 tr_ encryptionEncryptInit( tr_encryption * encryption)206 tr_cryptoEncryptInit( tr_crypto * crypto ) 235 207 { 236 208 unsigned char discard[1024]; 237 const char * txt = encryption->isIncoming ? "keyB" : "keyA";238 initRC4( encryption, &encryption->enc_key, txt );239 RC4( & encryption->enc_key, sizeof(discard), discard, discard );240 } 241 242 void 243 tr_ encryptionEncrypt( tr_encryption * encryption,244 size_tbuf_len,245 const void* buf_in,246 void* buf_out )247 { 248 RC4( & encryption->enc_key, buf_len,209 const char * txt = crypto->isIncoming ? "keyB" : "keyA"; 210 initRC4( crypto, &crypto->enc_key, txt ); 211 RC4( &crypto->enc_key, sizeof(discard), discard, discard ); 212 } 213 214 void 215 tr_cryptoEncrypt( tr_crypto * crypto, 216 size_t buf_len, 217 const void * buf_in, 218 void * buf_out ) 219 { 220 RC4( &crypto->enc_key, buf_len, 249 221 (const unsigned char*)buf_in, 250 222 (unsigned char*)buf_out ); … … 256 228 257 229 void 258 tr_ encryptionSetTorrentHash( tr_encryption * e,259 260 { 261 e->torrentHashIsSet = hash ? 1 : 0;230 tr_cryptoSetTorrentHash( tr_crypto * crypto, 231 const uint8_t * hash ) 232 { 233 crypto->torrentHashIsSet = hash ? 1 : 0; 262 234 263 235 if( hash != NULL ) 264 memcpy( e->torrentHash, hash, SHA_DIGEST_LENGTH );236 memcpy( crypto->torrentHash, hash, SHA_DIGEST_LENGTH ); 265 237 else 266 memset( e->torrentHash, 0, SHA_DIGEST_LENGTH );238 memset( crypto->torrentHash, 0, SHA_DIGEST_LENGTH ); 267 239 } 268 240 269 241 const uint8_t* 270 tr_ encryptionGetTorrentHash( const tr_encryption * e)271 { 272 assert( e->torrentHashIsSet );273 274 return e->torrentHash;275 } 242 tr_cryptoGetTorrentHash( const tr_crypto * crypto ) 243 { 244 assert( crypto->torrentHashIsSet ); 245 246 return crypto->torrentHash; 247 } -
branches/encryption/libtransmission/crypto.h
r2936 r2938 8 8 * the Transmission project. 9 9 * 10 * $Id :$10 * $Id$ 11 11 */ 12 12 … … 21 21 22 22 struct evbuffer; 23 typedef struct tr_ encryption tr_encryption;23 typedef struct tr_crypto tr_crypto; 24 24 25 25 /** … … 27 27 **/ 28 28 29 tr_ encryption* tr_encryptionNew ( const uint8_t * torrentHash,30 29 tr_crypto* tr_cryptoNew ( const uint8_t * torrentHash, 30 int isIncoming ); 31 31 32 void tr_ encryptionFree( tr_encryption * encryption);32 void tr_cryptoFree( tr_crypto * crypto ); 33 33 34 34 /** … … 36 36 **/ 37 37 38 void tr_ encryptionSetTorrentHash( tr_encryption * encryption,39 38 void tr_cryptoSetTorrentHash( tr_crypto * crypto, 39 const uint8_t * torrentHash ); 40 40 41 const uint8_t* tr_ encryptionGetTorrentHash( const tr_encryption * encryption);41 const uint8_t* tr_cryptoGetTorrentHash( const tr_crypto * crypto ); 42 42 43 43 /** … … 45 45 **/ 46 46 47 const uint8_t* tr_ encryptionComputeSecret ( tr_encryption * encryption,48 47 const uint8_t* tr_cryptoComputeSecret ( tr_crypto * crypto, 48 const uint8_t * peerPublicKey ); 49 49 50 const uint8_t* tr_ encryptionGetMyPublicKey ( const tr_encryption * encryption,51 int* setme_len );50 const uint8_t* tr_cryptoGetMyPublicKey ( const tr_crypto * crypto, 51 int * setme_len ); 52 52 53 void tr_ encryptionDecryptInit( tr_encryption * encryption);53 void tr_cryptoDecryptInit( tr_crypto * crypto ); 54 54 55 void tr_ encryptionDecrypt ( tr_encryption * encryption,56 size_tbuflen,57 const void* buf_in,58 void* buf_out );55 void tr_cryptoDecrypt ( tr_crypto * crypto, 56 size_t buflen, 57 const void * buf_in, 58 void * buf_out ); 59 59 60 void tr_ encryptionEncryptInit( tr_encryption * encryption);60 void tr_cryptoEncryptInit( tr_crypto * crypto ); 61 61 62 void tr_ encryptionEncrypt ( tr_encryption * encryption,63 size_tbuflen,64 const void* buf_in,65 void* buf_out );62 void tr_cryptoEncrypt ( tr_crypto * crypto, 63 size_t buflen, 64 const void * buf_in, 65 void * buf_out ); 66 66 67 67 /** … … 69 69 **/ 70 70 71 72 73 void tr_sha1( uint8_t* setme, 74 const void * content1, int content1_len, 75 ... ); 76 77 void tr_sha1_buf( struct evbuffer* outbuf, 78 const void * content1, int content1_len, 79 ... ); 71 void tr_sha1( uint8_t* setme, 72 const void * content1, int content1_len, 73 ... ); 80 74 81 75 /** -
branches/encryption/libtransmission/handshake.c
r2936 r2938 8 8 * the Transmission project. 9 9 * 10 * $Id :$10 * $Id$ 11 11 */ 12 12 … … 24 24 #include <event.h> 25 25 26 #include "transmission.h"27 #include "encryption.h"28 #include "handshake.h"29 #include "peer-connection.h"30 #include "utils.h"26 #include <libtransmission/transmission.h> 27 #include <libtransmission/crypto.h> 28 #include <libtransmission/handshake.h> 29 #include <libtransmission/peer-connection.h> 30 #include <libtransmission/utils.h> 31 31 32 32 /*** … … 78 78 { 79 79 tr_peerConnection * connection; 80 tr_ encryption * encryption;80 tr_crypto * crypto; 81 81 struct tr_handle * handle; 82 82 uint8_t myPublicKey[96]; … … 180 180 181 181 /* add our public key (Ya) */ 182 public_key = tr_ encryptionGetMyPublicKey( handshake->encryption, &len );182 public_key = tr_cryptoGetMyPublicKey( handshake->crypto, &len ); 183 183 assert( len == KEY_LEN ); 184 184 assert( public_key != NULL ); … … 203 203 { 204 204 uint8_t *walk = buf; 205 const uint8_t * torrentHash = tr_ encryptionGetTorrentHash( handshake->encryption);205 const uint8_t * torrentHash = tr_cryptoGetTorrentHash( handshake->crypto ); 206 206 207 207 memcpy( walk, HANDSHAKE_NAME, HANDSHAKE_NAME_LEN ); … … 259 259 /* read the incoming peer's public key */ 260 260 evbuffer_remove( inbuf, ya, KEY_LEN ); 261 secret = tr_ encryptionComputeSecret( handshake->encryption, ya );261 secret = tr_cryptoComputeSecret( handshake->crypto, ya ); 262 262 memcpy( handshake->mySecret, secret, KEY_LEN ); 263 263 tr_sha1( handshake->myReq1, "req1", 4, secret, KEY_LEN, NULL ); … … 265 265 /* send our public key to the peer */ 266 266 walk = outbuf; 267 myKey = tr_ encryptionGetMyPublicKey( handshake->encryption, &len );267 myKey = tr_cryptoGetMyPublicKey( handshake->crypto, &len ); 268 268 memcpy( walk, myKey, len ); 269 269 len = tr_rand( 512 ); … … 340 340 /* next part: ENCRYPT(VC, crypto_provide, len(PadC), */ 341 341 342 tr_ encryptionDecryptInit( handshake->encryption);342 tr_cryptoDecryptInit( handshake->crypto ); 343 343 344 344 evbuffer_remove( inbuf, vc_in, VC_LENGTH ); 345 tr_ encryptionDecrypt( handshake->encryption, VC_LENGTH, vc_in, vc_in );345 tr_cryptoDecrypt( handshake->crypto, VC_LENGTH, vc_in, vc_in ); 346 346 fprintf( stderr, "read vc -> %d %d %d %d %d %d %d %d\n", 347 347 (int)vc_in[0], (int)vc_in[1], (int)vc_in[2], (int)vc_in[3], … … 349 349 350 350 evbuffer_remove( inbuf, &crypto_provide, sizeof(crypto_provide) ); 351 tr_ encryptionDecrypt( handshake->encryption, sizeof(crypto_provide),351 tr_cryptoDecrypt( handshake->crypto, sizeof(crypto_provide), 352 352 &crypto_provide, &crypto_provide ); 353 353 crypto_provide = ntohl( crypto_provide ); … … 355 355 356 356 evbuffer_remove( inbuf, &padc_len, sizeof(padc_len) ); 357 tr_ encryptionDecrypt( handshake->encryption, sizeof(padc_len), &padc_len, &padc_len );357 tr_cryptoDecrypt( handshake->crypto, sizeof(padc_len), &padc_len, &padc_len ); 358 358 padc_len = ntohs( padc_len ); 359 359 fprintf( stderr, "padc is %d\n", (int)padc_len ); … … 393 393 ia = tr_new( uint8_t, handshake->ia_len ); 394 394 evbuffer_remove( inbuf, ia, handshake->ia_len ); 395 tr_ encryptionDecrypt( handshake->encryption, handshake->ia_len, ia, ia );395 tr_cryptoDecrypt( handshake->crypto, handshake->ia_len, ia, ia ); 396 396 fprintf( stderr, "got their payload ia: [%*.*s]\n", (int)needlen, (int)needlen, ia ); 397 397 … … 425 425 /* compute the secret */ 426 426 evbuffer_remove( inbuf, yb, KEY_LEN ); 427 secret = tr_ encryptionComputeSecret( handshake->encryption, yb );427 secret = tr_cryptoComputeSecret( handshake->crypto, yb ); 428 428 memcpy( handshake->mySecret, secret, KEY_LEN ); 429 429 … … 445 445 uint8_t req3[SHA_DIGEST_LENGTH]; 446 446 uint8_t buf[SHA_DIGEST_LENGTH]; 447 tr_sha1( req2, "req2", 4, tr_ encryptionGetTorrentHash(handshake->encryption), SHA_DIGEST_LENGTH, NULL );447 tr_sha1( req2, "req2", 4, tr_cryptoGetTorrentHash(handshake->crypto), SHA_DIGEST_LENGTH, NULL ); 448 448 tr_sha1( req3, "req3", 4, secret, KEY_LEN, NULL ); 449 449 for( i=0; i<SHA_DIGEST_LENGTH; ++i ) … … 459 459 uint32_t crypto_provide; 460 460 461 tr_ encryptionEncryptInit( handshake->encryption);461 tr_cryptoEncryptInit( handshake->crypto ); 462 462 463 463 /* vc */ 464 tr_ encryptionEncrypt( handshake->encryption, VC_LENGTH, vc, vc );464 tr_cryptoEncrypt( handshake->crypto, VC_LENGTH, vc, vc ); 465 465 evbuffer_add( outbuf, vc, VC_LENGTH ); 466 466 … … 473 473 assert( 1<=crypto_provide && crypto_provide<=3 ); 474 474 crypto_provide = htonl( crypto_provide ); 475 tr_ encryptionEncrypt( handshake->encryption, sizeof(crypto_provide), &crypto_provide, &crypto_provide );475 tr_cryptoEncrypt( handshake->crypto, sizeof(crypto_provide), &crypto_provide, &crypto_provide ); 476 476 fprintf( stderr, "crypto_provide is [%d]\n", crypto_provide ); 477 477 evbuffer_add( outbuf, &crypto_provide, sizeof(crypto_provide) ); … … 480 480 i = len = tr_rand( 512 ); 481 481 i = htons( i ); 482 tr_ encryptionEncrypt( handshake->encryption, sizeof(i), &i, &i );482 tr_cryptoEncrypt( handshake->crypto, sizeof(i), &i, &i ); 483 483 evbuffer_add( outbuf, &i, sizeof(i) ); 484 484 … … 495 495 496 496 i = htons( HANDSHAKE_SIZE ); 497 tr_ encryptionEncrypt( handshake->encryption, sizeof(uint16_t), &i, &i );497 tr_cryptoEncrypt( handshake->crypto, sizeof(uint16_t), &i, &i ); 498 498 evbuffer_add( outbuf, &i, sizeof(uint16_t) ); 499 499 500 tr_ encryptionEncrypt( handshake->encryption, HANDSHAKE_SIZE, msg, msg );500 tr_cryptoEncrypt( handshake->crypto, HANDSHAKE_SIZE, msg, msg ); 501 501 evbuffer_add( outbuf, msg, HANDSHAKE_SIZE ); 502 502 } 503 503 504 504 /* send it */ 505 tr_ encryptionDecryptInit( handshake->encryption);505 tr_cryptoDecryptInit( handshake->crypto ); 506 506 setState( handshake, SENDING_CRYPTO_PROVIDE ); 507 507 tr_peerConnectionWriteBuf( handshake->connection, outbuf ); … … 528 528 529 529 memcpy( tmp, EVBUFFER_DATA(inbuf), key_len ); 530 tr_ encryptionDecryptInit( handshake->encryption);531 tr_ encryptionDecrypt( handshake->encryption, key_len, tmp, tmp );530 tr_cryptoDecryptInit( handshake->crypto ); 531 tr_cryptoDecrypt( handshake->crypto, key_len, tmp, tmp ); 532 532 if( !memcmp( tmp, key, key_len ) ) 533 533 break; … … 552 552 return READ_MORE; 553 553 554 // tr_ encryptionDecryptInit( handshake->encryption);554 // tr_cryptoDecryptInit( handshake->crypto ); 555 555 556 556 evbuffer_remove( inbuf, &crypto_select, sizeof(uint32_t) ); 557 tr_ encryptionDecrypt( handshake->encryption, sizeof(uint32_t), &crypto_select, &crypto_select );557 tr_cryptoDecrypt( handshake->crypto, sizeof(uint32_t), &crypto_select, &crypto_select ); 558 558 fprintf( stderr, "crypto select 1 is %d\n", crypto_select ); 559 559 crypto_select = ntohl( crypto_select ); … … 563 563 564 564 evbuffer_remove( inbuf, &pad_d_len, sizeof(uint16_t) ); 565 tr_ encryptionDecrypt( handshake->encryption, sizeof(uint16_t), &pad_d_len, &pad_d_len );565 tr_cryptoDecrypt( handshake->crypto, sizeof(uint16_t), &pad_d_len, &pad_d_len ); 566 566 pad_d_len = ntohs( pad_d_len ); 567 567 fprintf( stderr, "pad_d_len is %d\n", (int)pad_d_len ); … … 585 585 buf = tr_new( uint8_t, needlen ); 586 586 evbuffer_remove( inbuf, buf, needlen ); 587 tr_ encryptionDecrypt( handshake->encryption, needlen, buf, buf );587 tr_cryptoDecrypt( handshake->crypto, needlen, buf, buf ); 588 588 tr_free( buf ); 589 589 … … 617 617 if( encrypted ) { 618 618 fprintf( stderr, "clearly it's encrypted...\n" ); 619 //tr_ encryptionDecryptInit( handshake->encryption);620 tr_ encryptionDecrypt( handshake->encryption, 1, &pstrlen, &pstrlen );619 //tr_cryptoDecryptInit( handshake->crypto ); 620 tr_cryptoDecrypt( handshake->crypto, 1, &pstrlen, &pstrlen ); 621 621 } 622 622 fprintf( stderr, "pstrlen is %d [%c]\n", (int)pstrlen, pstrlen ); … … 627 627 evbuffer_remove( inbuf, pstr, pstrlen ); 628 628 if( encrypted ) 629 tr_ encryptionDecrypt( handshake->encryption, pstrlen, pstr, pstr );629 tr_cryptoDecrypt( handshake->crypto, pstrlen, pstr, pstr ); 630 630 pstr[pstrlen] = '\0'; 631 631 fprintf( stderr, "pstrlen is [%s]\n", pstr ); … … 635 635 evbuffer_remove( inbuf, reserved, sizeof(reserved) ); 636 636 if( encrypted ) 637 tr_ encryptionDecrypt( handshake->encryption, sizeof(reserved), reserved, reserved );637 tr_cryptoDecrypt( handshake->crypto, sizeof(reserved), reserved, reserved ); 638 638 639 639 /* torrent hash */ 640 640 evbuffer_remove( inbuf, hash, sizeof(hash) ); 641 641 if( encrypted ) 642 tr_ encryptionDecrypt( handshake->encryption, sizeof(hash), hash, hash );642 tr_cryptoDecrypt( handshake->crypto, sizeof(hash), hash, hash ); 643 643 assert( !memcmp( hash, tr_peerConnectionGetTorrent(handshake->connection)->info.hash, SHA_DIGEST_LENGTH ) ); 644 644 … … 647 647 evbuffer_remove( inbuf, peer_id, sizeof(peer_id) ); 648 648 if( encrypted ) 649 tr_ encryptionDecrypt( handshake->encryption, sizeof(peer_id), peer_id, peer_id );649 tr_cryptoDecrypt( handshake->crypto, sizeof(peer_id), peer_id, peer_id ); 650 650 fprintf( stderr, "peer_id: " ); 651 651 for( i=0; i<20; ++i ) fprintf( stderr, "[%c]", peer_id[i] ); … … 790 790 handshake = tr_new0( tr_handshake, 1 ); 791 791 handshake->connection = connection; 792 handshake-> encryption = tr_peerConnectionGetEncryption( connection );792 handshake->crypto = tr_peerConnectionGetCrypto( connection ); 793 793 handshake->encryptionPreference = encryptionPreference; 794 794 handshake->doneCB = doneCB; -
branches/encryption/libtransmission/inout.c
r2936 r2938 21 21 #include "transmission.h" 22 22 #include "completion.h" 23 #include " encryption.h"23 #include "crypto.h" 24 24 #include "fdlimit.h" 25 25 #include "inout.h" -
branches/encryption/libtransmission/makemeta.c
r2936 r2938 22 22 #include <dirent.h> 23 23 24 #include " encryption.h" /* tr_sha1 */24 #include "crypto.h" /* tr_sha1 */ 25 25 #include "trcompat.h" /* strlcpy */ 26 26 #include "transmission.h" -
branches/encryption/libtransmission/metainfo.c
r2936 r2938 34 34 #include "transmission.h" 35 35 #include "bencode.h" 36 #include " encryption.h" /* tr_sha1 */36 #include "crypto.h" /* tr_sha1 */ 37 37 #include "http.h" /* tr_httpParseUrl */ 38 38 #include "metainfo.h" -
branches/encryption/libtransmission/peer-connection.c
r2936 r2938 8 8 * the Transmission project. 9 9 * 10 * $Id :$10 * $Id$ 11 11 */ 12 12 … … 18 18 #include <event.h> 19 19 #include "transmission.h" 20 #include " encryption.h"20 #include "crypto.h" 21 21 #include "net.h" 22 22 #include "peer-connection.h" … … 49 49 void * userData; 50 50 51 tr_ encryption * encryption;51 tr_crypto * crypto; 52 52 }; 53 53 … … 103 103 c = tr_new0( tr_peerConnection, 1 ); 104 104 c->torrent = torrent; 105 c-> encryption = tr_encryptionNew( torrent ? torrent->info.hash : NULL, isIncoming );105 c->crypto = tr_cryptoNew( torrent ? torrent->info.hash : NULL, isIncoming ); 106 106 c->handle = handle; 107 107 c->in_addr = *in_addr; … … 150 150 bufferevent_free( c->bufev ); 151 151 tr_netClose( c->socket ); 152 tr_ encryptionFree( c->encryption);152 tr_cryptoFree( c->crypto ); 153 153 tr_free( c ); 154 154 } … … 203 203 204 204 205 tr_ encryption*206 tr_peerConnectionGet Encryption( tr_peerConnection * c )207 { 208 return c-> encryption;205 tr_crypto* 206 tr_peerConnectionGetCrypto( tr_peerConnection * c ) 207 { 208 return c->crypto; 209 209 } 210 210 … … 243 243 connection->torrent = torrent; 244 244 245 tr_ encryptionSetTorrentHash( connection->encryption, torrent->info.hash );245 tr_cryptoSetTorrentHash( connection->crypto, torrent->info.hash ); 246 246 } 247 247 -
branches/encryption/libtransmission/peer-connection.h
r2936 r2938 8 8 * the Transmission project. 9 9 * 10 * $Id :$10 * $Id$ 11 11 */ 12 12 … … 22 22 struct bufferevent; 23 23 struct tr_handle; 24 struct tr_ encryption;24 struct tr_crypto; 25 25 struct tr_torrent; 26 26 typedef struct tr_peerConnection tr_peerConnection; … … 100 100 **/ 101 101 102 struct tr_ encryption*103 tr_peerConnectionGet Encryption( tr_peerConnection * connection );102 struct tr_crypto* 103 tr_peerConnectionGetCrypto( tr_peerConnection * connection ); 104 104 105 105 /** -
branches/encryption/libtransmission/torrent.c
r2936 r2938 32 32 #include "transmission.h" 33 33 #include "completion.h" 34 #include " encryption.h"34 #include "crypto.h" /* for tr_sha1 */ 35 35 #include "fastresume.h" 36 36 #include "handshake.h"
Note: See TracChangeset
for help on using the changeset viewer.