summaryrefslogtreecommitdiff
path: root/src/lib/crypt_ops
AgeCommit message (Collapse)Author
2020-10-28Do not define OPENSSL_VERSION in compat_openssl.hNick Mathewson
Apparently it conflicts with definitions elsewhere in Openssl 3.0.0.
2020-10-28Include a more modest openssl header in crypto_openssl_mgt.hNick Mathewson
The "engines.h" header has lots of stuff; the "opensslv.h" header has the version number, which is all we actually need here. We need to do this because we're about to change this header to conditionally define OPENSSL_SUPPRESS_DEPRECATED, and it would be too late to do so if we'd already included "engines.h".
2020-05-06Use __attribute__((fallthrough)) rather than magic GCC comments.Nick Mathewson
GCC added an implicit-fallthrough warning a while back, where it would complain if you had a nontrivial "case:" block that didn't end with break, return, or something like that. Clang recently added the same thing. GCC, however, would let you annotate a fall-through as intended by any of various magic "/* fall through */" comments. Clang, however, only seems to like "__attribute__((fallthrough))". Fortunately, GCC accepts that too. A previous commit in this branch defined a FALLTHROUGH macro to do the right thing if GNUC is defined; here we replace all of our "fall through" comments with uses of that macro. This is an automated commit, made with the following perl one-liner: #!/usr/bin/perl -i -p s#/\* *falls? ?thr.*?\*/#FALLTHROUGH;#i;
2020-05-06Remove an incorrect "Fall through" comment.Nick Mathewson
2020-03-18Port rsa_private_key_too_long() to work on OpenSSL 1.1.0.Nick Mathewson
2020-03-17Merge branch 'trove_2020_002_035' into maint-0.3.5Nick Mathewson
2020-03-17Trivial bugfixes found during TROVE investigation.George Kadianakis
2020-03-17Use >= consistently with max_bits.Nick Mathewson
2020-03-17Extract key length check into a new function, and check more fields.Nick Mathewson
In the openssl that I have, it should be safe to only check the size of n. But if I'm wrong, or if other openssls work differently, we should check whether any of the fields are too large. Issue spotted by Teor.
2020-03-14Fix memory leak in crypto_pk_asn1_decode_private.Nick Mathewson
(Deep, deep thanks to Taylor for reminding me to test this!)
2020-03-14Revise TROVE-2020-002 fix to work on older OpenSSL versions.Nick Mathewson
Although OpenSSL before 1.1.1 is no longer supported, it's possible that somebody is still using it with 0.3.5, so we probably shouldn't break it with this fix.
2020-02-05When parsing, reject >1024-bit RSA private keys sooner.Nick Mathewson
Private-key validation is fairly expensive for long keys in openssl, so we need to avoid it sooner.
2019-04-17Do not warn about compatible OpenSSL upgradesBernhard M. Wiedemann
When releasing OpenSSL patch-level maintenance updates, we do not want to rebuild binaries using it. And since they guarantee ABI stability, we do not have to. Without this patch, warning messages were produced that confused users: https://bugzilla.opensuse.org/show_bug.cgi?id=1129411 Fixes bug 30190; bugfix on 0.2.4.2-alpha commit 7607ad2bec Signed-off-by: Bernhard M. Wiedemann <bwiedemann@suse.de>
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-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 2019.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.
2018-12-13Lower the loop_max constant in curve25519_basepoint_spot_check()Nick Mathewson
The point of this function is to make sure that the ed25519-based implementation of curve25519_basepoint() actually works when we start tor, and use the regular fallback implementation if it doesn't. But it accounts for 9% of our startup time in the case when we have directory information, and I think it's safe to make the test shorter. After all, it has yet to find any actual bugs in curved25519_scalarmult_basepoint_donna() on any platforms. Closes ticket 28838.
2018-11-13Merge branch 'maint-0.3.4' into maint-0.3.5Nick Mathewson
2018-10-19Rename a function; it is used to convert a value _From_ le.Nick Mathewson
We can't use htons()/ntohs() -- those are no-ops on exactly the wrong platforms.
2018-10-19Fix a misspelled macro test that was breaking big-endian OPENick Mathewson
Fixes bug 28115; bugfix on 0.3.5.1-alpha.
2018-10-14Merge branch 'bug27772_squashed'Nick Mathewson
2018-10-09Merge remote-tracking branch 'public/ticket27856'Nick Mathewson
2018-10-01Merge remote-tracking branch 'public/bug27728'Nick Mathewson
2018-09-27Prevent duplicate initialization of NSS DH moduleNick Mathewson
Allowing this didn't do any actual harm, since there aren't any shared structures or leakable objects here. Still, it's bad style and might cause trouble in the future. Closes ticket 27856.
2018-09-24Fix arm compilation with openssl <1.1Nick Mathewson
Bug 27781; bugfix on 0.3.5.1-alpha.
2018-09-18Assert that some trunnel _new() functions return non-NULLNick Mathewson
The trunnel functions are written under the assumption that their allocators can fail, so GCC LTO thinks they might return NULL. In point of fact, they're using tor_malloc() and friends, which can't fail, but GCC won't necessarily figure that out. Fixes part of #27772.
2018-09-18Make crypto_strongest_rand() non-mockableNick Mathewson
Instead, have it call a mockable function. We don't want crypto_strongest_rand() to be mockable, since doing so creates a type error when we call it from ed25519-donna, which we do not build in a test mode. Fixes bug 27728; bugfix on 0.3.5.1-alpha
2018-09-18Fix minor memleak in edge-case of crypto_rsa.c function.George Kadianakis
2018-09-17Lower the maximum size of a private key file to 16 MBNick Mathewson
This shouldn't be a user-visible change: nobody has a 16 MB RSA key that they're trying to use with Tor. I'm doing this to fix CID 1439330 / ticket 27730, where coverity complains (on 64-bit) that we are making a comparison that is never true.
2018-09-16When Tor is compiled with NSS, don't claim support for LinkAuth=1Nick Mathewson
Closes ticket 27288
2018-09-13Fix a 32-bit off_t/size_t warning in crypto_rsa.cNick Mathewson
Bug not in any released Tor.
2018-09-09Refactor initialization in curve25519_basepoint_spot_checkNick Mathewson
This is an attempt to work around what I think may be a bug in OSS-Fuzz, which thinks that uninitialized data might be passed to the curve25519 functions.
2018-09-07Merge remote-tracking branch 'dgoulet/ticket20700_035_03'Nick Mathewson
2018-09-07test: Build an HSv3 descriptor with authorized clientSuphanat Chunhapanya
Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-09-05Fix checkspacesNick Mathewson
2018-09-05Add a last-ditch memwipe() implementation for nss+old glibcNick Mathewson
On new glibc versions, there's an explicit_bzero(). With openssl, there's openssl_memwipe(). When no other approach works, use memwipe() and a memory barrier.
2018-09-04Fix documentation of initialized fields in crypto_init.cNick Mathewson
2018-09-04Make some additional RSA functions constNick Mathewson
2018-09-04Rename crypto_pk_check_key(), use it more reasonably, add testsNick Mathewson
This function was a wrapper around RSA_check_key() in openssl, which checks for invalid RSA private keys (like those where p or q are composite, or where d is not the inverse of e, or where n != p*q). We don't need a function like this in NSS, since unlike OpenSSL, NSS won't let you import a bogus private key. I've renamed the function and changed its return type to make it more reasonable, and added a unit test for trying to read a key where n != p*q.
2018-09-04Unify functions for reading/writing PEM keys, to avoid duplication.Nick Mathewson
2018-09-04Do not leak a reference to "slot" when decoding private key.Nick Mathewson
2018-09-04Update prefork and postfork NSS code for unit tests.Nick Mathewson
2018-09-04Several unit tests to improve test coverage of x509*.cNick Mathewson
2018-08-22NSS support for x509 certsNick Mathewson
7 unit tests are failing at this point, but they're all TLS-related.
2018-08-22Log error strings in crypto_nss_log_errors().Nick Mathewson
I'll need this for debugging.
2018-08-21Implement PBKDF2 with NSS.Nick Mathewson
This was a gap that we left in the last commit.
2018-08-21When enabling NSS, disable OpenSSL.Nick Mathewson
We used to link both libraries at once, but now that I'm working on TLS, there's nothing left to keep OpenSSL around for when NSS is enabled. Note that this patch causes a couple of places that still assumed OpenSSL to be disabled when NSS is enabled - tor-gencert - pbkdf2