040c39
diff -up libgcrypt-1.6.2/src/fips.c.use-fipscheck libgcrypt-1.6.2/src/fips.c
040c39
--- libgcrypt-1.6.2/src/fips.c.use-fipscheck	2014-08-21 14:50:39.000000000 +0200
040c39
+++ libgcrypt-1.6.2/src/fips.c	2014-09-26 11:42:20.999588282 +0200
040c39
@@ -578,23 +578,48 @@ run_random_selftests (void)
4b8542
   return !!err;
4b8542
 }
4b8542
 
4b8542
+static int
4b8542
+get_library_path(const char *libname, const char *symbolname, char *path, size_t pathlen)
4b8542
+{
4b8542
+    Dl_info info;
4b8542
+    void *dl, *sym;
4b8542
+    int rv = -1;
4b8542
+
4b8542
+        dl = dlopen(libname, RTLD_LAZY);
4b8542
+        if (dl == NULL) {
4b8542
+            return -1;
4b8542
+        }       
4b8542
+
4b8542
+    sym = dlsym(dl, symbolname);
4b8542
+
4b8542
+    if (sym != NULL && dladdr(sym, &info)) {
4b8542
+	strncpy(path, info.dli_fname, pathlen-1);
4b8542
+	path[pathlen-1] = '\0';
4b8542
+	rv = 0;
4b8542
+    }
4b8542
+
4b8542
+    dlclose(dl);	
4b8542
+    
4b8542
+    return rv;
4b8542
+}
4b8542
+
4b8542
 /* Run an integrity check on the binary.  Returns 0 on success.  */
4b8542
 static int
4b8542
 check_binary_integrity (void)
4b8542
 {
4b8542
 #ifdef ENABLE_HMAC_BINARY_CHECK
4b8542
   gpg_error_t err;
4b8542
-  Dl_info info;
4b8542
+  char libpath[4096];
4b8542
   unsigned char digest[32];
4b8542
   int dlen;
4b8542
   char *fname = NULL;
4b8542
-  const char key[] = "What am I, a doctor or a moonshuttle conductor?";
b50545
-
4b8542
-  if (!dladdr ("gcry_check_version", &info))
b50545
+  const char key[] = "orboDeJITITejsirpADONivirpUkvarP";
b50545
+  
85a7dd
+  if (get_library_path ("libgcrypt.so.20", "gcry_check_version", libpath, sizeof(libpath)))
4b8542
     err = gpg_error_from_syserror ();
4b8542
   else
4b8542
     {
4b8542
-      dlen = _gcry_hmac256_file (digest, sizeof digest, info.dli_fname,
4b8542
+      dlen = _gcry_hmac256_file (digest, sizeof digest, libpath,
4b8542
                                  key, strlen (key));
4b8542
       if (dlen < 0)
4b8542
         err = gpg_error_from_syserror ();
040c39
@@ -602,7 +627,7 @@ check_binary_integrity (void)
4b8542
         err = gpg_error (GPG_ERR_INTERNAL);
4b8542
       else
4b8542
         {
040c39
-          fname = xtrymalloc (strlen (info.dli_fname) + 1 + 5 + 1 );
040c39
+          fname = xtrymalloc (strlen (libpath) + 1 + 5 + 1 );
4b8542
           if (!fname)
4b8542
             err = gpg_error_from_syserror ();
4b8542
           else
040c39
@@ -611,7 +636,7 @@ check_binary_integrity (void)
4b8542
               char *p;
4b8542
 
4b8542
               /* Prefix the basename with a dot.  */
4b8542
-              strcpy (fname, info.dli_fname);
4b8542
+              strcpy (fname, libpath);
4b8542
               p = strrchr (fname, '/');
4b8542
               if (p)
4b8542
                 p++;
040c39
diff -up libgcrypt-1.6.2/src/Makefile.in.use-fipscheck libgcrypt-1.6.2/src/Makefile.in
040c39
--- libgcrypt-1.6.2/src/Makefile.in.use-fipscheck	2014-08-21 15:14:08.000000000 +0200
040c39
+++ libgcrypt-1.6.2/src/Makefile.in	2014-09-26 11:41:13.271059281 +0200
040c39
@@ -449,7 +449,7 @@ libgcrypt_la_LIBADD = $(gcrypt_res) \
e569e4
 	../cipher/libcipher.la \
e569e4
 	../random/librandom.la \
e569e4
 	../mpi/libmpi.la \
b50545
-	../compat/libcompat.la  $(GPG_ERROR_LIBS)
b50545
+	../compat/libcompat.la  $(GPG_ERROR_LIBS) -ldl
e569e4
 
e569e4
 dumpsexp_SOURCES = dumpsexp.c
b50545
 dumpsexp_CFLAGS = $(arch_gpg_error_cflags)