summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2011-12-31 00:03:54 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2011-12-31 00:27:51 +0200
commit06c6a7ed3f7448bf2a94af14c10d872e71f97269 (patch)
treeda07ddb0dc9bda88b0095804614d4236582dfeec
parent07cd58a5b21bca3d59d62285fae68dd341433c43 (diff)
downloadgnutls-06c6a7ed3f7448bf2a94af14c10d872e71f97269.tar.gz
Removed unneeded opencdk functionality.
-rw-r--r--lib/opencdk/Makefile.am2
-rw-r--r--lib/opencdk/armor.c110
-rw-r--r--lib/opencdk/keydb.c108
-rw-r--r--lib/opencdk/main.c339
-rw-r--r--lib/opencdk/opencdk.h71
-rw-r--r--lib/openpgp/extras.c5
-rw-r--r--lib/openpgp/gnutls_openpgp.c3
7 files changed, 11 insertions, 627 deletions
diff --git a/lib/opencdk/Makefile.am b/lib/opencdk/Makefile.am
index fd8ea230a9..3f31c294cb 100644
--- a/lib/opencdk/Makefile.am
+++ b/lib/opencdk/Makefile.am
@@ -32,7 +32,7 @@ endif
noinst_LTLIBRARIES = libminiopencdk.la
-libminiopencdk_la_SOURCES = armor.c filters.h keydb.h main.c types.h \
+libminiopencdk_la_SOURCES = armor.c filters.h keydb.h types.h \
kbnode.c main.h packet.h 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
diff --git a/lib/opencdk/armor.c b/lib/opencdk/armor.c
index 9462b2b15a..19b8d4bdd3 100644
--- a/lib/opencdk/armor.c
+++ b/lib/opencdk/armor.c
@@ -463,7 +463,6 @@ search_header (const char *buf, const char **array)
if (strlen (buf) < 5 || strncmp (buf, "-----", 5))
{
- gnutls_assert ();
return -1;
}
for (i = 0; (s = array[i]); i++)
@@ -517,7 +516,6 @@ armor_decode (void *data, FILE * in, FILE * out)
if (feof (in) || !pgp_data)
{
- gnutls_assert ();
return CDK_Armor_Error; /* no data found */
}
@@ -616,114 +614,6 @@ armor_decode (void *data, FILE * in, FILE * out)
return rc;
}
-
-/**
- * cdk_file_armor:
- * @hd: Handle
- * @file: Name of the file to protect.
- * @output: Output filename.
- *
- * Protect a file with ASCII armor.
- **/
-cdk_error_t
-cdk_file_armor (cdk_ctx_t hd, const char *file, const char *output)
-{
- cdk_stream_t inp, out;
- cdk_error_t rc;
-
- rc = _cdk_check_args (hd->opt.overwrite, file, output);
- if (rc)
- return rc;
-
- rc = cdk_stream_open (file, &inp);
- if (rc)
- {
- gnutls_assert ();
- return rc;
- }
-
- rc = cdk_stream_new (output, &out);
- if (rc)
- {
- cdk_stream_close (inp);
- gnutls_assert ();
- return rc;
- }
-
- cdk_stream_set_armor_flag (out, CDK_ARMOR_MESSAGE);
- if (hd->opt.compress)
- rc = cdk_stream_set_compress_flag (out, hd->compress.algo,
- hd->compress.level);
- if (!rc)
- rc = cdk_stream_set_literal_flag (out, 0, file);
- if (!rc)
- rc = cdk_stream_kick_off (inp, out);
- if (!rc)
- rc = _cdk_stream_get_errno (out);
-
- cdk_stream_close (out);
- cdk_stream_close (inp);
- return rc;
-}
-
-
-/**
- * cdk_file_dearmor:
- * @file: Name of the file to unprotect.
- * @output: Output filename.
- *
- * Remove ASCII armor from a file.
- **/
-cdk_error_t
-cdk_file_dearmor (const char *file, const char *output)
-{
- cdk_stream_t inp, out;
- cdk_error_t rc;
- int zipalgo;
-
- rc = _cdk_check_args (1, file, output);
- if (rc)
- {
- gnutls_assert ();
- return rc;
- }
-
- rc = cdk_stream_open (file, &inp);
- if (rc)
- {
- gnutls_assert ();
- return rc;
- }
-
- rc = cdk_stream_create (output, &out);
- if (rc)
- {
- cdk_stream_close (inp);
- gnutls_assert ();
- return rc;
- }
-
- if (cdk_armor_filter_use (inp))
- {
- rc = cdk_stream_set_literal_flag (inp, 0, NULL);
- zipalgo = cdk_stream_is_compressed (inp);
- if (zipalgo)
- rc = cdk_stream_set_compress_flag (inp, zipalgo, 0);
- if (!rc)
- rc = cdk_stream_set_armor_flag (inp, 0);
- if (!rc)
- rc = cdk_stream_kick_off (inp, out);
- if (!rc)
- rc = _cdk_stream_get_errno (inp);
- }
-
- cdk_stream_close (inp);
- cdk_stream_close (out);
- gnutls_assert ();
- return rc;
-}
-
-
int
_cdk_filter_armor (void *data, int ctl, FILE * in, FILE * out)
{
diff --git a/lib/opencdk/keydb.c b/lib/opencdk/keydb.c
index c47154ef3f..10e46a77c1 100644
--- a/lib/opencdk/keydb.c
+++ b/lib/opencdk/keydb.c
@@ -279,13 +279,15 @@ keydb_idx_search (cdk_stream_t inp, u32 * keyid, const byte * fpr,
/**
* cdk_keydb_new_from_mem:
* @r_hd: The keydb output handle.
+ * @secret: does the stream contain secret key data
+ * @armor: the stream is base64
* @data: The raw key data.
* @datlen: The length of the raw data.
*
* Create a new keyring db handle from the contents of a buffer.
*/
cdk_error_t
-cdk_keydb_new_from_mem (cdk_keydb_hd_t * r_db, int secret,
+cdk_keydb_new_from_mem (cdk_keydb_hd_t * r_db, int secret, int armor,
const void *data, size_t datlen)
{
cdk_keydb_hd_t db;
@@ -305,7 +307,8 @@ cdk_keydb_new_from_mem (cdk_keydb_hd_t * r_db, int secret,
gnutls_assert ();
return rc;
}
- if (cdk_armor_filter_use (db->fp))
+
+ if (armor)
cdk_stream_set_armor_flag (db->fp, 0);
db->type = CDK_DBTYPE_DATA;
db->secret = secret;
@@ -313,102 +316,6 @@ cdk_keydb_new_from_mem (cdk_keydb_hd_t * r_db, int secret,
return 0;
}
-
-/**
- * cdk_keydb_new_from_stream:
- * @r_hd: the output keydb handle
- * @secret: does the stream contain secret key data
- * @in: the input stream to use
- *
- * This function creates a new keydb handle based on the given
- * stream. The stream is not closed in cdk_keydb_free() and it
- * is up to the caller to close it. No decoding is done.
- */
-cdk_error_t
-cdk_keydb_new_from_stream (cdk_keydb_hd_t * r_hd, int secret, cdk_stream_t in)
-{
- cdk_keydb_hd_t hd;
-
- if (!r_hd)
- {
- gnutls_assert ();
- return CDK_Inv_Value;
- }
- *r_hd = NULL;
-
- hd = calloc (1, sizeof *hd);
- hd->fp = in;
- hd->fp_ref = 1;
- hd->type = CDK_DBTYPE_STREAM;
- hd->secret = secret;
- *r_hd = hd;
-
- /* We do not push any filters and thus we expect that the format
- of the stream has the format the user wanted. */
-
- return 0;
-}
-
-
-cdk_error_t
-cdk_keydb_new_from_file (cdk_keydb_hd_t * r_hd, int secret, const char *fname)
-{
- cdk_keydb_hd_t hd;
-
- if (!r_hd)
- {
- gnutls_assert ();
- return CDK_Inv_Value;
- }
- *r_hd = NULL;
- hd = calloc (1, sizeof *hd);
- hd->name = cdk_strdup (fname);
- if (!hd->name)
- {
- cdk_free (hd);
- gnutls_assert ();
- return CDK_Out_Of_Core;
- }
- hd->type = secret ? CDK_DBTYPE_SK_KEYRING : CDK_DBTYPE_PK_KEYRING;
- hd->secret = secret;
- *r_hd = hd;
- return 0;
-}
-
-
-
-/**
- * cdk_keydb_new:
- * @r_hd: handle to store the new keydb object
- * @type: type of the keyring
- * @data: data which depends on the keyring type
- * @count: length of the data
- *
- * Create a new keydb object
- **/
-cdk_error_t
-cdk_keydb_new (cdk_keydb_hd_t * r_hd, int type, void *data, size_t count)
-{
- switch (type)
- {
- case CDK_DBTYPE_PK_KEYRING:
- case CDK_DBTYPE_SK_KEYRING:
- return cdk_keydb_new_from_file (r_hd, type == CDK_DBTYPE_SK_KEYRING,
- (const char *) data);
-
- case CDK_DBTYPE_DATA:
- return cdk_keydb_new_from_mem (r_hd, 0, data, count);
-
- case CDK_DBTYPE_STREAM:
- return cdk_keydb_new_from_stream (r_hd, 0, (cdk_stream_t) data);
-
- default:
- gnutls_assert ();
- return CDK_Inv_Mode;
- }
-}
-
-
/**
* cdk_keydb_free:
* @hd: the keydb object
@@ -453,7 +360,7 @@ _cdk_keydb_open (cdk_keydb_hd_t hd, cdk_stream_t * ret_kr)
}
rc = 0;
- if ((hd->type == CDK_DBTYPE_DATA || hd->type == CDK_DBTYPE_STREAM)
+ if ((hd->type == CDK_DBTYPE_DATA)
&& hd->fp)
{
kr = hd->fp;
@@ -466,9 +373,6 @@ _cdk_keydb_open (cdk_keydb_hd_t hd, cdk_stream_t * ret_kr)
if (rc)
goto leave;
-
- if (cdk_armor_filter_use (kr))
- cdk_stream_set_armor_flag (kr, 0);
}
else
{
diff --git a/lib/opencdk/main.c b/lib/opencdk/main.c
deleted file mode 100644
index bb1a163f64..0000000000
--- a/lib/opencdk/main.c
+++ /dev/null
@@ -1,339 +0,0 @@
-/* main.c
- * 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 3 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 program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <stdio.h>
-#include <errno.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#include "opencdk.h"
-#include "main.h"
-#include "packet.h"
-
-
-/* Set a default cipher algorithm and a digest algorithm.
- Even if AES and SHA-256 are not 'MUST' in the latest
- OpenPGP draft, AES seems to be a good choice. */
-#define DEFAULT_DIGEST_ALGO GNUTLS_DIG_SHA256
-
-/* Use the passphrase callback in the handle HD or
- return NULL if there is no valid callback. */
-char *
-_cdk_passphrase_get (cdk_ctx_t hd, const char *prompt)
-{
- if (!hd || !hd->passphrase_cb)
- return NULL;
- return hd->passphrase_cb (hd->passphrase_cb_value, prompt);
-}
-
-
-static void
-handle_set_digest (cdk_ctx_t hd, int digest)
-{
- if (!hd)
- return;
- if (_gnutls_hash_get_algo_len (digest) <= 0)
- digest = DEFAULT_DIGEST_ALGO;
- hd->digest_algo = digest;
-}
-
-
-static void
-handle_set_s2k (cdk_ctx_t hd, int mode, int digest)
-{
- if (!hd)
- return;
- if (_gnutls_hash_get_algo_len (digest) <= 0)
- digest = DEFAULT_DIGEST_ALGO;
- if (mode != CDK_S2K_SIMPLE &&
- mode != CDK_S2K_SALTED && mode != CDK_S2K_ITERSALTED)
- mode = CDK_S2K_ITERSALTED;
- hd->_s2k.mode = mode;
- hd->_s2k.digest_algo = digest;
-}
-
-
-static void
-handle_set_compress (cdk_ctx_t hd, int algo, int level)
-{
- if (!hd)
- return;
- if (algo < 0 || algo > 2)
- algo = 0;
- hd->compress.algo = algo;
- if (!algo)
- hd->opt.compress = 0;
- else
- {
- if (level > 0 && level < 10)
- hd->compress.level = level;
- else
- hd->compress.level = 6;
- }
-}
-
-
-/**
- * cdk_handle_control:
- * @hd: session handle
- * @action: flag which indicates whether put or get is requested
- * @cmd: command id
- *
- * Perform various control operations for the current session.
- **/
-int
-cdk_handle_control (cdk_ctx_t hd, int action, int cmd, ...)
-{
- va_list arg_ptr;
- int set = action == CDK_CTLF_SET, val = 0;
-
- if (!hd)
- return -1;
-
- if (action != CDK_CTLF_SET && action != CDK_CTLF_GET)
- return -1;
- va_start (arg_ptr, cmd);
- switch (cmd)
- {
- case CDK_CTL_ARMOR:
- if (set)
- hd->opt.armor = va_arg (arg_ptr, int);
- else
- val = hd->opt.armor;
- break;
-
- case CDK_CTL_DIGEST:
- if (set)
- handle_set_digest (hd, va_arg (arg_ptr, int));
- else
- val = hd->digest_algo;
- break;
-
- case CDK_CTL_OVERWRITE:
- if (set)
- hd->opt.overwrite = va_arg (arg_ptr, int);
- else
- val = hd->opt.overwrite;
- break;
-
- case CDK_CTL_COMPRESS:
- if (set)
- {
- int algo = va_arg (arg_ptr, int);
- int level = va_arg (arg_ptr, int);
- handle_set_compress (hd, algo, level);
- }
- else
- val = hd->compress.algo;
- break;
-
- case CDK_CTL_S2K:
- if (set)
- {
- int mode = va_arg (arg_ptr, int);
- int digest = va_arg (arg_ptr, int);
- handle_set_s2k (hd, mode, digest);
- }
- else
- val = hd->_s2k.mode;
- break;
-
- case CDK_CTL_FORCE_DIGEST:
- if (set)
- hd->opt.force_digest = va_arg (arg_ptr, int);
- else
- val = hd->opt.force_digest;
- break;
-
- case CDK_CTL_BLOCKMODE_ON:
- if (set)
- hd->opt.blockmode = va_arg (arg_ptr, int);
- else
- val = hd->opt.blockmode;
- break;
-
- default:
- val = -1;
- break;
- }
- va_end (arg_ptr);
- return val;
-}
-
-
-
-/**
- * cdk_handle_new:
- * @r_ctx: context to store the handle
- *
- * create a new session handle.
- **/
-cdk_error_t
-cdk_handle_new (cdk_ctx_t * r_ctx)
-{
- cdk_ctx_t c;
-
- if (!r_ctx)
- return CDK_Inv_Value;
-
- c = cdk_calloc (1, sizeof *c);
- if (!c)
- return CDK_Out_Of_Core;
-
- /* For S2K use the iterated and salted mode and use the
- default digest and cipher algorithms. Because the MDC
- feature will be used, the default cipher should use a
- blocksize of 128 bits. */
- c->_s2k.mode = CDK_S2K_ITERSALTED;
- c->_s2k.digest_algo = DEFAULT_DIGEST_ALGO;
-
- c->opt.mdc = 1;
- c->opt.compress = 1;
- c->opt.armor = 0;
- c->opt.textmode = 0;
-
- c->digest_algo = DEFAULT_DIGEST_ALGO;
-
- c->compress.algo = CDK_COMPRESS_ZIP;
- c->compress.level = 6;
-
- *r_ctx = c;
- return 0;
-}
-
-
-/**
- * cdk_handle_set_keyring:
- * @hd: session handle
- * @type: public=0 or secret=1 keyring type
- * @kringname: file name of the keyring which shall be used.
- *
- * Convenient function to set the keyring for the current session.
- */
-cdk_error_t
-cdk_handle_set_keyring (cdk_ctx_t hd, int type, const char *kringname)
-{
- cdk_keydb_hd_t db;
- cdk_error_t err;
-
- err = cdk_keydb_new_from_file (&db, type, kringname);
- if (err)
- return err;
-
- if (!type)
- hd->db.pub = db;
- else
- hd->db.sec = db;
- hd->db.close_db = 1;
- return 0;
-}
-
-
-/**
- * cdk_handle_set_keydb:
- * @hd: session handle
- * @db: the database handle
- *
- * set the key database handle.
- * the function automatically detects whether this is a public or
- * secret keyring and the right handle is set.
- **/
-void
-cdk_handle_set_keydb (cdk_ctx_t hd, cdk_keydb_hd_t db)
-{
- if (!hd)
- return;
- if (_cdk_keydb_is_secret (db))
- hd->db.sec = db;
- else
- hd->db.pub = db;
-}
-
-
-/**
- * cdk_handle_get_keydb:
- * @hd: session handle
- * @type: type of the keyring
- *
- * Return the keydb handle from the session handle.
- * The caller should not free these handles.
- **/
-cdk_keydb_hd_t
-cdk_handle_get_keydb (cdk_ctx_t hd, int type)
-{
- if (!hd)
- return NULL;
- if (type == CDK_DBTYPE_PK_KEYRING)
- return hd->db.pub;
- else if (type == CDK_DBTYPE_SK_KEYRING)
- return hd->db.sec;
- return NULL;
-}
-
-
-/**
- * cdk_handle_set_passphrase_cb:
- * @hd: session handle
- * @cb: callback function
- * @cb_value: the opaque value for the cb function
- *
- * set the passphrase callback.
- **/
-void
-cdk_handle_set_passphrase_cb (cdk_ctx_t hd,
- char *(*cb) (void *opa, const char *prompt),
- void *cb_value)
-{
- if (!hd)
- return;
- hd->passphrase_cb = cb;
- hd->passphrase_cb_value = cb_value;
-}
-
-/**
- * cdk_handle_free:
- * @hd: the handle
- *
- * Release the main handle.
- **/
-void
-cdk_handle_free (cdk_ctx_t hd)
-{
- if (!hd)
- return;
-
- /* 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. */
- if (hd->db.close_db)
- {
- if (hd->db.pub)
- cdk_keydb_free (hd->db.pub);
- if (hd->db.sec)
- cdk_keydb_free (hd->db.sec);
- hd->db.pub = hd->db.sec = NULL;
- }
- cdk_free (hd);
-}
diff --git a/lib/opencdk/opencdk.h b/lib/opencdk/opencdk.h
index 113e64e88e..c15abfbf4f 100644
--- a/lib/opencdk/opencdk.h
+++ b/lib/opencdk/opencdk.h
@@ -258,7 +258,6 @@ extern "C"
CDK_DBTYPE_PK_KEYRING = 100, /* A file with one or more public keys */
CDK_DBTYPE_SK_KEYRING = 101, /* A file with one or more secret keys */
CDK_DBTYPE_DATA = 102, /* A buffer with at least one public key */
- CDK_DBTYPE_STREAM = 103 /* A stream is used to read keys from */
};
@@ -576,56 +575,6 @@ extern "C"
};
typedef struct cdk_packet_s *cdk_packet_t;
-/* Session handle routines */
- cdk_error_t cdk_handle_new (cdk_ctx_t * r_ctx);
- void cdk_handle_free (cdk_ctx_t c);
-
-/* Set the key database handle for the given session handle.
- The type of the key db handle (public or secret) decides
- which session key db handle to use. */
- void cdk_handle_set_keydb (cdk_ctx_t hd, cdk_keydb_hd_t db);
-
-/* Convenient function to avoid to open a key db first.
- The user can directly use the file name, the rest is
- done internally. */
- cdk_error_t cdk_handle_set_keyring (cdk_ctx_t hd, int type,
- const char *kringname);
-
-/* Return keydb handle stored in the session handle. */
- cdk_keydb_hd_t cdk_handle_get_keydb (cdk_ctx_t hd, int type);
- int cdk_handle_control (cdk_ctx_t hd, int action, int cmd, ...);
-
-/* Set a passphrase callback for the given session handle. */
- void cdk_handle_set_passphrase_cb (cdk_ctx_t hd,
- char *(*cb) (void *opa,
- const char *prompt),
- void *cb_value);
-
-/* shortcuts for some controls */
-
-/* Enable or disable armor output. */
-#define cdk_handle_set_armor(a, val) \
- cdk_handle_control ((a), CDK_CTLF_SET, CDK_CTL_ARMOR, (val))
-
-/* Set the compression algorithm and level. 0 means disable compression. */
-#define cdk_handle_set_compress(a, algo, level) \
- cdk_handle_control ((a), CDK_CTLF_SET, CDK_CTL_COMPRESS, (algo), (level))
-
-/* Activate partial bodies for the output. This is needed if the length
- of the data is not known in advance or for the use with sockets
- or pipes. */
-#define cdk_handle_set_blockmode(a, val) \
- cdk_handle_control ((a), CDK_CTLF_SET, CDK_CTL_BLOCKMODE_ON, (val))
-
-/* Set the digest for the PK signing operation. */
-#define cdk_handle_set_digest(a, val) \
- cdk_handle_control ((a), CDK_CTLF_SET, CDK_CTL_DIGEST, (val))
-
-/* 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))
-/* Raw packet routines. */
-
/* Allocate a new packet or a new packet with the given packet type. */
cdk_error_t cdk_pkt_new (cdk_packet_t * r_pkt);
cdk_error_t cdk_pkt_alloc (cdk_packet_t * r_pkt, cdk_packet_type_t pkttype);
@@ -750,9 +699,6 @@ extern "C"
const unsigned char *salt);
void cdk_s2k_free (cdk_s2k_t s2k);
- cdk_error_t cdk_file_armor (cdk_ctx_t hd, const char *file,
- const char *output);
- cdk_error_t cdk_file_dearmor (const char *file, const char *output);
int cdk_armor_filter_use (cdk_stream_t inp);
/* Protect the inbuf with ASCII armor of the specified type.
@@ -833,26 +779,11 @@ extern "C"
the requested amount of bytes. */
int cdk_stream_peek (cdk_stream_t inp, unsigned char *buf, size_t buflen);
-/* A wrapper around the various new_from_XXX functions. Because
- the function does not support all combinations, the dedicated
- functions should be preferred. */
- cdk_error_t cdk_keydb_new (cdk_keydb_hd_t * r_hd, int type, void *data,
- size_t count);
-
/* Create a new key db handle from a memory buffer. */
cdk_error_t cdk_keydb_new_from_mem (cdk_keydb_hd_t * r_hd, int secret,
+ int armor,
const void *data, size_t datlen);
-/* Create a new key db which uses an existing file. */
- cdk_error_t cdk_keydb_new_from_file (cdk_keydb_hd_t * r_hd, int secret,
- const char *fname);
-
-/* Uses a stream as the key db input. For searching it is important
- that the seek function is supported on the stream. Furthermore,
- the stream is not closed in cdk_keydb_free(). The caller must do it. */
- cdk_error_t cdk_keydb_new_from_stream (cdk_keydb_hd_t * r_hd, int secret,
- cdk_stream_t in);
-
/* Check that a secret key with the given key ID is available. */
cdk_error_t cdk_keydb_check_sk (cdk_keydb_hd_t hd, unsigned int *keyid);
diff --git a/lib/openpgp/extras.c b/lib/openpgp/extras.c
index 6e1e29730b..726379fa70 100644
--- a/lib/openpgp/extras.c
+++ b/lib/openpgp/extras.c
@@ -147,7 +147,7 @@ gnutls_openpgp_keyring_import (gnutls_openpgp_keyring_t keyring,
size_t written = 0;
err = cdk_stream_tmp_from_mem (data->data, data->size, &input);
- if (!err)
+ if (err == 0)
err = cdk_stream_set_armor_flag (input, 0);
if (err)
{
@@ -183,7 +183,6 @@ gnutls_openpgp_keyring_import (gnutls_openpgp_keyring_t keyring,
while (written < raw_len && err != EOF && err > 0);
raw_len = written;
-
}
else
{ /* RAW */
@@ -191,7 +190,7 @@ gnutls_openpgp_keyring_import (gnutls_openpgp_keyring_t keyring,
raw_data = data->data;
}
- err = cdk_keydb_new (&keyring->db, CDK_DBTYPE_DATA, raw_data, raw_len);
+ err = cdk_keydb_new_from_mem (&keyring->db, 0, 0, raw_data, raw_len);
if (err)
gnutls_assert ();
diff --git a/lib/openpgp/gnutls_openpgp.c b/lib/openpgp/gnutls_openpgp.c
index ae7320aaf6..b13281c50f 100644
--- a/lib/openpgp/gnutls_openpgp.c
+++ b/lib/openpgp/gnutls_openpgp.c
@@ -1,6 +1,5 @@
/*
- * Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
- * Free Software Foundation, Inc.
+ * Copyright (C) 2002-2011 Free Software Foundation, Inc.
*
* Author: Timo Schulz, Nikos Mavrogiannopoulos
*