summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cipher/ChangeLog3
-rw-r--r--cipher/ac.c2
-rw-r--r--cipher/pubkey.c28
-rw-r--r--src/cipher.h5
-rw-r--r--tests/ChangeLog4
-rw-r--r--tests/pubkey.c29
6 files changed, 66 insertions, 5 deletions
diff --git a/cipher/ChangeLog b/cipher/ChangeLog
index 9eabcf03..2c51ebc5 100644
--- a/cipher/ChangeLog
+++ b/cipher/ChangeLog
@@ -1,5 +1,8 @@
2003-09-04 Werner Koch <wk@gnupg.org>
+ * pubkey.c (_gcry_pk_aliased_algo_name): New.
+ * ac.c (gcry_ac_open): Use it here.
+
* Makefile.am (EXTRA_libcipher_la_SOURCES): Add serpent.c
2003-09-02 Moritz Schulte <mo@g10code.com>
diff --git a/cipher/ac.c b/cipher/ac.c
index 98e4dfad..3a3e1891 100644
--- a/cipher/ac.c
+++ b/cipher/ac.c
@@ -688,7 +688,7 @@ gcry_ac_open (gcry_ac_handle_t *handle,
const char *algorithm_name;
/* Get name. */
- algorithm_name = gcry_pk_algo_name (algorithm);
+ algorithm_name = _gcry_pk_aliased_algo_name (algorithm);
if (! *algorithm_name)
err = GPG_ERR_PUBKEY_ALGO;
diff --git a/cipher/pubkey.c b/cipher/pubkey.c
index 54097b10..de7c810b 100644
--- a/cipher/pubkey.c
+++ b/cipher/pubkey.c
@@ -284,6 +284,34 @@ gcry_pk_algo_name (int algorithm)
}
+/* A special version of gcry_pk_algo name to return the first aliased
+ name of the algorithm. This is required to adhere to the spki
+ specs where the algorithm names are lowercase. */
+const char *
+_gcry_pk_aliased_algo_name (int algorithm)
+{
+ const char *name = NULL;
+ gcry_module_t module;
+
+ REGISTER_DEFAULT_PUBKEYS;
+
+ ath_mutex_lock (&pubkeys_registered_lock);
+ module = _gcry_module_lookup_id (pubkeys_registered, algorithm);
+ if (module)
+ {
+ gcry_pk_spec_t *pubkey = (gcry_pk_spec_t *) module->spec;
+
+ name = pubkey->aliases? *pubkey->aliases : NULL;
+ if (!name || !*name)
+ name = pubkey->name;
+ _gcry_module_release (module);
+ }
+ ath_mutex_unlock (&pubkeys_registered_lock);
+
+ return name;
+}
+
+
static void
disable_pubkey_algo (int algorithm)
{
diff --git a/src/cipher.h b/src/cipher.h
index 392b646a..8af097a5 100644
--- a/src/cipher.h
+++ b/src/cipher.h
@@ -41,6 +41,11 @@ void _gcry_register_pk_elg_progress (gcry_handler_progress_t cb, void *cb_data);
/*-- primegen.c --*/
void _gcry_register_primegen_progress (gcry_handler_progress_t cb, void *cb_data);
+
+/*-- pubkey.c --*/
+const char * _gcry_pk_aliased_algo_name (int algorithm);
+
+
/* Declarations for the cipher specifications. */
extern gcry_cipher_spec_t cipher_spec_blowfish;
extern gcry_cipher_spec_t cipher_spec_des;
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 62d485e6..6a2d37ad 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,7 @@
+2003-09-04 Werner Koch <wk@gnupg.org>
+
+ * pubkey.c (check_keys_crypt): Fix for compatibility mode.
+
2003-08-27 Moritz Schulte <mo@g10code.com>
* basic.c (check_ciphers): Added: Serpent.
diff --git a/tests/pubkey.c b/tests/pubkey.c
index f405e122..747f9460 100644
--- a/tests/pubkey.c
+++ b/tests/pubkey.c
@@ -82,6 +82,7 @@ check_keys_crypt (gcry_sexp_t pkey, gcry_sexp_t skey,
gcry_sexp_t plain1, cipher, l;
gcry_mpi_t x0, x1;
int rc;
+ int have_flags;
/* Extract data from plaintext. */
l = gcry_sexp_find_token (plain0, "value", 0);
@@ -92,17 +93,37 @@ check_keys_crypt (gcry_sexp_t pkey, gcry_sexp_t skey,
if (rc)
die ("encryption failed: %s\n", gcry_strerror (rc));
+ l = gcry_sexp_find_token (plain1, "flags", 0);
+ have_flags = !!l;
+ gcry_sexp_release (l);
+
/* Decrypt data. */
rc = gcry_pk_decrypt (&plain1, cipher, skey);
gcry_sexp_release (cipher);
if (rc)
die ("decryption failed: %s\n", gcry_strerror (rc));
- /* Extract decrypted data. */
+ /* Extract decrypted data. Note that for compatibility reasons, the
+ output opf gcry_pk_decrypt depends on whether a flags lists (even
+ if empty) occurs in its input data. Because we passed the output
+ of encrypt directly to decrypt, such a flag value won't be there
+ as of today. We check it anyway. */
l = gcry_sexp_find_token (plain1, "value", 0);
- gcry_sexp_release (plain1);
- x1 = gcry_sexp_nth_mpi (l, 1, GCRYMPI_FMT_USG);
- gcry_sexp_release (l);
+ if (l)
+ {
+ if (!have_flags)
+ die ("compatibility mode of pk_decrypt broken\n");
+ gcry_sexp_release (plain1);
+ x1 = gcry_sexp_nth_mpi (l, 1, GCRYMPI_FMT_USG);
+ gcry_sexp_release (l);
+ }
+ else
+ {
+ if (have_flags)
+ die ("compatibility mode of pk_decrypt broken\n");
+ x1 = gcry_sexp_nth_mpi (plain1, 0, GCRYMPI_FMT_USG);
+ gcry_sexp_release (plain1);
+ }
/* Compare. */
if (gcry_mpi_cmp (x0, x1))