summaryrefslogtreecommitdiffstats
path: root/crypto/trace.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* 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)