summaryrefslogtreecommitdiff
path: root/tests/pubkey.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2003-09-04 10:11:25 +0000
committerWerner Koch <wk@gnupg.org>2003-09-04 10:11:25 +0000
commita619027c2cebc9f64e125efa1675a43b0bd89910 (patch)
treeec92b185b48b280db0fe1e636bc820a4cb795253 /tests/pubkey.c
parent5cc08d1294a92339c62316be091d6b3701025174 (diff)
downloadlibgcrypt-a619027c2cebc9f64e125efa1675a43b0bd89910.tar.gz
* pubkey.c (_gcry_pk_aliased_algo_name): New.
* ac.c (gcry_ac_open): Use it here. * pubkey.c (check_keys_crypt): Fix for compatibility mode.
Diffstat (limited to 'tests/pubkey.c')
-rw-r--r--tests/pubkey.c29
1 files changed, 25 insertions, 4 deletions
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))