CERT_CertificateRequestTemplate);
SEC_ASN1_GET(CERT_CertificateRequestTemplate));
GenerateCertRequest(JNIEnv *env, 		    unsigned int ktype, const char *subject, int keysize,		    PK11SlotInfo *slot,		     unsigned char **b64request,		    PQGParams *dsaParams) {	CERTCertificateRequest *req;	SECKEYPrivateKey *privk = NULL;	SECKEYPublicKey *pubk = NULL;	SECStatus rv;	PRArenaPool *arena;	SECItem result_der, result;	SECItem *blob;#ifdef DEBUG      	printf("in GenerateCertRequest(), subject=%s, keysize = %d",	       subject, keysize);#endif	if( GenerateKeyPair(env, ktype, slot, &pubk, &privk, keysize,			    dsaParams) != SECSuccess) {#ifdef DEBUG      		printf("Error generating keypair.");#endif	}#ifdef DEBUG      	printf("before make_cert_request");#endif	req = make_cert_request (env, subject, pubk);#ifdef DEBUG      	printf("after make_cert_request");#endif	if (req == NULL) {	  return;	}	result_der.len = 0;	result_der.data = NULL;#ifdef DEBUG      	printf("before SEC_ASN1EncodeItem");#endif	/* der encode the request */	blob = SEC_ASN1EncodeItem(req->arena, &result_der, req,				  CERT_CertificateRequestTemplate);	/* sign the request */	arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);	if ( !arena ) {	  JSS_throw(env, OUT_OF_MEMORY_ERROR);	  return;	}	rv = SEC_DerSignData(arena, &result, result_der.data, result_der.len,			     privk,                         (ktype==KEYTYPE_RSA)? SEC_OID_PKCS1_MD5_WITH_RSA_ENCRYPTION:SEC_OID_ANSIX9_DSA_SIGNATURE_WITH_SHA1_DIGEST);	if (rv) {	  JSS_nativeThrowMsg(env, TOKEN_EXCEPTION,			     "signing of data failed");	  return;	}	*b64request = (unsigned char*) BTOA_DataToAscii(result.data, result.len);#ifdef DEBUG      	printf("data = %s\n", *b64request);#endif}