Added support for afs_string_to_key.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@666 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
1996-08-22 19:02:56 +00:00
parent 33ae7e3466
commit b178376810

View File

@@ -2,6 +2,8 @@
#include <config.h>
#endif
RCSID("$Id$");
#include "ftp_locl.h"
#include <krb.h>
@@ -11,10 +13,11 @@ void kauth(int argc, char **argv)
char buf[1024];
des_cblock key;
des_key_schedule schedule;
KTEXT_ST tkt;
KTEXT_ST tkt, tktcopy;
char *name;
char *p;
int overbose;
char passwd[100];
if(argc > 2){
printf("usage: %s [principal]\n", argv[0]);
@@ -48,6 +51,7 @@ void kauth(int argc, char **argv)
code = -1;
return;
}
tktcopy.length = tkt.length;
p = strstr(reply_string, "P=");
if(!p){
@@ -59,17 +63,28 @@ void kauth(int argc, char **argv)
for(; *p && *p != ' ' && *p != '\r' && *p != '\n'; p++);
*p = 0;
sprintf(buf, "Password for %s:", name);
des_read_password(&key, buf, 0);
if (des_read_pw_string (passwd, sizeof(passwd)-1, buf, 0))
*passwd = '\0';
des_string_to_key (passwd, &key);
des_key_sched(&key, schedule);
des_pcbc_encrypt((des_cblock*)tkt.dat, (des_cblock*)tkt.dat, tkt.length,
des_pcbc_encrypt((des_cblock*)tkt.dat, (des_cblock*)tktcopy.dat,
tkt.length,
schedule, &key, DES_DECRYPT);
if (strcmp (tktcopy.dat + 8, "krbtgt") != 0) {
afs_string_to_key (passwd, krb_realmofhost(hostname), &key);
des_key_sched (&key, schedule);
des_pcbc_encrypt((des_cblock*)tkt.dat, (des_cblock*)tktcopy.dat,
tkt.length,
schedule, &key, DES_DECRYPT);
}
memset(key, 0, sizeof(key));
memset(schedule, 0, sizeof(schedule));
base64_encode(tkt.dat, tkt.length, &p);
memset(passwd, 0, sizeof(passwd));
base64_encode(tktcopy.dat, tktcopy.length, &p);
memset (tktcopy.dat, 0, tktcopy.length);
ret = command("SITE KAUTH %s %s", name, p);
free(p);
if(ret != COMPLETE){