if (len + 3 > RSAref_MAX_LEN) { RSAREFerr(RSAREF_F_RSA_REF_PUBLIC_ENCRYPT,RSAREF_R_LEN); goto err; }
int RSA_ref_public_encrypt(int len, unsigned char *from, unsigned char *to,	     RSA *rsa, int padding)	{	int outlen= -1;	int i;	RSArefPublicKey RSAkey;	RSARandomState rnd;	unsigned char buf[16];	if (padding != RSA_PKCS1_PADDING && padding != RSA_SSLV23_PADDING) 		{		RSAREFerr(RSAREF_F_RSA_REF_PUBLIC_ENCRYPT, RSA_R_UNKNOWN_PADDING_TYPE);		goto err;		}		R_RandomInit(&rnd);	R_GetRandomBytesNeeded((unsigned int *)&i,&rnd);	while (i > 0)		{		RAND_bytes(buf,16);		R_RandomUpdate(&rnd,buf,(unsigned int)((i>16)?16:i));		i-=16;		}	if (!RSAref_Public_eay2ref(rsa,&RSAkey))		goto err;	if (len + 3 > RSAref_MAX_LEN)		{		RSAREFerr(RSAREF_F_RSA_REF_PUBLIC_ENCRYPT,RSAREF_R_LEN);		goto err;		}	if ((i=RSAPublicEncrypt(to,&outlen,from,len,&RSAkey,&rnd)) != 0)		{		RSAREFerr(RSAREF_F_RSA_REF_PUBLIC_ENCRYPT,i);		outlen= -1;		goto err;		}err:	memset(&RSAkey,0,sizeof(RSAkey));	R_RandomFinal(&rnd);	memset(&rnd,0,sizeof(rnd));	return(outlen);	}