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