• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/transmission/transmission-2.73/libtransmission/

Lines Matching refs:crypto

10  * $Id: crypto.c 12885 2011-09-16 22:55:58Z jordan $
28 #include "crypto.h"
94 ensureKeyExists( tr_crypto * crypto)
96 if( crypto->dh == NULL )
125 memset( crypto->myPublicKey, 0, offset );
126 BN_bn2bin( dh->pub_key, crypto->myPublicKey + offset );
128 crypto->dh = dh;
133 tr_cryptoConstruct( tr_crypto * crypto, const uint8_t * torrentHash, bool isIncoming )
135 memset( crypto, 0, sizeof ( tr_crypto ) );
137 crypto->dh = NULL;
138 crypto->isIncoming = isIncoming;
139 tr_cryptoSetTorrentHash( crypto, torrentHash );
143 tr_cryptoDestruct( tr_crypto * crypto )
145 if( crypto->dh != NULL )
146 DH_free( crypto->dh );
154 tr_cryptoComputeSecret( tr_crypto * crypto,
162 ensureKeyExists( crypto );
163 dh = crypto->dh;
174 memset( crypto->mySecret, 0, offset );
175 memcpy( crypto->mySecret + offset, secret, len );
176 crypto->mySecretIsSet = 1;
180 return crypto->mySecret;
184 tr_cryptoGetMyPublicKey( const tr_crypto * crypto,
187 ensureKeyExists( (tr_crypto *) crypto );
189 return crypto->myPublicKey;
197 initRC4( tr_crypto * crypto,
204 assert( crypto->torrentHashIsSet );
205 assert( crypto->mySecretIsSet );
209 && SHA1_Update( &sha, crypto->mySecret, KEY_LEN )
210 && SHA1_Update( &sha, crypto->torrentHash, SHA_DIGEST_LENGTH )
222 tr_cryptoDecryptInit( tr_crypto * crypto )
225 const char * txt = crypto->isIncoming ? "keyA" : "keyB";
227 initRC4( crypto, &crypto->dec_key, txt );
228 RC4( &crypto->dec_key, sizeof( discard ), discard, discard );
232 tr_cryptoDecrypt( tr_crypto * crypto,
237 RC4( &crypto->dec_key, buf_len,
243 tr_cryptoEncryptInit( tr_crypto * crypto )
246 const char * txt = crypto->isIncoming ? "keyB" : "keyA";
248 initRC4( crypto, &crypto->enc_key, txt );
249 RC4( &crypto->enc_key, sizeof( discard ), discard, discard );
253 tr_cryptoEncrypt( tr_crypto * crypto,
258 RC4( &crypto->enc_key, buf_len,
268 tr_cryptoSetTorrentHash( tr_crypto * crypto,
271 crypto->torrentHashIsSet = hash ? 1 : 0;
274 memcpy( crypto->torrentHash, hash, SHA_DIGEST_LENGTH );
276 memset( crypto->torrentHash, 0, SHA_DIGEST_LENGTH );
280 tr_cryptoGetTorrentHash( const tr_crypto * crypto )
282 assert( crypto );
283 assert( crypto->torrentHashIsSet );
285 return crypto->torrentHash;
289 tr_cryptoHasTorrentHash( const tr_crypto * crypto )
291 assert( crypto );
293 return crypto->torrentHashIsSet ? 1 : 0;