in the features list reported by "haproxy -vv"
(which means a <name> appears after a '+')
+ - fips_mode() : returns true if the loaded SSL library is
+ currently running in FIPS mode.
+
- openssl_version_atleast(<ver>) : returns true if the current openssl
version is at least as recent as <ver> otherwise
false.
CFG_PRED_AWSLC_API_ATLEAST, // "awslc_api_atleast"
CFG_PRED_AWSLC_API_BEFORE, // "awslc_api_before"
CFG_PRED_ENABLED, // "enabled"
+ CFG_PRED_FIPS_MODE, // "fips_mode"
};
/* types for condition terms */
int openssl_compare_current_version(const char *version);
/* compare the current OpenSSL name to a string */
int openssl_compare_current_name(const char *name);
+/* returns whether the SSL library is currently running in FIPS mode */
+int openssl_fips_mode(void);
/* vma helpers */
void vma_set_name(void *addr, size_t size, const char *type, const char *name);
{ "awslc_api_atleast", CFG_PRED_AWSLC_API_ATLEAST, ARG1(1, STR) },
{ "awslc_api_before", CFG_PRED_AWSLC_API_BEFORE, ARG1(1, STR) },
{ "enabled", CFG_PRED_ENABLED, ARG1(1, STR) },
+ { "fips_mode", CFG_PRED_FIPS_MODE, 0 },
{ NULL, CFG_PRED_NONE, 0 }
};
ret = cfg_eval_cond_enabled(term->args[0].data.str.area) != 0;
break;
}
+ case CFG_PRED_FIPS_MODE: { // checks if the SSL library is currently running in FIPS mode
+ int fipsret = openssl_fips_mode();
+
+ /* < -1 (i.e. -2) means the loaded SSL library doesn't support
+ * FIPS mode at all, in which case the condition is simply false.
+ */
+ ret = fipsret > 0;
+ break;
+ }
default:
memprintf(err, "internal error: unhandled conditional expression predicate '%s'", term->pred->word);
break;
return 1;
}
+/*
+ * This function returns whether the SSL library currently loaded is running
+ * in FIPS mode.
+ *
+ * FIPS_mode() is implemented by OpenSSL 1.0.x/1.1.x (including
+ * FIPS-validated builds) as well as by libraries providing a compatible API
+ * such as AWS-LC. It was removed in OpenSSL 3.0, replaced by a provider-based
+ * FIPS model: EVP_default_properties_is_fips_enabled() reports whether the
+ * default library context currently resolves algorithm fetches to the FIPS
+ * provider, which is the closest 3.x equivalent.
+ *
+ * 1 : FIPS mode is enabled
+ * 0 : FIPS mode is disabled
+ * -2 : not applicable, the loaded SSL library does not support FIPS mode
+ */
+int openssl_fips_mode(void)
+{
+#if defined(USE_OPENSSL) && (HA_OPENSSL_VERSION_NUMBER < 0x3000000fL)
+ return FIPS_mode() ? 1 : 0;
+#elif defined(USE_OPENSSL) && (HA_OPENSSL_VERSION_NUMBER >= 0x3000000fL)
+ return EVP_default_properties_is_fips_enabled(NULL) ? 1 : 0;
+#else
+ return -2;
+#endif
+}
+
/* prctl/PR_SET_VMA wrapper to easily give a name to virtual memory areas,
* knowing their address and size.
*