privKey->keyType = dhKey;
privKey->keyType = lowDHKey;
pk11_mkPrivKey(PK11Object *object,CK_KEY_TYPE key_type){    SECKEYLowPrivateKey *privKey;    PLArenaPool *arena;    CK_RV crv = CKR_OK;    SECStatus rv;    arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);    if (arena == NULL) return NULL;    privKey = (SECKEYLowPrivateKey *)			PORT_ArenaAlloc(arena,sizeof(SECKEYLowPrivateKey));    if (privKey == NULL)  {	PORT_FreeArena(arena,PR_FALSE);	return NULL;    }    /* in future this would be a switch on key_type */    privKey->arena = arena;    switch (key_type) {    case CKK_RSA:	privKey->keyType = rsaKey;	crv=pk11_Attribute2SSecItem(arena,&privKey->u.rsa.modulus,							object,CKA_MODULUS);	if (crv != CKR_OK) break;	crv=pk11_Attribute2SSecItem(arena,&privKey->u.rsa.publicExponent,object,							CKA_PUBLIC_EXPONENT);	if (crv != CKR_OK) break;	crv=pk11_Attribute2SSecItem(arena,&privKey->u.rsa.privateExponent,object,							CKA_PRIVATE_EXPONENT);	if (crv != CKR_OK) break;	crv=pk11_Attribute2SSecItem(arena,&privKey->u.rsa.prime1,object,								CKA_PRIME_1);	if (crv != CKR_OK) break;	crv=pk11_Attribute2SSecItem(arena,&privKey->u.rsa.prime2,object,								CKA_PRIME_2);	if (crv != CKR_OK) break;	crv=pk11_Attribute2SSecItem(arena,&privKey->u.rsa.exponent1,						object, CKA_EXPONENT_1);	if (crv != CKR_OK) break;	crv=pk11_Attribute2SSecItem(arena,&privKey->u.rsa.exponent2,							object, CKA_EXPONENT_2);	if (crv != CKR_OK) break;	crv=pk11_Attribute2SSecItem(arena,&privKey->u.rsa.coefficient,object,							      CKA_COEFFICIENT);	if (crv != CKR_OK) break;        rv = DER_SetUInteger(privKey->arena, &privKey->u.rsa.version,                          SEC_PRIVATE_KEY_VERSION);	if (rv != SECSuccess) crv = CKR_HOST_MEMORY;	break;    case CKK_DSA:	privKey->keyType = dsaKey;	crv = pk11_Attribute2SSecItem(arena,&privKey->u.dsa.params.prime,							object,CKA_PRIME);    	if (crv != CKR_OK) break;	crv = pk11_Attribute2SSecItem(arena,&privKey->u.dsa.params.subPrime,							object,CKA_SUBPRIME);    	if (crv != CKR_OK) break;	crv = pk11_Attribute2SSecItem(arena,&privKey->u.dsa.params.base,							object,CKA_BASE);    	if (crv != CKR_OK) break;    	crv = pk11_Attribute2SSecItem(arena,&privKey->u.dsa.privateValue,							object,CKA_VALUE);    	if (crv != CKR_OK) break;    	crv = pk11_Attribute2SSecItem(arena,&privKey->u.dsa.publicValue,							object,CKA_NETSCAPE_DB);	/* can't set the public value.... */	break;    case CKK_DH:	privKey->keyType = dhKey;	crv = pk11_Attribute2SSecItem(arena,&privKey->u.dh.prime,							object,CKA_PRIME);    	if (crv != CKR_OK) break;	crv = pk11_Attribute2SSecItem(arena,&privKey->u.dh.base,							object,CKA_BASE);    	if (crv != CKR_OK) break;    	crv = pk11_Attribute2SSecItem(arena,&privKey->u.dh.privateValue,							object,CKA_VALUE);	break;    default:	crv = CKR_KEY_TYPE_INCONSISTENT;	break;    }    if (crv != CKR_OK) {	PORT_FreeArena(arena,PR_FALSE);	return NULL;    }    return privKey;}