#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include "qick.h"

static char rcsid[] = "$Id: answer.c,v 2.1 2000/08/18 19:27:33 dgc Exp $";

main()
{
	char	 in[1024], *challenge;
	char	 out[1024];
	char	*p;
	char	 pass[128];

	/* pass = getpass("Password: "); */
	printf("Password: ");
	fflush(stdout);
	fgets(pass, 127, stdin);
	if ((p = strchr(pass, '\n')) != NULL)
		*p = '\0';
	
	printf("challenge: ");
	fgets(in, 1023, stdin);
	if (strncmp(in, "301:", 4) == 0)
		challenge = &in[4];
	else
		challenge = in;

	if ((p = strrchr(challenge, '\r')) != NULL)
		*p = '\0';
	if ((p = strrchr(challenge, '\n')) != NULL)
		*p = '\0';

	qi_crypt(out, 1023, pass, challenge, 0);
	printf ("qiapi:\nanswer %s\n", out);

	p = qi_crypt(NULL, 0, pass, challenge, 0);
	printf ("qick:\nanswer %s\n", S(p));
	fflush(stdout);

	exit(0);
}

