From 9cc130f06fe11f2ba343298c1e43903c198b6a83 Mon Sep 17 00:00:00 2001
From: Vladimir Davydov <vdavydov@tarantool.org>
Date: Tue, 31 May 2022 14:37:34 +0300
Subject: [PATCH] crypto: use ERR_reason_error_string instead of
 ERR_error_string

ERR_error_string adds some extra information that depends on the OpenSSL
library version (code, module, method). This information says nothing to
the end user, and it results in different test results after updating to
OpenSSL 3.0. Let's use ERR_reason_error_string instead, which just
prints a human-readable error message.

Part of #6477

NO_DOC=minor change in error message
NO_CHANGELOG=minor change in error message
---
 src/lib/crypto/crypto.c | 2 +-
 test/app/crypto.result  | 6 ++----
 test/app/digest.result  | 3 +--
 3 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/lib/crypto/crypto.c b/src/lib/crypto/crypto.c
index a5423cd82b..c729576060 100644
--- a/src/lib/crypto/crypto.c
+++ b/src/lib/crypto/crypto.c
@@ -112,7 +112,7 @@ evp_cipher_find(enum crypto_algo algo, enum crypto_mode mode)
  */
 #define diag_set_OpenSSL()					\
 	diag_set(CryptoError, "OpenSSL error: %s",		\
-		 ERR_error_string(ERR_get_error(), NULL))
+		 ERR_reason_error_string(ERR_get_error()))
 
 /** Stream to encrypt/decrypt data packets step by step. */
 struct crypto_stream {
diff --git a/test/app/crypto.result b/test/app/crypto.result
index 7bfb4d1988..b59583fce7 100644
--- a/test/app/crypto.result
+++ b/test/app/crypto.result
@@ -167,13 +167,11 @@ bad_iv = '123456abcdefghij'
 ...
 ciph.decrypt(enc, bad_pass, iv)
 ---
-- error: 'OpenSSL error: error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad
-    decrypt'
+- error: 'OpenSSL error: bad decrypt'
 ...
 ciph.decrypt(enc, pass, bad_iv)
 ---
-- error: 'OpenSSL error: error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad
-    decrypt'
+- error: 'OpenSSL error: bad decrypt'
 ...
 test_run:cmd("clear filter")
 ---
diff --git a/test/app/digest.result b/test/app/digest.result
index 1246b279fa..dc296bf16d 100644
--- a/test/app/digest.result
+++ b/test/app/digest.result
@@ -448,8 +448,7 @@ digest.aes256cbc.decrypt(digest.aes256cbc.encrypt('test123', 'passpasspasspasspa
 ...
 digest.aes256cbc.decrypt(digest.aes256cbc.encrypt('test123', 'passpasspasspasspasspasspasspass', 'iv12tras8712cvbh'), 'nosspasspasspasspasspasspasspass', 'iv12tras8712cvbh')
 ---
-- error: 'OpenSSL error: error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad
-    decrypt'
+- error: 'OpenSSL error: bad decrypt'
 ...
 --
 -- Test base64 options. (gh-2479, gh-2478, gh-2777).
-- 
GitLab