summaryrefslogtreecommitdiff
path: root/src/openssl/globals.h
diff options
context:
space:
mode:
authorKonrad Lipinski <k.lipinski2@partner.samsung.com>2019-06-11 16:25:51 +0200
committerKonrad Lipinski <k.lipinski2@samsung.com>2019-08-01 14:37:53 +0200
commitcc6febdd37186eeea33bcbce89d79f661ee0009f (patch)
tree100542f7f8fd3b3c9548150362efe35adde47551 /src/openssl/globals.h
parentc40fbfa8503e7763ef630496852f4d6b5e63b58c (diff)
downloadxmlsec1-cc6febdd37186eeea33bcbce89d79f661ee0009f.tar.gz
xmlsec1-cc6febdd37186eeea33bcbce89d79f661ee0009f.tar.bz2
xmlsec1-cc6febdd37186eeea33bcbce89d79f661ee0009f.zip
Import upstream commit c4d0493d545b99194eea1b2b058930d5a9bb91b1 (1.2.28)
Change-Id: I10f71567cb140be223923e1cd0b5895e366ac23e
Diffstat (limited to 'src/openssl/globals.h')
-rw-r--r--src/openssl/globals.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/openssl/globals.h b/src/openssl/globals.h
index 065c3e8f..291a84e0 100644
--- a/src/openssl/globals.h
+++ b/src/openssl/globals.h
@@ -21,4 +21,79 @@
#define IN_XMLSEC_CRYPTO
#define XMLSEC_PRIVATE
+/* Include common error helper macros. */
+#include "../errors_helpers.h"
+
+/**************************************************************
+ *
+ * Error constants for OpenSSL
+ *
+ *************************************************************/
+/**
+ * XMLSEC_OPENSSL_ERRORS_LIB:
+ *
+ * Macro. The XMLSec library klass for OpenSSL errors reporting functions.
+ */
+#define XMLSEC_OPENSSL_ERRORS_LIB (ERR_LIB_USER + 57)
+
+/**
+ * XMLSEC_OPENSSL_ERRORS_FUNCTION:
+ *
+ * Macro. The XMLSec library functions OpenSSL errors reporting functions.
+ */
+#define XMLSEC_OPENSSL_ERRORS_FUNCTION 0
+
+/**
+ * xmlSecOpenSSLError:
+ * @errorFunction: the failed function name.
+ * @errorObject: the error specific error object (e.g. transform, key data, etc).
+ *
+ * Macro. The XMLSec library macro for reporting OpenSSL crypro errors.
+ */
+#define xmlSecOpenSSLError(errorFunction, errorObject) \
+ { \
+ unsigned long error_code = ERR_peek_error(); \
+ const char* lib = ERR_lib_error_string(error_code); \
+ const char* func = ERR_func_error_string(error_code); \
+ const char* reason = ERR_reason_error_string(error_code); \
+ xmlSecError(XMLSEC_ERRORS_HERE, \
+ (const char*)(errorObject), \
+ (errorFunction), \
+ XMLSEC_ERRORS_R_CRYPTO_FAILED, \
+ "openssl error: %lu: %s: %s %s", \
+ error_code, \
+ xmlSecErrorsSafeString(lib), \
+ xmlSecErrorsSafeString(func), \
+ xmlSecErrorsSafeString(reason) \
+ ); \
+ }
+
+/**
+ * xmlSecOpenSSLError2:
+ * @errorFunction: the failed function name.
+ * @errorObject: the error specific error object (e.g. transform, key data, etc).
+ * @msg: the extra message.
+ * @param: the extra message param.
+ *
+ * Macro. The XMLSec library macro for reporting OpenSSL crypro errors.
+ */
+#define xmlSecOpenSSLError2(errorFunction, errorObject, msg, param) \
+ { \
+ unsigned long error_code = ERR_peek_error(); \
+ const char* lib = ERR_lib_error_string(error_code); \
+ const char* func = ERR_func_error_string(error_code); \
+ const char* reason = ERR_reason_error_string(error_code); \
+ xmlSecError(XMLSEC_ERRORS_HERE, \
+ (const char*)(errorObject), \
+ (errorFunction), \
+ XMLSEC_ERRORS_R_CRYPTO_FAILED, \
+ msg "; openssl error: %lu: %s: %s %s", \
+ (param), \
+ error_code, \
+ xmlSecErrorsSafeString(lib), \
+ xmlSecErrorsSafeString(func), \
+ xmlSecErrorsSafeString(reason) \
+ ); \
+ }
+
#endif /* ! __XMLSEC_GLOBALS_H__ */