~nutznboltz-deactivatedaccount/ubuntu/precise/gnutls26/fix-lp926350

« back to all changes in this revision

Viewing changes to tests/cve-2009-1415.c

  • Committer: Package Import Robot
  • Author(s): Andreas Metzler
  • Date: 2011-10-01 15:28:13 UTC
  • mfrom: (12.1.20 sid)
  • Revision ID: package-import@ubuntu.com-20111001152813-yygm1c4cxonfxhzy
Tags: 2.12.11-1
* New upstream version.
  + Allow CA importing of 0 certificates to succeed. Closes: #640639
* Add libp11-kit-dev to libgnutls-dev dependencies. (see #643811)
* [20_guiledocstring.diff] guile: Fix docstring extraction with CPP 4.5+.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 */
22
22
 
23
23
#ifdef HAVE_CONFIG_H
24
 
# include <config.h>
 
24
#include <config.h>
25
25
#endif
26
26
 
27
27
/*
46
46
 
47
47
#include <gnutls/gnutls.h>
48
48
#include <gnutls/x509.h>
 
49
#include <gnutls/abstract.h>
49
50
 
50
51
static char dsa_cert[] =
51
52
  "-----BEGIN CERTIFICATE-----\n"
77
78
main (void)
78
79
{
79
80
  gnutls_x509_crt_t crt;
 
81
  gnutls_pubkey_t pubkey;
80
82
  gnutls_datum_t data = { (char *) "foo", 3 };
81
83
  gnutls_datum_t sig = { (char *) "bar", 3 };
82
84
  int ret;
87
89
  if (ret < 0)
88
90
    return 1;
89
91
 
 
92
  ret = gnutls_pubkey_init (&pubkey);
 
93
  if (ret < 0)
 
94
    return 1;
 
95
 
90
96
  ret = gnutls_x509_crt_import (crt, &dsa_cert_dat, GNUTLS_X509_FMT_PEM);
91
97
  if (ret < 0)
92
98
    return 1;
93
99
 
94
 
  ret = gnutls_x509_crt_verify_data (crt, 0, &data, &sig);
 
100
  ret = gnutls_pubkey_import_x509( pubkey, crt, 0);
95
101
  if (ret < 0)
96
102
    return 1;
97
103
 
 
104
  ret = gnutls_pubkey_verify_data (pubkey, 0, &data, &sig);
 
105
  if (ret < 0 && ret != GNUTLS_E_PK_SIG_VERIFY_FAILED)
 
106
    return 1;
 
107
 
98
108
  //printf ("success!\n");
99
109
 
100
110
  gnutls_x509_crt_deinit (crt);
 
111
  gnutls_pubkey_deinit( pubkey);
101
112
  gnutls_global_deinit ();
102
113
 
103
114
  return 0;