summaryrefslogtreecommitdiffstats
path: root/crypto/encode_decode/decoder_lib.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2020-10-28 10:13:24 +0100
committerRichard Levitte <levitte@openssl.org>2020-11-11 11:42:06 +0100
commitde5008a4076e36f7038180d60ae1521afb524d68 (patch)
tree80039a3b1d068a6f3ab62470a11c36db269dc431 /crypto/encode_decode/decoder_lib.c
parentdf65c06b59f0ccd06398c0ff3034371fdefd8e70 (diff)
DECODER: Add tracing
Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/13248)
Diffstat (limited to 'crypto/encode_decode/decoder_lib.c')
-rw-r--r--crypto/encode_decode/decoder_lib.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/crypto/encode_decode/decoder_lib.c b/crypto/encode_decode/decoder_lib.c
index 64e6bcc185..8e9af13bbb 100644
--- a/crypto/encode_decode/decoder_lib.c
+++ b/crypto/encode_decode/decoder_lib.c
@@ -14,6 +14,7 @@
#include <openssl/evperr.h>
#include <openssl/ecerr.h>
#include <openssl/x509err.h>
+#include <openssl/trace.h>
#include "internal/passphrase.h"
#include "crypto/decoder.h"
#include "encoder_local.h"
@@ -210,6 +211,8 @@ void ossl_decoder_instance_free(OSSL_DECODER_INSTANCE *decoder_inst)
int ossl_decoder_ctx_add_decoder_inst(OSSL_DECODER_CTX *ctx,
OSSL_DECODER_INSTANCE *di)
{
+ int ok;
+
if (ctx->decoder_insts == NULL
&& (ctx->decoder_insts =
sk_OSSL_DECODER_INSTANCE_new_null()) == NULL) {
@@ -217,7 +220,18 @@ int ossl_decoder_ctx_add_decoder_inst(OSSL_DECODER_CTX *ctx,
return 0;
}
- return (sk_OSSL_DECODER_INSTANCE_push(ctx->decoder_insts, di) > 0);
+ ok = (sk_OSSL_DECODER_INSTANCE_push(ctx->decoder_insts, di) > 0);
+ if (ok) {
+ OSSL_TRACE_BEGIN(DECODER) {
+ BIO_printf(trc_out,
+ "(ctx %p) Added decoder instance %p (decoder %p) with:\n",
+ (void *)ctx, (void *)di, (void *)di->decoder);
+ BIO_printf(trc_out,
+ " input type: %s, input structure: %s\n",
+ di->input_type, di->input_structure);
+ } OSSL_TRACE_END(DECODER);
+ }
+ return ok;
}
int OSSL_DECODER_CTX_add_decoder(OSSL_DECODER_CTX *ctx, OSSL_DECODER *decoder)
@@ -615,6 +629,13 @@ static int decoder_process(const OSSL_PARAM params[], void *arg)
decoder_process, &new_data,
ossl_pw_passphrase_callback_dec,
&new_data.ctx->pwdata);
+
+ OSSL_TRACE_BEGIN(DECODER) {
+ BIO_printf(trc_out,
+ "(ctx %p) Running decoder instance %p => %d\n",
+ (void *)new_data.ctx, (void *)new_decoder_inst, ok);
+ } OSSL_TRACE_END(DECODER);
+
if (ok)
break;
err = ERR_peek_last_error();