skey = ssh2_load_userkey(&filename, passphrase);
skey = ssh2_load_userkey(&filename, passphrase, NULL);
static void add_keyfile(Filename filename){    char passphrase[PASSPHRASE_MAXLEN];    struct RSAKey *rkey = NULL;    struct ssh2_userkey *skey = NULL;    int needs_pass;    int ret;    int attempts;    char *comment;    struct PassphraseProcStruct pps;    int type;    int original_pass;	    type = key_type(&filename);    if (type != SSH_KEYTYPE_SSH1 && type != SSH_KEYTYPE_SSH2) {	char msg[256];	sprintf(msg, "Couldn't load this key (%s)", key_type_to_str(type));	MessageBox(NULL, msg, APPNAME, MB_OK | MB_ICONERROR);	return;    }    /*     * See if the key is already loaded (in the primary Pageant,     * which may or may not be us).     */    {	void *blob;	unsigned char *keylist, *p;	int i, nkeys, bloblen;	if (type == SSH_KEYTYPE_SSH1) {	    if (!rsakey_pubblob(&filename, &blob, &bloblen)) {		MessageBox(NULL, "Couldn't load private key.", APPNAME,			   MB_OK | MB_ICONERROR);		return;	    }	    keylist = get_keylist1();	} else {	    unsigned char *blob2;	    blob = ssh2_userkey_loadpub(&filename, NULL, &bloblen);	    if (!blob) {		MessageBox(NULL, "Couldn't load private key.", APPNAME,			   MB_OK | MB_ICONERROR);		return;	    }	    /* For our purposes we want the blob prefixed with its length */	    blob2 = snewn(bloblen+4, unsigned char);	    PUT_32BIT(blob2, bloblen);	    memcpy(blob2 + 4, blob, bloblen);	    sfree(blob);	    blob = blob2;	    keylist = get_keylist2();	}	if (keylist) {	    nkeys = GET_32BIT(keylist);	    p = keylist + 4;	    for (i = 0; i < nkeys; i++) {		if (!memcmp(blob, p, bloblen)) {		    /* Key is already present; we can now leave. */		    sfree(keylist);		    sfree(blob);		    return;		}		/* Now skip over public blob */		if (type == SSH_KEYTYPE_SSH1)		    p += rsa_public_blob_len(p);		else		    p += 4 + GET_32BIT(p);		/* Now skip over comment field */		p += 4 + GET_32BIT(p);	    }	    sfree(keylist);	}	sfree(blob);    }    if (type == SSH_KEYTYPE_SSH1)	needs_pass = rsakey_encrypted(&filename, &comment);    else	needs_pass = ssh2_userkey_encrypted(&filename, &comment);    attempts = 0;    if (type == SSH_KEYTYPE_SSH1)	rkey = snew(struct RSAKey);    pps.passphrase = passphrase;    pps.comment = comment;    original_pass = 0;    do {	if (needs_pass) {	    /* try all the remembered passphrases first */	    char *pp = index234(passphrases, attempts);	    if(pp) {		strcpy(passphrase, pp);	    } else {		int dlgret;		original_pass = 1;		dlgret = DialogBoxParam(instance, MAKEINTRESOURCE(210),					NULL, PassphraseProc, (LPARAM) & pps);		passphrase_box = NULL;		if (!dlgret) {		    if (comment)			sfree(comment);		    if (type == SSH_KEYTYPE_SSH1)			sfree(rkey);		    return;		       /* operation cancelled */		}	    }	} else	    *passphrase = '\0';	if (type == SSH_KEYTYPE_SSH1)	    ret = loadrsakey(&filename, rkey, passphrase);	else {	    skey = ssh2_load_userkey(&filename, passphrase);	    if (skey == SSH2_WRONG_PASSPHRASE)		ret = -1;	    else if (!skey)		ret = 0;	    else		ret = 1;	}	attempts++;    } while (ret == -1);    /* if they typed in an ok passphrase, remember it */    if(original_pass && ret) {	char *pp = dupstr(passphrase);	addpos234(passphrases, pp, 0);    }    if (comment)	sfree(comment);    if (ret == 0) {	MessageBox(NULL, "Couldn't load private key.", APPNAME,		   MB_OK | MB_ICONERROR);	if (type == SSH_KEYTYPE_SSH1)	    sfree(rkey);	return;    }    if (type == SSH_KEYTYPE_SSH1) {	if (already_running) {	    unsigned char *request, *response;	    void *vresponse;	    int reqlen, clen, resplen, ret;	    clen = strlen(rkey->comment);	    reqlen = 4 + 1 +	       /* length, message type */		4 +		       /* bit count */		ssh1_bignum_length(rkey->modulus) +		ssh1_bignum_length(rkey->exponent) +		ssh1_bignum_length(rkey->private_exponent) +		ssh1_bignum_length(rkey->iqmp) +		ssh1_bignum_length(rkey->p) +		ssh1_bignum_length(rkey->q) + 4 + clen	/* comment */		;	    request = snewn(reqlen, unsigned char);	    request[4] = SSH1_AGENTC_ADD_RSA_IDENTITY;	    reqlen = 5;	    PUT_32BIT(request + reqlen, bignum_bitcount(rkey->modulus));	    reqlen += 4;	    reqlen += ssh1_write_bignum(request + reqlen, rkey->modulus);	    reqlen += ssh1_write_bignum(request + reqlen, rkey->exponent);	    reqlen +=		ssh1_write_bignum(request + reqlen,				  rkey->private_exponent);	    reqlen += ssh1_write_bignum(request + reqlen, rkey->iqmp);	    reqlen += ssh1_write_bignum(request + reqlen, rkey->p);	    reqlen += ssh1_write_bignum(request + reqlen, rkey->q);	    PUT_32BIT(request + reqlen, clen);	    memcpy(request + reqlen + 4, rkey->comment, clen);	    reqlen += 4 + clen;	    PUT_32BIT(request, reqlen - 4);	    ret = agent_query(request, reqlen, &vresponse, &resplen,			      NULL, NULL);	    assert(ret == 1);	    response = vresponse;	    if (resplen < 5 || response[4] != SSH_AGENT_SUCCESS)		MessageBox(NULL, "The already running Pageant "			   "refused to add the key.", APPNAME,			   MB_OK | MB_ICONERROR);	    sfree(request);	    sfree(response);	} else {	    if (add234(rsakeys, rkey) != rkey)		sfree(rkey);	       /* already present, don't waste RAM */	}    } else {	if (already_running) {	    unsigned char *request, *response;	    void *vresponse;	    int reqlen, alglen, clen, keybloblen, resplen, ret;	    alglen = strlen(skey->alg->name);	    clen = strlen(skey->comment);	    keybloblen = skey->alg->openssh_fmtkey(skey->data, NULL, 0);	    reqlen = 4 + 1 +	       /* length, message type */		4 + alglen +	       /* algorithm name */		keybloblen +	       /* key data */		4 + clen	       /* comment */		;	    request = snewn(reqlen, unsigned char);	    request[4] = SSH2_AGENTC_ADD_IDENTITY;	    reqlen = 5;	    PUT_32BIT(request + reqlen, alglen);	    reqlen += 4;	    memcpy(request + reqlen, skey->alg->name, alglen);	    reqlen += alglen;	    reqlen += skey->alg->openssh_fmtkey(skey->data,						request + reqlen,						keybloblen);	    PUT_32BIT(request + reqlen, clen);	    memcpy(request + reqlen + 4, skey->comment, clen);	    PUT_32BIT(request, reqlen - 4);	    reqlen += clen + 4;	    ret = agent_query(request, reqlen, &vresponse, &resplen,			      NULL, NULL);	    assert(ret == 1);	    response = vresponse;	    if (resplen < 5 || response[4] != SSH_AGENT_SUCCESS)		MessageBox(NULL, "The already running Pageant "			   "refused to add the key.", APPNAME,			   MB_OK | MB_ICONERROR);	    sfree(request);	    sfree(response);	} else {	    if (add234(ssh2keys, skey) != skey) {		skey->alg->freekey(skey->data);		sfree(skey);	       /* already present, don't waste RAM */	    }	}    }}