Commit Graph

50 Commits

Author SHA1 Message Date
Charles Kerr b0ee4007ff
refactor: include cleanups (#2392)
* refactor: include <memory> when using shared_ptr or unique_ptr

* refactor: include <cstdio> iff we use it

* refactor: include <cstring> iff we use it

* refactor: include <cstdlib> iff we use it

* refactor: include <string_view> or <string> iff we use it

* refactor: include <array> iff we use it

* refactor: include <ctime> iff we use it

* refactor: include <cctype> iff we use it

* refactor: misc #include cleanups in libtransmission
2022-01-12 20:13:58 -06:00
Charles Kerr 0e321c2d21
fix: clang warnings (#2339)
* fix: comparison-is-always-false warning

* fix: C/C++ mixing (memset() to clear a C++ object)
2021-12-25 11:22:12 -06:00
Charles Kerr bd68d3a2fd
refactor: use tr_sha1_digest_t everywhere (#2330) 2021-12-21 16:14:15 -06:00
Charles Kerr b93f3f0463
refactor: more tr_torrent housekeeping (#2320) 2021-12-16 03:43:51 -06:00
Charles Kerr d8b57fe4dc
refactor: web_utils (#2121)
* chore: move web utils from web, utils to web-utils
2021-11-08 21:30:03 -06:00
Charles Kerr cc204e0b2c
refactor: prefer "using" over "typedef" (#1883)
* refactor: prefer "using" over "typedef"
2021-10-06 09:26:07 -05:00
Charles Kerr 17ee032dd8
refactor: remove TR_BEGIN_DECLS, TR_END_DECLS (#1837)
* refactor: remove TR_BEGIN_DECLS, TR_END_DECLS
2021-09-25 11:07:22 -05:00
Mike Gelfand a459e5e11b
Switch to a standalone ARC4 implementation (#1788)
* Switch to a standalone ARC4 implementation

This frees us from expecting it being provided by one of the crypto
libraries we support, all of which deprecated and/or removed it at this
point.

Fixes: #1103
Fixes: #1777

* Suppress lgtm warnings about RC4 being weak (we don't care)
2021-09-12 06:47:29 +03:00
Mike Gelfand db3d40d0ed Switch to clang-format for code formatting, include Mac client 2021-08-16 00:38:29 +03:00
Charles Kerr 677dc73eac
refactor: use GTest for running tests (#1383)
* refactor: use google-test on libtransmission tests
2020-08-11 13:11:55 -05:00
Mike Gelfand 5b29fe1556 Ensure include guard is the first non-comment line 2017-11-14 23:21:28 +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
Jordan Lee 7cd2d10d00 crypto.h and crypto-utils.h can't use #pragma once, it breaks our name munging in crypto-test-ref.h 2016-03-29 19:02:26 +00:00
Jordan Lee 1af60ad6ad use '#pragma once' instead of #ifndef..#define..#endif guards 2016-03-29 16:37:21 +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 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 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 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 324f0f470c (trunk libT) copyediting: '#include "crypto.h"' cleanup 2011-03-25 01:21:31 +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 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 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 0d91f3cadf (trunk libT) more documentation and doxygen markup 2010-01-06 00:18:33 +00:00
Charles Kerr 5c26afdb52 happy new year! 2010-01-04 21:00:47 +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 452cb27f9e (trunk libT) re-start work on making libT doxygen friendly. still a long ways to go on this. 2009-05-29 19:17:12 +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
Charles Kerr fe816d8135 (trunk) update the GPL code's copyright dates 2009-01-10 23:09:07 +00:00
Charles Kerr 9594112d27 updated email address 2008-12-16 00:20:44 +00:00
Charles Kerr a1cd6d85dc (libT) add #ifdefs to ensure that client apps don't #include private libtransmission headers. 2008-11-24 20:17:36 +00:00
Charles Kerr ee5797caa3 fix mac build? 2008-10-22 17:19:22 +00:00
Charles Kerr fc99ff6881 (libT) add some extra gcc safeguards. fix a couple of compiler warnings in makemeta 2008-10-22 17:14:50 +00:00
Charles Kerr cc89872dd4 run libT, cli, daemon, gtk through the source-code formatter "uncrustify" as promised/threatened 2008-09-23 19:11:04 +00:00
Charles Kerr 64e08510f0 (libT) maybe fix the hangs reported by users in the recent nightlies. 2008-08-27 18:50:21 +00:00
Mukund Sivaraman de62de3e19 Replace random number generation code 2008-08-14 11:11:25 +00:00
Charles Kerr ce6c33b7bf set copyright info to 2008 2008-01-01 17:20:20 +00:00
Mitchell Livingston 76da1185ca merge encryption branch to trunk (xcode project is still out of date) 2007-09-20 16:32:01 +00:00