我正在尝试使用 OpenSSL 在 linux 上运行的嵌入式系统上加密字符串。本系统采用imx6ul微处理器。它包含一个硬件加密引擎。
root@imx6ulevk:/# openssl version
OpenSSL 1.0.2d 9 Jul 2015
root@imx6ulevk:/# openssl engine
(cryptodev) BSD cryptodev engine
(dynamic) Dynamic engine loading support
当我在代码中调用 RSA_public_encrypt() 函数时,它会出错。
root@imx6ulevk:/vp/test# ./RsaEnDc
cryptodev_digest_update: illegal inputs
error:00000000:lib(0):func(0):reason(0)
当我在嵌入式系统启动时删除加载的cryptodev驱动程序然后运行程序时,它工作正常。但我需要 cryptodev 支持我系统中的其他操作。
这是我的代码
void encrypt(RSA* pRsaKey, char* message, int msgLen, char* cipher, int *cipherLen)
{
if((*cipherLen = RSA_public_encrypt(msgLen, (unsigned char*)message, (unsigned char*)cipher, pRsaKey, RSA_PKCS1_OAEP_PADDING)) == -1)
{
ERR_load_crypto_strings();
fprintf(stderr, "Error encrypting message: %s\n", ERR_error_string(ERR_get_error(), NULL));
}
}
有没有办法指定 RSA_public_encrypt() 函数不使用 cryptodev 引擎?