RSA encryption and BSD cryptodev engine

461 views Asked by At

I'm trying to encrypt a string on an embedded system running on linux using OpenSSL. The system uses imx6ul microprocessor. It consists with a hardware crypto engine.

root@imx6ulevk:/# openssl version
OpenSSL 1.0.2d 9 Jul 2015
root@imx6ulevk:/# openssl engine
(cryptodev) BSD cryptodev engine
(dynamic) Dynamic engine loading support

When I call RSA_public_encrypt() function in my code it gives an error.

root@imx6ulevk:/vp/test# ./RsaEnDc 
cryptodev_digest_update: illegal inputs
error:00000000:lib(0):func(0):reason(0)

And when I remove loading cryptodev driver at the startup of my embedded system and then run the program, it works fine. But I need the cryptodev support for other operations in my system.

Here is my code

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));
    }
}

Is there any way to specify RSA_public_encrypt() function not to use cryptodev engine?

0

There are 0 answers