prepare_dsa_pub_key_for_asn1(pubk);
SECKEY_CreateSubjectPublicKeyInfo(SECKEYPublicKey *pubk){    CERTSubjectPublicKeyInfo *spki;    PRArenaPool *arena;    SECItem params = { siBuffer, NULL, 0 };    arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);    if (arena == NULL) {	PORT_SetError(SEC_ERROR_NO_MEMORY);	return NULL;    }    spki = (CERTSubjectPublicKeyInfo *) PORT_ArenaZAlloc(arena, sizeof (*spki));    if (spki != NULL) {	SECStatus rv;	SECItem *rv_item;		spki->arena = arena;	switch(pubk->keyType) {	  case rsaKey:	    rv = SECOID_SetAlgorithmID(arena, &spki->algorithm,				     SEC_OID_PKCS1_RSA_ENCRYPTION, 0);	    if (rv == SECSuccess) {		/*		 * DER encode the public key into the subjectPublicKeyInfo.		 */		rv_item = SEC_ASN1EncodeItem(arena, &spki->subjectPublicKey,					     pubk, SECKEY_RSAPublicKeyTemplate);		if (rv_item != NULL) {		    /*		     * The stored value is supposed to be a BIT_STRING,		     * so convert the length.		     */		    spki->subjectPublicKey.len <<= 3;		    /*		     * We got a good one; return it.		     */		    return spki;		}	    }	    break;	  case dsaKey:	    /* DER encode the params. */	    rv_item = SEC_ASN1EncodeItem(arena, &params, &pubk->u.dsa.params,					 SECKEY_PQGParamsTemplate);	    if (rv_item != NULL) {		rv = SECOID_SetAlgorithmID(arena, &spki->algorithm,					   SEC_OID_ANSIX9_DSA_SIGNATURE,					   &params);		if (rv == SECSuccess) {		    /*		     * DER encode the public key into the subjectPublicKeyInfo.		     */		    rv_item = SEC_ASN1EncodeItem(arena, &spki->subjectPublicKey,						 pubk,						 SECKEY_DSAPublicKeyTemplate);		    if (rv_item != NULL) {			/*			 * The stored value is supposed to be a BIT_STRING,			 * so convert the length.			 */			spki->subjectPublicKey.len <<= 3;			/*			 * We got a good one; return it.			 */			return spki;		    }		}	    }	    SECITEM_FreeItem(&params, PR_FALSE);	    break;	  case keaKey:	  case dhKey: /* later... */	  break;  	  case fortezzaKey:#ifdef notdef	    /* encode the DSS parameters (PQG) */	    rv = FortezzaBuildParams(&params,pubk);	    if (rv != SECSuccess) break;	    /* set the algorithm */	    rv = SECOID_SetAlgorithmID(arena, &spki->algorithm,				       SEC_OID_MISSI_KEA_DSS, &params);	    PORT_Free(params.data);	    if (rv == SECSuccess) {		/*		 * Encode the public key into the subjectPublicKeyInfo.		 * Fortezza key material is not standard DER		 */		rv = FortezzaEncodeCertKey(arena,&spki->subjectPublicKey,pubk);		if (rv == SECSuccess) {		    /*		     * The stored value is supposed to be a BIT_STRING,		     * so convert the length.		     */		    spki->subjectPublicKey.len <<= 3;		    /*		     * We got a good one; return it.		     */		    return spki;		}	    }#endif	    break;	  default:	    break;	}    } else {	PORT_SetError(SEC_ERROR_NO_MEMORY);    }    PORT_FreeArena(arena, PR_FALSE);    return NULL;}