diff options
author | Richard Levitte <levitte@openssl.org> | 2018-12-13 01:53:13 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2019-03-06 11:15:14 +0100 |
commit | 3a9b3d2d93017014032d1bbed3e4193bb423eaae (patch) | |
tree | 6ea5907c397a8ee94bdbe5ab8b28e6c3168e4886 /crypto | |
parent | f518e3e802d8dcad283be6cb4913dd7cfc6f11fd (diff) |
Adapt OPENSSL_DEBUG_PKCS5V2 to the new generic trace API
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)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/evp/p5_crpt2.c | 41 | ||||
-rw-r--r-- | crypto/trace.c | 1 |
2 files changed, 17 insertions, 25 deletions
diff --git a/crypto/evp/p5_crpt2.c b/crypto/evp/p5_crpt2.c index 4210e51678..ac5b974e54 100644 --- a/crypto/evp/p5_crpt2.c +++ b/crypto/evp/p5_crpt2.c @@ -14,16 +14,10 @@ #include <openssl/evp.h> #include <openssl/kdf.h> #include <openssl/hmac.h> +#include <openssl/trace.h> #include "internal/evp_int.h" #include "evp_locl.h" -/* set this to print out info about the keygen algorithm */ -/* #define OPENSSL_DEBUG_PKCS5V2 */ - -#ifdef OPENSSL_DEBUG_PKCS5V2 -static void h__dump(const unsigned char *p, int len); -#endif - int PKCS5_PBKDF2_HMAC(const char *pass, int passlen, const unsigned char *salt, int saltlen, int iter, const EVP_MD *digest, int keylen, unsigned char *out) @@ -55,15 +49,21 @@ int PKCS5_PBKDF2_HMAC(const char *pass, int passlen, EVP_KDF_CTX_free(kctx); -# ifdef OPENSSL_DEBUG_PKCS5V2 - fprintf(stderr, "Password:\n"); - h__dump(pass, passlen); - fprintf(stderr, "Salt:\n"); - h__dump(salt, saltlen); - fprintf(stderr, "Iteration count %d\n", iter); - fprintf(stderr, "Key:\n"); - h__dump(out, keylen); -# endif + OSSL_TRACE_BEGIN(PKCS5V2) { + BIO_printf(trc_out, "Password:\n"); + BIO_hex_string(trc_out, + 0, passlen, pass, passlen); + BIO_printf(trc_out, "\n"); + BIO_printf(trc_out, "Salt:\n"); + BIO_hex_string(trc_out, + 0, saltlen, salt, saltlen); + BIO_printf(trc_out, "\n"); + BIO_printf(trc_out, "Iteration count %d\n", iter); + BIO_printf(trc_out, "Key:\n"); + BIO_hex_string(trc_out, + 0, keylen, out, keylen); + BIO_printf(trc_out, "\n"); + } OSSL_TRACE_END(PKCS5V2); return rv; } @@ -200,12 +200,3 @@ int PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, PBKDF2PARAM_free(kdf); return rv; } - -# ifdef OPENSSL_DEBUG_PKCS5V2 -static void h__dump(const unsigned char *p, int len) -{ - for (; len--; p++) - fprintf(stderr, "%02X ", *p); - fprintf(stderr, "\n"); -} -# endif diff --git a/crypto/trace.c b/crypto/trace.c index 8e1db68190..904f3f6b33 100644 --- a/crypto/trace.c +++ b/crypto/trace.c @@ -126,6 +126,7 @@ static const struct trace_category_st trace_categories[] = { TRACE_CATEGORY_(ENGINE_CONF), TRACE_CATEGORY_(ENGINE_TABLE), TRACE_CATEGORY_(ENGINE_REF_COUNT), + TRACE_CATEGORY_(PKCS5V2), }; const char *OSSL_trace_get_category_name(int num) |