]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Print plaintext/ciphertext in cipher_rsa_decrypt/encrypt_xlat at debug level 3
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 6 May 2019 19:23:26 +0000 (15:23 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 6 May 2019 19:23:36 +0000 (15:23 -0400)
src/modules/rlm_cipher/rlm_cipher.c

index f71766c15ab6389af015d73fdd5d771b2b32477a..0d097128456916fad24ca52320f93834a0f4f48f 100644 (file)
@@ -492,6 +492,7 @@ static xlat_action_t cipher_rsa_encrypt_xlat(TALLOC_CTX *ctx, fr_cursor_t *out,
        /*
         *      Figure out the buffer we need
         */
+       RHEXDUMP(L_DBG_LVL_3, plaintext, plaintext_len, "Plaintext (%zu bytes)", plaintext_len);
        if (EVP_PKEY_encrypt(xt->evp_encrypt_ctx, NULL, &ciphertext_len,
                             (unsigned char const *)plaintext, plaintext_len) <= 0) {
                tls_log_error(request, "Failed getting length of encrypted plaintext");
@@ -504,6 +505,7 @@ static xlat_action_t cipher_rsa_encrypt_xlat(TALLOC_CTX *ctx, fr_cursor_t *out,
                tls_log_error(request, "Failed encrypting plaintext");
                return XLAT_ACTION_FAIL;
        }
+       RHEXDUMP(L_DBG_LVL_3, ciphertext, ciphertext_len, "Ciphertext (%zu bytes)", ciphertext_len);
 
        if (ciphertext_len != talloc_array_length(ciphertext)) {
                uint8_t *n;
@@ -654,8 +656,9 @@ static xlat_action_t cipher_rsa_decrypt_xlat(TALLOC_CTX *ctx, fr_cursor_t *out,
        ciphertext_len = (*in)->vb_length;
 
        /*
-        *      Decrypt the plaintext
+        *      Decrypt the ciphertext
         */
+       RHEXDUMP(L_DBG_LVL_3, ciphertext, ciphertext_len, "Ciphertext (%zu bytes)", ciphertext_len);
        if (EVP_PKEY_decrypt(xt->evp_decrypt_ctx, NULL, &plaintext_len, ciphertext, ciphertext_len) <= 0) {
                tls_log_error(request, "Failed getting length of cleartext");
                return XLAT_ACTION_FAIL;
@@ -667,6 +670,7 @@ static xlat_action_t cipher_rsa_decrypt_xlat(TALLOC_CTX *ctx, fr_cursor_t *out,
                tls_log_error(request, "Failed decrypting ciphertext");
                return XLAT_ACTION_FAIL;
        }
+       RHEXDUMP(L_DBG_LVL_3, plaintext, plaintext_len, "Plaintext (%zu bytes)", plaintext_len);
 
        /*
         *      Fixup the output buffer (and ensure it's \0 terminated)