Beispiel #1
0
/*
 * Display the fingerprints of the PGP Master Keys to the user.
 */
void pgp_fingerprints(void)
{
    message_box("These are the fingerprints of the PuTTY PGP Master Keys. They can\n"
		"be used to establish a trust path from this executable to another\n"
		"one. See the manual for more information.\n"
		"(Note: these fingerprints have nothing to do with SSH!)\n"
		"\n"
		"PuTTY Master Key (RSA), 1024-bit:\n"
		"  " PGP_RSA_MASTER_KEY_FP "\n"
		"PuTTY Master Key (DSA), 1024-bit:\n"
		"  " PGP_DSA_MASTER_KEY_FP,
		"PGP fingerprints", MB_ICONINFORMATION | MB_OK,
		HELPCTXID(pgp_fingerprints));
}
Beispiel #2
0
/*
 * Display the fingerprints of the PGP Master Keys to the user.
 */
void pgp_fingerprints(void)
{
    message_box("These are the fingerprints of the PuTTY PGP Master Keys. They can\n"
                "be used to establish a trust path from this executable to another\n"
                "one. See the manual for more information.\n"
                "(Note: these fingerprints have nothing to do with SSH!)\n"
                "\n"
                "PuTTY Master Key (RSA), 1024-bit:\n"
                "  " PGP_RSA_MASTER_KEY_FP "\n"
                "PuTTY Master Key (DSA), 1024-bit:\n"
                "  " PGP_DSA_MASTER_KEY_FP "\n"
                "\n"
                "PuTTYTray is signed by the unrelated:\n"
                "Chris West (Faux) <*****@*****.**>:\n"
                "  408A E4F1 4EA7 33EF 1265  82C1 B195 E1C4 779B A9B2\n",
                "PGP fingerprints", MB_ICONINFORMATION | MB_OK,
                HELPCTXID(pgp_fingerprints));
}
Beispiel #3
0
void load_key_file(HWND hwnd, struct MainDlgState *state,
		   Filename *filename, int was_import_cmd)
{
    char *passphrase;
    int needs_pass;
    int type, realtype;
    int ret;
    const char *errmsg = NULL;
    char *comment;
    struct RSAKey newkey1;
    struct ssh2_userkey *newkey2 = NULL;

    type = realtype = key_type(filename);
    if (type != SSH_KEYTYPE_SSH1 &&
	type != SSH_KEYTYPE_SSH2 &&
	!import_possible(type)) {
	char *msg = dupprintf("Couldn't load private key (%s)",
			      key_type_to_str(type));
	message_box(msg, "PuTTYgen Error", MB_OK | MB_ICONERROR,
		    HELPCTXID(errors_cantloadkey));
	sfree(msg);
	return;
    }

    if (type != SSH_KEYTYPE_SSH1 &&
	type != SSH_KEYTYPE_SSH2) {
	realtype = type;
	type = import_target_type(type);
    }

    comment = NULL;
    passphrase = NULL;
    if (realtype == SSH_KEYTYPE_SSH1)
	needs_pass = rsakey_encrypted(filename, &comment);
    else if (realtype == SSH_KEYTYPE_SSH2)
	needs_pass = ssh2_userkey_encrypted(filename, &comment);
    else
	needs_pass = import_encrypted(filename, realtype, &comment);
    do {
        burnstr(passphrase);
        passphrase = NULL;

	if (needs_pass) {
	    int dlgret;
            struct PassphraseProcStruct pps;
            pps.passphrase = &passphrase;
            pps.comment = comment;
	    dlgret = DialogBoxParam(hinst,
				    MAKEINTRESOURCE(210),
				    NULL, PassphraseProc,
				    (LPARAM) &pps);
	    if (!dlgret) {
		ret = -2;
		break;
	    }
            assert(passphrase != NULL);
	} else
	    passphrase = dupstr("");
	if (type == SSH_KEYTYPE_SSH1) {
	    if (realtype == type)
		ret = loadrsakey(filename, &newkey1, passphrase, &errmsg);
	    else
		ret = import_ssh1(filename, realtype, &newkey1,
                                  passphrase, &errmsg);
	} else {
	    if (realtype == type)
		newkey2 = ssh2_load_userkey(filename, passphrase, &errmsg);
	    else
		newkey2 = import_ssh2(filename, realtype, passphrase, &errmsg);
	    if (newkey2 == SSH2_WRONG_PASSPHRASE)
		ret = -1;
	    else if (!newkey2)
		ret = 0;
	    else
		ret = 1;
	}
    } while (ret == -1);
    if (comment)
	sfree(comment);
    if (ret == 0) {
	char *msg = dupprintf("Couldn't load private key (%s)", errmsg);
	message_box(msg, "PuTTYgen Error", MB_OK | MB_ICONERROR,
		    HELPCTXID(errors_cantloadkey));
	sfree(msg);
    } else if (ret == 1) {
	/*
	 * Now update the key controls with all the
	 * key data.
	 */
	{
	    SetDlgItemText(hwnd, IDC_PASSPHRASE1EDIT,
			   passphrase);
	    SetDlgItemText(hwnd, IDC_PASSPHRASE2EDIT,
			   passphrase);
	    if (type == SSH_KEYTYPE_SSH1) {
		char buf[128];
		char *savecomment;

		state->ssh2 = FALSE;
		state->commentptr = &state->key.comment;
		state->key = newkey1;

		/*
		 * Set the key fingerprint.
		 */
		savecomment = state->key.comment;
		state->key.comment = NULL;
		rsa_fingerprint(buf, sizeof(buf),
				&state->key);
		state->key.comment = savecomment;

		SetDlgItemText(hwnd, IDC_FINGERPRINT, buf);
		/*
		 * Construct a decimal representation
		 * of the key, for pasting into
		 * .ssh/authorized_keys on a Unix box.
		 */
		setupbigedit1(hwnd, IDC_KEYDISPLAY,
			      IDC_PKSTATIC, &state->key);
	    } else {
		char *fp;
		char *savecomment;

		state->ssh2 = TRUE;
		state->commentptr =
		    &state->ssh2key.comment;
		state->ssh2key = *newkey2;	/* structure copy */
		sfree(newkey2);

		savecomment = state->ssh2key.comment;
		state->ssh2key.comment = NULL;
		fp =
		    state->ssh2key.alg->
		    fingerprint(state->ssh2key.data);
		state->ssh2key.comment = savecomment;

		SetDlgItemText(hwnd, IDC_FINGERPRINT, fp);
		sfree(fp);

		setupbigedit2(hwnd, IDC_KEYDISPLAY,
			      IDC_PKSTATIC, &state->ssh2key);
	    }
	    SetDlgItemText(hwnd, IDC_COMMENTEDIT,
			   *state->commentptr);
	}
	/*
	 * Finally, hide the progress bar and show
	 * the key data.
	 */
	ui_set_state(hwnd, state, 2);
	state->key_exists = TRUE;

	/*
	 * If the user has imported a foreign key
	 * using the Load command, let them know.
	 * If they've used the Import command, be
	 * silent.
	 */
	if (realtype != type && !was_import_cmd) {
	    char msg[512];
	    sprintf(msg, "Successfully imported foreign key\n"
		    "(%s).\n"
		    "To use this key with PuTTY, you need to\n"
		    "use the \"Save private key\" command to\n"
		    "save it in PuTTY's own format.",
		    key_type_to_str(realtype));
	    MessageBox(NULL, msg, "PuTTYgen Notice",
		       MB_OK | MB_ICONINFORMATION);
	}
    }
    burnstr(passphrase);
}
Beispiel #4
0
static void win_add_keyfile(Filename *filename)
{
  char *err;
  int ret;
  char *passphrase = NULL;

  /*
   * Try loading the key without a passphrase. (Or rather, without a
   * _new_ passphrase; pageant_add_keyfile will take care of trying
   * all the passphrases we've already stored.)
   */
  ret = pageant_add_keyfile(filename, NULL, &err);
  if (ret == PAGEANT_ACTION_OK) {
    goto done;
  } else if (ret == PAGEANT_ACTION_FAILURE) {
    goto error;
  }

  /*
   * OK, a passphrase is needed, and we've been given the key
   * comment to use in the passphrase prompt.
   */
  while (1) {
    INT_PTR dlgret;
    struct PassphraseProcStruct pps;

    pps.passphrase = &passphrase;
    pps.comment = err;

    // region tray-fatty
    dlgret = DialogBoxParam(
        hinst, MAKEINTRESOURCE(910), NULL, PassphraseProc, (LPARAM)&pps);
    // endregion

    passphrase_box = NULL;

    if (!dlgret)
      goto done; /* operation cancelled */

    sfree(err);

    assert(passphrase != NULL);

    ret = pageant_add_keyfile(filename, passphrase, &err);
    if (ret == PAGEANT_ACTION_OK) {
      goto done;
    } else if (ret == PAGEANT_ACTION_FAILURE) {
      goto error;
    }

    smemclr(passphrase, strlen(passphrase));
    sfree(passphrase);
    passphrase = NULL;
  }

error:
  message_box(
      err, APPNAME, MB_OK | MB_ICONERROR, HELPCTXID(errors_cantloadkey));
done:
  if (passphrase) {
    smemclr(passphrase, strlen(passphrase));
    sfree(passphrase);
  }
  sfree(err);
  return;
}