mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-10 13:04:23 +01:00
gpg: Show the default PIN hint also before "name" and "key-attr"
* g10/card-util.c (USER_PIN_DEFAULT): Move to the top. Same for the other constants. (show_pin_hint): New. (generate_card_keys): Use show_pin_hint. (do_change_keyattr): Also show pin hint here. (change_name): And here. -- We used to show a hint for the default PINs only before generate. However it is often useful to first change the attributes and thus the hint should be show here as well. The above is only done if no name has yet been set, thus before setting the name we also show the hint.
This commit is contained in:
parent
f476370916
commit
cbc7fa0c8e
@ -40,6 +40,11 @@
|
|||||||
#include "call-agent.h"
|
#include "call-agent.h"
|
||||||
|
|
||||||
#define CONTROL_D ('D' - 'A' + 1)
|
#define CONTROL_D ('D' - 'A' + 1)
|
||||||
|
#define USER_PIN_DEFAULT "123456"
|
||||||
|
#define ADMIN_PIN_DEFAULT "12345678"
|
||||||
|
|
||||||
|
#define KDF_DATA_LENGTH_MIN 90
|
||||||
|
#define KDF_DATA_LENGTH_MAX 110
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -716,6 +721,26 @@ current_card_status (ctrl_t ctrl, estream_t fp,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
show_pin_hint (void)
|
||||||
|
{
|
||||||
|
static int shown;
|
||||||
|
|
||||||
|
if (shown)
|
||||||
|
return;
|
||||||
|
shown = 1;
|
||||||
|
|
||||||
|
/* If no displayed name has been set, we assume that this is a fresh
|
||||||
|
card and print a hint about the default PINs. */
|
||||||
|
tty_printf ("\n");
|
||||||
|
tty_printf (_("Please note that the factory settings of the PINs are\n"
|
||||||
|
" PIN = '%s' Admin PIN = '%s'\n"
|
||||||
|
"You should change them using the command --change-pin\n"),
|
||||||
|
USER_PIN_DEFAULT, ADMIN_PIN_DEFAULT);
|
||||||
|
tty_printf ("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Print all available information for specific card with SERIALNO.
|
/* Print all available information for specific card with SERIALNO.
|
||||||
Print all available information for current card when SERIALNO is NULL.
|
Print all available information for current card when SERIALNO is NULL.
|
||||||
Or print for all cards when SERIALNO is "all". */
|
Or print for all cards when SERIALNO is "all". */
|
||||||
@ -850,6 +875,8 @@ change_name (void)
|
|||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
show_pin_hint ();
|
||||||
|
|
||||||
rc = agent_scd_setattr ("DISP-NAME", isoname, strlen (isoname));
|
rc = agent_scd_setattr ("DISP-NAME", isoname, strlen (isoname));
|
||||||
if (rc)
|
if (rc)
|
||||||
log_error ("error setting Name: %s\n", gpg_strerror (rc));
|
log_error ("error setting Name: %s\n", gpg_strerror (rc));
|
||||||
@ -1405,6 +1432,7 @@ show_keysize_warning (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Ask for the size of a card key. NBITS is the current size
|
/* Ask for the size of a card key. NBITS is the current size
|
||||||
configured for the card. Returns 0 to use the default size
|
configured for the card. Returns 0 to use the default size
|
||||||
(i.e. NBITS) or the selected size. */
|
(i.e. NBITS) or the selected size. */
|
||||||
@ -1590,6 +1618,8 @@ do_change_keyattr (int keyno, const struct key_attr *key_attr)
|
|||||||
return gpg_error (GPG_ERR_PUBKEY_ALGO);
|
return gpg_error (GPG_ERR_PUBKEY_ALGO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
show_pin_hint ();
|
||||||
|
|
||||||
err = agent_scd_setattr ("KEY-ATTR", args, strlen (args));
|
err = agent_scd_setattr ("KEY-ATTR", args, strlen (args));
|
||||||
if (err)
|
if (err)
|
||||||
log_error (_("error changing key attribute for key %d: %s\n"),
|
log_error (_("error changing key attribute for key %d: %s\n"),
|
||||||
@ -1622,6 +1652,7 @@ key_attr (void)
|
|||||||
{
|
{
|
||||||
struct key_attr *key_attr;
|
struct key_attr *key_attr;
|
||||||
|
|
||||||
|
|
||||||
if ((key_attr = ask_card_keyattr (keyno, &info.key_attr[keyno])))
|
if ((key_attr = ask_card_keyattr (keyno, &info.key_attr[keyno])))
|
||||||
{
|
{
|
||||||
err = do_change_keyattr (keyno, key_attr);
|
err = do_change_keyattr (keyno, key_attr);
|
||||||
@ -1687,15 +1718,7 @@ generate_card_keys (ctrl_t ctrl)
|
|||||||
/* If no displayed name has been set, we assume that this is a fresh
|
/* If no displayed name has been set, we assume that this is a fresh
|
||||||
card and print a hint about the default PINs. */
|
card and print a hint about the default PINs. */
|
||||||
if (!info.disp_name || !*info.disp_name)
|
if (!info.disp_name || !*info.disp_name)
|
||||||
{
|
show_pin_hint ();
|
||||||
tty_printf ("\n");
|
|
||||||
tty_printf (_("Please note that the factory settings of the PINs are\n"
|
|
||||||
" PIN = '%s' Admin PIN = '%s'\n"
|
|
||||||
"You should change them using the command --change-pin\n"),
|
|
||||||
"123456", "12345678");
|
|
||||||
tty_printf ("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (check_pin_for_key_operation (&info, &forced_chv1))
|
if (check_pin_for_key_operation (&info, &forced_chv1))
|
||||||
goto leave;
|
goto leave;
|
||||||
@ -2060,11 +2083,6 @@ factory_reset (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define USER_PIN_DEFAULT "123456"
|
|
||||||
#define ADMIN_PIN_DEFAULT "12345678"
|
|
||||||
#define KDF_DATA_LENGTH_MIN 90
|
|
||||||
#define KDF_DATA_LENGTH_MAX 110
|
|
||||||
|
|
||||||
/* Generate KDF data. */
|
/* Generate KDF data. */
|
||||||
static gpg_error_t
|
static gpg_error_t
|
||||||
gen_kdf_data (unsigned char *data, int single_salt)
|
gen_kdf_data (unsigned char *data, int single_salt)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user