From: Marcus Brinkmann Date: Tue, 26 Feb 2002 23:39:58 +0000 (+0000) Subject: doc/ X-Git-Tag: V0-3-4~15 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=31b2a458ff66a70fffe587448d60044b7127b795;p=gpgme.git doc/ 2002-02-27 Marcus Brinkmann * gpgme.texi (Encrypting a Plaintext): Document GPGME_Invalid_Recipients. (Error Values): Likewise. gpgme/ 2002-02-27 Marcus Brinkmann * gpgme.h: Add new error code GPGME_Invalid_Recipient. * encrypt.c (struct encrypt_result_s): New member invalid_recipients, rename no_recipients to no_valid_recipients. (_gpgme_encrypt_status_handler): Include error for invalid recipients. * engine-gpgsm.c (gpgsm_set_recipients): Change type of first argument to GpgsmObject. Use that to report back the status about the recipients. --- diff --git a/NEWS b/NEWS index 4476d40..8d7a2ba 100644 --- a/NEWS +++ b/NEWS @@ -6,8 +6,16 @@ * New interfaces gpgme_op_encrypt_sign and gpgme_op_encrypt_sign_start to encrypt and sign a message in a combined operation. + * gpgme_op_encrypt does now fail with GPGME_Invalid_Recipients if + some recipients have been invalid, whereas earlier versions + succeeded in this case. The plaintext is still encrypted for all valid + recipients, so the application might take this error as a hint that + the ciphertext is not usable for all requested recipients. + Information about invalid recipients is available with gpgme_get_op_info. + * Interface changes relative to the 0.3.3 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +gpgme_op_encrypt CHANGED: Can fail with GPGME_Invalid_Recipients gpgme_set_include_certs NEW gpgme_get_include_certs NEW gpgme_op_encrypt_sign NEW diff --git a/doc/ChangeLog b/doc/ChangeLog index fe5eb4e..8ae8ae2 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,9 @@ +2002-02-27 Marcus Brinkmann + + * gpgme.texi (Encrypting a Plaintext): Document + GPGME_Invalid_Recipients. + (Error Values): Likewise. + 2002-02-26 Marcus Brinkmann * gpgme.texi (Encrypting a Plaintext): Document diff --git a/doc/gpgme.texi b/doc/gpgme.texi index 2be6170..5c2a084 100644 --- a/doc/gpgme.texi +++ b/doc/gpgme.texi @@ -615,7 +615,11 @@ This value means that there are too many active backend processes. This value means that the creation of a pipe failed. @item GPGME_No_Recipients -This value means that no recipients for a message have been set. +This value means that no valid recipients for a message have been set. + +@item GPGME_Invalid_Recipients +This value means that some, but not all, recipients for a message have +been invalid. @item GPGME_No_Data This value means that a @code{GpgmeData} object which was expected to @@ -2207,16 +2211,20 @@ ciphertext in the data object @var{cipher}. The type of the ciphertext created is determined by the @acronym{ASCII} armor and text mode attributes set for the context @var{ctx}. -More information about the encrypted text is available with +If @code{GPGME_Invalid_Recipients} is returned, some recipients in +@var{rset} are invalid, but not all. In this case the plaintext is +encrypted for all valid recipients and returned in @var{cipher}. More +information about the invalid recipients is available with @code{gpgme_get_op_info}. @xref{Detailed Results}. The function returns @code{GPGME_No_Error} if the ciphertext could be created successfully, @code{GPGME_Invalid_Value} if @var{ctx}, @var{rset}, @var{plain} or @var{cipher} is not a valid pointer, -@code{GPGME_No_Recipient} if @var{rset} does not contain any -valid recipients, @code{GPGME_No_Passphrase} if the passphrase for the -secret key could not be retrieved, and passes through any errors that -are reported by the crypto engine support routines. +@code{GPGME_No_Recipients} if @var{rset} does not contain any valid +recipients, @code{GPGME_Invalid_Recipients} if @var{rset} contains +some invalid recipients, @code{GPGME_No_Passphrase} if the passphrase +for the secret key could not be retrieved, and passes through any +errors that are reported by the crypto engine support routines. @end deftypefun @deftypefun GpgmeError gpgme_op_encrypt_start (@w{GpgmeCtx @var{ctx}}, @w{GpgmeRecipients @var{rset}}, @w{GpgmeData @var{plain}}, @w{GpgmeData @var{cipher}}) @@ -2227,7 +2235,7 @@ The function @code{gpgme_op_encrypt_start} initiates a The function returns @code{GPGME_No_Error} if the operation could be started successfully, @code{GPGME_Invalid_Value} if @var{ctx}, @var{rset}, @var{plain} or @var{cipher} is not a valid pointer, and -@code{GPGME_No_Recipient} if @var{rset} does not contain any valid +@code{GPGME_No_Recipients} if @var{rset} does not contain any valid recipients. @end deftypefun @@ -2251,7 +2259,7 @@ Completion}. The function returns @code{GPGME_No_Error} if the operation could be started successfully, @code{GPGME_Invalid_Value} if @var{ctx}, @var{rset}, @var{plain} or @var{cipher} is not a valid pointer, and -@code{GPGME_No_Recipient} if @var{rset} does not contain any valid +@code{GPGME_No_Recipients} if @var{rset} does not contain any valid recipients. @end deftypefun diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog index b8d396a..55358f7 100644 --- a/gpgme/ChangeLog +++ b/gpgme/ChangeLog @@ -1,3 +1,14 @@ +2002-02-27 Marcus Brinkmann + + * gpgme.h: Add new error code GPGME_Invalid_Recipient. + * encrypt.c (struct encrypt_result_s): New member invalid_recipients, + rename no_recipients to no_valid_recipients. + (_gpgme_encrypt_status_handler): Include error for invalid + recipients. + * engine-gpgsm.c (gpgsm_set_recipients): Change type of first + argument to GpgsmObject. Use that to report back the status about + the recipients. + 2002-02-26 Marcus Brinkmann * verify.c (_gpgme_verify_status_handler): Fix the last change. diff --git a/gpgme/encrypt.c b/gpgme/encrypt.c index 2f6abda..ffaf2d9 100644 --- a/gpgme/encrypt.c +++ b/gpgme/encrypt.c @@ -38,7 +38,8 @@ struct encrypt_result_s { - int no_recipients; + int no_valid_recipients; + int invalid_recipients; GpgmeData xmlinfo; }; @@ -113,16 +114,19 @@ _gpgme_encrypt_status_handler (GpgmeCtx ctx, GpgStatusCode code, char *args) _gpgme_set_op_info (ctx, ctx->result.encrypt->xmlinfo); ctx->result.encrypt->xmlinfo = NULL; } - if (ctx->result.encrypt->no_recipients) + if (ctx->result.encrypt->no_valid_recipients) ctx->error = mk_error (No_Recipients); + else if (ctx->result.encrypt->invalid_recipients) + ctx->error = mk_error (Invalid_Recipients); break; case STATUS_INV_RECP: + ctx->result.encrypt->invalid_recipients++; append_xml_encinfo (&ctx->result.encrypt->xmlinfo, args); break; case STATUS_NO_RECP: - ctx->result.encrypt->no_recipients = 1; /* i.e. no usable ones */ + ctx->result.encrypt->no_valid_recipients = 1; break; default: diff --git a/gpgme/engine-gpgsm.c b/gpgme/engine-gpgsm.c index 1bc688e..a88d638 100644 --- a/gpgme/engine-gpgsm.c +++ b/gpgme/engine-gpgsm.c @@ -423,12 +423,14 @@ _gpgme_gpgsm_op_delete (GpgsmObject gpgsm, GpgmeKey key, int allow_secret) static GpgmeError -gpgsm_set_recipients (ASSUAN_CONTEXT ctx, GpgmeRecipients recp) +gpgsm_set_recipients (GpgsmObject gpgsm, GpgmeRecipients recp) { GpgmeError err; + ASSUAN_CONTEXT ctx = gpgsm->assuan_ctx; char *line; int linelen; struct user_id_s *r; + int valid_recipients = 0; linelen = 10 + 40 + 1; /* "RECIPIENT " + guess + '\0'. */ line = xtrymalloc (10 + 40 + 1); @@ -452,13 +454,24 @@ gpgsm_set_recipients (ASSUAN_CONTEXT ctx, GpgmeRecipients recp) strcpy (&line[10], r->name); err = gpgsm_assuan_simple_command (ctx, line); - if (err) + if (!err) + valid_recipients = 1; + else if (err == GPGME_Invalid_Key && gpgsm->status.fnc) + { + /* FIXME: Include other reasons. */ + line[8] = '0'; /* FIXME: Report detailed reason. */ + gpgsm->status.fnc (gpgsm->status.fnc_value, STATUS_INV_RECP, &line[8]); + line[8] = 'T'; + } + else if (err != GPGME_Invalid_Key) { xfree (line); return err; } } xfree (line); + if (!valid_recipients && gpgsm->status.fnc) + gpgsm->status.fnc (gpgsm->status.fnc_value, STATUS_NO_RECP, ""); return 0; } @@ -487,7 +500,7 @@ _gpgme_gpgsm_op_encrypt (GpgsmObject gpgsm, GpgmeRecipients recp, return err; _gpgme_io_close (gpgsm->message_fd); - err = gpgsm_set_recipients (gpgsm->assuan_ctx, recp); + err = gpgsm_set_recipients (gpgsm, recp); if (err) return err; diff --git a/gpgme/gpgme.h b/gpgme/gpgme.h index 713125a..623264d 100644 --- a/gpgme/gpgme.h +++ b/gpgme/gpgme.h @@ -73,30 +73,31 @@ typedef struct gpgme_trust_item_s *GpgmeTrustItem; /* The error numbers used by GPGME. */ typedef enum { - GPGME_EOF = -1, - GPGME_No_Error = 0, - GPGME_General_Error = 1, - GPGME_Out_Of_Core = 2, - GPGME_Invalid_Value = 3, - GPGME_Busy = 4, - GPGME_No_Request = 5, - GPGME_Exec_Error = 6, - GPGME_Too_Many_Procs = 7, - GPGME_Pipe_Error = 8, - GPGME_No_Recipients = 9, - GPGME_No_Data = 10, - GPGME_Conflict = 11, - GPGME_Not_Implemented = 12, - GPGME_Read_Error = 13, - GPGME_Write_Error = 14, - GPGME_Invalid_Type = 15, - GPGME_Invalid_Mode = 16, - GPGME_File_Error = 17, /* errno is set in this case. */ - GPGME_Decryption_Failed = 18, - GPGME_No_Passphrase = 19, - GPGME_Canceled = 20, - GPGME_Invalid_Key = 21, - GPGME_Invalid_Engine = 22 + GPGME_EOF = -1, + GPGME_No_Error = 0, + GPGME_General_Error = 1, + GPGME_Out_Of_Core = 2, + GPGME_Invalid_Value = 3, + GPGME_Busy = 4, + GPGME_No_Request = 5, + GPGME_Exec_Error = 6, + GPGME_Too_Many_Procs = 7, + GPGME_Pipe_Error = 8, + GPGME_No_Recipients = 9, + GPGME_No_Data = 10, + GPGME_Conflict = 11, + GPGME_Not_Implemented = 12, + GPGME_Read_Error = 13, + GPGME_Write_Error = 14, + GPGME_Invalid_Type = 15, + GPGME_Invalid_Mode = 16, + GPGME_File_Error = 17, /* errno is set in this case. */ + GPGME_Decryption_Failed = 18, + GPGME_No_Passphrase = 19, + GPGME_Canceled = 20, + GPGME_Invalid_Key = 21, + GPGME_Invalid_Engine = 22, + GPGME_Invalid_Recipients = 23 } GpgmeError;