2 genauth.c -- generate a random passphrase
3 Copyright (C) 1998,1999,2000 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.
32 unsigned char initvec[] = { 0x22, 0x7b, 0xad, 0x55, 0x41, 0xf4, 0x3e, 0xf3 };
34 int main(int argc, char **argv)
37 int bits, c, i, bytes;
40 if(argc > 2 || (argc == 2 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))))
42 fprintf(stderr, _("Usage: %s bits\n"), argv[0]);
49 if(!(bits = atol(argv[1])))
51 fprintf(stderr, _("Illegal number: %s\n"), argv[1]);
55 bits = ((bits - 1) | 63) + 1;
56 fprintf(stderr, _("Generating %d bits number"), bits);
59 if((fp = fopen("/dev/urandom", "r")) == NULL)
61 perror(_("Opening /dev/urandom"));
68 for(i = 0; i < bytes; i++)
74 fprintf(stderr, _("File was empty!\n"));
82 fprintf(stderr, _(": done.\nThe following line should be ENTIRELY copied into a passphrase file:\n"));
84 for(i = 0; i < bytes; i++)
91 for(i = 0; i < bytes; i++)
94 fprintf(stderr, _(": done.\n"));