125 |
Shishi_key * enckey; |
Shishi_key * enckey; |
126 |
shishi_ivector iv1, iv2, iv3, iv4; |
shishi_ivector iv1, iv2, iv3, iv4; |
127 |
shishi_ivector *ivtab[4]; |
shishi_ivector *ivtab[4]; |
128 |
|
int protocol; |
129 |
#endif |
#endif |
130 |
# define VERSION_SIZE 9 |
# define VERSION_SIZE 9 |
131 |
# define SECURE_MESSAGE "This rsh session is using DES encryption for all transmissions.\r\n" |
# define SECURE_MESSAGE "This rsh session is using DES encryption for all transmissions.\r\n" |
308 |
int pv1[2], pv2[2]; |
int pv1[2], pv2[2]; |
309 |
fd_set wready, writeto; |
fd_set wready, writeto; |
310 |
int keytype, keylen; |
int keytype, keylen; |
|
int proto; |
|
|
|
|
311 |
#endif |
#endif |
312 |
|
|
313 |
signal(SIGINT, SIG_DFL); |
signal(SIGINT, SIG_DFL); |
567 |
int rc; |
int rc; |
568 |
char * err_msg = NULL; |
char * err_msg = NULL; |
569 |
|
|
570 |
rc = get_auth (STDIN_FILENO, &h, &enckey, &err_msg, &proto); |
rc = get_auth (STDIN_FILENO, &h, &enckey, &err_msg, &protocol); |
571 |
if (rc != SHISHI_OK) |
if (rc != SHISHI_OK) |
572 |
{ |
{ |
573 |
error ("Kerberos authentication failure: %s\n", err_msg); |
error ("Kerberos authentication failure: %s\n", err_msg); |
618 |
ivtab[i]->keyusage = SHISHI_KEYUSAGE_KCMD_DES; |
ivtab[i]->keyusage = SHISHI_KEYUSAGE_KCMD_DES; |
619 |
ivtab[i]->iv = malloc (ivtab[i]->ivlen); |
ivtab[i]->iv = malloc (ivtab[i]->ivlen); |
620 |
memset (ivtab[i]->iv, 2*i -3*(i>=2), ivtab[i]->ivlen); |
memset (ivtab[i]->iv, 2*i -3*(i>=2), ivtab[i]->ivlen); |
621 |
|
ivtab[i]->ctx = shishi_crypto (h, enckey, ivtab[i]->keyusage, shishi_key_type (enckey), |
622 |
|
ivtab[i]->iv, ivtab[i]->ivlen); |
623 |
|
break; |
624 |
|
case SHISHI_ARCFOUR_HMAC: |
625 |
|
case SHISHI_ARCFOUR_HMAC_EXP: |
626 |
|
ivtab[i]->keyusage = SHISHI_KEYUSAGE_KCMD_DES + 4*(i<2) + 2 + 2*(i%2); |
627 |
|
ivtab[i]->ctx = shishi_crypto (h, enckey, ivtab[i]->keyusage, shishi_key_type (enckey), |
628 |
|
NULL, 0); |
629 |
break; |
break; |
630 |
default : |
default : |
631 |
ivtab[i]->keyusage = SHISHI_KEYUSAGE_KCMD_DES + 4*(i<2) + 2 + 2*(i%2); |
ivtab[i]->keyusage = SHISHI_KEYUSAGE_KCMD_DES + 4*(i<2) + 2 + 2*(i%2); |
632 |
ivtab[i]->iv = malloc (ivtab[i]->ivlen); |
ivtab[i]->iv = malloc (ivtab[i]->ivlen); |
633 |
memset (ivtab[i]->iv, 0, ivtab[i]->ivlen); |
memset (ivtab[i]->iv, 0, ivtab[i]->ivlen); |
634 |
|
if (protocol == 2) |
635 |
|
ivtab[i]->ctx = shishi_crypto (h, enckey, ivtab[i]->keyusage, shishi_key_type (enckey), |
636 |
|
ivtab[i]->iv, ivtab[i]->ivlen); |
637 |
} |
} |
638 |
} |
} |
639 |
|
|
863 |
else |
else |
864 |
#elif defined(SHISHI) |
#elif defined(SHISHI) |
865 |
if (doencrypt) |
if (doencrypt) |
866 |
readenc (h, s, &sig, &ret, &iv2, enckey, proto); |
readenc (h, s, &sig, &ret, &iv2, enckey, protocol); |
867 |
else |
else |
868 |
#endif |
#endif |
869 |
#endif |
#endif |
891 |
else |
else |
892 |
#elif defined(SHISHI) |
#elif defined(SHISHI) |
893 |
if (doencrypt) |
if (doencrypt) |
894 |
writeenc (h, s, buf, cc, &n, &iv4, enckey, proto); |
writeenc (h, s, buf, cc, &n, &iv4, enckey, protocol); |
895 |
else |
else |
896 |
#endif |
#endif |
897 |
#endif |
#endif |
911 |
} |
} |
912 |
else |
else |
913 |
#ifdef SHISHI |
#ifdef SHISHI |
914 |
writeenc (h, STDOUT_FILENO, buf, cc, &n, &iv3, enckey, proto); |
writeenc (h, STDOUT_FILENO, buf, cc, &n, &iv3, enckey, protocol); |
915 |
#else |
#else |
916 |
des_write (STDOUT_FILENO, buf, cc); |
des_write (STDOUT_FILENO, buf, cc); |
917 |
#endif |
#endif |
921 |
{ |
{ |
922 |
errno = 0; |
errno = 0; |
923 |
#ifdef SHISHI |
#ifdef SHISHI |
924 |
readenc (h, STDIN_FILENO, buf, &cc, &iv1, enckey, proto); |
readenc (h, STDIN_FILENO, buf, &cc, &iv1, enckey, protocol); |
925 |
#else |
#else |
926 |
cc = des_read (STDIN_FILENO, buf, sizeof buf); |
cc = des_read (STDIN_FILENO, buf, sizeof buf); |
927 |
#endif |
#endif |
970 |
} |
} |
971 |
#endif |
#endif |
972 |
#endif |
#endif |
973 |
|
|
974 |
|
#if defined(SHISHI) |
975 |
|
if (use_kerberos) |
976 |
|
{ |
977 |
|
int i; |
978 |
|
|
979 |
|
shishi_done (h); |
980 |
|
#ifdef ENCRYPTION |
981 |
|
if (doencrypt) |
982 |
|
{ |
983 |
|
shishi_key_done (enckey); |
984 |
|
for (i = 0; i < 4; i++) |
985 |
|
{ |
986 |
|
shishi_crypto_close (ivtab[i]->ctx); |
987 |
|
free (ivtab[i]->iv); |
988 |
|
} |
989 |
|
} |
990 |
|
#endif |
991 |
|
} |
992 |
|
|
993 |
|
#endif |
994 |
|
|
995 |
dup2 (pv[1], STDERR_FILENO); /* stderr of shell has to go |
dup2 (pv[1], STDERR_FILENO); /* stderr of shell has to go |
996 |
pipe to control process */ |
pipe to control process */ |
997 |
close (pv[1]); |
close (pv[1]); |