2 * This is a trivial private key generator using a less secure
3 * random generator (/dev/urandom). This should be safe enough
4 * for the short-lived contest keys and it helps us to avoid
5 * spending hours by generating super-safe random numbers.
7 * (c) 2007 Martin Mares <mj@ucw.cz>
13 #include <sys/types.h>
14 #include <gnutls/gnutls.h>
15 #include <gnutls/x509.h>
20 gnutls_x509_privkey key;
24 gcry_control(GCRYCTL_ENABLE_QUICK_RANDOM);
25 err = gnutls_x509_privkey_init(&key);
27 die("privkey_init: %s", gnutls_strerror(err));
28 err = gnutls_x509_privkey_generate(key, GNUTLS_PK_RSA, 1024, 0);
30 die("privkey_generate: %s", gnutls_strerror(err));
33 size_t size = sizeof(buf);
34 err = gnutls_x509_privkey_export(key, GNUTLS_X509_FMT_PEM, buf, &size);
36 die("privkey_export: %s", gnutls_strerror(err));