aboutsummaryrefslogtreecommitdiff
path: root/src/lib
AgeCommit message (Collapse)Author
2019-02-26Merge branch 'tor-github/pr/611'George Kadianakis
2019-02-19Implement code to manage a per-thread instance of crypto_fast_rng()Nick Mathewson
The subsystems API makes this really simple, fortunately. Closes ticket 29536
2019-02-14Merge branch 'tor-github/pr/702'David Goulet
2019-02-14Merge branch 'maint-0.3.5'George Kadianakis
2019-02-14Merge branch 'tor-github/pr/689' into maint-0.3.5George Kadianakis
2019-02-14Implement a fast aes-ctr prngNick Mathewson
This module is currently implemented to use the same technique as libottery (later used by the bsds' arc4random replacement), using AES-CTR-256 as its underlying stream cipher. It's backtracking- resistant immediately after each call, and prediction-resistant after a while. Here's how it works: We generate psuedorandom bytes using AES-CTR-256. We generate BUFLEN bytes at a time. When we do this, we keep the first SEED_LEN bytes as the key and the IV for our next invocation of AES_CTR, and yield the remaining BUFLEN - SEED_LEN bytes to the user as they invoke the PRNG. As we yield bytes to the user, we clear them from the buffer. Every RESEED_AFTER times we refill the buffer, we mix in an additional SEED_LEN bytes from our strong PRNG into the seed. If the user ever asks for a huge number of bytes at once, we pull SEED_LEN bytes from the PRNG and use them with our stream cipher to fill the user's request.
2019-02-14Extract the common body of our random-int functions into a macroNick Mathewson
This is the second part of refactoring the random-int-in-range code.
2019-02-13Merge branch 'tor-github/pr/651'David Goulet
2019-02-13Merge branch 'tor-github/pr/650' into maint-0.3.5David Goulet
2019-02-08Add more openssl includes to fix no-deprecated compilationNick Mathewson
Closes ticket 29026; patch from Mangix.
2019-02-08Fix compilation when openssl is compiled without engine support.Nick Mathewson
Patch from Mangix. Closes part of ticket 29026.
2019-02-06Extract numeric CSPRNG functions into a new module.Nick Mathewson
Some of the code for getting a random value within a range wants to be shared between crypto_rand() and the new crypto_fast_rng() code.
2019-02-06Remove extraneous #if/#endif wrapper in crypto_rand.cNick Mathewson
I don't know how this got here, but this kind of a wrapper only belongs in a header file.
2019-02-06Code for anonymous mappings via mmap() or CreateFileMapping().Nick Mathewson
Using an anonymous mmap() is a good way to get pages that we can set kernel-level flags on, like minherit() or madvise() or mlock(). We're going to use that so that we can make uninheritable locked pages to store PRNG data.
2019-01-23Merge branch 'ticket28668_035' into ticket28668_040Nick Mathewson
2019-01-23Capture more BUG warnings in util/time testNick Mathewson
These are ones that happen on windows only. Fixes bug 29161.
2019-01-22Allow getsockopt(…, SOL_SOCKET, SO_ACCEPTCONN, …) in sandboxPeter Gerber
SO_ACCEPTCONN checks whether socket listening is enabled and is used ever since 9369152aae9527cc3764 has been merged. Closes ticket #29150
2019-01-22Merge branch 'maint-0.3.5'Nick Mathewson
2019-01-22Merge branch 'bug29042_035' into maint-0.3.5Nick Mathewson
2019-01-16Merge branch 'maint-0.3.5'Nick Mathewson
2019-01-16Update and fix a couple of comments in meminfo.cKris Katterjohn
This fixes a typo and also notes that HW_PHYSMEM64 is defined on NetBSD (not just OpenBSD). Signed-off-by: Kris Katterjohn <katterjohn@gmail.com>
2019-01-16Use HW_PHYSMEM instead of HW_USERMEM in get_total_system_memory_implKris Katterjohn
The code checked for sysctl being available and HW_PHYSMEM being defined, but HW_USERMEM was actually being used with sysctl instead of HW_PHYSMEM. The case for OpenBSD, etc. use HW_PHYSMEM64 (which is obviously a 64-bit variant of HW_PHYSMEM) and the case for OSX uses HW_MEMSIZE (which appears to be a 64-bit variant of HW_PHYSMEM). Signed-off-by: Kris Katterjohn <katterjohn@gmail.com>
2019-01-16Log more messages when failing to decode RSA keysNick Mathewson
We log these messages at INFO level, except when we are reading a private key from a file, in which case we log at WARN. This fixes a regression from when we re-wrote our PEM code to be generic between nss and openssl. Fixes bug 29042, bugfix on 0.3.5.1-alpha.
2019-01-16Bump copyright date to 2019Nick Mathewson
2019-01-16Bump copyright date to 2019.Nick Mathewson
2019-01-14Merge remote-tracking branch 'asn-github/adaptive_padding-final'Nick Mathewson
2019-01-14Merge remote-tracking branch 'teor/bug29015'Nick Mathewson
2019-01-11Actually close the stdout pipe on error in process_unix_execKris Katterjohn
When cleaning up after an error in process_unix_exec, the stdin pipe was being double closed instead of closing both the stdin and stdout pipes. This occurred in two places. Signed-off-by: Kris Katterjohn <katterjohn@gmail.com>
2019-01-11Include the beginnings of a FAQ about which timer to use.Nick Mathewson
2019-01-11Add some more type checking.Taylor R Campbell
NOTE: This commit breaks the build, because there was a mistake in an earlier change of exactly the sort that this is meant to detect! I'm leaving it broken for illustration.
2019-01-11Use the distribution abstraction as an abstraction.Taylor R Campbell
2019-01-11Move ceil call back into the geometric sampler.Taylor R Campbell
Test exactly what the geometric sampler returns, because that's what the downstream callers of it are going to use. While here, also assert that the geometric sampler returns a positive integer. (Our geometric distribution is the one suported on {1, 2, 3, ...} that returns the number of trials before the first success, not the one supported on {0, 1, 2, ...} that returns the number of failures before the first success.)
2019-01-10Rename crypto_rand_uint32() -> crypto_rand_u32()George Kadianakis
See https://github.com/torproject/tor/pull/624#discussion_r246453777
2019-01-09Merge branch 'maint-0.3.5'Nick Mathewson
2019-01-09Merge remote-tracking branch 'tor-github/pr/636' into maint-0.3.5Nick Mathewson
2019-01-09Merge branch 'maint-0.3.5'Nick Mathewson
2019-01-09Fix (and make consistent) the use of OpenBSD preprocessor macro testsKris Katterjohn
Prior to this commit, the testsuite was failing on OpenBSD. After this commit the testsuite runs fine on OpenBSD. It was previously decided to test for the OpenBSD macro (rather than __OpenBSD__, etc.) because OpenBSD forks seem to have the former macro defined. sys/param.h must be included for the OpenBSD macro definition; however, many files tested for the OpenBSD macro without having this header included. This commit includes sys/param.h in the files where the OpenBSD macro is used (and sys/param.h is not already included), and it also changes some instances of the __OpenBSD__ macro to OpenBSD. See commit 27df23abb675ffeb198bf0c1cc85c4baed77a988 which changed everything to use OpenBSD instead of __OpenBSD__ or OPENBSD. See also tickets #6982 and #20980 (the latter ticket is where it was decided to use the OpenBSD macro). Signed-off-by: Kris Katterjohn <katterjohn@gmail.com>
2019-01-09Merge branch 'ticket28856_v2'Nick Mathewson
2019-01-08lib/net: improve the docs for tor_{ersatz_,}socketpair()teor
Add some details about IP family support, and point to tor_socketpair() from tor_ersatz_socketpair(). Closes ticket 29015.
2019-01-07Fix tor_ersatz_socketpair on IPv6-only systemsKris Katterjohn
In get_local_listener used by tor_ersatz_socketpair, the address family used when binding the IPv6 socket was AF_INET instead of AF_INET6. Fixes bug 28995; bugfix on 0.3.5.1-alpha. Signed-off-by: Kris Katterjohn <katterjohn@gmail.com>
2019-01-03Add a #ifdef HAVE_UNISTD_H check to buffers.cNick Mathewson
Reported on tor-dev by Gisle Vanem. Bug not in any released Tor (The suggested patch used _MSC_VER, but that's not how we do stuff with autoconf. With autoconf, you detect the feature you want, rather than trying to list all the systems that do or do not have it.)
2019-01-03Merge branch 'maint-0.3.5'Nick Mathewson
2019-01-03Merge branch 'ticket28851_035_squashed' into maint-0.3.5Nick Mathewson
2019-01-03Stop re-checking our hardcoded dh parameters on every startupNick Mathewson
Closes ticket 28851.
2019-01-03Merge branch 'maint-0.3.5'Nick Mathewson
2019-01-03Merge remote-tracking branch 'public/ticket28838_035' into maint-0.3.5Nick Mathewson
2019-01-03Merge branch 'maint-0.3.5'Nick Mathewson
2019-01-03Merge branch 'maint-0.3.4' into maint-0.3.5Nick Mathewson
2019-01-02Merge branch 'maint-0.3.5'Nick Mathewson
2019-01-02Add an errno.h include to freespace.c to fix bug 28974.Nick Mathewson