2 genauth.c -- generate a random passphrase
3 Copyright (C) 1998,99 Ivo Timmermans <zarq@iname.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 unsigned char initvec[] = { 0x22, 0x7b, 0xad, 0x55, 0x41, 0xf4, 0x3e, 0xf3 };
32 int main(int argc, char **argv)
35 int bits, c, i, bytes;
38 if(argc > 2 || (argc == 2 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))))
40 fprintf(stderr, "Usage: %s bits\n", argv[0]);
47 if(!(bits = atol(argv[1])))
49 fprintf(stderr, "Illegal number: %s\n", argv[1]);
53 bits = ((bits - 1) | 63) + 1;
54 fprintf(stderr, "Generating %d bits number", bits);
57 if((fp = fopen("/dev/urandom", "r")) == NULL)
59 perror("Opening /dev/urandom");
66 for(i = 0; i < bytes; i++)
72 fprintf(stderr, "File was empty!\n");
80 fprintf(stderr, ": done.\nThe following line should be ENTIRELY copied into a passphrase file:\n");
82 for(i = 0; i < bytes; i++)
89 for(i = 0; i < bytes; i++)
92 fprintf(stderr, ": done.\n");