Openssl RSA编程代码在pc机上可以正常运行。
交叉编译到ARM 上会有错误,
错误信息error:0306E06C:bignum routines:BN_mod_inverse:no inverse。求大神指教。
``RSA *rsa = NULL;
BIO *bio = NULL;
int rsa_len = 0;
int num = 0;
if ((bio = BIO_new_mem_buf((void *)PubKeyAuth, -1)) == NULL)
{
return RSA_ENCRYPT_ERROR;
}
if ((rsa = PEM_read_bio_RSA_PUBKEY(bio, NULL, NULL, NULL)) == NULL)
{
return RSA_ENCRYPT_ERROR;
}
BIO_free_all(bio);
rsa_len = RSA_size(rsa);
num = RSA_public_encrypt(rsa_len, (unsigned char *)str, (unsigned char *)SendMessageBuff, rsa, RSA_PKCS1_PADDING );
if (num < 0)
{
return RSA_ENCRYPT_ERROR;
}
RSA_free(rsa);
return num;`