summaryrefslogtreecommitdiff
path: root/src/lib
AgeCommit message (Collapse)Author
2019-03-13prob_distr: Better document our public API.George Kadianakis
2019-03-13prob_distr: Implement type-safe downcasting functions.George Kadianakis
2019-03-12Merge branch 'maint-0.4.0'George Kadianakis
2019-03-12Merge branch 'tor-github/pr/763' into maint-0.4.0George Kadianakis
2019-03-11Merge branch 'maint-0.4.0'Nick Mathewson
2019-03-08Merge remote-tracking branch 'bug28525_029' into maint-0.3.5teor
2019-03-04Merge branch 'tor-github/pr/723'George Kadianakis
2019-03-04doc: Fix an incorrect comment about calling FreeLibrary() on Windowsteor
There's an incorrect comment in compat_time.c that suggests we call FreeLibrary() before we're done using the library's functions. See 29642 for background. Closes ticket 29643.
2019-03-01Merge branch 'tor-github/pr/718'David Goulet
2019-03-01Document crypto_fast_rng_one_in_n.Nick Mathewson
2019-02-26Merge branch 'tor-github/pr/655'David Goulet
2019-02-26Merge branch 'tor-github/pr/611'George Kadianakis
2019-02-25Re-enable and fix unit test for nofork mappingsNick Mathewson
This test was previously written to use the contents of the system headers to decide whether INHERIT_NONE or INHERIT_ZERO was going to work. But that won't work across different environments, such as (for example) when the kernel doesn't match the headers. Instead, we add a testing-only feature to the code to track which of these options actually worked, and verify that it behaved as we expected. Closes ticket 29541; bugfix not on any released version of Tor.
2019-02-20Remove all uses of weak_rng.Nick Mathewson
I'm not removing the weak_rng code itself yet, since it is possible that we will want to revert one of these.
2019-02-20Add a convenience macro to get a fast one-in-n calculationNick Mathewson
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-17Add a function to compute an XOF in one shot.Nick Mathewson
Motivation: 1. It's convenient. 2. It's all that openssl supports. Part of 28837.
2019-01-17Use openssl's version of sha3 when available.Nick Mathewson
Part of 28837.
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