pk->keyType = dsaKey;
pk->keyType = lowDSAKey;
seckey_decrypt_private_key(SECKEYEncryptedPrivateKeyInfo *epki,			   SECItem *pwitem){    SECKEYLowPrivateKey *pk = NULL;    SECKEYPrivateKeyInfo *pki = NULL;    SECStatus rv = SECFailure;    SECOidTag algorithm;    PLArenaPool *temparena = NULL, *permarena = NULL;    SECItem *salt = NULL, *dest = NULL, *key = NULL;    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 = (SECKEYPrivateKeyInfo *)PORT_ArenaZAlloc(temparena, 	sizeof(SECKEYPrivateKeyInfo));    /* allocate permanent arena items */    pk = (SECKEYLowPrivateKey *)PORT_ArenaZAlloc(permarena,	sizeof(SECKEYLowPrivateKey));    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_cipher(key, &epki->encryptedData, 			PR_FALSE);		}	    }		    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. */	    dest = SEC_PKCS5CipherData(&epki->algorithm, pwitem, 		&epki->encryptedData, PR_FALSE, NULL);	    break;    }    if(dest != NULL)    {	rv = SEC_ASN1DecodeItem(temparena, pki, 	    SECKEY_PrivateKeyInfoTemplate, dest);	if(rv == SECSuccess)	{	    switch(SECOID_GetAlgorithmTag(&pki->algorithm)) {	      case SEC_OID_X500_RSA_ENCRYPTION:	      case SEC_OID_PKCS1_RSA_ENCRYPTION:		pk->keyType = rsaKey;		rv = SEC_ASN1DecodeItem(permarena, pk,					SECKEY_RSAPrivateKeyTemplate,					&pki->privateKey);		break;	      case SEC_OID_ANSIX9_DSA_SIGNATURE:		pk->keyType = dsaKey;		rv = SEC_ASN1DecodeItem(permarena, pk,					SECKEY_DSAPrivateKeyTemplate,					&pki->privateKey);		if (rv != SECSuccess)		    goto loser;		rv = SEC_ASN1DecodeItem(permarena, &pk->u.dsa.params,					SECKEY_PQGParamsTemplate,					&pki->algorithm.parameters);		break;	      case SEC_OID_X942_DIFFIE_HELMAN_KEY:		pk->keyType = dhKey;		rv = SEC_ASN1DecodeItem(permarena, pk,					SECKEY_DHPrivateKeyTemplate,					&pki->privateKey);		break;	      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;}