case dsaKey:
case lowDSAKey:
pk11_importPrivateKey(PK11Slot *slot,SECKEYLowPrivateKey *lowPriv,							SECItem *dbKey){    PK11Object *privateKey;    CK_KEY_TYPE key_type;    CK_BBOOL cktrue = CK_TRUE;    CK_BBOOL ckfalse = CK_FALSE;    CK_BBOOL sign = CK_TRUE;    CK_BBOOL recover = CK_TRUE;    CK_BBOOL decrypt = CK_TRUE;    CK_BBOOL derive = CK_FALSE;    CK_RV crv = CKR_OK;    CK_OBJECT_CLASS privClass = CKO_PRIVATE_KEY;    unsigned char cka_id[SHA1_LENGTH];    /*     * now lets create an object to hang the attributes off of     */    privateKey = pk11_NewObject(slot); /* fill in the handle later */    if (privateKey == NULL) {	pk11_FreeObject(privateKey);	return NULL;    }    /* Netscape Private Attribute for dealing with database storeage */	    if (pk11_AddAttributeType(privateKey, CKA_NETSCAPE_DB,					pk11_item_expand(dbKey)) ) {	 pk11_FreeObject(privateKey);	 return NULL;    }    /* now force the CKA_ID */    SHA1_HashBuf(cka_id, (unsigned char *)dbKey->data, (uint32)dbKey->len);    if (pk11_AddAttributeType(privateKey, CKA_ID, cka_id, sizeof(cka_id))) {	 pk11_FreeObject(privateKey);	 return NULL;    }    /* Fill in the common Default values */    if (pk11_AddAttributeType(privateKey,CKA_CLASS, &privClass,					sizeof(CK_OBJECT_CLASS)) != CKR_OK) {	 pk11_FreeObject(privateKey);	 return NULL;    }    if (pk11_AddAttributeType(privateKey,CKA_TOKEN, &cktrue,					      sizeof(CK_BBOOL)) != CKR_OK) {	pk11_FreeObject(privateKey);	return NULL;    }    if (pk11_AddAttributeType(privateKey,CKA_PRIVATE, &cktrue,					      sizeof(CK_BBOOL)) != CKR_OK) {	pk11_FreeObject(privateKey);	return NULL;    }    if (pk11_AddAttributeType(privateKey,CKA_MODIFIABLE, &cktrue,					      sizeof(CK_BBOOL)) != CKR_OK) {	pk11_FreeObject(privateKey);	return NULL;    }    if (pk11_AddAttributeType(privateKey,CKA_LABEL, NULL, 0) != CKR_OK) {	pk11_FreeObject(privateKey);	return NULL;    }    if (pk11_AddAttributeType(privateKey,CKA_START_DATE, NULL, 0) != CKR_OK) {	pk11_FreeObject(privateKey);	return NULL;    }    if (pk11_AddAttributeType(privateKey,CKA_END_DATE, NULL, 0) != CKR_OK) {	pk11_FreeObject(privateKey);	return NULL;    }    if (pk11_AddAttributeType(privateKey,CKA_DERIVE, &ckfalse,					      sizeof(CK_BBOOL)) != CKR_OK) {	pk11_FreeObject(privateKey);	return NULL;    }    /* local: well we really don't know for sure... it could have been an      * imported key, but it's not a useful attribute anyway. */    if (pk11_AddAttributeType(privateKey,CKA_LOCAL, &cktrue,					      sizeof(CK_BBOOL)) != CKR_OK) {	pk11_FreeObject(privateKey);	return NULL;    }    if (pk11_AddAttributeType(privateKey,CKA_SUBJECT, NULL, 0) != CKR_OK) {	pk11_FreeObject(privateKey);	return NULL;    }    if (pk11_AddAttributeType(privateKey,CKA_SENSITIVE, &cktrue,					      sizeof(CK_BBOOL)) != CKR_OK) {	pk11_FreeObject(privateKey);	return NULL;    }    if (pk11_AddAttributeType(privateKey,CKA_EXTRACTABLE, &cktrue,					      sizeof(CK_BBOOL)) != CKR_OK) {	pk11_FreeObject(privateKey);	return NULL;    }    /* is this really true? Maybe we should just say false here? */    if (pk11_AddAttributeType(privateKey,CKA_ALWAYS_SENSITIVE, &cktrue,					      sizeof(CK_BBOOL)) != CKR_OK) {	pk11_FreeObject(privateKey);	return NULL;    }    if (pk11_AddAttributeType(privateKey,CKA_NEVER_EXTRACTABLE, &ckfalse,					      sizeof(CK_BBOOL)) != CKR_OK) {	pk11_FreeObject(privateKey);	return NULL;    }    /* Now Set up the parameters to generate the key (based on mechanism) */    /* NOTE: for safety sake we *DO NOT* remember critical attributes. PKCS #11     * will look them up again from the database when it needs them.     */    switch (lowPriv->keyType) {    case rsaKey:	/* format the keys */	key_type = CKK_RSA;	sign = CK_TRUE;	recover = CK_TRUE;	decrypt = CK_TRUE;	derive = CK_FALSE;        /* now fill in the RSA dependent parameters in the public key */        crv = pk11_AddAttributeType(privateKey,CKA_MODULUS,			   pk11_item_expand(&lowPriv->u.rsa.modulus));	if (crv != CKR_OK) break;        crv = pk11_AddAttributeType(privateKey,CKA_PRIVATE_EXPONENT,NULL,0);	if (crv != CKR_OK) break;        crv = pk11_AddAttributeType(privateKey,CKA_PUBLIC_EXPONENT,			   pk11_item_expand(&lowPriv->u.rsa.publicExponent));	if (crv != CKR_OK) break;        crv = pk11_AddAttributeType(privateKey,CKA_PRIME_1,NULL,0);	if (crv != CKR_OK) break;        crv = pk11_AddAttributeType(privateKey,CKA_PRIME_2,NULL,0);	if (crv != CKR_OK) break;        crv = pk11_AddAttributeType(privateKey,CKA_EXPONENT_1,NULL,0);	if (crv != CKR_OK) break;        crv = pk11_AddAttributeType(privateKey,CKA_EXPONENT_2,NULL,0);	if (crv != CKR_OK)  break;        crv = pk11_AddAttributeType(privateKey,CKA_COEFFICIENT,NULL,0);	break;    case dsaKey:	key_type = CKK_DSA;	sign = CK_TRUE;	recover = CK_FALSE;	decrypt = CK_FALSE;	derive = CK_FALSE;	crv = pk11_AddAttributeType(privateKey,CKA_PRIME,			   pk11_item_expand(&lowPriv->u.dsa.params.prime));	if (crv != CKR_OK) break;	crv = pk11_AddAttributeType(privateKey,CKA_SUBPRIME,			   pk11_item_expand(&lowPriv->u.dsa.params.subPrime));	if (crv != CKR_OK) break;	crv = pk11_AddAttributeType(privateKey,CKA_BASE,			   pk11_item_expand(&lowPriv->u.dsa.params.base));	if (crv != CKR_OK) break;	crv = pk11_AddAttributeType(privateKey,CKA_VALUE,NULL,0);	if (crv != CKR_OK) break;	break;    case dhKey:	key_type = CKK_DH;	sign = CK_FALSE;	decrypt = CK_FALSE;	recover = CK_FALSE;	derive = CK_TRUE;	crv = CKR_MECHANISM_INVALID;	break;    default:	crv = CKR_MECHANISM_INVALID;    }    if (crv != CKR_OK) {	pk11_FreeObject(privateKey);	return NULL;    }    if (pk11_AddAttributeType(privateKey,CKA_SIGN, &sign,					      sizeof(CK_BBOOL)) != CKR_OK) {	pk11_FreeObject(privateKey);	return NULL;    }    if (pk11_AddAttributeType(privateKey,CKA_SIGN_RECOVER, &recover,					      sizeof(CK_BBOOL)) != CKR_OK) {	pk11_FreeObject(privateKey);	return NULL;    }    if (pk11_AddAttributeType(privateKey,CKA_DECRYPT, &decrypt,					      sizeof(CK_BBOOL)) != CKR_OK) {	pk11_FreeObject(privateKey);	return NULL;    }    if (pk11_AddAttributeType(privateKey,CKA_UNWRAP, &decrypt,					      sizeof(CK_BBOOL)) != CKR_OK) {	pk11_FreeObject(privateKey);	return NULL;    }    if (pk11_AddAttributeType(privateKey,CKA_DERIVE, &derive,					      sizeof(CK_BBOOL)) != CKR_OK) {	pk11_FreeObject(privateKey);	return NULL;    }    if (pk11_AddAttributeType(privateKey,CKA_KEY_TYPE,&key_type,					     sizeof(CK_KEY_TYPE)) != CKR_OK) {	 pk11_FreeObject(privateKey);	 return NULL;    }    PK11_USE_THREADS(PZ_Lock(slot->objectLock);)    privateKey->handle = slot->tokenIDCount++;    privateKey->handle |= (PK11_TOKEN_MAGIC | PK11_TOKEN_TYPE_PRIV);    PK11_USE_THREADS(PZ_Unlock(slot->objectLock);)    privateKey->objclass = privClass;    privateKey->slot = slot;    privateKey->inDB = PR_TRUE;    return privateKey;}