146045Sbostic /*-
2*61435Sbostic * Copyright (c) 1990, 1993
3*61435Sbostic * The Regents of the University of California. All rights reserved.
446045Sbostic *
546045Sbostic * %sccs.include.redist.c%
622421Sdist */
722421Sdist
822421Sdist #ifndef lint
9*61435Sbostic static char copyright[] =
10*61435Sbostic "@(#) Copyright (c) 1990, 1993\n\
11*61435Sbostic The Regents of the University of California. All rights reserved.\n";
1246045Sbostic #endif /* not lint */
1322421Sdist
1422421Sdist #ifndef lint
15*61435Sbostic static char sccsid[] = "@(#)makekey.c 8.1 (Berkeley) 06/04/93";
1646045Sbostic #endif /* not lint */
1722421Sdist
1860098Sbostic #include <sys/types.h>
1960098Sbostic
2060098Sbostic #include <err.h>
2146673Sbostic #include <errno.h>
2246673Sbostic #include <stdio.h>
2346045Sbostic #include <stdlib.h>
2446045Sbostic #include <string.h>
2560098Sbostic #include <unistd.h>
261047Sbill
2760098Sbostic static void get __P((char *, int));
2846673Sbostic
2960098Sbostic int
main()301047Sbill main()
311047Sbill {
3246045Sbostic int len;
3346673Sbostic char *r, key[9], salt[3];
341047Sbill
3546045Sbostic get(key, sizeof(key) - 1);
3646045Sbostic get(salt, sizeof(salt) - 1);
3746045Sbostic len = strlen(r = crypt(key, salt));
3846045Sbostic if (write(STDOUT_FILENO, r, len) != len)
3960098Sbostic err(1, "stdout");
4046045Sbostic exit(0);
411047Sbill }
4246045Sbostic
4346673Sbostic static void
get(bp,len)4446045Sbostic get(bp, len)
4546045Sbostic char *bp;
4646045Sbostic register int len;
4746045Sbostic {
4846045Sbostic register int nr;
4946045Sbostic
5046045Sbostic bp[len] = '\0';
5146045Sbostic if ((nr = read(STDIN_FILENO, bp, len)) == len)
5246045Sbostic return;
5346045Sbostic if (nr >= 0)
5446045Sbostic errno = EFTYPE;
5560098Sbostic err(1, "stdin");
5646045Sbostic }
57