&pki->privateKey);
&newPrivateKey);
seckey_decrypt_private_key(NSSLOWKEYEncryptedPrivateKeyInfo *epki,			   SECItem *pwitem){    NSSLOWKEYPrivateKey *pk = NULL;    NSSLOWKEYPrivateKeyInfo *pki = NULL;    SECStatus rv = SECFailure;    SECOidTag algorithm;    PLArenaPool *temparena = NULL, *permarena = NULL;    SECItem *salt = NULL, *dest = NULL, *key = NULL;    NSSPKCS5PBEParameter *param;#ifdef NSS_ENABLE_ECC    ECPrivateKey *ecpriv;    SECItem *fordebug = NULL;    int i;#endif    if((epki == NULL) || (pwitem == NULL))	goto loser;    temparena = PORT_NewArena(SEC_ASN1_DEFAULT_ARENA_SIZE);    permarena = PORT_NewArena(SEC_ASN1_DEFAULT_ARENA_SIZE);    if((temparena == NULL) || (permarena == NULL))	goto loser;    /* allocate temporary items */    pki = (NSSLOWKEYPrivateKeyInfo *)PORT_ArenaZAlloc(temparena, 	sizeof(NSSLOWKEYPrivateKeyInfo));    /* allocate permanent arena items */    pk = (NSSLOWKEYPrivateKey *)PORT_ArenaZAlloc(permarena,	sizeof(NSSLOWKEYPrivateKey));    if((pk == NULL) || (pki == NULL))	goto loser;    pk->arena = permarena;	    algorithm = SECOID_GetAlgorithmTag(&(epki->algorithm));    switch(algorithm)    {	case SEC_OID_RC4:	    salt = SECITEM_DupItem(&epki->algorithm.parameters);	    if(salt != NULL)	    {		key = seckey_create_rc4_key(pwitem, salt);		if(key != NULL)		{		    dest = seckey_rc4_decode(key, &epki->encryptedData);		}	    }		    if(salt != NULL)		SECITEM_ZfreeItem(salt, PR_TRUE);	    if(key != NULL)		SECITEM_ZfreeItem(key, PR_TRUE);	    break;	default:	    /* we depend on the fact that if this key was encoded with	     * DES, that the pw was also encoded with DES, so we don't have	     * to do the update here, the password code will handle it. */	    param = nsspkcs5_AlgidToParam(&epki->algorithm);	    if (param == NULL) {		break;	    }	    dest = nsspkcs5_CipherData(param, pwitem, &epki->encryptedData, 							PR_FALSE, NULL);	    nsspkcs5_DestroyPBEParameter(param);	    break;    }    if(dest != NULL)    {        SEC_PRINT("seckey_decrypt_private_key()", "PrivateKeyInfo", -1,		  dest);	rv = SEC_ASN1DecodeItem(temparena, pki, 	    nsslowkey_PrivateKeyInfoTemplate, dest);	if(rv == SECSuccess)	{	    switch(SECOID_GetAlgorithmTag(&pki->algorithm)) {	      case SEC_OID_X500_RSA_ENCRYPTION:	      case SEC_OID_PKCS1_RSA_ENCRYPTION:		pk->keyType = NSSLOWKEYRSAKey;		prepare_low_rsa_priv_key_for_asn1(pk);		rv = SEC_ASN1DecodeItem(permarena, pk,					nsslowkey_RSAPrivateKeyTemplate,					&pki->privateKey);		break;	      case SEC_OID_ANSIX9_DSA_SIGNATURE:		pk->keyType = NSSLOWKEYDSAKey;		prepare_low_dsa_priv_key_for_asn1(pk);		rv = SEC_ASN1DecodeItem(permarena, pk,					nsslowkey_DSAPrivateKeyTemplate,					&pki->privateKey);		if (rv != SECSuccess)		    goto loser;		prepare_low_pqg_params_for_asn1(&pk->u.dsa.params);		rv = SEC_ASN1DecodeItem(permarena, &pk->u.dsa.params,					nsslowkey_PQGParamsTemplate,					&pki->algorithm.parameters);		break;	      case SEC_OID_X942_DIFFIE_HELMAN_KEY:		pk->keyType = NSSLOWKEYDHKey;		prepare_low_dh_priv_key_for_asn1(pk);		rv = SEC_ASN1DecodeItem(permarena, pk,					nsslowkey_DHPrivateKeyTemplate,					&pki->privateKey);		break;#ifdef NSS_ENABLE_ECC	      case SEC_OID_ANSIX962_EC_PUBLIC_KEY:		pk->keyType = NSSLOWKEYECKey;		prepare_low_ec_priv_key_for_asn1(pk);		fordebug = &pki->privateKey;		SEC_PRINT("seckey_decrypt_private_key()", "PrivateKey", 			  pk->keyType, fordebug);		rv = SEC_ASN1DecodeItem(permarena, pk,					nsslowkey_ECPrivateKeyTemplate,					&pki->privateKey);		if (rv != SECSuccess)		    goto loser;		prepare_low_ecparams_for_asn1(&pk->u.ec.ecParams);		rv = SECITEM_CopyItem(permarena, 		    &pk->u.ec.ecParams.DEREncoding, 		    &pki->algorithm.parameters);		if (rv != SECSuccess)		    goto loser;		/* Fill out the rest of EC params */		rv = EC_FillParams(permarena, &pk->u.ec.ecParams.DEREncoding,				   &pk->u.ec.ecParams);		/* 		 * NOTE: Encoding of the publicValue is optional		 * so we need to be able to regenerate the publicValue		 * from the base point and the private key.		 *		 * XXX This part of the code needs more testing.		 */		if (pk->u.ec.publicValue.len == 0) {		    rv = EC_NewKeyFromSeed(&pk->u.ec.ecParams, 				      &ecpriv, pk->u.ec.privateValue.data,				      pk->u.ec.privateValue.len);		    if (rv == SECSuccess) {			SECITEM_CopyItem(permarena, &pk->u.ec.publicValue,					 &(ecpriv->publicValue));			PORT_FreeArena(ecpriv->ecParams.arena, PR_TRUE);		    }		} else {		    /* If publicValue was filled as part of DER decoding,		     * change length in bits to length in bytes.		     */		    pk->u.ec.publicValue.len >>= 3;		}		break;#endif /* NSS_ENABLE_ECC */	      default:		rv = SECFailure;		break;	    }	}	else if(PORT_GetError() == SEC_ERROR_BAD_DER)	{	    PORT_SetError(SEC_ERROR_BAD_PASSWORD);	    goto loser;	}    }    /* let success fall through */loser:    if(temparena != NULL)	PORT_FreeArena(temparena, PR_TRUE);    if(dest != NULL)	SECITEM_ZfreeItem(dest, PR_TRUE);    if(rv != SECSuccess)    {	if(permarena != NULL)	    PORT_FreeArena(permarena, PR_TRUE);	pk = NULL;    }    return pk;}