mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-02 12:01:32 +01:00
Added GENKEY --preset to add the passphrase of the generated key to the cache.
This commit is contained in:
parent
893b455a3d
commit
944bf8f5b5
@ -1,3 +1,8 @@
|
|||||||
|
2011-04-10 Ben Kibbey <bjk@luxsci.net>
|
||||||
|
|
||||||
|
* command.c: (cmd_genkey): Add option --preset.
|
||||||
|
* genkey.c: (agent_genkey): Add parameter preset.
|
||||||
|
|
||||||
2011-04-06 Ben Kibbey <bjk@luxsci.net>
|
2011-04-06 Ben Kibbey <bjk@luxsci.net>
|
||||||
|
|
||||||
* command.c: (do_one_keyinfo): Add protection type field.
|
* command.c: (do_one_keyinfo): Add protection type field.
|
||||||
|
@ -313,7 +313,7 @@ gpg_error_t agent_ask_new_passphrase (ctrl_t ctrl, const char *prompt,
|
|||||||
char **r_passphrase);
|
char **r_passphrase);
|
||||||
int agent_genkey (ctrl_t ctrl, const char *cache_nonce,
|
int agent_genkey (ctrl_t ctrl, const char *cache_nonce,
|
||||||
const char *keyparam, size_t keyparmlen,
|
const char *keyparam, size_t keyparmlen,
|
||||||
int no_protection, membuf_t *outbuf);
|
int no_protection, int preset, membuf_t *outbuf);
|
||||||
gpg_error_t agent_protect_and_store (ctrl_t ctrl, gcry_sexp_t s_skey,
|
gpg_error_t agent_protect_and_store (ctrl_t ctrl, gcry_sexp_t s_skey,
|
||||||
char **passphrase_addr);
|
char **passphrase_addr);
|
||||||
|
|
||||||
|
@ -831,7 +831,7 @@ cmd_pkdecrypt (assuan_context_t ctx, char *line)
|
|||||||
|
|
||||||
|
|
||||||
static const char hlp_genkey[] =
|
static const char hlp_genkey[] =
|
||||||
"GENKEY [--no-protection] [<cache_nonce>]\n"
|
"GENKEY [--no-protection] [--preset] [<cache_nonce>]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Generate a new key, store the secret part and return the public\n"
|
"Generate a new key, store the secret part and return the public\n"
|
||||||
"part. Here is an example transaction:\n"
|
"part. Here is an example transaction:\n"
|
||||||
@ -843,6 +843,9 @@ static const char hlp_genkey[] =
|
|||||||
" S: D (public-key\n"
|
" S: D (public-key\n"
|
||||||
" S: D (rsa (n 326487324683264) (e 10001)))\n"
|
" S: D (rsa (n 326487324683264) (e 10001)))\n"
|
||||||
" S: OK key created\n"
|
" S: OK key created\n"
|
||||||
|
"\n"
|
||||||
|
"When the --preset option is used the passphrase for the generated\n"
|
||||||
|
"key will be added to the cache.\n"
|
||||||
"\n";
|
"\n";
|
||||||
static gpg_error_t
|
static gpg_error_t
|
||||||
cmd_genkey (assuan_context_t ctx, char *line)
|
cmd_genkey (assuan_context_t ctx, char *line)
|
||||||
@ -854,8 +857,10 @@ cmd_genkey (assuan_context_t ctx, char *line)
|
|||||||
size_t valuelen;
|
size_t valuelen;
|
||||||
membuf_t outbuf;
|
membuf_t outbuf;
|
||||||
char *cache_nonce = NULL;
|
char *cache_nonce = NULL;
|
||||||
|
int opt_preset;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
|
opt_preset = has_option (line, "--preset");
|
||||||
no_protection = has_option (line, "--no-protection");
|
no_protection = has_option (line, "--no-protection");
|
||||||
line = skip_options (line);
|
line = skip_options (line);
|
||||||
|
|
||||||
@ -874,7 +879,7 @@ cmd_genkey (assuan_context_t ctx, char *line)
|
|||||||
init_membuf (&outbuf, 512);
|
init_membuf (&outbuf, 512);
|
||||||
|
|
||||||
rc = agent_genkey (ctrl, cache_nonce, (char*)value, valuelen, no_protection,
|
rc = agent_genkey (ctrl, cache_nonce, (char*)value, valuelen, no_protection,
|
||||||
&outbuf);
|
opt_preset, &outbuf);
|
||||||
xfree (value);
|
xfree (value);
|
||||||
if (rc)
|
if (rc)
|
||||||
clear_outbuf (&outbuf);
|
clear_outbuf (&outbuf);
|
||||||
|
@ -357,7 +357,7 @@ agent_ask_new_passphrase (ctrl_t ctrl, const char *prompt,
|
|||||||
int
|
int
|
||||||
agent_genkey (ctrl_t ctrl, const char *cache_nonce,
|
agent_genkey (ctrl_t ctrl, const char *cache_nonce,
|
||||||
const char *keyparam, size_t keyparamlen, int no_protection,
|
const char *keyparam, size_t keyparamlen, int no_protection,
|
||||||
membuf_t *outbuf)
|
int preset, membuf_t *outbuf)
|
||||||
{
|
{
|
||||||
gcry_sexp_t s_keyparam, s_key, s_private, s_public;
|
gcry_sexp_t s_keyparam, s_key, s_private, s_public;
|
||||||
char *passphrase;
|
char *passphrase;
|
||||||
@ -434,6 +434,16 @@ agent_genkey (ctrl_t ctrl, const char *cache_nonce,
|
|||||||
&& !agent_put_cache (cache_nonce, CACHE_MODE_NONCE,
|
&& !agent_put_cache (cache_nonce, CACHE_MODE_NONCE,
|
||||||
passphrase, 900 /*seconds*/))
|
passphrase, 900 /*seconds*/))
|
||||||
agent_write_status (ctrl, "CACHE_NONCE", cache_nonce, NULL);
|
agent_write_status (ctrl, "CACHE_NONCE", cache_nonce, NULL);
|
||||||
|
if (preset && !no_protection)
|
||||||
|
{
|
||||||
|
unsigned char grip[20];
|
||||||
|
char hexgrip[40+1];
|
||||||
|
if (gcry_pk_get_keygrip (s_private, grip))
|
||||||
|
{
|
||||||
|
bin2hex(grip, 20, hexgrip);
|
||||||
|
rc = agent_put_cache (hexgrip, CACHE_MODE_ANY, passphrase, 900);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
xfree (passphrase);
|
xfree (passphrase);
|
||||||
passphrase = NULL;
|
passphrase = NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user