OPENSSL_assert(strlen(objstr)+23+2*enc->iv_len+13 <= sizeof buf);
int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,	     unsigned char *kstr, int klen, pem_password_cb *cb, void *u)	{	EVP_CIPHER_CTX ctx;	int i,ret=0;	unsigned char *data=NULL;	const char *objstr=NULL;	char buf[PEM_BUFSIZE];	unsigned char *iv=NULL;		if (enc != NULL)		{		objstr=OBJ_nid2sn(EVP_CIPHER_nid(enc));		if (objstr == NULL)			{			PEMerr(PEM_F_PEM_X509_INFO_WRITE_BIO,PEM_R_UNSUPPORTED_CIPHER);			goto err;			}		}	/* now for the fun part ... if we have a private key then 	 * we have to be able to handle a not-yet-decrypted key	 * being written out correctly ... if it is decrypted or	 * it is non-encrypted then we use the base code	 */	if (xi->x_pkey!=NULL)		{		if ( (xi->enc_data!=NULL) && (xi->enc_len>0) )			{			/* copy from weirdo names into more normal things */			iv=xi->enc_cipher.iv;			data=(unsigned char *)xi->enc_data;			i=xi->enc_len;			/* we take the encryption data from the			 * internal stuff rather than what the			 * user has passed us ... as we have to 			 * match exactly for some strange reason			 */			objstr=OBJ_nid2sn(				EVP_CIPHER_nid(xi->enc_cipher.cipher));			if (objstr == NULL)				{				PEMerr(PEM_F_PEM_X509_INFO_WRITE_BIO,PEM_R_UNSUPPORTED_CIPHER);				goto err;				}			/* create the right magic header stuff */			buf[0]='\0';			PEM_proc_type(buf,PEM_TYPE_ENCRYPTED);			PEM_dek_info(buf,objstr,enc->iv_len,(char *)iv);			/* use the normal code to write things out */			i=PEM_write_bio(bp,PEM_STRING_RSA,buf,data,i);			if (i <= 0) goto err;			}		else			{			/* Add DSA/DH */#ifndef OPENSSL_NO_RSA			/* normal optionally encrypted stuff */			if (PEM_write_bio_RSAPrivateKey(bp,				xi->x_pkey->dec_pkey->pkey.rsa,				enc,kstr,klen,cb,u)<=0)				goto err;#endif			}		}	/* if we have a certificate then write it out now */	if ((xi->x509 != NULL) && (PEM_write_bio_X509(bp,xi->x509) <= 0))		goto err;	/* we are ignoring anything else that is loaded into the X509_INFO	 * structure for the moment ... as I don't need it so I'm not	 * coding it here and Eric can do it when this makes it into the	 * base library --tjh	 */	ret=1;err:	memset((char *)&ctx,0,sizeof(ctx));	memset(buf,0,PEM_BUFSIZE);	return(ret);	}