summaryrefslogtreecommitdiff
path: root/crypto/trace.c
Commit message (Collapse)AuthorAgeFilesLines
* add OSSL_TRACE_STRING(), OSSL_TRACE_STRING_MAX, and OSSL_trace_string()Dr. David von Oheimb2023-01-261-0/+25
| | | | | | | Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com> (Merged from https://github.com/openssl/openssl/pull/18704)
* set_trace_data(): prevent double free on OPENSSL_strdup() failureDr. David von Oheimb2023-01-241-5/+9
| | | | | | Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Hugo Landau <hlandau@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19959)
* Avoid ifdefs in trace categoriesTomas Mraz2022-12-221-14/+7
| | | | | | | | | | | The trace code assumes all categories are present and the category numbers are equal to the index in the table. Fixes #19915 Reviewed-by: Shane Lontis <shane.lontis@oracle.com> Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> (Merged from https://github.com/openssl/openssl/pull/19917)
* Add tests for trace_api.Daniel Fiala2022-09-161-0/+14
| | | | | | | | Fixes openssl#17422 Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19096)
* http_client.c: Dump response on error when tracing is enabledDr. David von Oheimb2022-05-301-2/+3
| | | | | | | Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com> (Merged from https://github.com/openssl/openssl/pull/18386)
* Update copyright yearMatt Caswell2022-05-031-1/+1
| | | | | Reviewed-by: Tomas Mraz <tomas@openssl.org> Release: yes
* str[n]casecmp => OPENSSL_strncasecmpDmitry Belyavskiy2022-04-221-3/+1
| | | | | | Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18069)
* Move e_os.h to include/internalRichard Levitte2022-02-051-1/+1
| | | | | | | | | | | | Including e_os.h with a path from a header file doesn't work well on certain exotic platform. It simply fails to build. Since we don't seem to be able to stop ourselves, the better move is to move e_os.h to an include directory that's part of the inclusion path given to the compiler. Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17641)
* trace.c: Add missing trace category entryTomas Mraz2022-01-051-0/+1
| | | | | | | Fixes #17397 Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17399)
* Validate the category in OSSL_trace_end()Matt Caswell2022-01-041-0/+2
| | | | | | | | | | | | | OSSL_trace_end() should validate that the category it has been passed by the caler is valid, and return immediately if not. Fixes #17353 Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17371)
* Rework and make DEBUG macros consistent.Rich Salz2021-05-281-0/+2
| | | | | | | | | | | | | | | | | | | | Remove unused -DCONF_DEBUG and -DBN_CTX_DEBUG. Rename REF_PRINT to REF_DEBUG for consistency, and add a new tracing category and use it for printing reference counts. Rename -DDEBUG_UNUSED to -DUNUSED_RESULT_DEBUG Fix BN_DEBUG_RAND so it compiles and, when set, force DEBUG_RAND to be set also. Rename engine_debug_ref to be ENGINE_REF_PRINT also for consistency. Fixes #15357 Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15353)
* Update copyright yearMatt Caswell2021-04-081-1/+1
| | | | | Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14801)
* Always check CRYPTO_LOCK_{read,write}_lockRich Salz2021-03-141-1/+2
| | | | | | | | | | | | | | Some functions that lock things are void, so we just return early. Also make ossl_namemap_empty return 0 on error. Updated the docs, and added some code to ossl_namemap_stored() to handle the failure, and updated the tests to allow for failure. Fixes: #14230 Reviewed-by: Shane Lontis <shane.lontis@oracle.com> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14238)
* ENCODER: Add tracingRichard Levitte2020-11-111-0/+1
| | | | | Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/13167)
* DECODER: Add tracingRichard Levitte2020-11-111-0/+1
| | | | | Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/13248)
* Run the withlibctx.pl scriptMatt Caswell2020-10-011-0/+0
| | | | | | | | Automatically rename all instances of _with_libctx() to _ex() as per our coding style. Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/12970)
* Update copyright yearRichard Levitte2020-07-161-1/+1
| | | | | Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com> (Merged from https://github.com/openssl/openssl/pull/12463)
* trace: condition out engine related tracingPauli2020-07-161-0/+2
| | | | | Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/12226)
* OSSL_STORE: add tracingRichard Levitte2019-11-031-0/+1
| | | | | Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/8442)
* Reorganize private crypto header filesDr. Matthias St. Pierre2019-09-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, there are two different directories which contain internal header files of libcrypto which are meant to be shared internally: While header files in 'include/internal' are intended to be shared between libcrypto and libssl, the files in 'crypto/include/internal' are intended to be shared inside libcrypto only. To make things complicated, the include search path is set up in such a way that the directive #include "internal/file.h" could refer to a file in either of these two directoroes. This makes it necessary in some cases to add a '_int.h' suffix to some files to resolve this ambiguity: #include "internal/file.h" # located in 'include/internal' #include "internal/file_int.h" # located in 'crypto/include/internal' This commit moves the private crypto headers from 'crypto/include/internal' to 'include/crypto' As a result, the include directives become unambiguous #include "internal/file.h" # located in 'include/internal' #include "crypto/file.h" # located in 'include/crypto' hence the superfluous '_int.h' suffixes can be stripped. The files 'store_int.h' and 'store.h' need to be treated specially; they are joined into a single file. Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/9333)
* prevent endless recursion when trace API is used within OPENSSL_init_crypto()Dr. David von Oheimb2019-08-201-10/+15
| | | | | | Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Paul Yang <kaishen.yy@antfin.com> (Merged from https://github.com/openssl/openssl/pull/9567)
* crypto/trace.c: Remove unexisting categoriesRichard Levitte2019-06-221-2/+0
| | | | | | | | | | Reverts an inadvertent change from commit fe26f798526c14a3f8c9bb55d0eaf8eaa0d086e1 Fixes #9220 Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> (Merged from https://github.com/openssl/openssl/pull/9218)
* OSSL_TRACE: ensure it's initialisedRichard Levitte2019-06-221-3/+12
| | | | | | | | | | | When OSSL_TRACE functionality is called before anything else, it finds itself uninitialised, i.e. its global lock hasn't been created yet. Fortunately, we have an internal general setup function for the trace functionality, that makes for a perfect spot to trigger initialisation. Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> (Merged from https://github.com/openssl/openssl/pull/9212)
* Convert the ENGINE_CONF trace calls to use CONF insteadRichard Levitte2019-04-051-2/+1
| | | | | | | | Additionally, merge ENGINE_CONF into CONF. Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> (Merged from https://github.com/openssl/openssl/pull/8680)
* Rename the PROVIDER_CONF trace to CONFRichard Levitte2019-04-051-1/+1
| | | | | | | | | | Other configuration modules may have use for tracing, and having one tracing category for each of them is a bit much. Instead, we make one category for them all. Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> (Merged from https://github.com/openssl/openssl/pull/8680)
* trace: add PROVIDER_CONF trace categoryDr. Matthias St. Pierre2019-04-041-0/+1
| | | | | | | Fixes #8667 Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/8672)
* trace: rename the default trace category from 'ANY' to 'ALL'Dr. Matthias St. Pierre2019-03-301-2/+2
| | | | | | | | 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-1/+1
| | | | | | | | | | | | | | | 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: fix out-of-bound memory accessDr. Matthias St. Pierre2019-03-291-1/+5
| | | | | | | | | When OSSL_trace_get_category_num() is called with an unknown category name, it returns -1. This case needs to be considered in order to avoid out-of-bound memory access to the `trace_channels` array. 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-20/+12
| | | | | | | | | | | | | | | | | | | | | | 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)
* trace: ensure correct groupingDr. Matthias St. Pierre2019-03-151-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-1/+1
| | | | | | | | | | | | | | | | | | | | | | | 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)
* trace: rename the trace channel typesDr. Matthias St. Pierre2019-03-151-7/+7
| | | | | | | | | | | | Since the term 'channel' is already used as synonym for a BIO object attached to a trace category, having a 't_channel' channel type and a 't_callback' channel type somehow overburdens this term. For that reason the type enum constants are renamed to 'SIMPE_CHANNEL' and 'CALLBACK_CHANNEL'. (The conversion to capital letters was done to comply to the coding style.) 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: remove some magic numbersDr. Matthias St. Pierre2019-03-151-15/+22
| | | | | | Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/8463)
* Don't fail when tracing is disabledRichard Levitte2019-03-141-16/+17
| | | | | | | | When tracing is disabled, don't generate errors, especially during init. Instead, just pretend the everything is fine. Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> (Merged from https://github.com/openssl/openssl/pull/8475)
* Make it possible to trace the trace functionality itselfRichard Levitte2019-03-061-76/+178
| | | | | | | 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)
* Adapt BN_CTX_DEBUG to the new generic trace APIRichard Levitte2019-03-061-0/+1
| | | | | | | 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)
* Adapt OPENSSL_DEBUG_DECRYPT to the new generic trace APIRichard Levitte2019-03-061-0/+1
| | | | | | | 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)
* Adapt OPENSSL_POLICY_DEBUG to the new generic trace APIRichard Levitte2019-03-061-0/+1
| | | | | | | 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)
* Adapt OPENSSL_DEBUG_KEYGEN to the new generic trace APIRichard Levitte2019-03-061-0/+1
| | | | | | | 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)
* Adapt OPENSSL_DEBUG_PKCS5V2 to the new generic trace APIRichard Levitte2019-03-061-0/+1
| | | | | | | 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)
* Adapt ENGINE_REF_COUNT_DEBUG to the new generic trace APIRichard Levitte2019-03-061-0/+1
| | | | | | | 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)
* Adapt ENGINE_TABLE_DEBUG to the new generic trace APIRichard Levitte2019-03-061-0/+1
| | | | | | | 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)
* Adapt ENGINE_CONF_DEBUG to the new generic trace APIRichard Levitte2019-03-061-0/+1
| | | | | | | 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)
* Adapt OPENSSL_INIT_DEBUG to the new generic trace APIRichard Levitte2019-03-061-0/+1
| | | | | | | 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)
* Adapt CIPHER_DEBUG to the new generic trace APIRichard Levitte2019-03-061-0/+1
| | | | | | | 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)
* Adapt SSL_DEBUG to the new generic trace APIRichard Levitte2019-03-061-0/+1
| | | | | | | 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)
* Make it possible to disable the TRACE APIRichard Levitte2019-03-061-8/+48
| | | | | | | | This disabled the tracing functionality by making functions do nothing, and making convenience macros produce dead code. Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/8198)
* Add generic trace APIRichard Levitte2019-03-061-0/+342
The idea is that the application shall be able to register output channels or callbacks to print tracing output as it sees fit. OpenSSL internals, on the other hand, want to print thoses texts using normal printing routines, such as BIO_printf() or BIO_dump() through well defined BIOs. When the application registers callbacks, the tracing functionality sets up an internal BIO that simply forwards received text to the appropriate application provided callback. 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)