2 * Copyright (C) 2009-2012 Free Software Foundation, Inc.
4 * Author: Simon Josefsson
6 * This file is part of GnuTLS.
8 * GnuTLS is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * GnuTLS is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with GnuTLS; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
28 * Small code to reproduce the CVE-2009-1416 bad DSA key problem.
32 * gcc -o cve-2009-1416 cve-2009-1416.c -lgnutls
34 * If your gnutls library is OK then running it will print 'success!'.
36 * If your gnutls library is buggy then running it will print 'buggy'.
45 #include <gnutls/gnutls.h>
46 #include <gnutls/x509.h>
51 gnutls_x509_privkey_t key
;
52 gnutls_datum_t p
, q
, g
, y
, x
;
55 gnutls_global_init ();
57 ret
= gnutls_x509_privkey_init (&key
);
61 ret
= gnutls_x509_privkey_generate (key
, GNUTLS_PK_DSA
, 512, 0);
65 ret
= gnutls_x509_privkey_export_dsa_raw (key
, &p
, &q
, &g
, &y
, &x
);
69 if (q
.size
== 3 && memcmp (q
.data
, "\x01\x00\x01", 3) == 0)
81 gnutls_x509_privkey_deinit (key
);
82 gnutls_global_deinit ();