Author: bh
Date: 2007-07-02 21:50:58 +0200 (Mon, 02 Jul 2007)
New Revision: 247
Modified:
trunk/openvas-server/ChangeLog
trunk/openvas-server/openvasd/plugs_hash.c
trunk/openvas-server/openvasd/users.c
Log:
* openvasd/users.c remove includes of openssl headers.
(check_user): Use libgcrypt to compute md5 sums.
* openvasd/plugs_hash.c (md5sum_hex): New function to convert a
binary md5 sum to hexadecimal.
(file_hash, dir_plugins_hash, plugins_hash): Use libgcrypt to
compute md5 sums.
Modified: trunk/openvas-server/ChangeLog
===================================================================
--- trunk/openvas-server/ChangeLog 2007-07-02 18:45:54 UTC (rev 246)
+++ trunk/openvas-server/ChangeLog 2007-07-02 19:50:58 UTC (rev 247)
@@ -1,5 +1,15 @@
2007-07-02 Bernhard Herzog <[EMAIL PROTECTED]>
+ * openvasd/users.c remove includes of openssl headers.
+ (check_user): Use libgcrypt to compute md5 sums.
+
+ * openvasd/plugs_hash.c (md5sum_hex): New function to convert a
+ binary md5 sum to hexadecimal.
+ (file_hash, dir_plugins_hash, plugins_hash): Use libgcrypt to
+ compute md5 sums.
+
+2007-07-02 Bernhard Herzog <[EMAIL PROTECTED]>
+
* openvasd/openvasd.c: Use the libopenvas ssl abstraction instead
of openssl. As a consequence the ssl_cipher_list config option is
no longer supported.
Modified: trunk/openvas-server/openvasd/plugs_hash.c
===================================================================
--- trunk/openvas-server/openvasd/plugs_hash.c 2007-07-02 18:45:54 UTC (rev
246)
+++ trunk/openvas-server/openvasd/plugs_hash.c 2007-07-02 19:50:58 UTC (rev
247)
@@ -29,11 +29,29 @@
#include <includes.h>
-#include "./md5.h"
+#include <gcrypt.h>
#include "users.h"
#include "log.h"
+/*
+ * Creates an emalloc'ed string with a hexadecimal representation of the
+ * binary md5sum md.
+ */
char *
+md5sum_hex(const unsigned char* md)
+{
+ char * ret = emalloc(33);
+ int i;
+
+ for (i = 0; i < 16; i++)
+ {
+ snprintf(ret + i * 2, 3, "%02x", md[i]);
+ }
+
+ return ret;
+}
+
+char *
file_hash(fname)
char * fname;
{
@@ -51,12 +69,14 @@
content = mmap(NULL,len, PROT_READ, MAP_SHARED,fd, 0);
if(content &&
(content != MAP_FAILED))
- {
- char * ret = md5sum(content, len);
+ {
+ char digest[16];
+ gcry_md_hash_buffer(GCRY_MD_MD5, digest, content, len);
+ char * ret = md5sum_hex(digest);
munmap(content, len);
close(fd);
return ret;
- }
+ }
return NULL;
}
@@ -65,9 +85,7 @@
* Returns a hash of each plugin hash
*/
static void
-dir_plugins_hash(ctx, dirname)
- md5_ctx * ctx;
- char * dirname;
+dir_plugins_hash(gcry_md_hd_t ctx, char * dirname)
{
DIR * dir;
struct dirent * dp;
@@ -106,7 +124,7 @@
tmp = file_hash(fullname);
if(tmp != NULL)
{
- md5update(ctx, tmp, strlen(tmp));
+ gcry_md_write(ctx, tmp, strlen(tmp));
efree(&tmp);
}
}
@@ -125,10 +143,12 @@
struct arglist * preferences = arg_get_value(globals,"preferences");
char *dir = arg_get_value(preferences, "plugins_folder");
char *uhome;
- md5_ctx * ctx;
+ gcry_md_hd_t ctx;
+ char * digest;
char * ret;
- ctx = md5init();
+ gcry_md_open(&ctx, GCRY_MD_MD5, 0);
+ /* FIXME: check for error return from gcry_md_open */
dir_plugins_hash(ctx, dir);
uhome = user_home(globals);
dir = emalloc(strlen(uhome) + strlen("/plugins") + 1);
@@ -136,8 +156,9 @@
efree(&uhome);
dir_plugins_hash(ctx, dir);
efree(&dir);
- ret = md5final(ctx);
- md5free(ctx);
+ digest = gcry_md_read(ctx, GCRY_MD_MD5);
+ ret = md5sum_hex(digest);
+ gcry_md_close(ctx);
return ret;
}
Modified: trunk/openvas-server/openvasd/users.c
===================================================================
--- trunk/openvas-server/openvasd/users.c 2007-07-02 18:45:54 UTC (rev
246)
+++ trunk/openvas-server/openvasd/users.c 2007-07-02 19:50:58 UTC (rev
247)
@@ -29,13 +29,10 @@
#include <includes.h>
+#include <gcrypt.h>
#include "log.h"
#include "users.h"
#include "rules.h"
-#include "md5.h"
-#ifdef HAVE_SSL
-#include <openssl/md5.h>
-#endif
char *
user_home(globals)
@@ -259,7 +256,7 @@
strncpy(p, password, n);
- MD5((unsigned char*)seed, strlen(seed), (unsigned char*)h2);
+ gcry_md_hash_buffer(GCRY_MD_MD5, h2, seed, strlen(seed));
if (memcmp(h1, h2, MD5_DIGEST_LENGTH) != 0)
{
return BAD_LOGIN_ATTEMPT;
_______________________________________________
Openvas-commits mailing list
[email protected]
http://lists.wald.intevation.org/mailman/listinfo/openvas-commits