apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mladen Turk" <mt...@mappingsoft.com>
Subject [PATCH] apr_password_validate with LIBEAY des_fcrypt support
Date Sat, 22 Sep 2001 17:47:34 GMT
Hi,

Couple of months ago I've posted a patch that enables WIN32 to deal with
crypt() encrypted passwords.

Here is a patch that uses dso to load a libeay32.dll from openssl an enables
apr to validate a password using des_fcrypt.

It would be much easier to implent that enhancement if apr_password_validate
function will has the apr_pool_t as a parameter.



Index: apr_md5.c
===================================================================
RCS file: /home/cvspublic/apr/passwd/apr_md5.c,v
retrieving revision 1.15
diff -u -r1.15 apr_md5.c
--- apr_md5.c	2001/08/06 15:46:04	1.15
+++ apr_md5.c	2001/09/22 17:29:07
@@ -101,6 +101,7 @@
 #include "apr_strings.h"
 #include "apr_md5.h"
 #include "apr_lib.h"
+#include "apr_dso.h"

 #if APR_HAVE_STRING_H
 #include <string.h>
@@ -669,6 +670,12 @@
     return APR_SUCCESS;
 }

+#if defined(WIN32) || defined(BEOS) || defined(NETWARE)
+typedef char* (*fp_des_fcrypt)(const char *,const char *, char *);
+static int passwd_pool_initialized = 0;
+static apr_pool_t *passwd_apr_pool;
+#define LIBEAY_DSO_NAME "libeay32"
+#endif
 /*
  * Validate a plaintext password against a smashed one.  Use either
  * crypt() (if available) or apr_md5_encode(), depending upon the format
@@ -680,7 +687,10 @@
                                                const char *hash)
 {
     char sample[120];
-#if !defined(WIN32) && !defined(BEOS) && !defined(NETWARE)
+#if defined(WIN32) || defined(BEOS) || defined(NETWARE)
+    static apr_dso_handle_t *libeay;
+    static fp_des_fcrypt des_fcrypt = NULL;
+#else
     char *crypt_pw;
 #endif
     if (!strncmp(hash, apr1_id, strlen(apr1_id))) {
@@ -694,7 +704,20 @@
          * It's not our algorithm, so feed it to crypt() if possible.
          */
 #if defined(WIN32) || defined(BEOS) || defined(NETWARE)
-        apr_cpystrn(sample, passwd, sizeof(sample) - 1);
+        /* It would be better to get the pool from the function call */
+        if (!passwd_pool_initialized) {
+            if (apr_pool_create(&passwd_apr_pool, NULL) != APR_SUCCESS) {
+                return APR_ENOPOOL;
+            }
+            ++passwd_pool_initialized;
+            if (apr_dso_load(&libeay, LIBEAY_DSO_NAME, passwd_apr_pool) ==
APR_SUCCESS)
+                if (apr_dso_sym((void **)&des_fcrypt, libeay, "des_fcrypt")
!= APR_SUCCESS)
+                    des_fcrypt = NULL;
+        }
+        if (des_fcrypt)
+            apr_cpystrn(sample, (des_fcrypt)(passwd, hash, sample),
sizeof(sample) - 1);
+        else
+            apr_cpystrn(sample, passwd, sizeof(sample) - 1);
 #else
         crypt_pw = crypt(passwd, hash);
         apr_cpystrn(sample, crypt_pw, sizeof(sample) - 1);






MT.


Mime
View raw message