Commit Graph

73 Commits

Author SHA1 Message Date
Mike Gelfand deea6fc6a2 Bring assertions closer to the beginning of blocks 2017-06-13 07:44:09 +03:00
Mike Gelfand 98695fe3c1 Introduce our own assertion macros with finer control 2017-06-08 10:24:12 +03:00
Mike Gelfand a762c770f2 Make conditional expressions explicitly boolean 2017-04-30 19:26:01 +03:00
Mike Gelfand 4f9d9ad92b Code style change leftovers
For some reason, GTK client wasn't fully processed. All the rest of changes
are mostly in comments.
2017-04-21 10:40:57 +03:00
Mike Gelfand dadffa2c0f Align type qualifiers to the right (code style)
This way all the qualifiers (`const`, `volatile`, `mutable`) are grouped
together, e.g. `T const* const x` vs. `const T* const x`. Also helps reading
types right-to-left, e.g. "constant pointer to constant T" vs. "constant
pointer to T which is constant".
2017-04-20 19:53:20 +03:00
Mike Gelfand d7930984ef Adjust uncrustify config, reformat all but Mac client
There're places where manual intervention is still required as uncrustify
is not ideal (unfortunately), but at least one may rely on it to do the
right thing most of the time (e.g. when sending in a patch).

The style itself is quite different from what we had before but making it
uniform across all the codebase is the key. I also hope that it'll make the
code more readable (YMMV) and less sensitive to further changes.
2017-04-20 10:01:22 +03:00
Mike Gelfand 2248d3670f Get rid of $Id$ SVN keywords in source files 2016-09-02 23:10:15 +03:00
Mike Gelfand 3f9575fcc8 Minor type adjustments (incomplete, it takes way too much time) 2015-03-15 11:43:32 +00:00
Mike Gelfand 748f8a75d2 #4400, #5462: Move SSHA1 helpers to crypto-utils
On a way to factoring out OpenSSL support to a standalone file to ease
addition of other crypto libraries support in the future, move helpers
providing SSHA1 password generation and checking to crypto-utils.{c,h}.
2014-12-04 20:45:18 +00:00
Mike Gelfand 117ab3e8d2 #4400, #5462: Move DH helpers to crypto-utils
On a way to factoring out OpenSSL support to a standalone file to ease
addition of other crypto libraries support in the future, move helpers
providing DH key exchange to crypto-utils.{c,h}. OpenSSL-related
functionality (DH context management) is moved to crypto-utils-openssl.c.
Since we know in advance that DH secret key management code will be the
same for most of backends, implement common functionality in separate
crypto-utils-fallback.c.

Add new tr_dh_ctx_t and tr_dh_secret_t types and functions to be
implemented by crypto backends:
* tr_dh_new - allocate DH context,
* tr_dh_free - free the context,
* tr_dh_make_key - generate private/public keypair,
* tr_dh_agree - perform DH key exchange and generate secret key,
* tr_dh_secret_derive - calculate secret key hash,
* tr_dh_secret_free - free the secret key,
* tr_dh_align_key - align some DH key in the buffer allocated for it.

Make DH secret key not accessible in plain form outside the crypto
backend. This allows for implementations where the key is managed by
the underlying library and is not even exposed to our backend.
2014-12-04 19:18:08 +00:00
Mike Gelfand d424ed143e #4400, #5462: Move RC4 helpers to crypto-utils
On a way to factoring out OpenSSL support to a standalone file to ease
addition of other crypto libraries support in the future, move helpers
providing RC4 ciphering to crypto-utils.{c,h}. OpenSSL-related
functionality (RC4 context management) is moved to crypto-utils-openssl.c.

Add new tr_rc4_ctx_t type and functions to be implemented by crypto
backends:
* tr_rc4_new - allocate RC4 context,
* tr_rc4_free - free the context,
* tr_rc4_set_key - set cipher key,
* tr_rc4_process - cipher memory block.
2014-12-04 12:37:08 +00:00
Mike Gelfand 4cfe7e7ddb #4400, #5462: Move SHA1 helpers to crypto-utils
On a way to factoring out OpenSSL support to a standalone file to ease
addition of other crypto libraries support in the future, move helpers
providing SHA1 calculation to crypto-utils.{c,h}. OpenSSL-related
functionality (SHA1 context management) is moved to crypto-utils-openssl.c.

Add new tr_sha1_ctx_t type and functions to be implemented by crypto
backends:
* tr_sha1_init - allocate SHA1 context and and initialize it,
* tr_sha1_update - hash some [more] data,
* tr_sha1_final - finish hash calculation and free the context.

Add new files to CMakeLists.txt (leftover from previous commit) to fix
CMake-based configuration.
2014-12-04 12:13:59 +00:00
Mike Gelfand f6f7bf8227 #4400, #5462: Move random helpers to crypto-utils
On a way to factoring out OpenSSL support to a standalone file to ease
addition of other crypto libraries support in the future, move helpers
providing random numbers/data generation to crypto-utils.{c,h}. OpenSSL-
related functionality (generation of cryptographically strong random
data) is moved to crypto-utils-openssl.c.

Rename functions to follow currently accepted style:
* tr_cryptoRandBuf -> tr_rand_buffer
* tr_cryptoRandInt -> tr_rand_int
* tr_cryptoWeakRandInt -> tr_rand_int_weak

Fix rare case of invalid value being returned from tr_rand_int. Return
value for abs(INT_MIN) may be undefined and thus negative, and so
tr_rand_int will return negative value which is incorrect (out of
requested and expected range).
2014-12-04 11:27:38 +00:00
Mike Gelfand e30728367f #5771: Use true and false instead of 1 and 0 for bool variables (patch by ticamkq + additional fixes) 2014-11-30 19:38:47 +00:00
Jordan Lee 4bb7f61e31 fix tr_cryptoGetTorrentHash() behavior for crypto-test.c 2014-05-18 20:47:58 +00:00
Jordan Lee 02cff80c2d Copyedit the license's revised text: (1) remove unnecessary repitition use of the word 'license' from the top of the header and source files (2) add the standard 'we hope it's useful, but no warranty' clause to COPYING (3) make explicit that linking OpenSSL is allowed (see https://people.gnome.org/~markmc/openssl-and-the-gpl.html for background) (4) sync the Qt and GTK+ clients' license popups with COPYING's revised text 2014-01-21 03:10:30 +00:00
Jordan Lee 4b9626bb83 Licensing changes:
1. add the option the code to be used under GPLv2 or GPLv3; previously only GPLv2 was allowed

2. add the "proxy option" as described in GPLv3 so we can add future licenses without having to bulk-edit everything again :)

3. remove the awkward "exception for MIT code in Mac client" clause; it was unnecessary and confusing.
2014-01-19 01:09:44 +00:00
Jordan Lee 4904b923fb (trunk) restore copyright year as suggested in email by rms 2014-01-18 20:56:57 +00:00
Jordan Lee 28fe36f1f8 #include limits.h where we use it, and don't where we don't 2013-08-24 17:53:45 +00:00
Jordan Lee f75027d5e9 make all the log functions/structs/enums use a single 'tr_log' namespace, such as tr_logGetQueue, tr_logAddInfo, tr_logIsLevelActive 2013-01-25 23:34:20 +00:00
Jordan Lee ad3407567b (libT) copyediting: modify more files to the new indentation/whitespace formatting 2013-01-24 23:59:52 +00:00
Jordan Lee 3d38723ad9 Follow more common whitespace style conventions in the C code (libtransmission, daemon, utils, cli, gtk). 2012-12-05 17:29:46 +00:00
Jordan Lee e2240e0831 (trunk libT) #4473 'underflow from malformed ssha1 can crash tr_ssha1_matches()' -- bah, fix oops in r12884. 2011-09-16 22:55:58 +00:00
Jordan Lee bb59768557 (trunk libT) #4473 "underflow from malformed ssha1 can crash tr_ssha1_matches()" -- fixed. Thanks to Volfram for finding this crash and tracking down the cause. 2011-09-16 22:53:26 +00:00
Jordan Lee 244bd7bc1c (trunk libT) more heap pruning: use composition rather than aggregation for the tr_crypto object owned by tr_peerIo. 2011-04-17 05:22:50 +00:00
Jordan Lee 375694eda9 (trunk) copyediting: remove some unneeded #includes, and annotate some needed ones 2011-03-24 21:49:42 +00:00
Jordan Lee b4d36aeb54 (trunk) #4138 "use stdbool.h instead of tr_bool" -- done. 2011-03-22 15:19:54 +00:00
Jordan Lee 4f6d46cf99 (trunk libT) minor code tweak to crypto.c's tr_sha1() function 2011-01-19 21:50:51 +00:00
Jordan Lee 6ae426696f tr_sha1(): remove unnecessary casts from va_arg 2011-01-19 21:43:43 +00:00
Jordan Lee 879a2afcbd Update the copyright year in the source code comments.
The Berne Convention says that the copyright year is moot, so instead of adding another year to each file as in previous years, I've removed the year altogether from the source code comments in libtransmission, gtk, qt, utils, daemon, and cli.

Juliusz's copyright notice in tr-dht and Johannes' copyright notice in tr-lpd have been left alone; it didn't seem appropriate to modify them.
2011-01-19 13:48:47 +00:00
Charles Kerr e5bb3205a1 (trunk) Join the 21st century and use only 1 space at the end sentences. This commit is nearly as important as the semi-annual ones that remove trailing spaces from the ends of lines of code... :) 2010-12-27 19:18:17 +00:00
Charles Kerr ad613b05f7 (trunk libT) #3638 "fewer crypto calls when creating peer-ids, session ids, announcer keys, etc" -- fixed. 2010-10-17 18:32:55 +00:00
Charles Kerr 6f5c9dcafb (trunk libt) rename tr_date() as tr_time_msec() for clarity 2010-07-11 20:49:19 +00:00
Charles Kerr 254a1f15cb (trunk libT) down the rabbit hole: various minor type correctness changes unearthed by -Wconversion 2010-06-30 16:40:19 +00:00
Charles Kerr 7936f0d5d1 (trunk libT) clean up #includes for event.h and evutil.h 2010-05-19 16:17:51 +00:00
Charles Kerr 74216be9df (trunk libT) "transmission.h" should *always* be #included before any other libtransmission header 2010-04-23 16:36:16 +00:00
Charles Kerr 8e16b74dad (trunk libT) #2775 "Saving some memory/storage" -- committed for 1.80 2010-01-20 18:48:52 +00:00
Charles Kerr 9eb07e9b16 (trunk) No code changes here... filling in some of the blanks in the "peers" and "utils" doxygen groups' documentation. 2010-01-19 19:37:00 +00:00
Charles Kerr 5c26afdb52 happy new year! 2010-01-04 21:00:47 +00:00
Mitchell Livingston bdf3144376 remove unnecessary asserts 2009-12-12 21:37:36 +00:00
Charles Kerr 196a7ccbb9 (trunk libT) #2658 "encryption improvements" - patch by sadface to make DH handshake ~2x faster. yay! 2009-12-12 03:51:36 +00:00
Charles Kerr 78ead8c3dd (trunk) update the copyright notices 2009-12-05 02:19:24 +00:00
Charles Kerr bf1a544939 (trunk) all this commit does is remove trailing whitespace from some c, c++, and javascript source 2009-08-12 14:40:32 +00:00
Charles Kerr 13cac341cd (trunk libT) avoid an extra malloc/free when sending the opening handshake message 2009-06-14 14:39:51 +00:00
Charles Kerr cd36431b0c (trunk libT) fix off-by-one in tr_ssha1() reported by lightix @ http://forum.transmissionbt.com/viewtopic.php?f=2&t=7684#p37556 2009-05-28 13:02:03 +00:00
Charles Kerr 979eddf61d (trunk libT) add some extra tests to tr_cryptoWeakRandInt() 2009-05-19 20:52:24 +00:00
Erick Turnquist 81a01fe1d3 (trunk libT) re-add rpc password to settings benc dict 2009-03-25 00:36:11 +00:00
Erick Turnquist 4b92e07ce0 (trunk libT) fix a couple warnings from r8080 2009-03-24 21:49:19 +00:00
Erick Turnquist 44ea61bced (trunk libT) #1276 - hash rpc password with sha1 2009-03-24 01:39:06 +00:00
Mitchell Livingston 50c9385ceb #1276 encrypt the password to access web client interface using SHA-2 2009-03-17 21:50:20 +00:00