gnutls-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GNU extensions to read_s2k for GnuTLS 2.4.x


From: Daniel Kahn Gillmor
Subject: Re: GNU extensions to read_s2k for GnuTLS 2.4.x
Date: Fri, 22 Aug 2008 11:30:23 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

On Fri 2008-08-22 08:45:35 -0400, Simon Josefsson wrote:

> Daniel, it would be excellent if you could implement a small self-test
> of the functionality using that dummy private key, to be placed in
> tests/.  It should use the public gnutls interfaces, not the direct
> opencdk interfaces.  For inspiration, look at for example
> tests/certificate_set_x509_crl.c.

Attached is such a test.  On a system running 2.4.1 without the
patches, it gives me rc -59 on the gnutls_openpgp_privkey_import.
With a patched GnuTLS, it exits cleanly:

0 vulcan:~# ./openpgp_gnu-dummy_extension 
gnutls_openpgp_privkey_import rc -59: GnuTLS internal error.
1 vulcan:~# dpkg --install 
~dkg/src/gnutls/tmp.rLUgIlxWJV/libgnutls26_2.4.1-1.s2kext1_amd64.deb 
(Reading database ... 22502 files and directories currently installed.)
Preparing to replace libgnutls26 2.4.1-1 (using 
.../libgnutls26_2.4.1-1.s2kext1_amd64.deb) ...
Unpacking replacement libgnutls26 ...
Setting up libgnutls26 (2.4.1-1.s2kext1) ...
0 vulcan:~# ./openpgp_gnu-dummy_extension 
0 vulcan:~# 

I see no reason why the same shouldn't be a valid test for the 2.5.x
series.

There are too many Makefiles in my git tests/ directory (and i assume
that some of them are generated from others -- why are they all in the
git repo?  i'm confused.) for me to know where/how to properly include
this in the actual tests that get run.  I'll watch the git repo
changes to see how it's done if this gets added for future reference,
though.

The test doesn't do anything fancier than verify that the key can be
successfully imported.

Regards,

        --dkg

/*
 * Copyright (C) 2008  Free Software Foundation, Inc.
 *
 * Author: Daniel Kahn Gillmor <address@hidden>
 *
 * 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 3 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 GNUTLS; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 */

#if HAVE_CONFIG_H
# include <config.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gnutls/gnutls.h>
#include <gnutls/openpgp.h>

static char dummy_key[] =
  "-----BEGIN PGP PRIVATE KEY BLOCK-----\n"
  "Version: GnuPG v1.4.9 (GNU/Linux)\n"
  "\n"
  "lQCVBEO3YdABBACRqqEnucag4+vyZny2M67Pai5+5suIRRvY+Ly8Ms5MvgCi3EVV\n"
  "xT05O/+0ShiRaf+QicCOFrhbU9PZzzU+seEvkeW2UCu4dQfILkmj+HBEIltGnHr3\n"
  "G0yegHj5pnqrcezERURf2e17gGFWX91cXB9Cm721FPXczuKraphKwCA9PwARAQAB\n"
  "/gNlAkdOVQG0OURlbW9uc3RyYXRpb24gS2V5IGZvciBTMksgR05VIGV4dGVuc2lv\n"
  "biAxMDAxIC0tIGdudS1kdW1teYi8BBMBAgAmBQJDt2HQAhsDBQkB4TOABgsJCAcD\n"
  "AgQVAggDBBYCAwECHgECF4AACgkQQZUwSa4UDezTOQP/TMQXUVrWzHYZGopoPZ2+\n"
  "ZS3qddiznBHsgb7MGYg1KlTiVJSroDUBCHIUJvdQKZV9zrzrFl47D07x6hGyUPHV\n"
  "aZXvuITW8t1o5MMHkCy3pmJ2KgfDvdUxrBvLfgPMICA4c6zA0mWquee43syEW9NY\n"
  "g3q61iPlQwD1J1kX1wlimLCdAdgEQ7dh0AEEANAwa63zlQbuy1Meliy8otwiOa+a\n"
  "mH6pxxUgUNggjyjO5qx+rl25mMjvGIRX4/L1QwIBXJBVi3SgvJW1COZxZqBYqj9U\n"
  "8HVT07mWKFEDf0rZLeUE2jTm16cF9fcW4DQhW+sfYm+hi2sY3HeMuwlUBK9KHfW2\n"
  "+bGeDzVZ4pqfUEudABEBAAEAA/0bemib+wxub9IyVFUp7nPobjQC83qxLSNzrGI/\n"
  "RHzgu/5CQi4tfLOnwbcQsLELfker2hYnjsLrT9PURqK4F7udrWEoZ1I1LymOtLG/\n"
  "4tNZ7Mnul3wRC2tCn7FKx8sGJwGh/3li8vZ6ALVJAyOia5TZ/buX0+QZzt6+hPKk\n"
  "7MU1WQIA4bUBjtrsqDwro94DvPj3/jBnMZbXr6WZIItLNeVDUcM8oHL807Am97K1\n"
  "ueO/f6v1sGAHG6lVPTmtekqPSTWBfwIA7CGFvEyvSALfB8NUa6jtk27NCiw0csql\n"
  "kuhCmwXGMVOiryKEfegkIahf2bAd/gnWHPrpWp7bUE20v8YoW22I4wIAhnm5Wr5Q\n"
  "Sy7EHDUxmJm5TzadFp9gq08qNzHBpXSYXXJ3JuWcL1/awUqp3tE1I6zZ0hZ38Ia6\n"
  "SdBMN88idnhDPqPoiKUEGAECAA8FAkO3YdACGyAFCQHhM4AACgkQQZUwSa4UDezm\n"
  "vQP/ZhK+2ly9oI2z7ZcNC/BJRch0/ybQ3haahII8pXXmOThpZohr/LUgoWgCZdXg\n"
  "vP6yiszNk2tIs8KphCAw7Lw/qzDC2hEORjWO4f46qk73RAgSqG/GyzI4ltWiDhqn\n"
  "vnQCFl3+QFSe4zinqykHnLwGPMXv428d/ZjkIc2ju8dRsn4=\n"
  "=CR5w\n"
  "-----END PGP PRIVATE KEY BLOCK-----\n";

/* Test capability of reading the gnu-dummy OpenPGP S2K extension. 
   See: doc/DETAILS from gnupg
        http://lists.gnu.org/archive/html/gnutls-devel/2008-08/msg00023.html
*/

int
main (void)
{
  int rc;
  gnutls_datum_t keydatum = { (unsigned char*)dummy_key, strlen (dummy_key) };
  gnutls_openpgp_privkey_t key;

  rc = gnutls_global_init ();
  if (rc)
    {
      printf ("gnutls_global_init rc %d: %s\n", rc, gnutls_strerror (rc));
      return 1;
    }

  rc = gnutls_openpgp_privkey_init (&key);
  if (rc)
    {
      printf ("gnutls_openpgp_privkey_init rc %d: %s\n",
              rc, gnutls_strerror (rc));
      return 1;
    }

  rc = gnutls_openpgp_privkey_import (key, &keydatum,
                                      GNUTLS_OPENPGP_FMT_BASE64, NULL, 0);
  if (rc)
    {
      printf ("gnutls_openpgp_privkey_import rc %d: %s\n", 
              rc, gnutls_strerror (rc));
      return 1;
    }

  gnutls_openpgp_privkey_deinit (key);

  gnutls_global_deinit ();

  return 0;
}

Attachment: pgpSbSzEeboaB.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]