--- cryptsetup-1.4.1/lib/crypto_backend/crypto_gcrypt.c 
+++ crypto_gcrypt.c 
@@ -43,6 +43,11 @@
 {
 	if (crypto_backend_initialised)
 		return 0;
+
+#if !CM_MULTIPLE_INIT
+	crypto_backend_initialised = 1;
+    return 0;   /* cryptmount will already have initialized libgcrypt */
+#endif
 
 	log_dbg("Initialising gcrypt crypto backend.");
 	if (!gcry_control (GCRYCTL_INITIALIZATION_FINISHED_P)) {
--- cryptsetup-1.4.1/lib/internal.h 
+++ internal.h 
@@ -1,16 +1,39 @@
 #ifndef INTERNAL_H
 #define INTERNAL_H
 
-#ifdef HAVE_CONFIG_H
-#	include "config.h"
-#endif
+#include <config.h>
+
 
 #include <stdint.h>
 #include <stdarg.h>
 #include <unistd.h>
 #include <inttypes.h>
+#if HAVE_UUID
+#  include <uuid.h>
+#endif
 
-#include "nls.h"
+
+/* cryptmount patches: */
+#ifndef _
+#  define _(Text) Text 
+#  define ngettext(Text, TextP, N) (N == 1 ? Text : TextP)
+#endif
+/* Avoid multiple libgcrypt inits within cryptmount: */
+#define CM_MULTIPLE_INIT 0
+#ifndef DEFAULT_KEYFILE_SIZE_MAXKB
+#  define DEFAULT_KEYFILE_SIZE_MAXKB 8192
+#endif
+#ifndef DEFAULT_PASSPHRASE_SIZE_MAX
+#  define DEFAULT_PASSPHRASE_SIZE_MAX 512
+#endif
+#ifndef DEFAULT_RNG
+#  define DEFAULT_RNG "/dev/random"
+#endif
+#ifndef DEFAULT_LOOPAES_CIPHER
+#  define DEFAULT_LOOPAES_CIPHER "aes"
+#endif
+
+
 #include "utils_crypt.h"
 #include "utils_loop.h"
 #include "utils_dm.h"
--- cryptsetup-1.4.1/lib/luks1/keymanage.c 
+++ keymanage.c 
@@ -411,6 +411,8 @@
 	return r;
 }
 
+#if HAVE_UUID
+
 int LUKS_write_phdr(const char *device,
 		    struct luks_phdr *hdr,
 		    struct crypt_device *ctx)
@@ -707,6 +709,8 @@
 	return r;
 }
 
+#endif	/* HAVE_UUID */
+
 /* Check whether a volume key is invalid. */
 int LUKS_verify_volume_key(const struct luks_phdr *hdr,
 			   const struct volume_key *vk)
@@ -781,8 +785,10 @@
 		goto out;
 
 	r = LUKS_verify_volume_key(hdr, vk);
-	if (!r)
+	if (!r) {
 		log_verbose(ctx, _("Key slot %d unlocked.\n"), keyIndex);
+		r = keyIndex;	/* cryptmount: return slot-number like LUKS_open_key_with_hdr() */
+	}
 out:
 	crypt_safe_free(AfKey);
 	crypt_free_volume_key(derived_key);
@@ -822,6 +828,8 @@
 	return -EPERM;
 }
 
+#if HAVE_UUID
+
 int LUKS_del_key(const char *device,
 		 unsigned int keyIndex,
 		 struct luks_phdr *hdr,
@@ -862,6 +870,8 @@
 
 	return r;
 }
+
+#endif	/* HAVE_UUID */
 
 crypt_keyslot_info LUKS_keyslot_info(struct luks_phdr *hdr, int keyslot)
 {
--- cryptsetup-1.4.1/lib/libcryptsetup.h 
+++ libcryptsetup.h 
@@ -15,6 +15,13 @@
 #include <stdint.h>
 
 struct crypt_device; /* crypt device handle */
+
+/* cryptmount helper routines: */
+struct luks_phdr;
+struct luks_phdr *crypt_get_lukshdr(struct crypt_device *luks_ctxt);
+void crypt_get_pbkdf2params(struct crypt_device *luks_ctxt,
+			uint64_t **ittime_ptr, uint64_t **persec_ptr);
+
 
 /**
  * Initialize crypt device handle and check if provided device exists.
--- cryptsetup-1.4.1/lib/libdevmapper.c 
+++ libdevmapper.c 
@@ -380,6 +380,8 @@
 	return r;
 }
 
+#if HAVE_UUID
+
 #define UUID_LEN 37 /* 36 + \0, libuuid ... */
 /*
  * UUID has format: CRYPT-<devicetype>-[<uuid>-]<device name>
@@ -412,6 +414,8 @@
 		log_err(NULL, _("DM-UUID for device %s was truncated.\n"), name);
 }
 
+#endif	/* HAVE_UUID */
+
 int dm_create_device(const char *name,
 		     const char *type,
 		     struct crypt_dm_active_device *dmd,
@@ -441,7 +445,9 @@
 		if (!dm_task_set_name(dmt, name))
 			goto out_no_removal;
 	} else {
+#if HAVE_UUID
 		dm_prepare_uuid(name, type, dmd->uuid, dev_uuid, sizeof(dev_uuid));
+#endif
 
 		if (!(dmt = dm_task_create(DM_DEVICE_CREATE)))
 			goto out_no_removal;
@@ -449,8 +455,10 @@
 		if (!dm_task_set_name(dmt, name))
 			goto out_no_removal;
 
+#if HAVE_UUID
 		if (!dm_task_set_uuid(dmt, dev_uuid))
 			goto out_no_removal;
+#endif
 
 		if (_dm_use_udev() && !_dm_task_set_cookie(dmt, &cookie, udev_flags))
 			goto out_no_removal;
--- cryptsetup-1.4.1/lib/luks1/luks.h 
+++ luks.h 
@@ -10,12 +10,12 @@
 #define LUKS_CIPHERNAME_L 32
 #define LUKS_CIPHERMODE_L 32
 #define LUKS_HASHSPEC_L 32
-#define LUKS_DIGESTSIZE 20 // since SHA1
+#define LUKS_DIGESTSIZE 20 /* since SHA1 */
 #define LUKS_HMACSIZE 32
 #define LUKS_SALTSIZE 32
 #define LUKS_NUMKEYS 8
 
-// Minimal number of iterations
+/* Minimal number of iterations */
 #define LUKS_MKD_ITERATIONS_MIN  1000
 #define LUKS_SLOT_ITERATIONS_MIN 1000
 
@@ -27,7 +27,7 @@
 
 #define LUKS_STRIPES 4000
 
-// partition header starts with magic
+/* partition header starts with magic */
 #define LUKS_MAGIC {'L','U','K','S', 0xba, 0xbe};
 #define LUKS_MAGIC_L 6
 
--- cryptsetup-1.4.1/lib/setup.c 
+++ setup.c 
@@ -76,6 +76,21 @@
 	/* last error message */
 	char error[MAX_ERROR_LENGTH];
 };
+
+
+/* cryptmount helper routines: */
+struct luks_phdr *crypt_get_lukshdr(struct crypt_device *luks_ctxt)
+{
+	return &luks_ctxt->hdr;
+}
+
+void crypt_get_pbkdf2params(struct crypt_device *luks_ctxt,
+			uint64_t **ittime_ptr, uint64_t **persec_ptr)
+{
+	*ittime_ptr = &luks_ctxt->iteration_time;
+	*persec_ptr = &luks_ctxt->PBKDF2_per_sec;
+}
+
 
 /* Global error */
 /* FIXME: not thread safe, remove this later */
@@ -739,6 +754,8 @@
 	return crypt_init_by_name_and_header(cd, name, NULL);
 }
 
+#if HAVE_UUID
+
 static int _crypt_format_plain(struct crypt_device *cd,
 			       const char *cipher,
 			       const char *cipher_mode,
@@ -927,6 +944,8 @@
 	return r;
 }
 
+#endif	/* HAVE_UUID */
+
 int crypt_load(struct crypt_device *cd,
 	       const char *requested_type,
 	       void *params __attribute__((unused)))
@@ -1250,6 +1269,8 @@
 	crypt_free_volume_key(vk);
 	return r < 0 ? r : keyslot;
 }
+
+#if HAVE_UUID
 
 // slot manipulation
 int crypt_keyslot_add_by_passphrase(struct crypt_device *cd,
@@ -1475,6 +1496,8 @@
 
 	return LUKS_del_key(mdata_device(cd), keyslot, &cd->hdr, cd);
 }
+
+#endif	/* HAVE_UUID */
 
 // activation/deactivation of device mapping
 int crypt_activate_by_passphrase(struct crypt_device *cd,
--- cryptsetup-1.4.1/lib/utils_crypt.c 
+++ utils_crypt.c 
@@ -29,8 +29,8 @@
 #include <fcntl.h>
 #include <termios.h>
 
+#include "internal.h"
 #include "libcryptsetup.h"
-#include "nls.h"
 #include "utils_crypt.h"
 
 #define log_dbg(x) crypt_log(NULL, CRYPT_LOG_DEBUG, x)
