mirror of
git://git.gnupg.org/gnupg.git
synced 2025-06-30 22:27:56 +02:00
agent: Simplify printing of INQUIRE_MAXLEN.
* agent/command.c: Include asshelp.h. (cmd_pkdecrypt, cmd_genkey, cmd_preset_passphrase) (pinentry_loopback): Use print_assuan_status for INQUIRE_MAXLEN.
This commit is contained in:
parent
1a0df85060
commit
7981cdd134
@ -39,6 +39,7 @@
|
|||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
#include "cvt-openpgp.h"
|
#include "cvt-openpgp.h"
|
||||||
#include "../common/ssh-utils.h"
|
#include "../common/ssh-utils.h"
|
||||||
|
#include "../common/asshelp.h"
|
||||||
|
|
||||||
|
|
||||||
/* Maximum allowed size of the inquired ciphertext. */
|
/* Maximum allowed size of the inquired ciphertext. */
|
||||||
@ -855,13 +856,11 @@ cmd_pkdecrypt (assuan_context_t ctx, char *line)
|
|||||||
unsigned char *value;
|
unsigned char *value;
|
||||||
size_t valuelen;
|
size_t valuelen;
|
||||||
membuf_t outbuf;
|
membuf_t outbuf;
|
||||||
char buf[50];
|
|
||||||
|
|
||||||
(void)line;
|
(void)line;
|
||||||
|
|
||||||
/* First inquire the data to decrypt */
|
/* First inquire the data to decrypt */
|
||||||
snprintf (buf, sizeof (buf), "%u", MAXLEN_CIPHERTEXT);
|
rc = print_assuan_status (ctx, "INQUIRE_MAXLEN", "%u", MAXLEN_CIPHERTEXT);
|
||||||
rc = assuan_write_status (ctx, "INQUIRE_MAXLEN", buf);
|
|
||||||
if (!rc)
|
if (!rc)
|
||||||
rc = assuan_inquire (ctx, "CIPHERTEXT",
|
rc = assuan_inquire (ctx, "CIPHERTEXT",
|
||||||
&value, &valuelen, MAXLEN_CIPHERTEXT);
|
&value, &valuelen, MAXLEN_CIPHERTEXT);
|
||||||
@ -912,7 +911,6 @@ cmd_genkey (assuan_context_t ctx, char *line)
|
|||||||
char *cache_nonce = NULL;
|
char *cache_nonce = NULL;
|
||||||
int opt_preset;
|
int opt_preset;
|
||||||
char *p;
|
char *p;
|
||||||
char buf[50];
|
|
||||||
|
|
||||||
opt_preset = has_option (line, "--preset");
|
opt_preset = has_option (line, "--preset");
|
||||||
no_protection = has_option (line, "--no-protection");
|
no_protection = has_option (line, "--no-protection");
|
||||||
@ -926,8 +924,7 @@ cmd_genkey (assuan_context_t ctx, char *line)
|
|||||||
cache_nonce = xtrystrdup (line);
|
cache_nonce = xtrystrdup (line);
|
||||||
|
|
||||||
/* First inquire the parameters */
|
/* First inquire the parameters */
|
||||||
snprintf (buf, sizeof (buf), "%u", MAXLEN_KEYPARAM);
|
rc = print_assuan_status (ctx, "INQUIRE_MAXLEN", "%u", MAXLEN_KEYPARAM);
|
||||||
rc = assuan_write_status (ctx, "INQUIRE_MAXLEN", buf);
|
|
||||||
if (!rc)
|
if (!rc)
|
||||||
rc = assuan_inquire (ctx, "KEYPARAM", &value, &valuelen, MAXLEN_KEYPARAM);
|
rc = assuan_inquire (ctx, "KEYPARAM", &value, &valuelen, MAXLEN_KEYPARAM);
|
||||||
if (rc)
|
if (rc)
|
||||||
@ -1704,11 +1701,9 @@ cmd_preset_passphrase (assuan_context_t ctx, char *line)
|
|||||||
{
|
{
|
||||||
/* Note that the passphrase will be truncated at any null byte and the
|
/* Note that the passphrase will be truncated at any null byte and the
|
||||||
* limit is 480 characters. */
|
* limit is 480 characters. */
|
||||||
char buf[50];
|
|
||||||
size_t maxlen = 480;
|
size_t maxlen = 480;
|
||||||
|
|
||||||
snprintf (buf, sizeof (buf), "%u", maxlen);
|
rc = print_assuan_status (ctx, "INQUIRE_MAXLEN", "%u", maxlen);
|
||||||
rc = assuan_write_status (ctx, "INQUIRE_MAXLEN", buf);
|
|
||||||
if (!rc)
|
if (!rc)
|
||||||
rc = assuan_inquire (ctx, "PASSPHRASE", &passphrase, &len, maxlen);
|
rc = assuan_inquire (ctx, "PASSPHRASE", &passphrase, &len, maxlen);
|
||||||
}
|
}
|
||||||
@ -2805,10 +2800,8 @@ pinentry_loopback(ctrl_t ctrl, const char *keyword,
|
|||||||
{
|
{
|
||||||
gpg_error_t rc;
|
gpg_error_t rc;
|
||||||
assuan_context_t ctx = ctrl->server_local->assuan_ctx;
|
assuan_context_t ctx = ctrl->server_local->assuan_ctx;
|
||||||
char buf[50];
|
|
||||||
|
|
||||||
snprintf (buf, sizeof (buf), "%u", max_length);
|
rc = print_assuan_status (ctx, "INQUIRE_MAXLEN", "%u", max_length);
|
||||||
rc = assuan_write_status (ctx, "INQUIRE_MAXLEN", buf);
|
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user