PEMerr(PEM_F_PEM_WRITE_BIO_PKCS8PRIVATEKEY, PEM_R_READ_KEY);
PEMerr(PEM_F_DO_PK8PKEY,PEM_R_READ_KEY);
static int do_pk8pkey(BIO *bp, EVP_PKEY *x, int isder, int nid, const EVP_CIPHER *enc,				  char *kstr, int klen,				  pem_password_cb *cb, void *u){	X509_SIG *p8;	PKCS8_PRIV_KEY_INFO *p8inf;	char buf[PEM_BUFSIZE];	int ret;	if(!(p8inf = EVP_PKEY2PKCS8(x))) {		PEMerr(PEM_F_PEM_WRITE_BIO_PKCS8PRIVATEKEY,					PEM_R_ERROR_CONVERTING_PRIVATE_KEY);		return 0;	}	if(enc || (nid != -1)) {		if(!kstr) {			if(!cb) klen = PEM_def_callback(buf, PEM_BUFSIZE, 1, u);			else klen = cb(buf, PEM_BUFSIZE, 1, u);			if(klen <= 0) {				PEMerr(PEM_F_PEM_WRITE_BIO_PKCS8PRIVATEKEY,								PEM_R_READ_KEY);				PKCS8_PRIV_KEY_INFO_free(p8inf);				return 0;			}							kstr = buf;		}		p8 = PKCS8_encrypt(nid, enc, kstr, klen, NULL, 0, 0, p8inf);		if(kstr == buf) OPENSSL_cleanse(buf, klen);		PKCS8_PRIV_KEY_INFO_free(p8inf);		if(isder) ret = i2d_PKCS8_bio(bp, p8);		else ret = PEM_write_bio_PKCS8(bp, p8);		X509_SIG_free(p8);		return ret;	} else {		if(isder) ret = i2d_PKCS8_PRIV_KEY_INFO_bio(bp, p8inf);		else ret = PEM_write_bio_PKCS8_PRIV_KEY_INFO(bp, p8inf);		PKCS8_PRIV_KEY_INFO_free(p8inf);		return ret;	}}