This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Checksums and Encryption of large files using the OCF /dev/crypto

Hi,

I have successfully installed the OCF on my DM814x system which enables the HW acceleration of the DSP. All the test code runs correctly and I get good performance.

But I cannot get it to work with buffers/files larger than 64K.

In cryptodev.h I can see that there is a limitation of CRYPTO_MAX_DATA_LEN (which is set to 64K-1) so I assume that this is the largest data size that can be processed per call to /dev/crypto but I cannot figure out how to split larger buffers into multiple calls into /dev/crypto in order to achieve the processing of larger buffers!

Can someone please help me get around this problem since I will typically have to get MD5/SHA-1/... for buffers larger than 1MB.

Best regards,

Karsten

  • Karsten,

    A good reference would be the Wiki for DM814x cryptodriver.

    http://processors.wiki.ti.com/index.php/Installing_AM387x_C6A814x_DM814x_Crypto_Support

    There is a section at the bottom on using cryptotest from the OCF software package.  The app cryptotest allows you to run an encrypt/decrypt sequence multiple times on various block sizes.  The parameter "count" is number of times to run the encrypt/decrypt sequence and "size" is for the block size.

    root@dm814x-evm:~# ./cryptotest --help
    usage: ./cryptotest [-czsbvVKD] [-d dev] [-a algorithm] [count] [size ...]
    where algorithm is one of:
    des 3des (default) blf (blowfish) cast skj (skipjack)
    aes (aka rijndael) aes192 aes256 arc4
    md5 md5_hmac sha1 sha1_hmac sha256 sha256_hmac
    sha384 sha384_hmac sha512 sha512_hmac
    count is the number of encrypt/decrypt ops to do
    size is the number of bytes of text to encrypt+decrypt

    -c check the results (slows timing)
    -d use specific device
    -z run all available algorithms on a variety of sizes
    -v be verbose
    -b mark operations for batching
    -p profile kernel crypto operation (must be root)
    -V swap IV
    -K swap KEY
    -D swap DATA
    root@dm814x-evm:~#
    root@dm814x-evm:~# ./cryptotest -c -a aes 128 64
    0.055 sec, 256 aes crypts, 64 bytes, 296925 byte/sec, 2.3 Mb/sec
    root@dm814x-evm:~#
    In the example above, the aes algorithm runs 256 times (128 encrypt/128 decrypt) on a block size of 64.  
    The -c switch performs a check of the data to see that the data is correct.

    You can also have a look in http://processors.wiki.ti.com/index.php/Cryptography_Users_Guide

    SHA Hash
    This example will perform a SHA1 hash function on the 10M file of random data (rnddata).  If the file doesn't exist, it is generated.

    Best regards,
    Pavel
  • Hi Pavel,

    I am running my system with the IPNC 2.8 (which has got IPNC PSP 04_04_00_01 package).

    I have already successfully followed the Crypto Support Wiki and got everything up and running before my original post and the ./cryptotest works correctly.

    The problem with the ./cryptotest test is that it only uses buffer sizes up to 65280 bytes (which is below the 64K-1 limit in the /dev/crypto) so it will of cause work correctly. But when I use OpenSSL like in the second link (http://processors.wiki.ti.com/index.php/Cryptography_Users_Guide) then it still fails when the /dev/crypto is invoked!

    And if you look at the comments section of that post you will see that I am not the only one seeing this problem. Gregturne replied that it is a known problem back in 2012.

    After that I applied the patch the Gregturne mentioned from (http://processors.wiki.ti.com/index.php/Build_OpenSSL_for_Sitara) but this didn't change anything. The /dev/crypto still fails during the HASH of files larger than 64K.

    I now returned to compile OpenSSL without the "-DHAVE_CRYPTODEV -DUSE_CRYPTO_DIGESTS" and I can now successfully create the hash'es (which I have verified on the PC) - but unfortunately it is not using the HW acceleration and therefore it is very slow on the large image files I have :-(

    But I hope for a solution on how to get this work so I can utilize the DM814x's HW acceleration and speed up the HASH calculations...

    Best regards,

    Karsten

  • Karsten,

    Karsten said:
    I am running my system with the IPNC 2.8

    I am working on EZSDK. I will notify the IPNC team for help.

    Regards,
    Pavel