diff --git a/hasl/haslversion.h b/hasl/haslversion.h
new file mode 100644
--- /dev/null
+++ b/hasl/haslversion.h
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2023 Hasl Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#ifndef HASL_VERSION_H
+#define HASL_VERSION_H
+
+#include <glib.h>
+
+#include <hasl/haslversionconsts.h>
+
+G_BEGIN_DECLS
+
+/**
+ * HASL_CHECK_VERSION:
+ * @major: The major version to check for.
+ * @minor: The minor version to check for.
+ * @micro: The micro version to check for.
+ *
+ * Checks the version of hasl being compiled against. See [func@check_version]
+ * for a runtime check.
+ *
+ * Returns: %TRUE if the version is the same or newer than the passed-in
+ *          version.
+ *
+ * Since: 0.2.0
+ */
+#define HASL_CHECK_VERSION(major, minor, micro) ((major) == HASL_MAJOR_VERSION && \
+                                                 ((minor) < HASL_MINOR_VERSION || \
+                                                  ((minor) == HASL_MINOR_VERSION && (micro) <= HASL_MICRO_VERSION)))
+
+/**
+ * hasl_check_version:
+ * @required_major: the required major version.
+ * @required_minor: the required minor version.
+ * @required_micro: the required micro version.
+ *
+ * Checks that the hasl version is compatible with the requested version.
+ *
+ * Returns: %NULL if the versions are compatible, or a string describing
+ *          the version mismatch if not compatible.
+ *
+ * Since: 0.2.0
+ */
+const char *hasl_check_version(guint required_major, guint required_minor, guint required_micro);
+
+/**
+ * hasl_version:
+ *
+ * The full version string of the running hasl.
+ *
+ * Since: 0.2.0
+ */
+extern const char *hasl_version;
+
+/**
+ * hasl_major_version:
+ *
+ * The major version of the running hasl. Contrast with #HASL_MAJOR_VERSION,
+ * which expands at compile time to the major version of hasl being compiled
+ * against.
+ *
+ * Since: 0.2.0
+ */
+extern const guint hasl_major_version;
+
+/**
+ * hasl_minor_version:
+ *
+ * The minor version of the running hasl. Contrast with #HASL_MINOR_VERSION,
+ * which expands at compile time to the minor version of hasl being compiled
+ * against.
+ *
+ * Since: 0.2.0
+ */
+extern const guint hasl_minor_version;
+
+/**
+ * hasl_micro_version:
+ *
+ * The micro version of the running hasl. Contrast with #HASL_MICRO_VERSION,
+ * which expands at compile time to the micro version of hasl being compiled
+ * against.
+ *
+ * Since: 0.2.0
+ */
+extern const guint hasl_micro_version;
+
+G_END_DECLS
+
+#endif /* HASL_VERSION_CONSTS_H */
# HG changeset patch
# Node ID 4c13eee574a1
# Parent  4350ec6c9fc6
diff --git a/hasl/haslversion.c b/hasl/haslversion.c
new file mode 100644
--- /dev/null
+++ b/hasl/haslversion.c
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2023 Hasl Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include "haslversion.h"
+
+/******************************************************************************
+ * Externals
+ *****************************************************************************/
+const guint hasl_major_version = HASL_MAJOR_VERSION;
+const guint hasl_minor_version = HASL_MINOR_VERSION;
+const guint hasl_micro_version = HASL_MICRO_VERSION;
+const char *hasl_version = HASL_VERSION;
+
+/******************************************************************************
+ * Public API
+ *****************************************************************************/
+const char *
+hasl_check_version(guint required_major, guint required_minor,
+                   guint required_micro)
+{
+	if(required_major > HASL_MAJOR_VERSION) {
+		return "hasl version too old (major mismatch)";
+	}
+
+#if HASL_CHECK_VERSION(1, 0, 0)
+	if(required_major < HASL_MAJOR_VERSION) {
+		return "hasl version too new (major mismatch)";
+	}
+#endif
+
+	if(required_minor > HASL_MINOR_VERSION) {
+		return "hasl version too old (minor mismatch)";
+	}
+
+	if((required_minor == HASL_MINOR_VERSION) &&
+	   (required_micro > HASL_MICRO_VERSION))
+	{
+		return "hasl version too old (micro mismatch)";
+	}
+
+	return NULL;
+}
diff --git a/hasl/haslversionconsts.h.in b/hasl/haslversionconsts.h.in
new file mode 100644
--- /dev/null
+++ b/hasl/haslversionconsts.h.in
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2023 Hasl Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#ifndef HASL_VERSION_CONSTS_H
+#define HASL_VERSION_CONSTS_H
+
+/**
+ * HASL_MAJOR_VERSION:
+ *
+ * The major version of the version of HASL that was compiled against.
+ *
+ * Since: 0.2.0
+ */
+#define HASL_MAJOR_VERSION (@HASL_MAJOR_VERSION@)
+
+/**
+ * HASL_MINOR_VERSION:
+ *
+ * The minor version of the version of HASL that was compiled against.
+ *
+ * Since: 0.2.0
+ */
+#define HASL_MINOR_VERSION (@HASL_MINOR_VERSION@)
+
+/**
+ * HASL_MICRO_VERSION:
+ *
+ * The micro version of the version of HASL that was compiled against.
+ *
+ * Since: 0.2.0
+ */
+#define HASL_MICRO_VERSION (@HASL_MICRO_VERSION@)
+
+/**
+ * HASL_EXTRA_VERSION:
+ *
+ * The extra version of the version of HASL that was compiled against.
+ *
+ * Since: 0.2.0
+ */
+#define HASL_EXTRA_VERSION ("@HASL_EXTRA_VERSION@")
+
+/**
+ * HASL_VERSION:
+ *
+ * The full version number for the version of HASL that was compiled against.
+ *
+ * Since: 0.2.0
+ */
+#define HASL_VERSION ("@HASL_VERSION@")
+
+#endif /* HASL_VERSION_CONSTS_H */
diff --git a/hasl/meson.build b/hasl/meson.build
--- a/hasl/meson.build
+++ b/hasl/meson.build
@@ -3,6 +3,7 @@
   'haslmechanism.c',
   'haslmechanismexternal.c',
   'haslmechanismplain.c',
+  'haslversion.c',
 ]
 
 HASL_HEADERS = [
@@ -11,6 +12,7 @@
   'haslmechanism.h',
   'haslmechanismexternal.h',
   'haslmechanismplain.h',
+  'haslversion.h',
 ]
 
 HASL_BUILT_SOURCES = []
@@ -18,6 +20,17 @@
 HASL_GENERATED_TARGETS = []
 
 ###############################################################################
+# haslversionconsts.h
+###############################################################################
+hasl_version_consts_h = configure_file(
+	input : 'haslversionconsts.h.in',
+	output : 'haslversionconsts.h',
+	configuration : version_config,
+	install : true,
+	install_dir : get_option('includedir') / 'hasl-1.0' / 'hasl')
+HASL_BUILT_HEADERS += hasl_version_consts_h
+
+###############################################################################
 # Single Header
 ###############################################################################
 HASL_H_INCLUDES = []
diff --git a/hasl/tests/meson.build b/hasl/tests/meson.build
--- a/hasl/tests/meson.build
+++ b/hasl/tests/meson.build
@@ -4,6 +4,7 @@
   'mechanism',
   'mechanism-external',
   'mechanism-plain',
+  'version',
 ]
 
 foreach program : TESTS
diff --git a/hasl/tests/test-version.c b/hasl/tests/test-version.c
new file mode 100644
--- /dev/null
+++ b/hasl/tests/test-version.c
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2023 Hasl Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+
+#include <hasl.h>
+
+/******************************************************************************
+ * Tests
+ *****************************************************************************/
+static void
+test_hasl_version_constants(void) {
+	/* Since we are hasl, our build time versions will always match our compile
+	 * time versions, so we can check that those are in fact, equal.
+	 */
+
+	g_assert_cmpuint(HASL_MAJOR_VERSION, ==, hasl_major_version);
+	g_assert_cmpuint(HASL_MINOR_VERSION, ==, hasl_minor_version);
+	g_assert_cmpuint(HASL_MICRO_VERSION, ==, hasl_micro_version);
+	g_assert_cmpstr(HASL_VERSION, ==, hasl_version);
+}
+
+static void
+test_hash_version_runtime_check(void) {
+	const char *reason = NULL;
+
+	/* We can't do this until 1.0.0 is released as it underflows. */
+#if HASL_CHECK_VERSION(1, 0, 0)
+	reason = hasl_check_version(hasl_major_version - 1, 0, 0);
+	g_assert_cmpstr(reason, ==, "hasl version too new (major mismatch)");
+#endif /* HASL_CHECK_VERSION */
+
+	/* Old minors from the same version are compatible. */
+	reason = hasl_check_version(hasl_major_version, hasl_minor_version - 1, 0);
+	g_assert_null(reason);
+
+#if HASL_CHECK_VERSION(HASL_MAJOR_VERSION, HASL_MINOR_VERSION, 1)
+	/* Old mircos from the same major and minors are compatible. */
+	reason = hasl_check_version(hasl_major_version, hasl_minor_version,
+	                            hasl_micro_version - 1);
+	g_assert_null(reason);
+#endif
+
+	/* Exact versions are compatible. */
+	reason = hasl_check_version(hasl_major_version, hasl_minor_version,
+	                            hasl_micro_version);
+	g_assert_null(reason);
+
+	/* Requiring newer majors should fail. */
+	reason  = hasl_check_version(hasl_major_version + 1, 0, 0);
+	g_assert_cmpstr(reason, ==, "hasl version too old (major mismatch)");
+
+	/* Requiring newer minors with the same major should fail. */
+	reason = hasl_check_version(hasl_major_version, hasl_minor_version + 1, 0);
+	g_assert_cmpstr(reason, ==, "hasl version too old (minor mismatch)");
+
+	/* Requiring new micros with the same major and minor should fail. */
+	reason = hasl_check_version(hasl_major_version, hasl_minor_version,
+	                            hasl_micro_version + 1);
+	g_assert_cmpstr(reason, ==, "hasl version too old (micro mismatch)");
+}
+
+static void
+test_hash_version_compile_time_check(void) {
+	/* Check the major versions. */
+#if HASL_CHECK_VERSION(HASL_MAJOR_VERSION + 1, 0, 0)
+	g_assert_not_reached();
+#endif
+
+#if HASL_CHECK_VERSION(HASL_MAJOR_VERSION - 1, 0, 0)
+	g_assert_not_reached();
+#endif
+
+#if !HASL_CHECK_VERSION(HASL_MAJOR_VERSION, 0, 0)
+	g_assert_not_reached();
+#endif
+
+	/* Check the minor version. */
+#if !HASL_CHECK_VERSION(HASL_MAJOR_VERSION, HASL_MINOR_VERSION - 1, 0)
+	g_assert_not_reached();
+#endif
+
+#if HASL_CHECK_VERSION(HASL_MAJOR_VERSION, HASL_MINOR_VERSION + 1, 0)
+	g_assert_not_reached();
+#endif
+
+#if !HASL_CHECK_VERSION(HASL_MAJOR_VERSION, HASL_MINOR_VERSION, 0)
+	g_assert_not_reached();
+#endif
+
+	/* Check the micro version. */
+#if !HASL_CHECK_VERSION(HASL_MAJOR_VERSION, HASL_MINOR_VERSION, \
+                        HASL_MICRO_VERSION - 1)
+	g_assert_not_reached();
+#endif
+
+#if !HASL_CHECK_VERSION(HASL_MAJOR_VERSION, HASL_MINOR_VERSION, \
+                        HASL_MICRO_VERSION)
+	g_assert_not_reached();
+#endif
+
+#if HASL_CHECK_VERSION(HASL_MAJOR_VERSION, HASL_MINOR_VERSION, \
+                       HASL_MICRO_VERSION + 1)
+	g_assert_not_reached();
+#endif
+}
+
+/******************************************************************************
+ * Main
+ *****************************************************************************/
+int
+main(int argc, char *argv[]) {
+	g_test_init(&argc, &argv, NULL);
+
+	g_test_add_func("/hasl/version/constants", test_hasl_version_constants);
+	g_test_add_func("/hasl/version/runtime-check",
+	                test_hash_version_runtime_check);
+	g_test_add_func("/hasl/version/compile-time-check",
+	                test_hash_version_compile_time_check);
+
+	return g_test_run();
+}
