2 genauth.c -- generate public/private keypairs
3 Copyright (C) 1998,1999,2000 Ivo Timmermans <zarq@iname.com>
4 2000 Guus Sliepen <guus@sliepen.warande.net>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 $Id: genauth.c,v 1.7.4.2 2000/10/15 00:59:34 guus Exp $
28 #include <openssl/rsa.h>
34 #define RSA_PUBLIC_EXPONENT 65535
36 void indicator(int a, int b, void *p)
53 fprintf(stderr, " p\n");
56 fprintf(stderr, " q\n");
67 int main(int argc, char **argv)
72 setlocale (LC_ALL, "");
73 bindtextdomain (PACKAGE, LOCALEDIR);
76 if(argc > 2 || (argc == 2 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))))
78 fprintf(stderr, _("Usage: %s bits\n"), argv[0]);
89 fprintf(stderr, _("Illegal number: %s\n"), argv[1]);
93 bits = ((bits - 1) | 7) + 1; /* Align to bytes for easy mallocing and reading */
95 fprintf(stderr, _("Generating %d bits keys:\n"), bits);
97 key = RSA_generate_key(bits, RSA_PUBLIC_EXPONENT, indicator, NULL);
99 fprintf(stderr, _("Done.\n"));
101 printf(_("Public key: %s\n"), BN_bn2hex(key->n));
102 printf(_("Private key: %s\n"), BN_bn2hex(key->d));