]> arthur.barton.de Git - netatalk.git/blobdiff - etc/uams/uams_pgp.c
Try using Tracker 0.15 from OpenCSW
[netatalk.git] / etc / uams / uams_pgp.c
index 823b060dbc8bc246211485de37ec6243abb5baa9..6a2994401c493d5cadd33a5f86161904d17f644c 100644 (file)
@@ -1,17 +1,41 @@
-/* Copyright (c) 1990,1993 Regents of The University of Michigan.
+/*
+ *
+ * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * Copyright (c) 1999 Adrian Sun (asun@u.washington.edu) 
  * All Rights Reserved.  See COPYRIGHT.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
 #ifdef UAM_PGP
+
+#include <atalk/standards.h>
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+#ifdef HAVE_CRYPT_H
+#include <crypt.h>
+#endif /* HAVE_CRYPT_H */
 #include <pwd.h>
-#include <syslog.h>
-
+#include <atalk/logger.h>
+
+#if defined(GNUTLS_DHX)
+#include <gnutls/openssl.h>
+#elif defined(OPENSSL_DHX)
+#include <openssl/bn.h>
+#include <openssl/dh.h>
+#include <openssl/cast.h>
+#else /* OPENSSL_DHX */
 #include <bn.h>
+#include <dh.h>
+#include <cast.h>
+#endif /* OPENSSL_DHX */
 
 #include <atalk/afp.h>
 #include <atalk/uam.h>
 
 /* the secret key */
 static struct passwd *pgppwd;
-
+static CAST_KEY castkey;
+static uint8_t randbuf[16];
 
 /* pgp passwd */
 static int pgp_login(void *obj, struct passwd **uam_pwd,
-                    char *ibuf, int ibuflen,
-                    char *rbuf, int *rbuflen)
+                    char *ibuf, size_t ibuflen,
+                    char *rbuf, size_t *rbuflen)
 {
-    BIGNUM *bn, *gbn, *pbn;
-    u_int16_t sessid;
-    int len, i;
+    size_t len, i;
     char *name;
 
     *rbuflen = 0;
@@ -55,11 +78,11 @@ static int pgp_login(void *obj, struct passwd **uam_pwd,
     if ((unsigned long) ibuf & 1) /* padding */
       ++ibuf;
 
-    if (( pgppwd = uam_getname(name, i)) == NULL ) {
+    if (( pgppwd = uam_getname(obj, name, i)) == NULL ) {
       return AFPERR_PARAM;
     }
 
-    syslog( LOG_INFO, "pgp login: %s", name);
+    LOG(log_info, logtype_uams, "pgp login: %s", name);
     if (uam_checkuser(pgppwd) < 0)
       return AFPERR_NOTAUTH;
 
@@ -71,7 +94,7 @@ static int pgp_login(void *obj, struct passwd **uam_pwd,
     if (uam_afpserver_option(obj, UAM_OPTION_SIGNATURE, 
                             (void *) &name, NULL) < 0) {
       *rbuflen = 0;
-      goto passwd_fail;
+      goto pgp_fail;
     }
     memcpy(rbuf + KEYSIZE, name, KEYSIZE); 
 
@@ -80,11 +103,12 @@ pgp_fail:
 }
 
 static int pgp_logincont(void *obj, struct passwd **uam_pwd,
-                        char *ibuf, int ibuflen, 
-                        char *rbuf, int *rbuflen)
+                        char *ibuf, size_t ibuflen, 
+                        char *rbuf, size_t *rbuflen)
 {
+       unsigned char iv[] = "RJscorat";
     BIGNUM *bn1, *bn2, *bn3;
-    u_int16_t sessid;
+    uint16_t sessid;
     char *p;
 
     *rbuflen = 0;
@@ -136,7 +160,7 @@ static int pgp_logincont(void *obj, struct passwd **uam_pwd,
       *uam_pwd = pgppwd;
       return AFP_OK;
     }
-#endif AFS
+#endif /* AFS */
 
     rbuf[PASSWDLEN] = '\0';
     p = crypt( rbuf, pgppwd->pw_passwd );
@@ -169,4 +193,5 @@ UAM_MODULE_EXPORT struct uam_export uams_pgp = {
   UAM_MODULE_VERSION,
   uam_setup, uam_cleanup
 };
-#endif
+
+#endif /* UAM_PGP */