]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
removed unused code
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Wed, 6 Apr 2011 22:48:46 +0000 (00:48 +0200)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Wed, 6 Apr 2011 22:48:46 +0000 (00:48 +0200)
lib/opencdk/Makefile.am
lib/opencdk/context.h
lib/opencdk/main.c
lib/opencdk/main.h
lib/opencdk/opencdk.h
lib/opencdk/verify.c [deleted file]

index 16c7707f682b8866749656d7f301adb14fdac5cc..5728d8bfb0f8aa53558670c8b0abc431cc9d497b 100644 (file)
@@ -35,7 +35,7 @@ endif
 noinst_LTLIBRARIES = libminiopencdk.la
 
 libminiopencdk_la_SOURCES = armor.c filters.h keydb.h main.c types.h   \
-       kbnode.c main.h packet.h dummy.c sig-check.c verify.c hash.c \
+       kbnode.c main.h packet.h dummy.c sig-check.c hash.c \
        keydb.c pubkey.c stream.c write-packet.c misc.c seskey.c \
        context.h literal.c new-packet.c read-packet.c stream.h opencdk.h
 
index 7c32ea7d8a96827d9775ff05589abbe7c12729e9..35ffc97d49acdaa03ad0200c75fdff52aa72f040 100644 (file)
@@ -76,10 +76,6 @@ struct cdk_ctx_s
     unsigned force_digest:1;
   } opt;
   struct
-  {
-    cdk_verify_result_t verify;
-  } result;
-  struct
   {
     cdk_pkt_seckey_t sk;
     unsigned on:1;
index 1dd0ea23eb6bf379e95749654bdc77ae38841b2a..5478a8bbe59ff84146889ea6a1d6bbe48e659791 100644 (file)
@@ -318,21 +318,6 @@ cdk_handle_set_passphrase_cb (cdk_ctx_t hd,
   hd->passphrase_cb_value = cb_value;
 }
 
-
-/**
- * cdk_handle_verify_get_result:
- * @hd: the session handle
- * 
- * Return the verify result for the current session.
- * Do not free the pointer.
- **/
-cdk_verify_result_t
-cdk_handle_verify_get_result (cdk_ctx_t hd)
-{
-  return hd->result.verify;
-}
-
-
 /**
  * cdk_handle_free:
  * @hd: the handle
@@ -344,7 +329,6 @@ cdk_handle_free (cdk_ctx_t hd)
 {
   if (!hd)
     return;
-  _cdk_result_verify_free (hd->result.verify);
 
   /* If cdk_handle_set_keyring() were used, we need to free the key db
      handles here because the handles are not controlled by the user. */
index b11a3c4741ac91320a0f1bfc884f7d69ddda1636..a8803081f884c7fbabf174f272868e572f42cbca 100644 (file)
@@ -179,10 +179,6 @@ int _cdk_stream_puts (cdk_stream_t s, const char *buf);
 cdk_error_t _cdk_stream_fpopen (FILE * fp, unsigned write_mode,
                                 cdk_stream_t * ret_out);
 
-/*-- verify.c --*/
-void _cdk_result_verify_free (cdk_verify_result_t res);
-cdk_verify_result_t _cdk_result_verify_new (void);
-
 
 /*-- read-packet.c --*/
 size_t _cdk_pkt_read_len (FILE * inp, size_t * ret_partial);
index d350f735383a9ca3eff3b824306a72413f509b5c..859920aaf72bea37a93713e7d1cf055b02aceedd 100644 (file)
@@ -625,29 +625,6 @@ extern "C"
 /* Set the mode and the digest for the S2K operation. */
 #define cdk_handle_set_s2k(a, val1, val2) \
   cdk_handle_control ((a), CDK_CTLF_SET, CDK_CTL_S2K, (val1), (val2))
-
-
-/* This context holds all information of the verification process. */
-  struct cdk_verify_result_s
-  {
-    int sig_ver;                /* Version of the signature. */
-    int sig_status;             /* The status (GOOD, BAD) of the signature */
-    int sig_flags;              /* May contain expired or revoked flags */
-    unsigned int keyid[2];      /* The issuer key ID */
-    unsigned int created;       /* Timestamp when the sig was created. */
-    unsigned int expires;
-    int pubkey_algo;
-    int digest_algo;
-    char *user_id;              /* NULL or user ID which issued the signature. */
-    char *policy_url;           /* If set, the policy the sig was created under. */
-    size_t sig_len;             /* Size of the signature data inbits. */
-    unsigned char *sig_data;    /* Raw signature data. */
-  };
-  typedef struct cdk_verify_result_s *cdk_verify_result_t;
-
-/* Return the verify result. Do not free the data. */
-  cdk_verify_result_t cdk_handle_verify_get_result (cdk_ctx_t hd);
-
 /* Raw packet routines. */
 
 /* Allocate a new packet or a new packet with the given packet type. */
@@ -1032,30 +1009,6 @@ extern "C"
                                   unsigned char **outbuf, size_t * outsize,
                                   int modval);
 
-/* Sign the stream @INP. Optionally, the output will be encrypted
-   if @REMUSR is not NULL and the @ENCRYPTFLAG is set.
-   The output will be written to @OUT.
-   @LOCUSR contains one ore more pattern for the secret key(s) to use. */
-  cdk_error_t cdk_stream_sign (cdk_ctx_t hd, cdk_stream_t inp,
-                               cdk_stream_t out, cdk_strlist_t locusr,
-                               cdk_strlist_t remusr, int encryptflag,
-                               int sigmode);
-
-/* Same as the function above but it works on files. */
-  cdk_error_t cdk_file_sign (cdk_ctx_t hd, cdk_strlist_t locusr,
-                             cdk_strlist_t remusr,
-                             const char *file, const char *output,
-                             int sigmode, int encryptflag);
-
-  cdk_error_t cdk_stream_verify (cdk_ctx_t hd, cdk_stream_t inp,
-                                 cdk_stream_t data, cdk_stream_t out);
-
-/* Verify the given file @FILE. For a detached signature, @DATA_FILE
-   contains the actual file data and @FILE is only the signature.
-   If the @OUTPUT is not NULL, the plaintext will be written to this file. */
-  cdk_error_t cdk_file_verify (cdk_ctx_t hd, const char *file,
-                               const char *data_file, const char *output);
-
   int cdk_trustdb_get_validity (cdk_stream_t inp, cdk_pkt_userid_t id,
                                 int *r_val);
   int cdk_trustdb_get_ownertrust (cdk_stream_t inp, cdk_pubkey_t pk,
diff --git a/lib/opencdk/verify.c b/lib/opencdk/verify.c
deleted file mode 100644 (file)
index 397b3ed..0000000
+++ /dev/null
@@ -1,319 +0,0 @@
-/* verify.c - Verify signatures
- * Copyright (C) 2001, 2002, 2003, 2007, 2008, 2010 Free Software
- * Foundation, Inc.
- *
- * Author: Timo Schulz
- *
- * This file is part of OpenCDK.
- *
- * The OpenCDK library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
- * USA
- *
- */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <stdio.h>
-#include <string.h>
-#include <sys/stat.h>
-
-#include "opencdk.h"
-#include "main.h"
-#include "filters.h"
-#include "packet.h"
-
-
-/* Table of all supported digest algorithms and their names. */
-struct
-{
-  const char *name;
-  int algo;
-} digest_table[] =
-{
-  {
-  "MD5", GNUTLS_DIG_MD5},
-  {
-  "SHA1", GNUTLS_DIG_SHA1},
-  {
-  "RIPEMD160", GNUTLS_DIG_RMD160},
-  {
-  "SHA256", GNUTLS_DIG_SHA256},
-  {
-  "SHA384", GNUTLS_DIG_SHA384},
-  {
-  "SHA512", GNUTLS_DIG_SHA512},
-  {
-  NULL, 0}
-};
-
-
-static cdk_error_t file_verify_clearsign (cdk_ctx_t, const char *,
-                                          const char *);
-
-
-/**
- * cdk_stream_verify:
- * @hd: session handle
- * @inp: the input stream
- * @data: for detached signatures, this is the data stream @inp is the sig
- * @out: where the output shall be written.
- *
- * Verify a signature in stream.
- */
-cdk_error_t
-cdk_stream_verify (cdk_ctx_t hd, cdk_stream_t inp, cdk_stream_t data,
-                   cdk_stream_t out)
-{
-  /* FIXME: out is not currently used. */
-  if (cdk_armor_filter_use (inp))
-    cdk_stream_set_armor_flag (inp, 0);
-  return _cdk_proc_packets (hd, inp, data, NULL, NULL, NULL);
-}
-
-/**
- * cdk_file_verify:
- * @hd: the session handle
- * @file: the input file
- * @data_file: for detached signature this is the data file and @file is the sig.
- * @output: the output file
- *
- * Verify a signature.
- **/
-cdk_error_t
-cdk_file_verify (cdk_ctx_t hd, const char *file, const char *data_file,
-                 const char *output)
-{
-  struct stat stbuf;
-  cdk_stream_t inp, data;
-  char buf[4096];
-  int n;
-  cdk_error_t rc;
-
-  if (!hd || !file)
-    return CDK_Inv_Value;
-  if (output && !hd->opt.overwrite && !stat (output, &stbuf))
-    return CDK_Inv_Mode;
-
-  rc = cdk_stream_open (file, &inp);
-  if (rc)
-    return rc;
-  if (cdk_armor_filter_use (inp))
-    {
-      n = cdk_stream_peek (inp, (byte *) buf, DIM (buf) - 1);
-      if (!n || n == -1)
-        return CDK_EOF;
-      buf[n] = '\0';
-      if (strstr (buf, "BEGIN PGP SIGNED MESSAGE"))
-        {
-          cdk_stream_close (inp);
-          return file_verify_clearsign (hd, file, output);
-        }
-      cdk_stream_set_armor_flag (inp, 0);
-    }
-
-  if (data_file)
-    {
-      rc = cdk_stream_open (data_file, &data);
-      if (rc)
-        {
-          cdk_stream_close (inp);
-          return rc;
-        }
-    }
-  else
-    data = NULL;
-
-  rc = _cdk_proc_packets (hd, inp, data, NULL, NULL, NULL);
-
-  if (data != NULL)
-    cdk_stream_close (data);
-  cdk_stream_close (inp);
-  return rc;
-}
-
-
-void
-_cdk_result_verify_free (cdk_verify_result_t res)
-{
-  if (!res)
-    return;
-  cdk_free (res->policy_url);
-  cdk_free (res->sig_data);
-  cdk_free (res);
-}
-
-
-cdk_verify_result_t
-_cdk_result_verify_new (void)
-{
-  cdk_verify_result_t res;
-
-  res = cdk_calloc (1, sizeof *res);
-  if (!res)
-    return NULL;
-  return res;
-}
-
-
-static cdk_error_t
-file_verify_clearsign (cdk_ctx_t hd, const char *file, const char *output)
-{
-  cdk_stream_t inp = NULL, out = NULL, tmp = NULL;
-  digest_hd_st md;
-  char buf[512], chk[512];
-  const char *s;
-  int i, is_signed = 0, nbytes;
-  int digest_algo = 0;
-  int err;
-  cdk_error_t rc;
-
-  memset(&md, 0, sizeof(md));
-
-  if (output)
-    {
-      rc = cdk_stream_create (output, &out);
-      if (rc)
-        return rc;
-    }
-
-  rc = cdk_stream_open (file, &inp);
-  if (rc)
-    {
-      if (output)
-        cdk_stream_close (out);
-      return rc;
-    }
-
-  s = "-----BEGIN PGP SIGNED MESSAGE-----";
-  while (!cdk_stream_eof (inp))
-    {
-      nbytes = _cdk_stream_gets (inp, buf, DIM (buf) - 1);
-      if (!nbytes || nbytes == -1)
-        break;
-      if (!strncmp (buf, s, strlen (s)))
-        {
-          is_signed = 1;
-          break;
-        }
-    }
-
-  if (cdk_stream_eof (inp) && !is_signed)
-    {
-      rc = CDK_Armor_Error;
-      goto leave;
-    }
-
-  while (!cdk_stream_eof (inp))
-    {
-      nbytes = _cdk_stream_gets (inp, buf, DIM (buf) - 1);
-      if (!nbytes || nbytes == -1)
-        break;
-      if (nbytes == 1)          /* Empty line */
-        break;
-      else if (!strncmp (buf, "Hash: ", 6))
-        {
-          for (i = 0; digest_table[i].name; i++)
-            {
-              if (!strcmp (buf + 6, digest_table[i].name))
-                {
-                  digest_algo = digest_table[i].algo;
-                  break;
-                }
-            }
-        }
-    }
-
-  if (digest_algo && _gnutls_hash_get_algo_len (digest_algo) <= 0)
-    {
-      rc = CDK_Inv_Algo;
-      goto leave;
-    }
-
-  if (!digest_algo)
-    digest_algo = GNUTLS_DIG_MD5;
-
-  err = _gnutls_hash_init (&md, digest_algo);
-  if (err < 0)
-    {
-      gnutls_assert ();
-      rc = map_gnutls_error (err);
-      goto leave;
-    }
-
-  s = "-----BEGIN PGP SIGNATURE-----";
-  while (!cdk_stream_eof (inp))
-    {
-      nbytes = _cdk_stream_gets (inp, buf, DIM (buf) - 1);
-      if (!nbytes || nbytes == -1)
-        break;
-      if (!strncmp (buf, s, strlen (s)))
-        break;
-      else
-        {
-          cdk_stream_peek (inp, (byte *) chk, DIM (chk) - 1);
-          i = strncmp (chk, s, strlen (s));
-          if (strlen (buf) == 0 && i == 0)
-            continue;           /* skip last '\n' */
-          _cdk_trim_string (buf, i == 0 ? 0 : 1);
-          _gnutls_hash (&md, buf, strlen (buf));
-        }
-      if (!strncmp (buf, "- ", 2))      /* FIXME: handle it recursive. */
-        memmove (buf, buf + 2, nbytes - 2);
-      if (out)
-        {
-          if (strstr (buf, "\r\n"))
-            buf[strlen (buf) - 2] = '\0';
-          cdk_stream_write (out, buf, strlen (buf));
-          _cdk_stream_puts (out, _cdk_armor_get_lineend ());
-        }
-    }
-
-  /* We create a temporary stream object to store the
-     signature data in there. */
-  rc = cdk_stream_tmp_new (&tmp);
-  if (rc)
-    goto leave;
-
-  s = "-----BEGIN PGP SIGNATURE-----\n";
-  _cdk_stream_puts (tmp, s);
-  while (!cdk_stream_eof (inp))
-    {
-      nbytes = _cdk_stream_gets (inp, buf, DIM (buf) - 1);
-      if (!nbytes || nbytes == -1)
-        break;
-      if (nbytes < (int) (DIM (buf) - 3))
-        {
-          buf[nbytes - 1] = '\n';
-          buf[nbytes] = '\0';
-        }
-      cdk_stream_write (tmp, buf, nbytes);
-    }
-
-  /* FIXME: This code is not very elegant. */
-  cdk_stream_tmp_set_mode (tmp, STREAMCTL_READ);
-  cdk_stream_seek (tmp, 0);
-  cdk_stream_set_armor_flag (tmp, 0);
-  cdk_stream_read (tmp, NULL, 0);
-
-  /* the digest handle will be closed there. */
-  rc = _cdk_proc_packets (hd, tmp, NULL, NULL, NULL, &md);
-
-leave:
-  _gnutls_hash_deinit (&md, NULL);
-  cdk_stream_close (out);
-  cdk_stream_close (tmp);
-  cdk_stream_close (inp);
-  return rc;
-}