/* * Copyright (C) 2001,2002,2003 Nikos Mavroyanopoulos * * This file is part of GNUTLS. * * GNUTLS is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * GNUTLS is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #include #include #include #include #include #include "../lib/defines.h" /* Generates Diffie Hellman parameters (a prime and a generator * of the group). Exports them in PKCS #3 format. Used by certtool. */ extern FILE* outfile; extern FILE* infile; extern unsigned char buffer[]; extern const int buffer_size; static int cparams = 0; int generate_prime(int bits) { unsigned int i; gnutls_dh_params dh_params; gnutls_datum p, g; gnutls_dh_params_init( &dh_params); fprintf(stderr, "Generating DH parameters..."); gnutls_dh_params_generate2( dh_params, bits); gnutls_dh_params_export_raw( dh_params, &p, &g, NULL); if (cparams) { fprintf( outfile, "/* generator */\n"); fprintf( outfile, "\nconst uint8 g[%d] = { ", g.size); for (i=0;i