2004-05-21  Marcus Brinkmann  <marcus@g10code.de>

	* gpgme.texi (Decrypt): Add note about new field wrong_key_usage
	of gpgme_decrypt_result_t.

gpgme/
2004-05-21  Marcus Brinkmann  <marcus@g10code.de>

	* gpgme.h (struct _gpgme_decrypt_result): New fields
	wrong_key_usage and _unused.
	* decrypt.c (_gpgme_decrypt_status_handler): Don't skip over
	character after a matched string, as in a protocol error this
	could skip over the trailing binary zero.
	Handle decrypt.keyusage error notifications.
This commit is contained in:
Marcus Brinkmann 2004-05-21 15:51:53 +00:00
parent 6aeee0426a
commit cf6910f69d
7 changed files with 48 additions and 7 deletions

5
NEWS
View File

@ -4,8 +4,13 @@ Noteworthy changes in version 0.9.0 (unreleased)
* The type gpgme_key_t has now a new field keylist_mode that contains * The type gpgme_key_t has now a new field keylist_mode that contains
the keylist mode that was active at the time the key was retrieved. the keylist mode that was active at the time the key was retrieved.
* The type gpgme_decrypt_result_t has a new field "wrong_key_usage"
that contains a flag indicating that the key should not have been
used for encryption.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gpgme_key_t EXTENDED: New field keylist_mode. gpgme_key_t EXTENDED: New field keylist_mode.
gpgme_decrypt_result_t EXTENDED: New field wrong_key_usage.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

2
TODO
View File

@ -96,6 +96,8 @@ Hey Emacs, this is -*- outline -*- mode!
password is required by crypto engine. !! password is required by crypto engine. !!
** Verify must not fail on NODATA premature if auto-key-retrieval failed. ** Verify must not fail on NODATA premature if auto-key-retrieval failed.
It should not fail silently if it knows there is an error. !!! It should not fail silently if it knows there is an error. !!!
** decrypt-verify sets wrong_key_usage even if not "verify.keyusage" is
encountered, but "decrypt.keyusage". Is this correct? !!
** All operations: Better error reporting. !! ** All operations: Better error reporting. !!
** Export status handler need much more work. !!! ** Export status handler need much more work. !!!
** Import should return a useful error when one happened. ** Import should return a useful error when one happened.

View File

@ -1,5 +1,8 @@
2004-05-21 Marcus Brinkmann <marcus@g10code.de> 2004-05-21 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Decrypt): Add note about new field wrong_key_usage
of gpgme_decrypt_result_t.
* gpgme.texi (Key Management): Add note about new field * gpgme.texi (Key Management): Add note about new field
keylist_mode of gpgme_key_t. keylist_mode of gpgme_key_t.

View File

@ -3523,6 +3523,9 @@ members:
@item char *unsupported_algorithm @item char *unsupported_algorithm
If an unsupported algorithm was encountered, this string describes the If an unsupported algorithm was encountered, this string describes the
algorithm that is not supported. algorithm that is not supported.
@item unsigned int wrong_key_usage : 1
This is true if the key was not used according to its policy.
@end table @end table
@end deftp @end deftp
@ -3608,7 +3611,7 @@ following members:
This is a pointer to the next new signature structure in the linked This is a pointer to the next new signature structure in the linked
list, or @code{NULL} if this is the last element. list, or @code{NULL} if this is the last element.
@item gpgme_sigsum_t summary; @item gpgme_sigsum_t summary
This is a bit vector giving a summary of the signature status. It This is a bit vector giving a summary of the signature status. It
provides an easy interface to a defined semantic of the signature provides an easy interface to a defined semantic of the signature
status. Checking just one bit is sufficient to see whether a status. Checking just one bit is sufficient to see whether a
@ -3701,7 +3704,7 @@ The creation timestamp of this signature.
The expiration timestamp of this signature, or 0 if the signature does The expiration timestamp of this signature, or 0 if the signature does
not expire. not expire.
@item unsigned int wrong_key_usage : 1; @item unsigned int wrong_key_usage : 1
This is true if the key was not used according to its policy. This is true if the key was not used according to its policy.
@item gpgme_validity_t validity @item gpgme_validity_t validity

View File

@ -1,5 +1,12 @@
2004-05-21 Marcus Brinkmann <marcus@g10code.de> 2004-05-21 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (struct _gpgme_decrypt_result): New fields
wrong_key_usage and _unused.
* decrypt.c (_gpgme_decrypt_status_handler): Don't skip over
character after a matched string, as in a protocol error this
could skip over the trailing binary zero.
Handle decrypt.keyusage error notifications.
* gpgme.h (struct _gpgme_key): New member keylist_mode. * gpgme.h (struct _gpgme_key): New member keylist_mode.
* keylist.c (keylist_colon_handler): Set the keylist_mode of KEY. * keylist.c (keylist_colon_handler): Set the keylist_mode of KEY.

View File

@ -1,6 +1,6 @@
/* decrypt.c - Decrypt function. /* decrypt.c - Decrypt function.
Copyright (C) 2000 Werner Koch (dd9jn) Copyright (C) 2000 Werner Koch (dd9jn)
Copyright (C) 2001, 2002, 2003 g10 Code GmbH Copyright (C) 2001, 2002, 2003, 2004 g10 Code GmbH
This file is part of GPGME. This file is part of GPGME.
@ -105,14 +105,16 @@ _gpgme_decrypt_status_handler (void *priv, gpgme_status_code_t code,
case GPGME_STATUS_ERROR: case GPGME_STATUS_ERROR:
/* Note that this is an informational status code which should /* Note that this is an informational status code which should
not lead to an erro retunr unless it is something not related not lead to an error return unless it is something not
to the backend. */ related to the backend. */
{ {
const char d_alg[] = "decrypt.algorithm"; const char d_alg[] = "decrypt.algorithm";
const char u_alg[] = "Unsupported_Algorithm"; const char u_alg[] = "Unsupported_Algorithm";
const char k_alg[] = "decrypt.keyusage";
if (!strncmp (args, d_alg, sizeof (d_alg) - 1)) if (!strncmp (args, d_alg, sizeof (d_alg) - 1))
{ {
args += sizeof (d_alg); args += sizeof (d_alg) - 1;
while (*args == ' ') while (*args == ' ')
args++; args++;
@ -120,7 +122,7 @@ _gpgme_decrypt_status_handler (void *priv, gpgme_status_code_t code,
{ {
char *end; char *end;
args += sizeof (u_alg); args += sizeof (u_alg) - 1;
while (*args == ' ') while (*args == ' ')
args++; args++;
@ -136,6 +138,18 @@ _gpgme_decrypt_status_handler (void *priv, gpgme_status_code_t code,
} }
} }
} }
else if (!strncmp (args, k_alg, sizeof (k_alg) - 1))
{
gpgme_error_t err;
args += sizeof (k_alg) - 1;
while (*args == ' ')
args++;
err = _gpgme_map_gnupg_error (args);
if (gpg_err_code (err) == GPG_ERR_WRONG_KEY_USAGE)
opd->result.wrong_key_usage = 1;
}
} }
break; break;

View File

@ -1063,6 +1063,12 @@ gpgme_error_t gpgme_op_encrypt_sign (gpgme_ctx_t ctx, gpgme_key_t recp[],
struct _gpgme_op_decrypt_result struct _gpgme_op_decrypt_result
{ {
char *unsupported_algorithm; char *unsupported_algorithm;
/* Key should not have been used for encryption. */
unsigned int wrong_key_usage : 1;
/* Internal to GPGME, do not use. */
int _unused : 31;
}; };
typedef struct _gpgme_op_decrypt_result *gpgme_decrypt_result_t; typedef struct _gpgme_op_decrypt_result *gpgme_decrypt_result_t;
@ -1192,6 +1198,7 @@ struct _gpgme_signature
/* Signature exipration time or 0. */ /* Signature exipration time or 0. */
unsigned long exp_timestamp; unsigned long exp_timestamp;
/* Key should not have been used for signing. */
unsigned int wrong_key_usage : 1; unsigned int wrong_key_usage : 1;
/* Internal to GPGME, do not use. */ /* Internal to GPGME, do not use. */