diff options
author | Werner Koch <[email protected]> | 2011-02-04 11:57:53 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2011-02-04 11:57:53 +0000 |
commit | b008274afdbe375b32a7e66dbd073e200f6f0587 (patch) | |
tree | 219e239d39cf06be3f03aa82fb572080ac163a15 /g10/card-util.c | |
parent | Let autogen.sh check the git config (diff) | |
download | gnupg-b008274afdbe375b32a7e66dbd073e200f6f0587.tar.gz gnupg-b008274afdbe375b32a7e66dbd073e200f6f0587.zip |
Nuked almost all trailing white space.post-nuke-of-trailing-ws
We better do this once and for all instead of cluttering all future
commits with diffs of trailing white spaces. In the majority of cases
blank or single lines are affected and thus this change won't disturb
a git blame too much. For future commits the pre-commit scripts
checks that this won't happen again.
Diffstat (limited to '')
-rw-r--r-- | g10/card-util.c | 107 |
1 files changed, 53 insertions, 54 deletions
diff --git a/g10/card-util.c b/g10/card-util.c index 966a3202b..2b7ac7469 100644 --- a/g10/card-util.c +++ b/g10/card-util.c @@ -87,7 +87,7 @@ change_pin (int unblock_v2, int allow_admin) gpg_strerror (rc)); return; } - + log_info (_("OpenPGP card no. %s detected\n"), info.serialno? info.serialno : "[none]"); @@ -181,7 +181,7 @@ change_pin (int unblock_v2, int allow_admin) rc = agent_scd_change_pin (102, info.serialno); write_sc_op_status (rc); if (rc) - tty_printf ("Error setting the Reset Code: %s\n", + tty_printf ("Error setting the Reset Code: %s\n", gpg_strerror (rc)); else tty_printf ("Reset Code set.\n"); @@ -383,7 +383,7 @@ card_status (estream_t fp, char *serialno, size_t serialnobuflen) else tty_fprintf (fp, "Application ID ...: %s\n", info.serialno? info.serialno : "[none]"); - if (!info.serialno || strncmp (info.serialno, "D27600012401", 12) + if (!info.serialno || strncmp (info.serialno, "D27600012401", 12) || strlen (info.serialno) != 32 ) { if (info.apptype && !strcmp (info.apptype, "NKS")) @@ -425,7 +425,7 @@ card_status (estream_t fp, char *serialno, size_t serialnobuflen) ; else if (strlen (serialno)+1 > serialnobuflen) log_error ("serial number longer than expected\n"); - else + else strcpy (serialno, info.serialno); if (opt.with_colons) @@ -438,7 +438,7 @@ card_status (estream_t fp, char *serialno, size_t serialnobuflen) uval = xtoi_2(info.serialno+16)*256 + xtoi_2 (info.serialno+18); es_fprintf (fp, "vendor:%04x:%s:\n", uval, get_manufacturer (uval)); es_fprintf (fp, "serial:%.8s:\n", info.serialno+20); - + print_isoname (fp, "Name of cardholder: ", "name", info.disp_name); es_fputs ("lang:", fp); @@ -498,18 +498,18 @@ card_status (estream_t fp, char *serialno, size_t serialnobuflen) (unsigned long)info.fpr1time, (unsigned long)info.fpr2time, (unsigned long)info.fpr3time); } - else + else { tty_fprintf (fp, "Version ..........: %.1s%c.%.1s%c\n", info.serialno[12] == '0'?"":info.serialno+12, info.serialno[13], info.serialno[14] == '0'?"":info.serialno+14, info.serialno[15]); - tty_fprintf (fp, "Manufacturer .....: %s\n", + tty_fprintf (fp, "Manufacturer .....: %s\n", get_manufacturer (xtoi_2(info.serialno+16)*256 + xtoi_2 (info.serialno+18))); tty_fprintf (fp, "Serial number ....: %.8s\n", info.serialno+20); - + print_isoname (fp, "Name of cardholder: ", "name", info.disp_name); print_name (fp, "Language prefs ...: ", info.disp_lang); tty_fprintf (fp, "Sex ..............: %s\n", @@ -572,13 +572,13 @@ card_status (estream_t fp, char *serialno, size_t serialnobuflen) if (info.fpr3valid && info.fpr3time) tty_fprintf (fp, " created ....: %s\n", isotimestamp (info.fpr3time)); - tty_fprintf (fp, "General key info..: "); + tty_fprintf (fp, "General key info..: "); - thefpr = (info.fpr1valid? info.fpr1 : info.fpr2valid? info.fpr2 : + thefpr = (info.fpr1valid? info.fpr1 : info.fpr2valid? info.fpr2 : info.fpr3valid? info.fpr3 : NULL); /* If the fingerprint is all 0xff, the key has no asssociated OpenPGP certificate. */ - if ( thefpr && !fpr_is_ff (thefpr) + if ( thefpr && !fpr_is_ff (thefpr) && !get_pubkey_byfprint (pk, thefpr, 20)) { print_pubkey_info (fp, pk); @@ -586,14 +586,14 @@ card_status (estream_t fp, char *serialno, size_t serialnobuflen) #if GNUPG_MAJOR_VERSION == 1 { kbnode_t keyblock = NULL; - + if ( !get_seckeyblock_byfprint (&keyblock, thefpr, 20) ) print_card_key_info (fp, keyblock); else if ( !get_keyblock_byfprint (&keyblock, thefpr, 20) ) { release_kbnode (keyblock); keyblock = NULL; - + if (!auto_create_card_key_stub (info.serialno, info.fpr1valid? info.fpr1:NULL, info.fpr2valid? info.fpr2:NULL, @@ -603,7 +603,7 @@ card_status (estream_t fp, char *serialno, size_t serialnobuflen) print_card_key_info (fp, keyblock); } } - + release_kbnode (keyblock); } #endif /* GNUPG_MAJOR_VERSION == 1 */ @@ -611,7 +611,7 @@ card_status (estream_t fp, char *serialno, size_t serialnobuflen) else tty_fprintf (fp, "[none]\n"); } - + free_public_key (pk); agent_release_card_info (&info); } @@ -640,7 +640,7 @@ get_one_name (const char *prompt1, const char *prompt2) else if (strchr (name, '<')) tty_printf (_("Error: The \"<\" character may not be used.\n")); else if (strstr (name, " ")) - tty_printf (_("Error: Double spaces are not allowed.\n")); + tty_printf (_("Error: Double spaces are not allowed.\n")); else return name; xfree (name); @@ -678,7 +678,7 @@ change_name (void) if (strlen (isoname) > 39 ) { tty_printf (_("Error: Combined name too long " - "(limit is %d characters).\n"), 39); + "(limit is %d characters).\n"), 39); xfree (isoname); return -1; } @@ -707,7 +707,7 @@ change_url (void) if (strlen (url) > 254 ) { tty_printf (_("Error: URL too long " - "(limit is %d characters).\n"), 254); + "(limit is %d characters).\n"), 254); xfree (url); return -1; } @@ -778,7 +778,7 @@ get_data_from_file (const char *fname, size_t maxlen, char **r_buffer) estream_t fp; char *data; int n; - + *r_buffer = NULL; fp = es_fopen (fname, "rb"); @@ -795,7 +795,7 @@ get_data_from_file (const char *fname, size_t maxlen, char **r_buffer) tty_printf (_("can't open `%s': %s\n"), fname, strerror (errno)); return -1; } - + data = xtrymalloc (maxlen? maxlen:1); if (!data) { @@ -826,7 +826,7 @@ static int put_data_to_file (const char *fname, const void *buffer, size_t length) { estream_t fp; - + fp = es_fopen (fname, "wb"); #if GNUPG_MAJOR_VERSION == 1 if (fp && is_secured_file (fileno (fp))) @@ -841,7 +841,7 @@ put_data_to_file (const char *fname, const void *buffer, size_t length) tty_printf (_("can't create `%s': %s\n"), fname, strerror (errno)); return -1; } - + if (length && es_fwrite (buffer, length, 1, fp) != 1) { tty_printf (_("error writing `%s': %s\n"), fname, strerror (errno)); @@ -882,7 +882,7 @@ change_login (const char *args) if (n > 254 ) { tty_printf (_("Error: Login data too long " - "(limit is %d characters).\n"), 254); + "(limit is %d characters).\n"), 254); xfree (data); return -1; } @@ -901,7 +901,7 @@ change_private_do (const char *args, int nr) char do_name[] = "PRIVATE-DO-X"; char *data; int n; - int rc; + int rc; assert (nr >= 1 && nr <= 4); do_name[11] = '0' + nr; @@ -928,7 +928,7 @@ change_private_do (const char *args, int nr) if (n > 254 ) { tty_printf (_("Error: Private DO too long " - "(limit is %d characters).\n"), 254); + "(limit is %d characters).\n"), 254); xfree (data); return -1; } @@ -1061,13 +1061,13 @@ change_sex (void) str = "1"; else if ((*data == 'F' || *data == 'f') && !data[1]) str = "2"; - else + else { tty_printf (_("Error: invalid response.\n")); xfree (data); return -1; } - + rc = agent_scd_setattr ("DISP-SEX", str, 1, NULL ); if (rc) log_error ("error setting sex: %s\n", gpg_strerror (rc)); @@ -1155,7 +1155,7 @@ get_info_for_key_operation (struct agent_card_info_s *info) memset (info, 0, sizeof *info); rc = agent_scd_getattr ("SERIALNO", info); - if (rc || !info->serialno || strncmp (info->serialno, "D27600012401", 12) + if (rc || !info->serialno || strncmp (info->serialno, "D27600012401", 12) || strlen (info->serialno) != 32 ) { log_error (_("key operation not possible: %s\n"), @@ -1180,7 +1180,7 @@ get_info_for_key_operation (struct agent_card_info_s *info) /* Helper for the key generation/edit functions. */ static int check_pin_for_key_operation (struct agent_card_info_s *info, int *forced_chv1) -{ +{ int rc = 0; agent_clear_pin_cache (info->serialno); @@ -1214,7 +1214,7 @@ check_pin_for_key_operation (struct agent_card_info_s *info, int *forced_chv1) } /* Helper for the key generation/edit functions. */ -static void +static void restore_forced_chv1 (int *forced_chv1) { int rc; @@ -1298,7 +1298,7 @@ ask_card_keysize (int keyno, unsigned int nbits) for (;;) { - prompt = xasprintf + prompt = xasprintf (keyno == 0? _("What keysize do you want for the Signature key? (%u) "): keyno == 1? @@ -1310,16 +1310,16 @@ ask_card_keysize (int keyno, unsigned int nbits) req_nbits = *answer? atoi (answer): nbits; xfree (prompt); xfree (answer); - + if (req_nbits != nbits && (req_nbits % 32) ) { req_nbits = ((req_nbits + 31) / 32) * 32; tty_printf (_("rounded up to %u bits\n"), req_nbits); } - + if (req_nbits == nbits) return 0; /* Use default. */ - + if (req_nbits < min_nbits || req_nbits > max_nbits) { tty_printf (_("%s keysizes must be in the range %u-%u\n"), @@ -1339,19 +1339,19 @@ ask_card_keysize (int keyno, unsigned int nbits) /* Change the size of key KEYNO (0..2) to NBITS and show an error message if that fails. */ static gpg_error_t -do_change_keysize (int keyno, unsigned int nbits) +do_change_keysize (int keyno, unsigned int nbits) { gpg_error_t err; char args[100]; - + snprintf (args, sizeof args, "--force %d 1 %u", keyno+1, nbits); err = agent_scd_setattr ("KEY-ATTR", args, strlen (args), NULL); if (err) - log_error (_("error changing size of key %d to %u bits: %s\n"), + log_error (_("error changing size of key %d to %u bits: %s\n"), keyno+1, nbits, gpg_strerror (err)); return err; } - + static void generate_card_keys (void) @@ -1432,7 +1432,7 @@ generate_card_keys (void) /* Note that INFO has not be synced. However we will only use the serialnumber and thus it won't harm. */ } - + generate_keypair (NULL, info.serialno, want_backup); leave: @@ -1450,11 +1450,11 @@ card_generate_subkey (KBNODE pub_keyblock) struct agent_card_info_s info; int forced_chv1 = 0; int keyno; - + err = get_info_for_key_operation (&info); if (err) return err; - + show_card_key_info (&info); tty_printf (_("Please select the type of key to generate:\n")); @@ -1463,7 +1463,7 @@ card_generate_subkey (KBNODE pub_keyblock) tty_printf (_(" (2) Encryption key\n")); tty_printf (_(" (3) Authentication key\n")); - for (;;) + for (;;) { char *answer = cpr_get ("cardedit.genkeys.subkeytype", _("Your selection? ")); @@ -1480,23 +1480,23 @@ card_generate_subkey (KBNODE pub_keyblock) break; /* Okay. */ tty_printf(_("Invalid selection.\n")); } - + if (replace_existing_key_p (&info, keyno)) { err = gpg_error (GPG_ERR_CANCELED); goto leave; } - + err = check_pin_for_key_operation (&info, &forced_chv1); if (err) goto leave; - + /* If the cards features changeable key attributes, we ask for the key size. */ if (info.is_v2 && info.extcap.aac) { unsigned int nbits; - + ask_again: nbits = ask_card_keysize (keyno-1, info.key_attr[keyno-1].nbits); if (nbits && do_change_keysize (keyno-1, nbits)) @@ -1511,9 +1511,9 @@ card_generate_subkey (KBNODE pub_keyblock) /* Note that INFO has not be synced. However we will only use the serialnumber and thus it won't harm. */ } - + err = generate_card_subkeypair (pub_keyblock, keyno, info.serialno); - + leave: agent_release_card_info (&info); restore_forced_chv1 (&forced_chv1); @@ -1525,7 +1525,7 @@ card_generate_subkey (KBNODE pub_keyblock) carry the serialno stuff instead of the actual secret key parameters. USE is the usage for that key; 0 means any usage. */ -int +int card_store_subkey (KBNODE node, int use) { log_info ("FIXME: card_store_subkey has not yet been implemented\n"); @@ -1722,7 +1722,7 @@ static struct { "privatedo", cmdPRIVATEDO, 0, NULL }, { "readcert", cmdREADCERT, 0, NULL }, { "writecert", cmdWRITECERT, 1, NULL }, - { NULL, cmdINVCMD, 0, NULL } + { NULL, cmdINVCMD, 0, NULL } }; @@ -1801,7 +1801,7 @@ card_edit (ctrl_t ctrl, strlist_t commands) char *p; int i; int cmd_admin_only; - + tty_printf("\n"); if (redisplay ) { @@ -1853,7 +1853,7 @@ card_edit (ctrl_t ctrl, strlist_t commands) cmd = cmdLIST; /* Default to the list command */ else if (*answer == CONTROL_D) cmd = cmdQUIT; - else + else { if ((p=strchr (answer,' '))) { @@ -1868,7 +1868,7 @@ card_edit (ctrl_t ctrl, strlist_t commands) while (spacep (arg_rest)) arg_rest++; } - + for (i=0; cmds[i].name; i++ ) if (!ascii_strcasecmp (answer, cmds[i].name )) break; @@ -2012,4 +2012,3 @@ card_edit (ctrl_t ctrl, strlist_t commands) leave: xfree (answer); } - |