summaryrefslogtreecommitdiff
path: root/apps/openssl.c
Commit message (Collapse)AuthorAgeFilesLines
* Replace BIO_free(bio_err) with BIO_free_all(bio_err)xkernel2022-10-211-1/+1
| | | | | | | | dup_bio_err() can return a BIO chain when 'OPENSSL_SYS_VMS' is defined. Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19446)
* APPS: Improve diagnostics on missing/extra args and unknown cipher/digestDr. David von Oheimb2021-12-071-1/+1
| | | | | Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16450)
* Move more general parts of internal/cryptlib.h to new internal/common.hDr. David von Oheimb2021-11-171-1/+1
| | | | | Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15847)
* Add and use HAS_PREFIX() and CHECK_AND_SKIP_PREFIX() for checking if string ↵Dr. David von Oheimb2021-11-171-3/+3
| | | | | | | has literal prefix Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15847)
* Clean up on failed BIO creationyuanjungong2021-10-221-1/+4
| | | | | | Reviewed-by: Shane Lontis <shane.lontis@oracle.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16316)
* Fully initialise cipher/digest app handlesViktor Dukhovni2021-10-011-0/+1
| | | | | | | | | | | This avoids a crash in e.g. `openssl chacha20` as reported by Steffen Nurpmeso on openssl-users. Resolves: #16713 Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16714)
* APPS: make apps strict on app_RAND_load() and app_RAND_write() failureDr. David von Oheimb2021-04-141-1/+2
| | | | | Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14840)
* Update copyright yearRichard Levitte2021-01-281-1/+1
| | | | | Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/13999)
* APPS: Print help also on -h and --h; print high-level help when no cmd givenDr. David von Oheimb2021-01-111-5/+9
| | | | | Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/13799)
* APPS: Fix confusion between program and app/command name used in ↵Dr. David von Oheimb2021-01-111-15/+10
| | | | | | | diagnostic/help output Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/13799)
* Check non-option argumentsRich Salz2020-12-151-0/+1
| | | | | | | | | | | | | Make sure all commands check to see if there are any "extra" arguments after the options, and print an error if so. Made all error messages consistent (which is to say, minimal). Fixes: #13527 Reviewed-by: Shane Lontis <shane.lontis@oracle.com> Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/13563)
* APPS: Add OSSL_STORE loader for engine keysRichard Levitte2020-12-021-0/+2
| | | | | | | | | | | | | | | | | The idea is to be able to have our apps load engine keys using a URI: org.openssl.engine:{engineid}:{keyid} This is legacy, but added for the time being to support keys given to the application like this: -engine {engineid} -key {keyid} -keyform ENGINE This latter form is recognised internally, and rewritten into the URI form. Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com> (Merged from https://github.com/openssl/openssl/pull/13570)
* Rename OPENSSL_CTX prefix to OSSL_LIB_CTXDr. Matthias St. Pierre2020-10-151-1/+1
| | | | | | | | | | | | Many of the new types introduced by OpenSSL 3.0 have an OSSL_ prefix, e.g., OSSL_CALLBACK, OSSL_PARAM, OSSL_ALGORITHM, OSSL_SERIALIZER. The OPENSSL_CTX type stands out a little by using a different prefix. For consistency reasons, this type is renamed to OSSL_LIB_CTX. Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/12621)
* apps: remove internal/cryptlib.h include that isn't usedPauli2020-10-071-4/+9
| | | | | | | [extended tests] Reviewed-by: Ben Kaduk <kaduk@mit.edu> (Merged from https://github.com/openssl/openssl/pull/13047)
* apps_ui.c: Improve error handling and return value of setup_ui_method()Dr. David von Oheimb2020-09-101-1/+1
| | | | | Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/12493)
* Test RSA oaep in fips modeShane Lontis2020-07-231-1/+16
| | | | | | | | | | Added RSA oaep test that uses the pkeyutl application. Added an openssl application option to support loading a (fips) provider via the '-config' option. Added openssl application related environment variable 'OPENSSL_TEST_LIBCTX' (for testing purposes only), that creates a non default library context. Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/11948)
* apps/openssl: clean-up of unused fallback codeRichard Levitte2020-06-281-6/+0
| | | | | | | | Remove code in help_main() that duplicates the case when 'openssl' is called with no arguments, which is now handled in main(). Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> (Merged from https://github.com/openssl/openssl/pull/12295)
* apps: avoid memory overrun.Pauli2020-06-241-1/+1
| | | | | | | | | | NULL terminate the built in "help" argv array to avoid reading beyond the end. Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> (Merged from https://github.com/openssl/openssl/pull/12258)
* APPS: Fix invoking openssl without a commandSebastian Andrzej Siewior2020-06-231-1/+3
| | | | | | | | | | | | | | Invoking help with "empty" argc leads to a segfault. Invoke do_cmd() with help as argument which invokes help_main() with proper argv. Fixes #12069 Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc> Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/12070)
* Fix segfault in openssl app called with no args.Shane Lontis2020-06-181-2/+7
| | | | | | | | This is a result of removal of interactive mode. Redirected it to now use 'openssl help'. Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/12164)
* APPS: Drop interactive mode in the 'openssl' programRichard Levitte2020-06-051-89/+8
| | | | | | | | | | | | This mode is severely untested and unmaintained, is seems not to be used very much. Closes #4679 Closes #6292 Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/12023)
* APPS: Remove make_config_name, use CONF_get1_default_config_file insteadRichard Levitte2020-06-021-22/+4
| | | | | | Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de> Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/11983)
* Remove getenv(OPENSSL_FIPS) in openssl commandBernd Edlinger2020-06-011-5/+0
| | | | | | | This is left over from the past. Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/11995)
* Update copyright yearMatt Caswell2020-04-231-1/+1
| | | | | Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/11616)
* openssl: include the version a command was deprecated in the output text.Pauli2020-04-191-7/+10
| | | | | Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/11225)
* Move legacy ciphers into the legacy providerShane Lontis2020-04-091-0/+1
| | | | | | | | | | | DES, idea, seed, rc2, rc4, rc5, cast and blowfish have been moved out of the default provider. Code shared between desx and tdes has been moved into a seperate file (cipher_tdes_common.c). 3 test recipes failed due to using app/openssl calls that used legacy ciphers. These calls have been updated to supply both the default and legacy providers. Fixed openssl app '-provider' memory leak Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/11419)
* app: add a deprecation warning to all deprecated commands.Pauli2020-02-121-0/+13
| | | | | Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/10977)
* APPS & TEST: Adapt to use the new BIO_f_prefix()Richard Levitte2019-12-181-12/+3
| | | | | Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/10531)
* Deprecate most of debug-memoryRich Salz2019-12-141-9/+0
| | | | | | | | | | | | | | | | | | | | | Fixes #8322 The leak-checking (and backtrace option, on some platforms) provided by crypto-mdebug and crypto-mdebug-backtrace have been mostly neutered; only the "make malloc fail" capability remains. OpenSSL recommends using the compiler's leak-detection instead. The OPENSSL_DEBUG_MEMORY environment variable is no longer used. CRYPTO_mem_ctrl(), CRYPTO_set_mem_debug(), CRYPTO_mem_leaks(), CRYPTO_mem_leaks_fp() and CRYPTO_mem_leaks_cb() return a failure code. CRYPTO_mem_debug_{malloc,realloc,free}() have been removed. All of the above are now deprecated. Merge (now really small) mem_dbg.c into mem.c Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/10572)
* Check the return from OPENSSL_buf2hexstr()Matt Caswell2019-11-291-1/+2
| | | | | | | | | | | | The function OPENSSL_buf2hexstr() can return NULL if it fails to allocate memory so the callers should check its return value. Fixes #10525 Reported-by: Ziyang Li (@Liby99) Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> (Merged from https://github.com/openssl/openssl/pull/10526)
* main: avoid a NULL dereference on initialisation.Pauli2019-11-221-0/+7
| | | | | Reviewed-by: Tim Hudson <tjh@openssl.org> (Merged from https://github.com/openssl/openssl/pull/10495)
* Document command parameters.Rich Salz2019-11-201-2/+4
| | | | | | | | | | | Add documentation for all commands that have parameters. Fix a couple of minor doc and programming bugs, too. Fixes #10313 Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/10371)
* Add "sections" to -help outputRich Salz2019-11-081-0/+2
| | | | | | | | | | | | | Remove "Valid options" label, since all commands have sections (and [almost] always the first one is "General options"). Have "list --options" ignore section headers Reformat ts's additional help Add output section Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/9953)
* Remove HEADER_X509_H and HEADER_SSL_H include detectors from appsDr. Matthias St. Pierre2019-07-241-1/+0
| | | | | | | | | | | | | The HEADER_X509_H check is redundant, because <openssl/x509.h> is already included. Instead of of checking for HEADER_SSL_H, include <openssl/ssl.h> explicitly in "s_apps.h" and don't include "s_apps.h" where it's not necessary. Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de> (Merged from https://github.com/openssl/openssl/pull/9364)
* Move the code for 'openssl list' to its own translation unit.Richard Levitte2019-07-151-511/+1
| | | | | | | | | That makes it easier to work with than going through apps/openssl.c This also moves the implementation of calculate_columns() and makes it generally accessible. Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/9340)
* Refactor apps/progs.* to be generate with 'make update'Richard Levitte2019-07-151-1/+0
| | | | | | | | | | | | | This makes for a cleaner apps/progs.h as well as as cleaner apps/build.info. We also break out the type declarations to apps/include/function.h apps/progs.c and apps/progs.h are NOT regenerated when 'apps' is disabled. Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/9340)
* Print thread IDs nicely.Pauli2019-06-211-11/+8
| | | | | | | | | | Remove the union that effectively cast thread IDs to long integers before display and instead print a hex dump of the entire object. Refer #9191 Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/9194)
* test/testutil/init.c, apps/openssl.c: add trace cleanup handle earlierRichard Levitte2019-06-201-1/+7
| | | | | | | | | | | It turned out that the internal trace cleanup handler was added too late, so it would be executed before OPENSSL_cleanup(). This results in address errors, as the trace code that's executed in OPENSSL_cleanup() itself tries to reach for data that's been freed at that point. Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/9196)
* trace: rename the default trace category from 'ANY' to 'ALL'Dr. Matthias St. Pierre2019-03-301-1/+1
| | | | | | | | It seems more intuitive to set `OPENSSL_TRACE=all` instead of `OPENSSL_TRACE=any` to obtain trace output for all categories. Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/8552)
* trace: apps/openssl: print the correct category nameDr. Matthias St. Pierre2019-03-301-18/+34
| | | | | | | | | | | | | | | Previously, if the openssl application was run with OPENSSL_TRACE=any, all trace output would just show 'ANY' as the category name, which was not very useful. To get the correct category name printed in the trace output, the openssl application now registers separate channels for each category. The trace API is unchanged, it is still possible for an application to register a single channel for the 'ANY' category to see all outputt, if it does not need this level of detail. Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/8552)
* trace: don't pretend success if it's not enabledDr. Matthias St. Pierre2019-03-291-0/+5
| | | | | | | | | | | | | | | | | | | | | | Partially reverts d33d76168fb7 Don't fail when tracing is disabled Commit d33d76168fb7 fixed the problem that the initialization of libcrypto failed when tracing was disabled, because the unoperational ossl_trace_init() function returned a failure code. The problem was fixed by changing its return value from failure to success. As part of the fix the return values of other unimplemented trace API functions (like OSSL_trace_set_channel(),OSSL_trace_set_callback()) was changed from failure to success, too. This change was not necessary and is a bit problematic IMHO, because nobody expects an unimplemented function to pretend it succeeded. It's the application's duty to handle the case correctly when the trace API is not enabled (i.e., OPENSSL_NO_TRACE is defined), not the API's job to pretend success just to prevent the application from failing. Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/8552)
* Remove heartbeats completelyRichard Levitte2019-03-291-3/+0
| | | | | | | Fixes #4856 Reviewed-by: Tim Hudson <tjh@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1928)
* Correctly zero the DISPLAY_COLUMNS structure.Pauli2019-03-291-1/+2
| | | | | Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/8611)
* trace: ensure correct groupingDr. Matthias St. Pierre2019-03-151-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | It is important that output to the trace channels occurs only inside a trace group. This precondtion is satisfied whenever the standard TRACE macros are used. It can be violated only by a bad programming mistake, like copying the 'trc_out' pointer and using it outside the trace group. This commit enforces correct pairing of the OSSL_TRACE_CTRL_BEGIN and OSSL_TRACE_CTRL_END callbacks, and checks that OSSL_TRACE_CTRL_WRITE callbacks only occur within such groups. While implementing it, it turned out that the group assertion failed apps/openssl.c:152: OpenSSL internal error: \ Assertion failed: trace_data->ingroup because the set_trace_data() function invokes some callbacks which generate trace output, but the correct channel type was set only after the set_trace_data() call. To fix the failed assertions, the correct channel type is now set inside the set_trace_data() call, instead of doing it afterwards. Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/8463)
* trace: don't leak the line prefixDr. Matthias St. Pierre2019-03-151-20/+16
| | | | | | | | | | | | | | | | | | | | | | | The openssl app registers trace callbacks which automatically set a line prefix in the OSSL_TRACE_CTRL_BEGIN callback. This prefix needs to be cleared in the OSSL_TRACE_CTRL_END callback, otherwise a memory leak is reported when openssl is built with crypto-mdebug enabled. This leak causes the tests to fail when tracing and memory debugging are enabled. The leak can be observed by any command that produces trace output, e.g. by OPENSSL_TRACE=ANY util/shlib_wrap.sh apps/openssl version ... [00:19:14] 4061 file=apps/bf_prefix.c, line=152, ... 26 bytes leaked in 1 chunks Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/8463)
* Fix typo in ifndef OPENSSL_NO_ENGINES.Darren Tucker2019-03-101-1/+1
| | | | | | | | | | | All other instances are OPENSSL_NO_ENGINE without the trailing "S". Fixes build when configured with no-engine. CLA: trivial Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> (Merged from https://github.com/openssl/openssl/pull/8449)
* Print all loaded engines with openssl list -enginesTomas Mraz2019-03-091-2/+24
| | | | | | Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> (Merged from https://github.com/openssl/openssl/pull/8434)
* apps/openssl.c: avoid memory leaksRichard Levitte2019-03-061-1/+22
| | | | | | | | | | | The trace API doesn't know that the BIOs we give it, let alone those we attach to callbacks as 'void *data', need to be cleaned up. This must be done in the application. To ensure this cleanup is done as late as possible, use atexit(). Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/8198)
* apps/openssl.c: Adapt to enable tracing outputRichard Levitte2019-03-061-1/+93
| | | | | | | | | | | | | | | | | | | Use the environment variables OPENSSL_TRACE to determine what's going to be enabled. The value of this variables is a comma separated list of trace and debugging names, which correspond to the trace category macros defined in include/openssl/trace.h. For example, setting OPENSSL_DEBUG=TRACE,SSL will enable debugging output for the types OSSL_TRACE_CATEGORY_TRACE and OSSL_TRACE_CATEGORY_SSL. This also slightly changes the handling of the prefix method in apps/apps.c. This is for the better, as the prefix method pointer was unneccessarily stored in two places. Co-authored-by: Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/8198)
* VMS: move copy_argc to its own module and make it an aux sourceRichard Levitte2019-03-051-3/+1
| | | | | | | | | copy_argv was never initialization code. Make it self-cleaning too. Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/8381)