File:  [Research Unix] / researchv10no / cmd / descrypt / setup.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:35 2018 UTC (8 years, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv10, HEAD
researchv10 Norman

/*
 *	Process Arguments to Command and Set Up Key and Permutation
 *	D.P.Mitchell  83/07/01.
 */

#include <stdio.h>
#include "crypt.h"

Block random;
int pflag;

Block
setup(argc, argv)
int argc;
char *argv[];
{
	char tempkey[128];
	Block key;
	char *keystring;
	int i;
	extern Block key_crunch(), recrunch(), rand_block();
	extern char *getpass(), *strcpy();

	if (--argc > 0 && argv[1][0] == '-' && argv[1][1] == 'p')
		pflag = 1;
	else
		argc++;
	if (argc > 2) {
		fprintf(stderr, "Usage: en/decrypt [-p] [key]\n");
		exit(1);
	}
	if (argc == 2)
		keystring = argv[1 + pflag];
	else {
		keystring = getpass("Enter Key: ");
		(void) strcpy(tempkey, keystring);
		keystring = getpass("Enter Key Again: ");
		if (strcmp(keystring, tempkey)) {
			fprintf(stderr, "Key Mistyped\n");
			exit(1);
		}
	}
	random = rand_block();
	key = key_crunch(keystring);
	while (*keystring)
		*keystring++ = '\0';
	/*
	 *	Repeating shuffle and recrunch prevents the recovery of
	 *	the key if the permutation becomes known.
	 */
	for (i = 0; i < 7; i++) {
		shuffle_permutation();
		key = recrunch();
	}
	return key;
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.