Blame SOURCES/aide-0.16-crypto-disable-haval-and-others.patch

6ac4f1
diff -up ./include/md.h.crypto ./include/md.h
6ac4f1
--- ./include/md.h.crypto	2016-07-25 22:56:55.000000000 +0200
6ac4f1
+++ ./include/md.h	2018-08-29 15:00:30.827491299 +0200
6ac4f1
@@ -149,6 +149,7 @@ int init_md(struct md_container*);
6ac4f1
 int update_md(struct md_container*,void*,ssize_t);
6ac4f1
 int close_md(struct md_container*);
6ac4f1
 void md2line(struct md_container*,struct db_line*);
6ac4f1
+DB_ATTR_TYPE get_available_crypto();
6ac4f1
 
6ac4f1
 
6ac4f1
 #endif /*_MD_H_INCLUDED*/
6ac4f1
diff -up ./src/aide.c.crypto ./src/aide.c
6ac4f1
--- ./src/aide.c.crypto	2018-08-29 15:00:30.825491309 +0200
6ac4f1
+++ ./src/aide.c	2018-08-29 15:00:30.827491299 +0200
6ac4f1
@@ -349,7 +349,7 @@ static void setdefaults_before_config()
6ac4f1
 
6ac4f1
   conf->db_attrs = 0;
6ac4f1
 #if defined(WITH_MHASH) || defined(WITH_GCRYPT)
6ac4f1
-  conf->db_attrs |= DB_MD5|DB_TIGER|DB_HAVAL|DB_CRC32|DB_SHA1|DB_RMD160|DB_SHA256|DB_SHA512;
6ac4f1
+  conf->db_attrs |= get_available_crypto();
6ac4f1
 #ifdef WITH_MHASH
6ac4f1
   conf->db_attrs |= DB_GOST;
6ac4f1
 #ifdef HAVE_MHASH_WHIRLPOOL
6ac4f1
diff -up ./src/md.c.crypto ./src/md.c
6ac4f1
--- ./src/md.c.crypto	2018-08-29 15:00:30.823491319 +0200
6ac4f1
+++ ./src/md.c	2018-08-29 15:02:28.013903479 +0200
6ac4f1
@@ -78,6 +78,49 @@ DB_ATTR_TYPE hash_gcrypt2attr(int i) {
6ac4f1
   return r;
6ac4f1
 }
6ac4f1
 
6ac4f1
+const char * hash_gcrypt2str(int i) {
6ac4f1
+  char * r = "?";
6ac4f1
+#ifdef WITH_GCRYPT
6ac4f1
+  switch (i) {
6ac4f1
+  case GCRY_MD_MD5: {
6ac4f1
+    r = "MD5";
6ac4f1
+    break;
6ac4f1
+  }
6ac4f1
+  case GCRY_MD_SHA1: {
6ac4f1
+    r = "SHA1";
6ac4f1
+    break;
6ac4f1
+  }
6ac4f1
+  case GCRY_MD_RMD160: {
6ac4f1
+    r = "RMD160";
6ac4f1
+    break;
6ac4f1
+  }
6ac4f1
+  case GCRY_MD_TIGER: {
6ac4f1
+    r = "TIGER";
6ac4f1
+    break;
6ac4f1
+  }
6ac4f1
+  case GCRY_MD_HAVAL: {
6ac4f1
+    r = "HAVAL";
6ac4f1
+    break;
6ac4f1
+  }
6ac4f1
+  case GCRY_MD_SHA256: {
6ac4f1
+    r = "SHA256";
6ac4f1
+    break;
6ac4f1
+  }
6ac4f1
+  case GCRY_MD_SHA512: {
6ac4f1
+    r = "SHA512";
6ac4f1
+    break;
6ac4f1
+  }
6ac4f1
+  case GCRY_MD_CRC32: {
6ac4f1
+    r = "CRC32";
6ac4f1
+    break;
6ac4f1
+  }
6ac4f1
+  default:
6ac4f1
+    break;
6ac4f1
+  }
6ac4f1
+#endif
6ac4f1
+  return r;
6ac4f1
+}
6ac4f1
+
6ac4f1
 DB_ATTR_TYPE hash_mhash2attr(int i) {
6ac4f1
   DB_ATTR_TYPE r=0;
6ac4f1
 #ifdef WITH_MHASH
6ac4f1
@@ -163,6 +206,44 @@ DB_ATTR_TYPE hash_mhash2attr(int i) {
6ac4f1
   Initialise md_container according it's todo_attr field
6ac4f1
  */
6ac4f1
 
6ac4f1
+DB_ATTR_TYPE get_available_crypto() {
6ac4f1
+  
6ac4f1
+  DB_ATTR_TYPE ret = 0;
6ac4f1
+
6ac4f1
+/*
6ac4f1
+ * This function is usually called before config processing
6ac4f1
+ * and default verbose level is 5
6ac4f1
+ */
6ac4f1
+#define lvl 255
6ac4f1
+
6ac4f1
+  error(lvl, "get_available_crypto called\n");
6ac4f1
+
6ac4f1
+#ifdef WITH_GCRYPT
6ac4f1
+
6ac4f1
+  /*
6ac4f1
+ * some initialization for FIPS
6ac4f1
+ */
6ac4f1
+  gcry_check_version(NULL);
6ac4f1
+  error(lvl, "Found algos:");
6ac4f1
+
6ac4f1
+  for(int i=0;i<=HASH_GCRYPT_COUNT;i++) {
6ac4f1
+
6ac4f1
+    if ( (hash_gcrypt2attr(i) & HASH_USE_GCRYPT) == 0 )
6ac4f1
+      continue;
6ac4f1
+  
6ac4f1
+    if (gcry_md_algo_info(i, GCRYCTL_TEST_ALGO, NULL, NULL) == 0) {
6ac4f1
+      ret |= hash_gcrypt2attr(i);
6ac4f1
+      error(lvl, " %s", hash_gcrypt2str(i));
6ac4f1
+    }
6ac4f1
+  }
6ac4f1
+  error(lvl, "\n");
6ac4f1
+
6ac4f1
+#endif
6ac4f1
+
6ac4f1
+  error(lvl, "get_available_crypto_returned with %lld\n", ret);
6ac4f1
+  return ret;
6ac4f1
+}
6ac4f1
+
6ac4f1
 int init_md(struct md_container* md) {
6ac4f1
   
6ac4f1
   int i;
6ac4f1
@@ -201,18 +282,27 @@ int init_md(struct md_container* md) {
6ac4f1
   }
6ac4f1
 #endif 
6ac4f1
 #ifdef WITH_GCRYPT
6ac4f1
-        if(gcry_md_open(&md->mdh,0,GCRY_MD_FLAG_SECURE)!=GPG_ERR_NO_ERROR){
6ac4f1
+  if(gcry_md_open(&md->mdh,0,GCRY_MD_FLAG_SECURE)!=GPG_ERR_NO_ERROR){
6ac4f1
 		error(0,"gcrypt_md_open failed\n");
6ac4f1
 		exit(IO_ERROR);
6ac4f1
 	}
6ac4f1
   for(i=0;i<=HASH_GCRYPT_COUNT;i++) {
6ac4f1
+
6ac4f1
+
6ac4f1
     if (((hash_gcrypt2attr(i)&HASH_USE_GCRYPT)&md->todo_attr)!=0) {
6ac4f1
-      DB_ATTR_TYPE h=hash_gcrypt2attr(i);
6ac4f1
-      error(255,"inserting %llu\n",h);
6ac4f1
+
6ac4f1
+        DB_ATTR_TYPE h=hash_gcrypt2attr(i);
6ac4f1
+
6ac4f1
+        if (gcry_md_algo_info(i, GCRYCTL_TEST_ALGO, NULL, NULL) != 0) {
6ac4f1
+            error(0,"Algo %s is not available\n", hash_gcrypt2str(i));
6ac4f1
+            exit(-1);
6ac4f1
+        }
6ac4f1
+
6ac4f1
+        error(255,"inserting %llu\n",h);
6ac4f1
 			if(gcry_md_enable(md->mdh,i)==GPG_ERR_NO_ERROR){
6ac4f1
 				md->calc_attr|=h;
6ac4f1
 			} else {
6ac4f1
-				error(0,"gcry_md_enable %i failed",i);
6ac4f1
+				error(0,"gcry_md_enable %i failed\n",i);
6ac4f1
 				md->todo_attr&=~h;
6ac4f1
 			}
6ac4f1
 		}