From 86c61fcf5b56ede1f30d38ae856634b7913b80e7 Mon Sep 17 00:00:00 2001 From: Nils Maier Date: Mon, 23 Sep 2013 15:51:25 +0200 Subject: [PATCH 1/5] Make generateRandomBytes less biased. --- src/SimpleRandomizer.cc | 19 +++++++++++++++++++ src/SimpleRandomizer.h | 2 ++ src/util.cc | 4 +--- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/SimpleRandomizer.cc b/src/SimpleRandomizer.cc index aaba91a4..fea7262f 100644 --- a/src/SimpleRandomizer.cc +++ b/src/SimpleRandomizer.cc @@ -115,4 +115,23 @@ long int SimpleRandomizer::operator()(long int to) return getRandomNumber(to); } +void SimpleRandomizer::getRandomBytes(unsigned char *buf, size_t len) +{ +#ifdef __MINGW32__ + if (!CryptGenRandom(cryProvider_, len, (PBYTE)buf)) { + throw std::bad_alloc(); + } +#else + while (len) { + union { + int32_t r; + uint8_t b[4]; + } r = { (int32_t)random() }; + for (auto i = 0; i < 4 && len; ++i, --len) { + *buf++ = r.b[i]; + } + } +#endif +} + } // namespace aria2 diff --git a/src/SimpleRandomizer.h b/src/SimpleRandomizer.h index ffcb33ec..7e0afad9 100644 --- a/src/SimpleRandomizer.h +++ b/src/SimpleRandomizer.h @@ -71,6 +71,8 @@ public: */ virtual long int getRandomNumber(long int to) CXX11_OVERRIDE; + void getRandomBytes(unsigned char *buf, size_t len); + long int operator()(long int to); }; diff --git a/src/util.cc b/src/util.cc index e075dfd0..06d41a41 100644 --- a/src/util.cc +++ b/src/util.cc @@ -1595,9 +1595,7 @@ namespace { void generateRandomDataRandom(unsigned char* data, size_t length) { const auto& rd = SimpleRandomizer::getInstance(); - for(size_t i = 0; i < length; ++i) { - data[i] = static_cast(rd->getRandomNumber(256)); - } + rd->getRandomBytes(data, length); } } // namespace From 5787b1e1615e91814fd762d78de527f018c18482 Mon Sep 17 00:00:00 2001 From: ITriskTI Date: Tue, 24 Sep 2013 22:39:09 +0300 Subject: [PATCH 2/5] Update aria2c.rst --- doc/manual-src/ru/aria2c.rst | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/doc/manual-src/ru/aria2c.rst b/doc/manual-src/ru/aria2c.rst index 550ac840..a8c8c8b8 100644 --- a/doc/manual-src/ru/aria2c.rst +++ b/doc/manual-src/ru/aria2c.rst @@ -826,7 +826,7 @@ FTP, BitTorrent и Metalink. Для загрузки файла, aria2 може aria2 анализирует как torrent-файл и загружает файлы, указанные в нем. Если указано ``mem``, тогда torrent-файл не записывается на диск, а содержится в памяти. - Если указано ``false``, то файл `.torrent`` будет загружен на диск, но не + Если указано ``false``, то файл ``.torrent`` будет загружен на диск, но не будет проанализирован как торрент и его содержимое не будет загружено. По умолчанию: ``true`` @@ -988,9 +988,14 @@ FTP, BitTorrent и Metalink. Для загрузки файла, aria2 може .. option:: --rpc-certificate= Использовать сертификат в FILE для RPC-сервера. Сертификат должен быть - в PEM-формате. Используйте параметр :option:`--rpc-private-key`, - чтобы указать закрытый ключ. Используйте параметр :option:`--rpc-secure` - для включения шифрования. + один из двух: PKCS12 (.p12, .pfx) или в PEM-формате. + + PKCS12-файлы должны содержать сертификат, ключ и, необязательно, цепочку + дополнительных сертификатов. Могут быть открыты PKCS12-файлы только + с пустым импортированным паролем! + + При использовании PEM, вы также указываете закрытый ключ через :option:`--rpc-private-key`, + Используйте параметр :option:`--rpc-secure` для включения шифрования. *AppleTLS* пользователи должны использовать утилиту Keychain Access, чтобы сначала генерировать самоподписанный SSL-Server сертификат, например, From f2137eb784b9e8161b769327102848dce016dd27 Mon Sep 17 00:00:00 2001 From: ITriskTI Date: Wed, 25 Sep 2013 02:51:31 +0200 Subject: [PATCH 3/5] Fixed a typo in the English manual Closes #133 --- doc/manual-src/en/aria2c.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual-src/en/aria2c.rst b/doc/manual-src/en/aria2c.rst index c9fe91cd..356809b0 100644 --- a/doc/manual-src/en/aria2c.rst +++ b/doc/manual-src/en/aria2c.rst @@ -924,7 +924,7 @@ RPC Options Use the certificate in FILE for RPC server. The certificate must be either in PKCS12 (.p12, .pfx) or in PEM format. - PKCS12 files must contain the certifcate, a key and optionally a chain + PKCS12 files must contain the certificate, a key and optionally a chain of additional certificates. Only PKCS12 files with a blank import password can be opened! From ede8ee7fe8b22973ce6c0f8a24107c847c92ff28 Mon Sep 17 00:00:00 2001 From: Nils Maier Date: Wed, 25 Sep 2013 04:00:57 +0200 Subject: [PATCH 4/5] Add notes about AppleTLS and -MD --- README.rst | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 0abd677c..386ee023 100644 --- a/README.rst +++ b/README.rst @@ -99,10 +99,11 @@ Dependency ======================== ======================================== features dependency ======================== ======================================== -HTTPS GnuTLS or OpenSSL +HTTPS OSX or GnuTLS or OpenSSL BitTorrent libnettle+libgmp or libgcrypt or OpenSSL Metalink libxml2 or Expat. -Checksum libnettle or libgcrypt or OpenSSL +Checksum None. Optional: OSX or libnettle or libgcrypt + or OpenSSL (see note) gzip, deflate in HTTP zlib Async DNS C-Ares Firefox3/Chromium cookie libsqlite3 @@ -118,16 +119,25 @@ JSON-RPC over WebSocket libnettle or libgcrypt or OpenSSL .. note:: + On Apple OSX the OS-level SSL/TLS support will be preferred. Hence + neither GnuTLS nor OpenSSL are required on that platform. If you'd like + to disable this behavior, run configure with `--without-appletls`. + GnuTLS has precedence over OpenSSL if both libraries are installed. If you prefer OpenSSL, run configure with ``--without-gnutls`` ``--with-openssl``. .. note:: + On Apple OSX the OS-level checksumming support will be preferred. + libnettle has precedence over libgcrypt if both libraries are installed. If you prefer libgcrypt, run configure with ``--without-libnettle --with-libgcrypt``. If OpenSSL is selected over GnuTLS, neither libnettle nor libgcrypt will be used. + + If none of the optional dependencies are installed, an internal + implementation that only supports md5 and sha1 will be used. A user can have one of the following configurations for SSL and crypto libraries: From 450677f2bbf1bd6ce2672930143d013b8c32e2cb Mon Sep 17 00:00:00 2001 From: Nils Maier Date: Wed, 25 Sep 2013 04:10:19 +0200 Subject: [PATCH 5/5] Mention --without-appletls for checksumming --- README.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 386ee023..c65ea087 100644 --- a/README.rst +++ b/README.rst @@ -121,7 +121,7 @@ JSON-RPC over WebSocket libnettle or libgcrypt or OpenSSL On Apple OSX the OS-level SSL/TLS support will be preferred. Hence neither GnuTLS nor OpenSSL are required on that platform. If you'd like - to disable this behavior, run configure with `--without-appletls`. + to disable this behavior, run configure with ``--without-appletls``. GnuTLS has precedence over OpenSSL if both libraries are installed. If you prefer OpenSSL, run configure with ``--without-gnutls`` @@ -129,7 +129,8 @@ JSON-RPC over WebSocket libnettle or libgcrypt or OpenSSL .. note:: - On Apple OSX the OS-level checksumming support will be preferred. + On Apple OSX the OS-level checksumming support will be preferred, + unless aria2 is configured with ``--without-appletls``. libnettle has precedence over libgcrypt if both libraries are installed. If you prefer libgcrypt, run configure with