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