aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/plugins/openssl/openssl_util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstrongswan/plugins/openssl/openssl_util.h')
-rw-r--r--src/libstrongswan/plugins/openssl/openssl_util.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/libstrongswan/plugins/openssl/openssl_util.h b/src/libstrongswan/plugins/openssl/openssl_util.h
index 2db073139..264d47069 100644
--- a/src/libstrongswan/plugins/openssl/openssl_util.h
+++ b/src/libstrongswan/plugins/openssl/openssl_util.h
@@ -134,4 +134,42 @@ int openssl_asn1_known_oid(ASN1_OBJECT *obj);
*/
time_t openssl_asn1_to_time(ASN1_TIME *time);
+/**
+ * Macros to define fallback getters/setters to access keys (BIGNUM*) for types
+ * that were made opaque with OpenSSL 1.1.0.
+ */
+#define OPENSSL_KEY_FALLBACK(...) VA_ARGS_DISPATCH(OPENSSL_KEY_FALLBACK, __VA_ARGS__)(__VA_ARGS__)
+#define OPENSSL_KEY_FALLBACK3(type, k1, k2) \
+__attribute__((unused)) \
+static inline void type##_get0(const type *o, const BIGNUM **k1, const BIGNUM **k2) { \
+ if (k1) *k1 = o->k1; \
+ if (k2) *k2 = o->k2; } \
+__attribute__((unused)) \
+static inline int type##_set0(type *o, BIGNUM *k1, BIGNUM *k2) { \
+ if (k1) { BN_clear_free(o->k1); o->k1 = k1; } \
+ if (k2) { BN_clear_free(o->k2); o->k2 = k2; } \
+ return 1; }
+#define OPENSSL_KEY_FALLBACK4(type, name, k1, k2) \
+__attribute__((unused)) \
+static inline void type##_get0_##name(const type *o, const BIGNUM **k1, const BIGNUM **k2) { \
+ if (k1) *k1 = o->k1; \
+ if (k2) *k2 = o->k2; } \
+__attribute__((unused)) \
+static inline int type##_set0_##name(type *o, BIGNUM *k1, BIGNUM *k2) { \
+ if (k1) { BN_clear_free(o->k1); o->k1 = k1; } \
+ if (k2) { BN_clear_free(o->k2); o->k2 = k2; } \
+ return 1; }
+#define OPENSSL_KEY_FALLBACK5(type, name, k1, k2, k3) \
+__attribute__((unused)) \
+static inline void type##_get0_##name(const type *o, const BIGNUM **k1, const BIGNUM **k2, const BIGNUM **k3) { \
+ if (k1) *k1 = o->k1; \
+ if (k2) *k2 = o->k2; \
+ if (k3) *k3 = o->k3; } \
+__attribute__((unused)) \
+static inline int type##_set0_##name(type *o, BIGNUM *k1, BIGNUM *k2, BIGNUM *k3) { \
+ if (k1) { BN_clear_free(o->k1); o->k1 = k1; } \
+ if (k2) { BN_clear_free(o->k2); o->k2 = k2; } \
+ if (k3) { BN_clear_free(o->k3); o->k3 = k3; } \
+ return 1; }
+
#endif /** OPENSSL_UTIL_H_ @}*/