{ ret=i; break; }
return i;
static long enc_ctrl(BIO *b, int cmd, long num, void *ptr)	{	BIO *dbio;	BIO_ENC_CTX *ctx,*dctx;	long ret=1;	int i;	EVP_CIPHER_CTX **c_ctx;	ctx=(BIO_ENC_CTX *)b->ptr;	switch (cmd)		{	case BIO_CTRL_RESET:		ctx->ok=1;		ctx->finished=0;		EVP_CipherInit_ex(&(ctx->cipher),NULL,NULL,NULL,NULL,			ctx->cipher.encrypt);		ret=BIO_ctrl(b->next_bio,cmd,num,ptr);		break;	case BIO_CTRL_EOF:	/* More to read */		if (ctx->cont <= 0)			ret=1;		else			ret=BIO_ctrl(b->next_bio,cmd,num,ptr);		break;	case BIO_CTRL_WPENDING:		ret=ctx->buf_len-ctx->buf_off;		if (ret <= 0)			ret=BIO_ctrl(b->next_bio,cmd,num,ptr);		break;	case BIO_CTRL_PENDING: /* More to read in buffer */		ret=ctx->buf_len-ctx->buf_off;		if (ret <= 0)			ret=BIO_ctrl(b->next_bio,cmd,num,ptr);		break;	case BIO_CTRL_FLUSH:		/* do a final write */again:		while (ctx->buf_len != ctx->buf_off)			{			i=enc_write(b,NULL,0);			if (i < 0)				{				ret=i;				break;				}			}		if (!ctx->finished)			{			ctx->finished=1;			ctx->buf_off=0;			ret=EVP_CipherFinal_ex(&(ctx->cipher),				(unsigned char *)ctx->buf,				&(ctx->buf_len));			ctx->ok=(int)ret;			if (ret <= 0) break;			/* push out the bytes */			goto again;			}				/* Finally flush the underlying BIO */		ret=BIO_ctrl(b->next_bio,cmd,num,ptr);		break;	case BIO_C_GET_CIPHER_STATUS:		ret=(long)ctx->ok;		break;	case BIO_C_DO_STATE_MACHINE:		BIO_clear_retry_flags(b);		ret=BIO_ctrl(b->next_bio,cmd,num,ptr);		BIO_copy_next_retry(b);		break;	case BIO_C_GET_CIPHER_CTX:		c_ctx=(EVP_CIPHER_CTX **)ptr;		(*c_ctx)= &(ctx->cipher);		b->init=1;		break;	case BIO_CTRL_DUP:		dbio=(BIO *)ptr;		dctx=(BIO_ENC_CTX *)dbio->ptr;		memcpy(&(dctx->cipher),&(ctx->cipher),sizeof(ctx->cipher));		dbio->init=1;		break;	default:		ret=BIO_ctrl(b->next_bio,cmd,num,ptr);		break;		}	return(ret);	}