Blame SOURCES/libgcrypt-1.8.5-use-fipscheck.patch

150a03
diff -up libgcrypt-1.8.5/src/fips.c.use-fipscheck libgcrypt-1.8.5/src/fips.c
150a03
--- libgcrypt-1.8.5/src/fips.c.use-fipscheck	2017-11-23 19:16:58.000000000 +0100
150a03
+++ libgcrypt-1.8.5/src/fips.c	2020-04-23 10:18:36.235764741 +0200
150a03
@@ -581,23 +581,50 @@ run_random_selftests (void)
9fde57
   return !!err;
9fde57
 }
9fde57
 
9fde57
+#ifdef ENABLE_HMAC_BINARY_CHECK
9fde57
+static int
9fde57
+get_library_path(const char *libname, const char *symbolname, char *path, size_t pathlen)
9fde57
+{
9fde57
+    Dl_info info;
9fde57
+    void *dl, *sym;
9fde57
+    int rv = -1;
9fde57
+
9fde57
+        dl = dlopen(libname, RTLD_LAZY);
9fde57
+        if (dl == NULL) {
9fde57
+            return -1;
9fde57
+        }       
9fde57
+
9fde57
+    sym = dlsym(dl, symbolname);
9fde57
+
9fde57
+    if (sym != NULL && dladdr(sym, &info)) {
9fde57
+	strncpy(path, info.dli_fname, pathlen-1);
9fde57
+	path[pathlen-1] = '\0';
9fde57
+	rv = 0;
9fde57
+    }
9fde57
+
9fde57
+    dlclose(dl);	
9fde57
+    
9fde57
+    return rv;
9fde57
+}
9fde57
+#endif
9fde57
+
9fde57
 /* Run an integrity check on the binary.  Returns 0 on success.  */
9fde57
 static int
9fde57
 check_binary_integrity (void)
9fde57
 {
9fde57
 #ifdef ENABLE_HMAC_BINARY_CHECK
9fde57
   gpg_error_t err;
9fde57
-  Dl_info info;
9fde57
+  char libpath[4096];
9fde57
   unsigned char digest[32];
9fde57
   int dlen;
9fde57
   char *fname = NULL;
9fde57
-  const char key[] = "What am I, a doctor or a moonshuttle conductor?";
9fde57
-
9fde57
-  if (!dladdr ("gcry_check_version", &info))
9fde57
+  const char key[] = "orboDeJITITejsirpADONivirpUkvarP";
9fde57
+  
9fde57
+  if (get_library_path ("libgcrypt.so.20", "gcry_check_version", libpath, sizeof(libpath)))
9fde57
     err = gpg_error_from_syserror ();
9fde57
   else
9fde57
     {
9fde57
-      dlen = _gcry_hmac256_file (digest, sizeof digest, info.dli_fname,
9fde57
+      dlen = _gcry_hmac256_file (digest, sizeof digest, libpath,
9fde57
                                  key, strlen (key));
9fde57
       if (dlen < 0)
9fde57
         err = gpg_error_from_syserror ();
150a03
@@ -605,7 +632,7 @@ check_binary_integrity (void)
9fde57
         err = gpg_error (GPG_ERR_INTERNAL);
9fde57
       else
9fde57
         {
9fde57
-          fname = xtrymalloc (strlen (info.dli_fname) + 1 + 5 + 1 );
9fde57
+          fname = xtrymalloc (strlen (libpath) + 1 + 5 + 1 );
9fde57
           if (!fname)
9fde57
             err = gpg_error_from_syserror ();
9fde57
           else
150a03
@@ -614,7 +641,7 @@ check_binary_integrity (void)
9fde57
               char *p;
9fde57
 
9fde57
               /* Prefix the basename with a dot.  */
9fde57
-              strcpy (fname, info.dli_fname);
9fde57
+              strcpy (fname, libpath);
9fde57
               p = strrchr (fname, '/');
9fde57
               if (p)
9fde57
                 p++;
150a03
diff -up libgcrypt-1.8.5/src/Makefile.am.use-fipscheck libgcrypt-1.8.5/src/Makefile.am
150a03
--- libgcrypt-1.8.5/src/Makefile.am.use-fipscheck	2020-04-23 10:18:36.237764702 +0200
150a03
+++ libgcrypt-1.8.5/src/Makefile.am	2020-04-23 10:19:03.186247455 +0200
150a03
@@ -125,7 +125,7 @@ libgcrypt_la_LIBADD = $(gcrypt_res) \
9fde57
 	../cipher/libcipher.la \
9fde57
 	../random/librandom.la \
9fde57
 	../mpi/libmpi.la \
9fde57
-	../compat/libcompat.la  $(GPG_ERROR_LIBS)
9fde57
+	../compat/libcompat.la  $(GPG_ERROR_LIBS) -ldl
9fde57
 
150a03
 
9fde57
 dumpsexp_SOURCES = dumpsexp.c