[comp.lang.c] encrypt

marker@agnes.acc.stolaf.edu (bergen) (07/26/90)

	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@dagon.acc.stolaf.edu markerj@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."