简体   繁体   中英

C program for large file encryption/decryption using asymmetric keys

I am stuck on this problem where I need to do a encrypt-decrypt on a large file (>5MB) using asymmetric key with the help of OpenSSL.

Below is a brief description of my requirement:-

  1. I have a device running with Linux on it.
  2. The device can download a firmware image/patch from a server.
  3. The image/patch in the server will be encrypted using a public key which will be already shared to them.
  4. Once the image is downloaded, the device needs to verify its authenticity by decrypting it using the private key.
  5. The target device will use OpenSSL libraries built and installed on it for decryption.
  6. Along with this the target device needs to verify the signature of the firmware image/patch downloaded.

I have found a number of different ways of doing it on the Internet. The most appealing way to me is using OpenSSL S/MIME encrypt/decrypt . But I didn't find a suitable library/tool for doing this using C programming language. All the examples that I've found were mostly using a console application.

There were some sample C programs but those were not doing the encryption and decryption using asymmetric keys; they used a random 128 bit key and IV instead.

Could anyone please help me by providing some examples.

Do not forget that OpenSSL is open-source. If you want to see the source code of "openssl smime" command than you need to take a look at apps/smime.c file in openssl source code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM