support conditional KRB4
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@2219 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -9,9 +9,12 @@ do_read (int fd,
|
||||
int ret;
|
||||
|
||||
if (do_encrypt) {
|
||||
#ifdef KRB4
|
||||
if (auth_method == AUTH_KRB4) {
|
||||
return des_enc_read (fd, buf, sz, schedule, &iv);
|
||||
} else if(auth_method == AUTH_KRB5) {
|
||||
} else
|
||||
#endif /* KRB4 */
|
||||
if(auth_method == AUTH_KRB5) {
|
||||
u_int32_t len, outer_len;
|
||||
int status;
|
||||
krb5_data data;
|
||||
@@ -30,7 +33,7 @@ do_read (int fd,
|
||||
status = krb5_decrypt(context, buf, outer_len,
|
||||
ETYPE_DES_CBC_CRC, /* XXX */
|
||||
keyblock, &data);
|
||||
if (status != KSUCCESS)
|
||||
if (status)
|
||||
errx (1, "%s", krb5_get_err_text (context, status));
|
||||
memcpy (buf, data.data, len);
|
||||
free (data.data);
|
||||
@@ -48,9 +51,12 @@ do_write (int fd, void *buf, size_t sz)
|
||||
int ret;
|
||||
|
||||
if (do_encrypt) {
|
||||
#ifdef KRB4
|
||||
if(auth_method == AUTH_KRB4) {
|
||||
return des_enc_write (fd, buf, sz, schedule, &iv);
|
||||
} else if(auth_method == AUTH_KRB5) {
|
||||
} else
|
||||
#endif /* KRB4 */
|
||||
if(auth_method == AUTH_KRB5) {
|
||||
krb5_error_code status;
|
||||
krb5_data data;
|
||||
u_int32_t len;
|
||||
@@ -62,7 +68,7 @@ do_write (int fd, void *buf, size_t sz)
|
||||
ETYPE_DES_CBC_CRC, /* XXX */
|
||||
keyblock,
|
||||
&data);
|
||||
if (status != KSUCCESS)
|
||||
if (status)
|
||||
errx (1, "%s", krb5_get_err_text(context, status));
|
||||
len = htonl(sz);
|
||||
ret = krb5_net_write (context, fd, &len, 4);
|
||||
@@ -80,3 +86,40 @@ do_write (int fd, void *buf, size_t sz)
|
||||
return write (fd, buf, sz);
|
||||
}
|
||||
|
||||
ssize_t
|
||||
net_write (int fd,
|
||||
const void *buf,
|
||||
size_t len)
|
||||
{
|
||||
char *cbuf = (char *)buf;
|
||||
ssize_t count;
|
||||
size_t rem = len;
|
||||
|
||||
while (rem > 0) {
|
||||
count = write (fd, cbuf, rem);
|
||||
if (count < 0)
|
||||
return count;
|
||||
cbuf += count;
|
||||
rem -= count;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
ssize_t
|
||||
net_read (int fd,
|
||||
void *buf,
|
||||
size_t len)
|
||||
{
|
||||
char *cbuf = (char *)buf;
|
||||
ssize_t count;
|
||||
size_t rem = len;
|
||||
|
||||
while (rem > 0) {
|
||||
count = read (fd, cbuf, rem);
|
||||
if (count <= 0)
|
||||
return count;
|
||||
cbuf += count;
|
||||
rem -= count;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
Reference in New Issue
Block a user