doc,tests: Require use of ctx_flag before use of session_key.
* doc/gpgme.texi: Document requirements of verifying that it is OK to use session_key. * tests/run-decrypt.c: Ensure that we fail if we're unable to access the session key, so that we do not violate the guidance above. Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net> Changed the description -@code{gpgme_set_ctx_flag (ctx, "export-session-key")} returns -@code{GPG_ERR_NO_ERROR} or @code{gpgme_get_ctx_flag (ctx, -"export-session-key")} returns @code{"1"}. +@code{gpgme_set_ctx_flag (ctx, "export-session-key")} returns success +or @code{gpgme_get_ctx_flag (ctx, "export-session-key")} returns true +(non-empty string). to get gpgme_get_ctx_flag for boolean values in sync with its own description. Note that I don't agree with the above suggestion but it does not really harm to have it in the man page. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
b2c07bd47b
commit
5730647421
@ -4814,6 +4814,11 @@ set to export session keys (see @code{gpgme_set_ctx_flag,
|
|||||||
"export-session-key"}), and a session key was available for the most
|
"export-session-key"}), and a session key was available for the most
|
||||||
recent decryption operation. Otherwise, this is a null pointer.
|
recent decryption operation. Otherwise, this is a null pointer.
|
||||||
|
|
||||||
|
You must not try to access this member of the struct unless
|
||||||
|
@code{gpgme_set_ctx_flag (ctx, "export-session-key")} returns success
|
||||||
|
or @code{gpgme_get_ctx_flag (ctx, "export-session-key")} returns true
|
||||||
|
(non-empty string).
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
@end deftp
|
@end deftp
|
||||||
|
|
||||||
|
@ -174,9 +174,25 @@ main (int argc, char **argv)
|
|||||||
gpgme_set_ctx_flag (ctx, "full-status", "1");
|
gpgme_set_ctx_flag (ctx, "full-status", "1");
|
||||||
}
|
}
|
||||||
if (export_session_key)
|
if (export_session_key)
|
||||||
gpgme_set_ctx_flag (ctx, "export-session-key", "1");
|
{
|
||||||
|
err = gpgme_set_ctx_flag (ctx, "export-session-key", "1");
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
fprintf (stderr, PGM ": error requesting exported session key: %s\n",
|
||||||
|
gpgme_strerror (err));
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (override_session_key)
|
if (override_session_key)
|
||||||
gpgme_set_ctx_flag (ctx, "override-session-key", override_session_key);
|
{
|
||||||
|
err = gpgme_set_ctx_flag (ctx, "overrride-session-key", "1");
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
fprintf (stderr, PGM ": error overriding session key: %s\n",
|
||||||
|
gpgme_strerror (err));
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
err = gpgme_data_new_from_stream (&in, fp_in);
|
err = gpgme_data_new_from_stream (&in, fp_in);
|
||||||
if (err)
|
if (err)
|
||||||
@ -201,7 +217,8 @@ main (int argc, char **argv)
|
|||||||
fprintf (stderr, PGM ": decrypt failed: %s\n", gpgme_strerror (err));
|
fprintf (stderr, PGM ": decrypt failed: %s\n", gpgme_strerror (err));
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
if (result) {
|
if (result)
|
||||||
|
{
|
||||||
print_result (result);
|
print_result (result);
|
||||||
print_data (out);
|
print_data (out);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user