encrypt() and socket question

bergen marker at agnes.acc.stolaf.edu
Fri Jul 27 02:34:06 AEST 1990


	I have been trying to pass a string encrypted with encrypt(3)
through an INET socket to be decrypted on the other machine, but have been
unable to do so.  The same key is being used by both the client and the
server, and the decrypted string differs from the original string by only a
few letters.  I have included all the code dealing with this problem.
	
	Will anyone tell me what i am doing wrong?  Thanks.

					Jeff

--------
client.c
--------
    char *pass;
#ifdef SEND_PASS
    char *secpass;
#endif
	.
	.
	.

    pass = malloc(64);
    pass = getpass("Password: ");
	.
	.
	.

#ifdef SEND_PASS
    
    setkey(RPASSKEY);
    encrypt(pass, 0);
    secpass = malloc(strlen(pass));
    strcat(secpass, pass);
    encrypt(secpass, 1);
    printf("%s", secpass);
    printf("%sbun\n", pass);
    strcat(buf, ":");
    strncat(buf, pass, (strlen(pass) -1));
    encrypt(pass, 1);
    printf("%s\n", pass);

#endif



--------
server.c
--------
#ifdef SEND_PASS
    char *rch_secpass;
#endif
	.
	.
	.

#ifdef SEND_PASS	
	char *bung, *block;
	
			block = malloc((strlen(rh->rch_secpass) + 1));
			printf("%sbun\n", rh->rch_secpass);
			strcat(block, rh->rch_secpass);
			setkey(RPASSKEY);
			encrypt(block, 1);
			printf("%s:%s:%s:%s\n", rh->rch_mach,
				block,
				rh->rch_secpass, rh->rch_type);
#endif
---
--
marker@{troilus.math,balder.acc,dagon.acc,agnes.acc,thor.acc}.stolaf.edu
martyr at dagon.acc.stolaf.edu markerj at carleton.edu I appreciate any comments
on anything.  I don't claim to be right, just accurate.  Jeff Marker, Saint
Olaf College, Northfield, Mn, 55057 "Lord, not my will but Yours be done."



More information about the Comp.lang.c mailing list