此错误来自crypto/rsa/rsa_none.c
int RSA_padding_add_none(unsigned char *to, int tlen,
const unsigned char *from, int flen)
{
if (flen > tlen)
{
RSAerr(RSA_F_RSA_PADDING_ADD_NONE,RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE);
return(0);
}
if (flen < tlen)
{
RSAerr(RSA_F_RSA_PADDING_ADD_NONE,RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE);
return(0);
}
memcpy(to,from,(unsigned int)flen);
return(1);
}
从rypto/rsa/rsa_eay.c 调用
static int RSA_eay_public_encrypt(int flen, const unsigned char *from,
unsigned char *to, RSA *rsa, int padding)
...
i=RSA_padding_add_none(buf,num,from,flen);
是flen
一条消息 len;并且tlen
来自:num=BN_num_bytes(rsa->n);
因此,您需要您的数据具有与RSA 密钥参数相同的字节长度N
另外,据我所知,您的数据必须小于 N(如果将其视为单个 long-long-long 二进制数)