31807d
diff -up ./src/aide.c.orig ./aide-0.16b1/src/aide.c
31807d
--- ./src/aide.c.orig	2016-07-12 11:10:08.013158385 +0200
31807d
+++ ./src/aide.c	2016-07-12 11:30:54.867833064 +0200
31807d
@@ -511,9 +511,28 @@ int main(int argc,char**argv)
31807d
 #endif
31807d
   umask(0177);
31807d
   init_sighandler();
31807d
-
31807d
   setdefaults_before_config();
31807d
 
31807d
+#if WITH_GCRYPT
31807d
+  error(255,"Gcrypt library initialization\n");
31807d
+  /*
31807d
+   *  Initialize libgcrypt as per
31807d
+   *  http://www.gnupg.org/documentation/manuals/gcrypt/Initializing-the-library.html
31807d
+   *
31807d
+   *
31807d
+   */
31807d
+  gcry_control(GCRYCTL_SET_ENFORCED_FIPS_FLAG, 0);
31807d
+  gcry_control(GCRYCTL_INIT_SECMEM, 1);
31807d
+
31807d
+  if(!gcry_check_version(GCRYPT_VERSION)) {
31807d
+      error(0,"libgcrypt version mismatch\n");
31807d
+      exit(VERSION_MISMATCH_ERROR);
31807d
+  }
31807d
+
31807d
+  gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
31807d
+#endif /* WITH_GCRYPT */
31807d
+
31807d
+
31807d
   if(read_param(argc,argv)==RETFAIL){
31807d
     error(0, _("Invalid argument\n") );
31807d
     exit(INVALID_ARGUMENT_ERROR);
31807d
@@ -646,6 +665,9 @@ int main(int argc,char**argv)
31807d
     }
31807d
 #endif
31807d
   }
31807d
+#ifdef WITH_GCRYPT
31807d
+  gcry_control(GCRYCTL_TERM_SECMEM, 0);
31807d
+#endif /* WITH_GCRYPT */
31807d
   return RETOK;
31807d
 }
31807d
 const char* aide_key_3=CONFHMACKEY_03;
31807d
diff -up ./src/md.c.orig ./aide-0.16b1/src/md.c
31807d
--- ./src/md.c.orig	2016-04-15 23:30:16.000000000 +0200
31807d
+++ ./src/md.c	2016-07-12 11:35:04.007675329 +0200
31807d
@@ -201,14 +201,7 @@ int init_md(struct md_container* md) {
31807d
   }
31807d
 #endif 
31807d
 #ifdef WITH_GCRYPT
31807d
-  error(255,"Gcrypt library initialization\n");
31807d
-  	if(!gcry_check_version(GCRYPT_VERSION)) {
31807d
-		error(0,"libgcrypt version mismatch\n");
31807d
-		exit(VERSION_MISMATCH_ERROR);
31807d
-	}
31807d
-	gcry_control(GCRYCTL_DISABLE_SECMEM, 0);
31807d
-	gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
31807d
-	if(gcry_md_open(&md->mdh,0,0)!=GPG_ERR_NO_ERROR){
31807d
+        if(gcry_md_open(&md->mdh,0,GCRY_MD_FLAG_SECURE)!=GPG_ERR_NO_ERROR){
31807d
 		error(0,"gcrypt_md_open failed\n");
31807d
 		exit(IO_ERROR);
31807d
 	}
31807d
@@ -299,7 +292,7 @@ int close_md(struct md_container* md) {
31807d
   
31807d
   /*.    There might be more hashes in the library. Add those here..   */
31807d
   
31807d
-  gcry_md_reset(md->mdh);
31807d
+  gcry_md_close(md->mdh);
31807d
 #endif  
31807d
 
31807d
 #ifdef WITH_MHASH
31807d
diff -up ./src/util.c.orig ./aide-0.16b1/src/util.c
31807d
--- ./src/util.c.orig	2016-07-12 11:39:17.023437355 +0200
31807d
+++ ./src/util.c	2016-07-12 11:39:51.618721157 +0200
31807d
@@ -519,28 +519,5 @@ int syslog_facility_lookup(char *s)
31807d
 	return(AIDE_SYSLOG_FACILITY);
31807d
 }
31807d
 
31807d
-/* We need these dummy stubs to fool the linker into believing that
31807d
-   we do not need them at link time */
31807d
-
31807d
-void* dlopen(char*filename,int flag)
31807d
-{
31807d
-  return NULL;
31807d
-}
31807d
-
31807d
-void* dlsym(void*handle,char*symbol)
31807d
-{
31807d
-  return NULL;
31807d
-}
31807d
-
31807d
-void* dlclose(void*handle)
31807d
-{
31807d
-  return NULL;
31807d
-}
31807d
-
31807d
-const char* dlerror(void)
31807d
-{
31807d
-  return NULL;
31807d
-}
31807d
-
31807d
 const char* aide_key_2=CONFHMACKEY_02;
31807d
 const char* db_key_2=DBHMACKEY_02;