From: srittau Date: Sat, 14 Jun 2003 16:40:54 +0000 (+0000) Subject: Fixed error that I introduced into Burkhard's patch. Pointed out by X-Git-Tag: HEAD-before-afp3-merge~32 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=commitdiff_plain;h=44d08ebe8e6100697955a15409d81b7bbb4b1e04 Fixed error that I introduced into Burkhard's patch. Pointed out by Burkhard. --- diff --git a/etc/uams/uams_dhx_passwd.c b/etc/uams/uams_dhx_passwd.c index 51feca18..6442cf59 100644 --- a/etc/uams/uams_dhx_passwd.c +++ b/etc/uams/uams_dhx_passwd.c @@ -1,5 +1,5 @@ /* - * $Id: uams_dhx_passwd.c,v 1.21 2003-06-11 22:07:56 srittau Exp $ + * $Id: uams_dhx_passwd.c,v 1.22 2003-06-14 16:40:54 srittau Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * Copyright (c) 1999 Adrian Sun (asun@u.washington.edu) @@ -28,18 +28,6 @@ #include #endif /* SHADOWPW */ -#if defined(GNUTLS_DHX) -#include -#elif defined(OPENSSL_DHX) -#include -#include -#include -#else /* OPENSSL_DHX */ -#include -#include -#include -#endif /* OPENSSL_DHX */ - #include #include @@ -53,7 +41,6 @@ (unsigned long) (a)) & 0xffff) /* the secret key */ -static CAST_KEY castkey; static struct passwd *dhxpwd; static u_int8_t randbuf[16]; @@ -64,6 +51,8 @@ static u_int8_t randbuf[16]; static char *clientname; #endif /* TRU64 */ +#include "crypt.h" + /* dhx passwd */ static int pwd_login(void *obj, char *username, int ulen, struct passwd **uam_pwd, char *ibuf, int ibuflen, @@ -76,20 +65,19 @@ static int pwd_login(void *obj, char *username, int ulen, struct passwd **uam_pw #ifdef SHADOWPW struct spwd *sp; #endif /* SHADOWPW */ - BIGNUM *bn, *gbn, *pbn; + CastKey castkey; u_int16_t sessid; int i; #if 0 char *name; #endif - DH *dh; -#ifdef TRU64 +#if defined(TRU64) && !defined(HAVE_GCRYPT) int rnd_seed[256]; - for (i = 0; i < sizeof(rnd_seed); i++) - rnd_seed[i] = random(); - RAND_seed(rnd_seed, sizeof rnd_seed); -#endif /* TRU64 */ + for (i = 0; i < 256; i++) + rnd_seed[i] = random(); + RAND_seed(rnd_seed, sizeof(rnd_seed)); +#endif /* defined(TRU64) && !defined(HAVE_GCRYPT) */ *rbuflen = 0; @@ -118,44 +106,10 @@ static int pwd_login(void *obj, char *username, int ulen, struct passwd **uam_pw if (!dhxpwd->pw_passwd) return AFPERR_NOTAUTH; - /* get the client's public key */ - if (!(bn = BN_bin2bn(ibuf, KEYSIZE, NULL))) { - return AFPERR_PARAM; - } - - /* get our primes */ - if (!(gbn = BN_bin2bn(&g, sizeof(g), NULL))) { - BN_free(bn); + castkey = atalk_cast_key(ibuf, KEYSIZE); + if (!castkey) return AFPERR_PARAM; - } - if (!(pbn = BN_bin2bn(p, sizeof(p), NULL))) { - BN_free(gbn); - BN_free(bn); - return AFPERR_PARAM; - } - - /* okay, we're ready */ - if (!(dh = DH_new())) { - BN_free(pbn); - BN_free(gbn); - BN_free(bn); - return AFPERR_PARAM; - } - - /* generate key and make sure we have enough space */ - dh->p = pbn; - dh->g = gbn; - if (!DH_generate_key(dh) || (BN_num_bytes(dh->pub_key) > KEYSIZE)) { - goto passwd_fail; - } - - /* figure out the key. use rbuf as a temporary buffer. */ - i = DH_compute_key(rbuf, bn, dh); - - /* set the key */ - CAST_set_key(&castkey, i, rbuf); - /* session id. it's just a hashed version of the object pointer. */ sessid = dhxhash(obj); memcpy(rbuf, &sessid, sizeof(sessid));